diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
index 455c53885ea..09bc3c2517e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
@@ -9456,5 +9456,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/OptionStringListValueTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/OptionStringListValueTests.java
index 774e69fe913..f7424a301b4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/OptionStringListValueTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/OptionStringListValueTests.java
@@ -32,6 +32,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
+import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
@@ -281,4 +282,83 @@ public class OptionStringListValueTests extends TestCase {
checkOptionValues(option);
}
+ public void testSetToEmptyList_bug531106() throws Exception {
+ String projName = PROJ_NAME_PREFIX + "_bug531106";
+ IProject project = BuildSystemTestHelper.createProject(projName, null, "bug531106.tests.ptype");
+ ResourceHelper.addResourceCreated(project);
+ CoreModel model = CoreModel.getDefault();
+ ICProjectDescriptionManager mngr = model.getProjectDescriptionManager();
+
+ ICProjectDescription des = mngr.getProjectDescription(project);
+ ICConfigurationDescription cfgDes = des.getConfigurations()[0];
+ IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
+
+ ICFolderDescription fDes = cfgDes.getRootFolderDescription();
+ IFolderInfo fInfo = cfg.getRootFolderInfo();
+
+ ITool tool = fInfo.getToolsBySuperClassId("bug531106.tests.tool")[0];
+ testSetToEmptyList_VerifyValueCount(fInfo, tool, 1);
+
+ //Test clearing
+ IOption slOption = tool.getOptionBySuperClassId("bug531106.tests.option.stringList");
+ ManagedBuildManager.setOption(fInfo, tool, slOption, new OptionStringValue[0]);
+ IOption incPathOption = tool.getOptionBySuperClassId("bug531106.tests.option.incPath");
+ ManagedBuildManager.setOption(fInfo, tool, incPathOption, new OptionStringValue[0]);
+ IOption symbolsOption = tool.getOptionBySuperClassId("bug531106.tests.option.symbols");
+ ManagedBuildManager.setOption(fInfo, tool, symbolsOption, new OptionStringValue[0]);
+ IOption libsOption = tool.getOptionBySuperClassId("bug531106.tests.option.libs");
+ ManagedBuildManager.setOption(fInfo, tool, libsOption, new OptionStringValue[0]);
+ IOption userObjsOption = tool.getOptionBySuperClassId("bug531106.tests.option.userObjs");
+ ManagedBuildManager.setOption(fInfo, tool, userObjsOption, new OptionStringValue[0]);
+ IOption symFilesOption = tool.getOptionBySuperClassId("bug531106.tests.option.symFiles");
+ ManagedBuildManager.setOption(fInfo, tool, symFilesOption, new OptionStringValue[0]);
+ IOption incFilesOption = tool.getOptionBySuperClassId("bug531106.tests.option.incFiles");
+ ManagedBuildManager.setOption(fInfo, tool, incFilesOption, new OptionStringValue[0]);
+ IOption libPathsOption = tool.getOptionBySuperClassId("bug531106.tests.option.libPaths");
+ ManagedBuildManager.setOption(fInfo, tool, libPathsOption, new OptionStringValue[0]);
+ IOption libFilesOption = tool.getOptionBySuperClassId("bug531106.tests.option.libFiles");
+ ManagedBuildManager.setOption(fInfo, tool, libFilesOption, new OptionStringValue[0]);
+
+ testSetToEmptyList_VerifyValueCount(fInfo, tool, 0);
+
+ mngr.setProjectDescription(project, des);
+ ManagedBuildManager.saveBuildInfo(project, true);
+
+ //Close & re-open project
+ project.close(new NullProgressMonitor());
+ project.open(new NullProgressMonitor());
+
+ //Reload config
+ des = mngr.getProjectDescription(project);
+ cfgDes = des.getConfigurations()[0];
+ cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
+
+ fDes = cfgDes.getRootFolderDescription();
+ fInfo = cfg.getRootFolderInfo();
+
+ tool = fInfo.getToolsBySuperClassId("bug531106.tests.tool")[0];
+ testSetToEmptyList_VerifyValueCount(fInfo, tool, 0);
+ }
+
+ private void testSetToEmptyList_VerifyValueCount(IFolderInfo fInfo, ITool tool, int count) throws BuildException {
+ IOption slOption = tool.getOptionBySuperClassId("bug531106.tests.option.stringList");
+ assertEquals(count, slOption.getBasicStringListValueElements().length);
+ IOption incPathOption = tool.getOptionBySuperClassId("bug531106.tests.option.incPath");
+ assertEquals(count, incPathOption.getBasicStringListValueElements().length);
+ IOption symbolsOption = tool.getOptionBySuperClassId("bug531106.tests.option.symbols");
+ assertEquals(count, symbolsOption.getBasicStringListValueElements().length);
+ IOption libsOption = tool.getOptionBySuperClassId("bug531106.tests.option.libs");
+ assertEquals(count, libsOption.getBasicStringListValueElements().length);
+ IOption userObjsOption = tool.getOptionBySuperClassId("bug531106.tests.option.userObjs");
+ assertEquals(count, userObjsOption.getBasicStringListValueElements().length);
+ IOption symFilesOption = tool.getOptionBySuperClassId("bug531106.tests.option.symFiles");
+ assertEquals(count, symFilesOption.getBasicStringListValueElements().length);
+ IOption incFilesOption = tool.getOptionBySuperClassId("bug531106.tests.option.incFiles");
+ assertEquals(count, incFilesOption.getBasicStringListValueElements().length);
+ IOption libPathsOption = tool.getOptionBySuperClassId("bug531106.tests.option.libPaths");
+ assertEquals(count, libPathsOption.getBasicStringListValueElements().length);
+ IOption libFilesOption = tool.getOptionBySuperClassId("bug531106.tests.option.libFiles");
+ assertEquals(count, libFilesOption.getBasicStringListValueElements().length);
+ }
+
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
index 1a2ee15301a..582f3ab7bd9 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java
@@ -51,6 +51,8 @@ import org.eclipse.core.runtime.Status;
import org.osgi.framework.Version;
public class Option extends BuildObject implements IOption, IBuildPropertiesRestriction {
+ private static final String IS_BUILTIN_EMPTY = "IS_BUILTIN_EMPTY";
+ private static final String IS_VALUE_EMPTY = "IS_VALUE_EMPTY";
// Static default return values
public static final String EMPTY_STRING = "";
public static final String[] EMPTY_STRING_ARRAY = new String[0];
@@ -642,17 +644,10 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
// Note: These string-list options do not load either the "value" or
// "defaultValue" attributes. Instead, the ListOptionValue children
// are loaded in the value field.
- List vList = null;
- List biList = null;
+ List vList = new ArrayList();
+ List biList = new ArrayList();
configElements = element.getChildren();
for (ICStorageElement veNode : configElements) {
- if (vList==null) {
- vList = new ArrayList();
- }
- if (biList==null) {
- biList = new ArrayList();
- }
-
if (veNode.getName().equals(LIST_VALUE)) {
OptionStringValue ve = new OptionStringValue(veNode);
if(ve.isBuiltIn()) {
@@ -662,12 +657,30 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
}
}
}
- if(vList != null && vList.size() != 0) {
+
+ //Assume not empty unless specificaly flagged
+ boolean isValueEmpty = false;
+ boolean isBuiltinEmpty = false;
+
+ if (element.getAttribute(IS_VALUE_EMPTY) != null) {
+ Boolean isEmpty = new Boolean(element.getAttribute(IS_VALUE_EMPTY));
+ if (isEmpty.booleanValue()) {
+ isValueEmpty = true;
+ }
+ }
+ if (element.getAttribute(IS_BUILTIN_EMPTY) != null) {
+ Boolean isEmpty = new Boolean(element.getAttribute(IS_BUILTIN_EMPTY));
+ if (isEmpty.booleanValue()) {
+ isBuiltinEmpty = true;
+ }
+ }
+
+ if(vList.size() != 0 || isValueEmpty) {
value = vList;
} else {
value = null;
}
- if(biList != null && biList.size() != 0) {
+ if(biList.size() != 0 || isBuiltinEmpty) {
builtIns = biList;
} else {
builtIns = null;
@@ -883,14 +896,32 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
ICStorageElement valueElement = element.createChild(LIST_VALUE);
optValue.serialize(valueElement);
}
+
+ if(stringList.isEmpty()) {
+ element.setAttribute(IS_VALUE_EMPTY, Boolean.TRUE.toString());
+ } else {
+ element.setAttribute(IS_VALUE_EMPTY, Boolean.FALSE.toString());
+ }
+ } else {
+ element.setAttribute(IS_VALUE_EMPTY, Boolean.FALSE.toString());
}
+
// Serialize the built-ins that have been overridden
if (builtIns != null) {
for (OptionStringValue optionValue : builtIns) {
ICStorageElement valueElement = element.createChild(LIST_VALUE);
optionValue.serialize(valueElement);
}
+
+ if(builtIns.isEmpty()) {
+ element.setAttribute(IS_BUILTIN_EMPTY, Boolean.TRUE.toString());
+ } else {
+ element.setAttribute(IS_BUILTIN_EMPTY, Boolean.FALSE.toString());
+ }
+ } else {
+ element.setAttribute(IS_BUILTIN_EMPTY, Boolean.FALSE.toString());
}
+
break;
}
}