summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Zulliger2012-01-19 16:36:00 (EST)
committerAndrew Gvozdev2012-01-19 16:41:09 (EST)
commit533c75662e2f1e431c4a40feb44a6afc578e1b34 (patch)
tree9a88d9699566d0a7793f9eb067499fcf582bacb6
parent6408fe544c740054c72fd04811a3807c70a9d704 (diff)
downloadorg.eclipse.cdt-533c75662e2f1e431c4a40feb44a6afc578e1b34.zip
org.eclipse.cdt-533c75662e2f1e431c4a40feb44a6afc578e1b34.tar.gz
org.eclipse.cdt-533c75662e2f1e431c4a40feb44a6afc578e1b34.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 b83dcc5..99046b7 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, "_");
@@ -42,6 +45,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);
}
/**
@@ -426,6 +430,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());
+ }
+ }
+ }
+
@Override
protected void tearDown() throws Exception {
try {
@@ -448,5 +486,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 93bb40f..e8f16b8 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: