1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

bug 284699: Paths and Symbols inheritance problem

This commit is contained in:
Raphael Zulliger 2012-01-19 16:36:00 -05:00 committed by Andrew Gvozdev
parent 6408fe544c
commit 533c75662e
3 changed files with 75 additions and 6 deletions

View file

@ -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){
}
}
}

View file

@ -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;

View file

@ -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: