mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 403405: Fix for failing test case BackwardCompatibilityTests.testPathEntriesForNewStyle()
This commit is contained in:
parent
f11b13184e
commit
2764a28f64
2 changed files with 69 additions and 14 deletions
|
@ -78,12 +78,14 @@ public class BackwardCompatibilityTests extends BaseTestCase {
|
|||
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")),
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -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,10 +2103,14 @@ 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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue