mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
bug 396411: Resolve variables before checking if path is absolute in MBSLanguageSettingsProvider
This commit is contained in:
parent
fcd0216d66
commit
33514e1c84
1 changed files with 21 additions and 5 deletions
|
@ -15,6 +15,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
|
||||
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
|
||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsBroadcastingProvider;
|
||||
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
|
@ -26,6 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICPathEntry;
|
|||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -73,6 +77,12 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
|||
if (!new Path(pathStr).isAbsolute()) {
|
||||
// We need to add project-rooted entry for relative path as MBS counts it this way in some UI
|
||||
// The relative entry below also should be added for indexer to resolve from source file locations
|
||||
|
||||
ICdtVariableManager varManager = CCorePlugin.getDefault().getCdtVariableManager();
|
||||
try {
|
||||
// Substitute build/environment variables
|
||||
String location = varManager.resolveValue(pathStr, "", null, cfgDescription); //$NON-NLS-1$
|
||||
if (!new Path(location).isAbsolute()) {
|
||||
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
String projectRootedPath = mngr.generateVariableExpression("workspace_loc", rc.getProject().getName()) + Path.SEPARATOR + pathStr; //$NON-NLS-1$
|
||||
ICLanguageSettingEntry projectRootedEntry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, projectRootedPath, projectRootedPath, null, entry.getFlags());
|
||||
|
@ -80,6 +90,12 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
|||
list.add(projectRootedEntry);
|
||||
}
|
||||
}
|
||||
} catch (CdtVariableException e) {
|
||||
// Swallow exceptions but also log them
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (! list.contains(entry)) {
|
||||
list.add(entry);
|
||||
|
|
Loading…
Add table
Reference in a new issue