summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Zulliger2012-01-19 17:50:52 (EST)
committer Andrew Gvozdev2012-01-19 17:50:52 (EST)
commit30ed78d85def4468ff2cef59265fc666ddcdd298 (patch)
treeee30abf719ad4c2284af6fe4ca043f6c31161c29
parentb8419755911b921e72f9bdb2eb2318317c3e71ef (diff)
downloadorg.eclipse.cdt-30ed78d85def4468ff2cef59265fc666ddcdd298.zip
org.eclipse.cdt-30ed78d85def4468ff2cef59265fc666ddcdd298.tar.gz
org.eclipse.cdt-30ed78d85def4468ff2cef59265fc666ddcdd298.tar.bz2
bug 284699: Paths and Symbols inheritance problem
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java46
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java29
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java6
3 files changed, 75 insertions, 6 deletions
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java
index 7dce5fa..e904df0 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Intel Corporation and others.
+ * Copyright (c) 2007, 2012 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,9 @@
* Intel Corporation - Initial API and implementation
* James Blackburn (Broadcom Corp.)
* Christian Walther (Indel AG) - [335344] test for changing language IDs
+ * Raphael Zulliger (Indel AG) - [284699][237771] test having macros with same
+ * name but different values in same project
+ * configuration
*******************************************************************************/
package org.eclipse.cdt.core.settings.model;
@@ -29,7 +32,7 @@ import org.eclipse.core.runtime.Path;
public class ExternalSettingsProviderTests extends BaseTestCase{
private static final String PROJ_NAME_PREFIX = "espt_";
- ICProject p1, p2, p3, p4, p5;
+ ICProject p1, p2, p3, p4, p5, p6;
public static TestSuite suite() {
return suite(ExternalSettingsProviderTests.class, "_");
@@ -41,6 +44,7 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
p3 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "c", IPDOMManager.ID_NO_INDEXER);
p4 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "d", IPDOMManager.ID_NO_INDEXER);
p5 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "e", IPDOMManager.ID_NO_INDEXER);
+ p6 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "f", IPDOMManager.ID_NO_INDEXER);
}
/**
@@ -425,6 +429,40 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
assertTrue(Arrays.equals(expectedEntriesSet, entries));
}
+ /**
+ * Test if macros with the same name but different values can coexist when
+ * they belong to different language ids
+ */
+ public void testSameMacroWithDifferentValuesAndDifferentLanguageIds() throws CoreException {
+ TestExtSettingsProvider.setVariantNum(4);
+
+ CoreModel model = CoreModel.getDefault();
+ ICProjectDescriptionManager mngr = model.getProjectDescriptionManager();
+ IProject project = p6.getProject();
+
+ // add external settings provider
+ ICProjectDescription des = model.getProjectDescription(project);
+ ICConfigurationDescription cfgDes = des.getConfigurations()[0];
+ String[] extPIds = new String[]{TestExtSettingsProvider.TEST_EXTERNAL_PROVIDER_ID};
+ cfgDes.setExternalSettingsProviderIds(extPIds);
+ ICFolderDescription root = cfgDes.getRootFolderDescription();
+ model.setProjectDescription(project, des);
+
+ // read out the settings it caused
+ des = model.getProjectDescription(project, false);
+ cfgDes = des.getConfigurations()[0];
+ root = cfgDes.getRootFolderDescription();
+ for (ICLanguageSetting s: root.getLanguageSettings()) {
+ if( s.getLanguageId().equals("org.eclipse.cdt.core.assembly") ) {
+ assertEquals(1, s.getSettingEntries(ICSettingEntry.MACRO).length);
+ assertEquals("TheValue", s.getSettingEntries(4)[0].getValue());
+ } if( s.getLanguageId().equals("org.eclipse.cdt.core.g++") ) {
+ assertEquals(1, s.getSettingEntries(ICSettingEntry.MACRO).length);
+ assertEquals("", s.getSettingEntries(ICSettingEntry.MACRO)[0].getValue());
+ }
+ }
+ }
+
protected void tearDown() throws Exception {
try {
p1.getProject().delete(true, null);
@@ -446,5 +484,9 @@ public class ExternalSettingsProviderTests extends BaseTestCase{
p5.getProject().delete(true, null);
} catch (CoreException e){
}
+ try {
+ p6.getProject().delete(true, null);
+ } catch (CoreException e){
+ }
}
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java
index f954066..eeacbfb 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/TestExtSettingsProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Intel Corporation and others.
+ * Copyright (c) 2007, 2012 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,9 @@
* Contributors:
* Intel Corporation - Initial API and implementation
* Christian Walther (Indel AG) - [335344] test for changing language IDs
+ * Raphael Zulliger (Indel AG) - [284699][237771] test having macros with same
+ * name but different values in same project
+ * configuration
*******************************************************************************/
package org.eclipse.cdt.core.settings.model;
@@ -86,11 +89,33 @@ public class TestExtSettingsProvider extends CExternalSettingProvider {
)
};
+ private static CExternalSetting[] SETTINGS_5 = new CExternalSetting[]{
+ new CExternalSetting(
+ new String[]{
+ "org.eclipse.cdt.core.g++"
+ },
+ null, null,
+ new ICSettingEntry[]{
+ new CMacroEntry("THE_MACRO", "", 0)
+ }
+ ),
+ new CExternalSetting(
+ new String[]{
+ "org.eclipse.cdt.core.assembly"
+ },
+ null, null,
+ new ICSettingEntry[]{
+ new CMacroEntry("THE_MACRO", "TheValue", 0)
+ }
+ )
+ };
+
public static final CExternalSetting[][] SETTINGS_VARIANTS = new CExternalSetting[][]{
SETTINGS_1,
SETTINGS_2,
SETTINGS_3,
- SETTINGS_4};
+ SETTINGS_4,
+ SETTINGS_5};
private static int variantNum;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java
index b82fe35..2f9eabe 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CSettingEntryFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * Copyright (c) 2007, 2012 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,8 @@
*
* Contributors:
* Intel Corporation - Initial API and implementation
+ * Raphael Zulliger (Indel AG) - [284699][237771] fixing issues when using same
+ * macro names with different values
*******************************************************************************/
package org.eclipse.cdt.core.settings.model.util;
@@ -47,7 +49,7 @@ public class CSettingEntryFactory {
case ICSettingEntry.MACRO:
HashMap<String, HashMap<Integer, ICSettingEntry>> valueMap = getValueMap(name, create, (HashMap<String, HashMap<Integer, ICSettingEntry>>)null);
if(valueMap != null){
- return getMap(valueMap, name, create);
+ return getMap(valueMap, value, create);
}
return null;
case ICSettingEntry.SOURCE_PATH: