Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2013-04-30 14:32:59 +0000
committerAndrew Gvozdev2013-05-01 16:12:12 +0000
commit2764a28f649b37ede73d12a521d247a619342005 (patch)
treeeec446d9a148d1c0e17959b7a315da8d9032fa70
parentf11b13184e66bbfd139fe5b1055e137a5baf53ee (diff)
downloadorg.eclipse.cdt-2764a28f649b37ede73d12a521d247a619342005.tar.gz
org.eclipse.cdt-2764a28f649b37ede73d12a521d247a619342005.tar.xz
org.eclipse.cdt-2764a28f649b37ede73d12a521d247a619342005.zip
bug 403405: Fix for failing test case BackwardCompatibilityTests.testPathEntriesForNewStyle()
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java18
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java65
2 files changed, 69 insertions, 14 deletions
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java
index 4b364173ba..74c440d53b 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java
@@ -76,14 +76,16 @@ public class BackwardCompatibilityTests extends BaseTestCase {
checkEntriesMatch(expectedRawEntries, entries);
IPathEntry[] expectedResolvedEntries = new IPathEntry[]{
- CoreModel.newSourceEntry(project.getFullPath()),
- CoreModel.newOutputEntry(project.getFullPath()),
- CoreModel.newMacroEntry(project.getFullPath(), "a", "b"),
- CoreModel.newMacroEntry(project.getFullPath(), "c", ""),
- CoreModel.newIncludeEntry(project.getFullPath(), null, project.getLocation().append("a/b/c")),
- CoreModel.newIncludeEntry(project.getFullPath(), null, new Path("/d/e/f")),
- CoreModel.newIncludeEntry(project.getFullPath(), project.getFullPath().makeRelative(), new Path("g/h/i")),
- CoreModel.newIncludeEntry(project.getFullPath(), new Path("j"), new Path("k/l")),
+ CoreModel.newSourceEntry(project.getFullPath()),
+ CoreModel.newOutputEntry(project.getFullPath()),
+ CoreModel.newIncludeEntry(project.getFullPath(), null, project.getLocation().append("a/b/c")),
+ CoreModel.newIncludeEntry(project.getFullPath(), null, new Path("/d/e/f")),
+ // Relative path with VALUE_WORKSPACE_PATH generates 2 entries, see MBSLanguageSettingsProvider
+ CoreModel.newIncludeEntry(project.getFullPath(), null, project.getLocation().append("g/h/i")),
+ CoreModel.newIncludeEntry(project.getFullPath(), project.getFullPath().makeRelative(), new Path("g/h/i")),
+ CoreModel.newIncludeEntry(project.getFullPath(), new Path("j"), new Path("k/l")),
+ CoreModel.newMacroEntry(project.getFullPath(), "a", "b"),
+ CoreModel.newMacroEntry(project.getFullPath(), "c", ""),
};
checkEntriesMatch(expectedResolvedEntries, resolvedentries);
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java
index aa2ec77c8a..db86d0ab69 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java
@@ -26,6 +26,8 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
+import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
@@ -64,7 +66,6 @@ import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.cdtvariables.CoreVariableSubstitutor;
import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo;
import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
-import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.model.APathEntry;
import org.eclipse.cdt.internal.core.model.CModelStatus;
import org.eclipse.cdt.internal.core.model.PathEntry;
@@ -2034,6 +2035,54 @@ public class PathEntryTranslator {
return collector;
}
+ /**
+ * Returns the list of setting entries of a certain kind (such as include paths)
+ * for the given configuration description, resource and language. This is a
+ * combined list for all providers.
+ * This list does not include settings of parent folder.
+ *
+ * @param cfgDescription - configuration description.
+ * @param rc - resource such as file or folder.
+ * @param languageId - language id.
+ * @param kind - kind of language settings entries, such as {@link ICSettingEntry#INCLUDE_PATH} etc.
+ *
+ * @return the list of setting entries found.
+ */
+ private static List<ICLanguageSettingEntry> getSettingEntriesByKind(ICConfigurationDescription cfgDescription,
+ IResource rc, String languageId, int kind) {
+
+ if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) {
+ return null;
+ }
+
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ List<String> alreadyAdded = new ArrayList<String>();
+
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ for (ILanguageSettingsProvider provider: providers) {
+ List<ICLanguageSettingEntry> providerEntries = provider.getSettingEntries(cfgDescription, rc, languageId);
+ if (providerEntries != null) {
+ for (ICLanguageSettingEntry entry : providerEntries) {
+ if (entry != null) {
+ String entryName = entry.getName();
+ boolean isRightKind = (entry.getKind() & kind) == kind;
+ // Only first entry is considered
+ // Entry flagged as "UNDEFINED" prevents adding entry with the same name down the line
+ if (isRightKind && !alreadyAdded.contains(entryName)) {
+ int flags = entry.getFlags();
+ if ((flags & ICSettingEntry.UNDEFINED) != ICSettingEntry.UNDEFINED) {
+ entries.add(entry);
+ }
+ alreadyAdded.add(entryName);
+ }
+ }
+ }
+ }
+ }
+
+ return entries;
+ }
+
private static boolean collectResourceDataEntries(ICConfigurationDescription cfgDescription, int kind, CResourceData rcData, Set<ICLanguageSettingEntry> list) {
CLanguageData[] lDatas = null;
if (rcData instanceof CFolderData) {
@@ -2054,12 +2103,16 @@ public class PathEntryTranslator {
IProject project = cfgDescription.getProjectDescription().getProject();
if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project)) {
IResource rc = findResourceInWorkspace(project, rcData.getPath());
- if (rc != null) {
- for (CLanguageData lData : lDatas) {
- list.addAll(LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, rc, lData.getLanguageId(), kind));
- }
+ if (rc == null) {
+ // If resource does not exist make a handle to be able to supply the path.
+ // This does not create actual resource.
+ // Gotta be a folder so language settings provider won't filter out languages.
+ rc = project.getFolder(rcData.getPath());
+ }
+ for (CLanguageData lData : lDatas) {
+ list.addAll(getSettingEntriesByKind(cfgDescription, rc, lData.getLanguageId(), kind));
}
- return list.size()>0;
+ return list.size() > 0;
}
// Legacy logic (before Language Settings Providers)

Back to the top