1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

1. fix to [bug 175662] [Build] Include directory from workspace shows up invalid

2. fix to [Bug 175508] [New project model] Invalid warnings about includes in problems view
3. fix to [Bug 175198] Internal Builder does nothing after a clean.
4. fix to [Bug 175087] [New project model] PathEntry not converted
This commit is contained in:
Mikhail Sennikovsky 2007-02-27 19:03:54 +00:00
parent 6936ef3514
commit 77a8e0ef9c
19 changed files with 247 additions and 82 deletions

View file

@ -636,7 +636,7 @@ public class CommonBuilder extends ACBuilder {
IConfiguration cfg = builder.getParent().getParent();
boolean isParallel = builder.getParallelizationNum() != 0;
boolean buildIncrementaly = true;
// boolean buildIncrementaly = true;
boolean resumeOnErr = !builder.isStopOnError();
// Get the project and make sure there's a monitor to cancel the build
@ -654,13 +654,15 @@ public class CommonBuilder extends ACBuilder {
OutputStream epmOutputStream = null;
try {
int flags = 0;
IResourceDelta delta = null;
IResourceDelta delta = getDelta(currentProject);
if(buildIncrementaly){
if(delta != null){
flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS;
delta = getDelta(currentProject);
// delta = getDelta(currentProject);
}
boolean buildIncrementaly = delta != null;
IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags);
DescriptionBuilder dBuilder = null;

View file

@ -84,7 +84,9 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
}
public CConfigurationData applyConfiguration(
ICConfigurationDescription des, CConfigurationData base)
ICConfigurationDescription des,
ICConfigurationDescription baseDescription,
CConfigurationData base)
throws CoreException {
if(des.isPreferenceConfiguration())
return applyPreferences(des, base);
@ -115,7 +117,9 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
public CConfigurationData createConfiguration(
ICConfigurationDescription des, CConfigurationData base, boolean clone)
ICConfigurationDescription des,
ICConfigurationDescription baseDescription,
CConfigurationData base, boolean clone)
throws CoreException {
if(des.isPreferenceConfiguration())
return createPreferences(des, base);

View file

@ -189,6 +189,9 @@ public class EntryStorage {
if(size > 0){
for(int j = 0; j < size; j++){
String value = (String)list.get(j);
if(value.indexOf('"') == 0 && value.lastIndexOf('"') == value.length() - 1 && value.length() != 1){
value = value.substring(1, value.length() - 1);
}
ICLanguageSettingEntry entry = createEntry(discoveredEntryFromString(value), false, false);
EntryInfo discoveredInfo = fDiscoveredEntries.getEntryInfo(entry);
if(discoveredInfo != null){

View file

@ -149,7 +149,7 @@ public class ExternalExtensionMacroSupplier implements ICdtVariableSupplier{
case IBuildMacroProvider.CONTEXT_PROJECT:
if (contextData instanceof IManagedProject) {
IManagedProject project = (IManagedProject)contextData;
IProjectBuildMacroSupplier supplier = project.getProjectType().getBuildMacroSupplier();
IProjectBuildMacroSupplier supplier = project.getProjectType() != null ? project.getProjectType().getBuildMacroSupplier() : null;
if(supplier == null)
return null;
return supplier.getMacro(macroName,project,new ExtensionMacroProvider(contextType, contextData));
@ -187,7 +187,7 @@ public class ExternalExtensionMacroSupplier implements ICdtVariableSupplier{
case IBuildMacroProvider.CONTEXT_PROJECT:
if (contextData instanceof IManagedProject) {
IManagedProject project = (IManagedProject)contextData;
IProjectBuildMacroSupplier supplier = project.getProjectType().getBuildMacroSupplier();
IProjectBuildMacroSupplier supplier = project.getProjectType() != null ? project.getProjectType().getBuildMacroSupplier() : null;
if(supplier != null)
macros = supplier.getMacros(project,new ExtensionMacroProvider(contextType, contextData));
}

View file

@ -452,7 +452,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab {
}
private boolean isUserVar(ICdtVariable v) {
return mgr.isUserVariable(v, cfgd);
return cfgd != null ? mgr.isUserVariable(v, cfgd) : vars.contains(v);
}
/* check whether variable is dynamic */

View file

@ -40,7 +40,9 @@ public abstract class CConfigurationDataProvider {
* @return
* @throws CoreException
*/
public abstract CConfigurationData createConfiguration(ICConfigurationDescription des, CConfigurationData base, boolean clone) throws CoreException;
public abstract CConfigurationData createConfiguration(ICConfigurationDescription des,
ICConfigurationDescription baseDescription,
CConfigurationData baseData, boolean clone) throws CoreException;
/**
* called to notify the provider that the configuration is removed
@ -60,5 +62,7 @@ public abstract class CConfigurationDataProvider {
* @return
* @throws CoreException
*/
public abstract CConfigurationData applyConfiguration(ICConfigurationDescription des, CConfigurationData base) throws CoreException;
public abstract CConfigurationData applyConfiguration(ICConfigurationDescription des,
ICConfigurationDescription baseDescription,
CConfigurationData baseData) throws CoreException;
}

View file

@ -21,6 +21,9 @@ import java.util.Map;
import java.util.Set;
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.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.CoreModelUtil;
@ -54,7 +57,11 @@ import org.eclipse.cdt.core.settings.model.extension.CFileData;
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
import org.eclipse.cdt.internal.core.CdtVarPathEntryVariableManager;
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.model.APathEntry;
import org.eclipse.cdt.internal.core.model.CModelStatus;
import org.eclipse.cdt.internal.core.model.PathEntry;
@ -62,6 +69,7 @@ import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCac
import org.eclipse.cdt.internal.core.settings.model.CExternalSetting;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@ -112,6 +120,24 @@ public class PathEntryTranslator {
private Map fResourceMap = new HashMap();
private IWorkspaceRoot fRoot = ResourcesPlugin.getWorkspace().getRoot();
private static class VarSubstitutor extends CoreVariableSubstitutor {
ICConfigurationDescription fCfg;
ICdtVariableManager fMngr = CCorePlugin.getDefault().getCdtVariableManager();
public VarSubstitutor(ICConfigurationDescription cfg) {
super(new DefaultVariableContextInfo(ICoreVariableContextInfo.CONTEXT_CONFIGURATION, cfg), "", " "); //$NON-NLS-1$ //$NON-NLS-2$
fCfg = cfg;
}
protected ResolvedMacro resolveMacro(ICdtVariable macro)
throws CdtVariableException {
if(!CdtVarPathEntryVariableManager.isPathEntryVariable(macro, fCfg, fMngr))
return super.resolveMacro(macro);
return new ResolvedMacro(macro.getName(), CdtVariableResolver.createVariableReference(macro.getName()));
}
}
public static final class ReferenceSettingsInfo{
private IPath[] fRefProjPaths;
private ICExternalSetting[] fExtSettings;
@ -390,7 +416,7 @@ public class PathEntryTranslator {
}
if(path != null){
return new CLibraryFileEntry(path, flags);
return new CLibraryFileEntry(value.getName(), flags);
}
break;
}
@ -407,7 +433,7 @@ public class PathEntryTranslator {
}
if(path != null){
return new CIncludePathEntry(path, flags);
return new CIncludePathEntry(value.getName(), flags);
}
break;
}
@ -431,7 +457,7 @@ public class PathEntryTranslator {
}
if(path != null){
return new CIncludeFileEntry(path, flags);
return new CIncludeFileEntry(value.getName(), flags);
}
break;
}
@ -444,7 +470,7 @@ public class PathEntryTranslator {
}
if(path != null){
return new CMacroFileEntry(path, flags);
return new CMacroFileEntry(value.getName(), flags);
}
break;
}
@ -563,6 +589,9 @@ public class PathEntryTranslator {
basePath = mngr.resolvePath(basePath);
valuePath = mngr.resolvePath(valuePath);
fName = unresolvedBase.append(unresolvedValue).toString();
fValue = fName;
if (!basePath.isEmpty()) {
IPath loc = basePath;
@ -580,8 +609,6 @@ public class PathEntryTranslator {
}
}
fLocation = loc.append(valuePath);
fName = unresolvedBase.append(unresolvedValue).toString();
fValue = fName;
// fName = fValuePath.toString();
// fValue = fValuePath.toString();
break;
@ -604,11 +631,12 @@ public class PathEntryTranslator {
fResourceInfo = rcInfo;
// fFullPath = fResourceInfo.fRc.getFullPath();
// fLocation = fResourceInfo.fRc.getLocation();
break;
}
}
} else {
fLocation = valuePath;
}
fLocation = valuePath;
}while(false);
}
}
@ -722,27 +750,30 @@ public class PathEntryTranslator {
private Set fFiltersSet;
private boolean fIsExported;
private IProject fProject;
private ICConfigurationDescription fCfg;
PathEntryComposer(String projName, IProject project){
this(new Path(projName).makeAbsolute(), project);
PathEntryComposer(String projName, IProject project, ICConfigurationDescription cfg){
this(new Path(projName).makeAbsolute(), project, cfg);
}
PathEntryComposer(IPath path, IProject project){
PathEntryComposer(IPath path, IProject project, ICConfigurationDescription cfg){
fPath = toProjectPath(path);
fProject = project;
fCfg = cfg;
}
private static IPath toProjectPath(IPath path){
if(path.segmentCount() > 1)
path = new Path(path.segment(0));
return path.makeAbsolute();
}
PathEntryComposer(ICExclusionPatternPathEntry entry, IProject project){
PathEntryComposer(ICExclusionPatternPathEntry entry, IProject project, ICConfigurationDescription cfg){
fPath = new Path(entry.getValue());
fLangEntry = entry;
fProject = project;
fCfg = cfg;
IPath[] exclusions = entry.getExclusionPatterns();
if(exclusions.length != 0){
fFiltersSet = new HashSet(exclusions.length);
@ -750,11 +781,12 @@ public class PathEntryTranslator {
}
}
PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, IProject project){
PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, IProject project, ICConfigurationDescription cfg){
fPath = path;
fLangEntry = entry;
fIsExported = exported;
fProject = project;
fCfg = cfg;
}
public void addFilter(IPath path){
@ -778,32 +810,48 @@ public class PathEntryTranslator {
return new IPath[0];
}
private IPath[] getEntryPath(ICSettingEntry entry){
return valueToEntryPath(entry.getName(), (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0);
private IPath[] getEntryPath(ICSettingEntry entry, ICConfigurationDescription cfg){
return valueToEntryPath(entry.getName(), (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0, cfg);
}
private IPath[] valueToEntryPath(String value, boolean isWsp){
IPath path = new Path(value);
private IPath[] valueToEntryPath(String value, boolean isWsp, ICConfigurationDescription cfg){
String pathVarValue = resolveKeepingPathEntryFars(value, cfg);
String resolvedValue = resolveAll(value, cfg);
IPath resolvedPath = new Path(resolvedValue);
IPath pathVarPath = new Path(pathVarValue);
IPath result[] = new IPath[2];
if(isWsp){
if(!path.isAbsolute()){
if(!resolvedPath.isAbsolute()){
result[0] = fProject.getFullPath().makeRelative();
result[1] = path;
path = fProject.getFullPath().append(path);
result[1] = pathVarPath;
// path = fProject.getFullPath().append(path);
} else {
if(path.segmentCount() != 0){
result[0] = new Path(path.segment(0));
result[1] = path.removeFirstSegments(1).makeRelative();
if(resolvedPath.segmentCount() != 0){
String projName = resolvedPath.segment(0);
IPath valuePath = resolvedPath.removeFirstSegments(1).makeRelative();
if(pathVarPath.segmentCount() != 0){
String resolvedProjName = projName;
String varProjName = pathVarPath.segment(0);
IPath resolvedProjPath = CCorePlugin.getDefault().getPathEntryVariableManager().resolvePath(new Path(varProjName));
if(resolvedProjPath.segmentCount() == 1 && resolvedProjName.equals(resolvedProjPath.segment(0))){
projName = varProjName;
valuePath = pathVarPath.removeFirstSegments(1).makeRelative();
}
}
result[0] = new Path(projName);
result[1] = valuePath;
}
}
// path = path.makeRelative();
} else {
if(!path.isAbsolute()){
if(!resolvedPath.isAbsolute()){
IPath location = fProject.getLocation();
if(location != null)
path = location.append(path);
pathVarPath = location.append(pathVarPath);
}
result[1] = path;
result[1] = pathVarPath;
}
return result;
@ -813,24 +861,24 @@ public class PathEntryTranslator {
if(fLangEntry != null){
switch(fLangEntry.getKind()){
case ICLanguageSettingEntry.INCLUDE_FILE:{
IPath paths[] = getEntryPath(fLangEntry);
IPath paths[] = getEntryPath(fLangEntry, fCfg);
return CoreModel.newIncludeFileEntry(fPath, null, paths[0], paths[1], getExclusionPatterns(), fIsExported);
}
case ICLanguageSettingEntry.INCLUDE_PATH:{
IPath paths[] = getEntryPath(fLangEntry);
IPath paths[] = getEntryPath(fLangEntry, fCfg);
ICIncludePathEntry ipe = (ICIncludePathEntry)fLangEntry;
return CoreModel.newIncludeEntry(fPath, paths[0], paths[1], !ipe.isLocal(), getExclusionPatterns(), fIsExported);
}
case ICLanguageSettingEntry.MACRO:
return CoreModel.newMacroEntry(fPath, fLangEntry.getName(), fLangEntry.getValue(), getExclusionPatterns(), fIsExported);
case ICLanguageSettingEntry.MACRO_FILE:{
IPath paths[] = getEntryPath(fLangEntry);
IPath paths[] = getEntryPath(fLangEntry, fCfg);
return CoreModel.newMacroFileEntry(fPath, paths[0], null, paths[1], getExclusionPatterns(), fIsExported);
}
case ICLanguageSettingEntry.LIBRARY_PATH:
return null;
case ICLanguageSettingEntry.LIBRARY_FILE:{
IPath paths[] = getEntryPath(fLangEntry);
IPath paths[] = getEntryPath(fLangEntry, fCfg);
return CoreModel.newLibraryEntry(fPath, paths[0], paths[1], null, null, null, fIsExported);
}
case ICLanguageSettingEntry.OUTPUT_PATH:
@ -847,29 +895,52 @@ public class PathEntryTranslator {
}
}
private static String resolveAll(String value, ICConfigurationDescription cfg){
try {
return CCorePlugin.getDefault().getCdtVariableManager().resolveValue(value, "", " ", cfg);
} catch (CdtVariableException e) {
CCorePlugin.log(e);
}
return value;
}
private static String resolveKeepingPathEntryFars(String value, ICConfigurationDescription cfg){
try {
VarSubstitutor substitutor = new VarSubstitutor(cfg);
return CdtVariableResolver.resolveToString(value, substitutor);
} catch (CdtVariableException e) {
CCorePlugin.log(e);
}
return value;
}
public static class PathEntryCollector {
private PathSettingsContainer fStorage;
private KindBasedStore fStore;
private LinkedHashMap fRefProjMap;
private IProject fProject;
private ICConfigurationDescription fCfg;
private PathEntryCollector(IProject project){
private PathEntryCollector(IProject project, ICConfigurationDescription cfg){
fStorage = PathSettingsContainer.createRootContainer();
fStorage.setValue(this);
fStore = new KindBasedStore(false);
fCfg = cfg;
fProject = project;
}
private PathEntryCollector(PathSettingsContainer container, KindBasedStore store, IProject project){
private PathEntryCollector(PathSettingsContainer container, KindBasedStore store, IProject project, ICConfigurationDescription cfg){
fStorage = container;
fStore = store;
fCfg = cfg;
fProject = project;
}
public void setSourceOutputEntries(int kind, ICExclusionPatternPathEntry entries[]){
Map map = getEntriesMap(kind, true);
for(int i = 0; i < entries.length; i++){
map.put(entries[i], new PathEntryComposer(entries[i], fProject));
map.put(entries[i], new PathEntryComposer(entries[i], fProject, fCfg));
}
}
@ -879,7 +950,7 @@ public class PathEntryTranslator {
else {
fRefProjMap = new LinkedHashMap();
for(int i = 0; i < paths.length; i++){
PathEntryComposer cs = new PathEntryComposer(paths[i], fProject);
PathEntryComposer cs = new PathEntryComposer(paths[i], fProject, fCfg);
IPath path = cs.getPath();
fRefProjMap.put(path, cs);
}
@ -906,7 +977,7 @@ public class PathEntryTranslator {
info[i].setInfo((LinkedHashMap)map.clone());
}
}
PathEntryCollector newCr = new PathEntryCollector(newContainer, cloneStore, fProject);
PathEntryCollector newCr = new PathEntryCollector(newContainer, cloneStore, fProject, fCfg);
newContainer.setValue(newCr);
return newCr;
}
@ -944,7 +1015,7 @@ public class PathEntryTranslator {
continue;
ICLanguageSettingEntry entry = entries[i];
map.put(entry, new PathEntryComposer(fullPath, entry, exportedEntries.contains(entry), fProject));
map.put(entry, new PathEntryComposer(fullPath, entry, exportedEntries.contains(entry), fProject, fCfg));
}
}
}
@ -2157,13 +2228,13 @@ public class PathEntryTranslator {
CConfigurationData data = des instanceof CConfigurationDescriptionCache ?
(CConfigurationData)des : ((IInternalCCfgInfo)des).getConfigurationData(false);
ReferenceSettingsInfo info = new ReferenceSettingsInfo(des);
ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des);
return collectEntries(project, data, info);
}
public static PathEntryCollector collectEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo){
final PathEntryCollector cr = new PathEntryCollector(project);
// return collectEntries(project, data, info);
// }
//
// public static PathEntryCollector collectEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo){
final PathEntryCollector cr = new PathEntryCollector(project, des);
PathSettingsContainer rcDatas = createRcDataHolder(data);
IPath srcPaths[] = data.getSourcePaths();
ICSourceEntry sEntries[] = calculateSourceEntriesFromPaths(project, rcDatas, srcPaths);
@ -2250,8 +2321,9 @@ public class PathEntryTranslator {
return false;
}
public static IPathEntry[] getPathEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo, int flags){
PathEntryCollector cr = collectEntries(project, data, refInfo);
// public static IPathEntry[] getPathEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo, int flags){
public static IPathEntry[] getPathEntries(IProject project, ICConfigurationDescription cfg, int flags){
PathEntryCollector cr = collectEntries(project, cfg);
return cr.getEntries(flags);
}
//

View file

@ -41,7 +41,6 @@ import org.eclipse.cdt.core.settings.model.extension.CFolderData;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.CResourceData;
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -99,7 +98,7 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
if(baseData instanceof CConfigurationDescriptionCache){
baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();
}
setData(CProjectDescriptionManager.getInstance().createData(this, baseData, false));
setData(CProjectDescriptionManager.getInstance().createData(this, base, baseData, false));
}
/*
@ -138,8 +137,9 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
void doWritable() throws CoreException{
CConfigurationData data = getConfigurationData(false);
if(data instanceof CConfigurationDescriptionCache){
data = ((CConfigurationDescriptionCache)data).getConfigurationData();
setData(CProjectDescriptionManager.getInstance().createData(this, data, true));
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)data;
data = cache.getConfigurationData();
setData(CProjectDescriptionManager.getInstance().createData(this, cache, data, true));
}
}

View file

@ -89,7 +89,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
fInitializing = false;
}
CConfigurationDescriptionCache(CConfigurationData base, CConfigurationSpecSettings settingsBase, CProjectDescription parent, ICStorageElement rootEl, boolean saving) throws CoreException {
CConfigurationDescriptionCache(ICConfigurationDescription baseDescription, CConfigurationData base, CConfigurationSpecSettings settingsBase, CProjectDescription parent, ICStorageElement rootEl, boolean saving) throws CoreException {
super(base.getId(), base.getName(), null);
fInitializing = true;
fParent = parent;
@ -97,9 +97,10 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
if(base instanceof CConfigurationDescriptionCache){
fData = ((CConfigurationDescriptionCache)base).getConfigurationData();
fData = CProjectDescriptionManager.getInstance().applyData(this, fData);
fData = CProjectDescriptionManager.getInstance().applyData(this, baseDescription, fData);
} else {
base = CProjectDescriptionManager.getInstance().applyData(this, base);
fData = base;
base = CProjectDescriptionManager.getInstance().applyData(this, baseDescription, base);
fData = base;
}
fDataLoadded = true;

View file

@ -108,7 +108,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
if(baseData instanceof CConfigurationDescriptionCache){
baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();
}
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(baseData, cfgDes.getSpecSettings(), this, null, saving);
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription)cfgDes, baseData, cfgDes.getSpecSettings(), this, null, saving);
configurationCreated(cache);
} else {
CConfigurationData baseData = cfgDes.getConfigurationData(false);

View file

@ -149,6 +149,7 @@ public class CProjectDescriptionManager {
private static final String DEFAULT_CFG_NAME = "Configuration"; //$NON-NLS-1$
private static final QualifiedName SCANNER_INFO_PROVIDER_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "scannerInfoProvider"); //$NON-NLS-1$
private static final QualifiedName LOAD_FLAG = new QualifiedName(CCorePlugin.PLUGIN_ID, "descriptionLoadded"); //$NON-NLS-1$
private class CompositeSafeRunnable implements ISafeRunnable {
private List fRunnables = new ArrayList();
@ -376,7 +377,7 @@ public class CProjectDescriptionManager {
}
if(des != null){
if(setLoaddedDescription(project, des, false)){
if(setLoaddedDescriptionOnLoad(project, des)){
if(eDes != null)
saveConversion(project, eDes, (CProjectDescription)des, new NullProgressMonitor());
@ -414,6 +415,18 @@ public class CProjectDescriptionManager {
return des;
}
private synchronized boolean setLoaddedDescriptionOnLoad(IProject project, ICProjectDescription des){
des.setSessionProperty(LOAD_FLAG, Boolean.TRUE);
ICProjectDescription oldDes = getLoaddedDescription(project);
setLoaddedDescription(project, des, true);
if(oldDes == null)
return true;
return oldDes.getSessionProperty(LOAD_FLAG) == null;
}
private CProjectDescriptionEvent createLoaddedEvent(ICProjectDescription des){
return new CProjectDescriptionEvent(CProjectDescriptionEvent.LOADDED,
null,
@ -1304,9 +1317,9 @@ public class CProjectDescriptionManager {
return provider.loadConfiguration(des);
}
CConfigurationData applyData(ICConfigurationDescription des, CConfigurationData base) throws CoreException {
CConfigurationData applyData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base) throws CoreException {
CConfigurationDataProvider provider = getProvider(des);
return provider.applyConfiguration(des, base);
return provider.applyConfiguration(des, baseDescription, base);
}
void removeData(ICConfigurationDescription des, CConfigurationData data) throws CoreException{
@ -1314,9 +1327,9 @@ public class CProjectDescriptionManager {
provider.removeConfiguration(des, data);
}
CConfigurationData createData(ICConfigurationDescription des, CConfigurationData base, boolean clone) throws CoreException{
CConfigurationData createData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base, boolean clone) throws CoreException{
CConfigurationDataProvider provider = getProvider(des);
return provider.createConfiguration(des, base, clone);
return provider.createConfiguration(des, baseDescription, base, clone);
}
private CConfigurationDataProvider getProvider(ICConfigurationDescription des) throws CoreException{
@ -2583,7 +2596,7 @@ public class CProjectDescriptionManager {
rootParent.removeChild(rootEl);
ICStorageElement baseRootEl = settings.getRootStorageElement();
rootEl = rootParent.importChild(baseRootEl);
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(baseData, cfgDes.getSpecSettings(), null, rootEl, true);
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, cfgDes.getSpecSettings(), null, rootEl, true);
return cache;
}

View file

@ -20,14 +20,18 @@ public class DefaultConfigurationDataProvider extends
CConfigurationDataProvider {
public CConfigurationData applyConfiguration(
ICConfigurationDescription des, CConfigurationData base)
ICConfigurationDescription des,
ICConfigurationDescription baseDescription,
CConfigurationData base)
throws CoreException {
//TODO: implement load/store
return base;
}
public CConfigurationData createConfiguration(
ICConfigurationDescription des, CConfigurationData base,
ICConfigurationDescription des,
ICConfigurationDescription baseDescription,
CConfigurationData base,
boolean clone) throws CoreException {
//TODO: implement load/store
CDefaultConfigurationData data = new CDefaultConfigurationData(des.getId(), des.getName(), base, null, clone);

View file

@ -12,9 +12,7 @@ package org.eclipse.cdt.internal.core.settings.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
@ -220,7 +218,9 @@ public class PathEntryConfigurationDataProvider extends
}
public CConfigurationData applyConfiguration(
ICConfigurationDescription des, CConfigurationData base)
ICConfigurationDescription des,
ICConfigurationDescription baseDescription,
CConfigurationData base)
throws CoreException {
//TODO: check external/reference info here as well.
if(!fFactory.isModified(base))
@ -229,8 +229,8 @@ public class PathEntryConfigurationDataProvider extends
IProject project = des.getProjectDescription().getProject();
ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des);
IPathEntry entries[] = PathEntryTranslator.getPathEntries(project, base, refInfo, PathEntryTranslator.INCLUDE_USER);
// ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des);
IPathEntry entries[] = PathEntryTranslator.getPathEntries(project, baseDescription, PathEntryTranslator.INCLUDE_USER);
CModelManager manager = CModelManager.getDefault();
ICProject cproject = manager.create(project);
IPathEntry[] curRawEntries = PathEntryManager.getDefault().getRawPathEntries(cproject);
@ -249,7 +249,9 @@ public class PathEntryConfigurationDataProvider extends
}
public CConfigurationData createConfiguration(
ICConfigurationDescription des, CConfigurationData base,
ICConfigurationDescription des,
ICConfigurationDescription baseDescription,
CConfigurationData base,
boolean clone) throws CoreException {
CfgData copy = new CfgData(des.getId(), des.getName(), base, clone);
copy.setModified(false);

View file

@ -19,9 +19,11 @@ import java.util.Set;
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.resources.IPathEntryVariableChangeListener;
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
import org.eclipse.cdt.core.resources.PathEntryVariableChangeEvent;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.core.cdtvariables.ICdtVariableChangeListener;
import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
import org.eclipse.cdt.internal.core.cdtvariables.UserDefinedVariableSupplier;
@ -129,6 +131,23 @@ public class CdtVarPathEntryVariableManager implements
return null;
}
public static boolean isPathEntryVariable(ICdtVariable var, ICConfigurationDescription cfg){
return isPathEntryVariable(var, cfg, CCorePlugin.getDefault().getCdtVariableManager());
}
public static boolean isPathEntryVariable(ICdtVariable var, ICConfigurationDescription cfg, ICdtVariableManager mngr){
if(mngr.isUserVariable(var, cfg))
return false;
if(!mngr.isUserVariable(var, null))
return false;
if(getVariablePath(var) == null)
return false;
return true;
}
public String[] getVariableNames() {
ICdtVariable[] vars = fUserVarSupplier.getMacros(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null);
ArrayList list = new ArrayList();

View file

@ -17,7 +17,16 @@ import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager;
public class BuildSystemVariableSupplier extends CoreMacroSupplierBase {
private static BuildSystemVariableSupplier fInstance;
private BuildSystemVariableSupplier(){
}
public static BuildSystemVariableSupplier getInstance(){
if(fInstance == null){
fInstance = new BuildSystemVariableSupplier();
}
return fInstance;
}
private class ExtensionMacroProvider extends CdtVariableManager{
private IVariableContextInfo fStartInfo;
private int fContextType;

View file

@ -31,6 +31,7 @@ public class CdtVariableManager implements ICdtVariableManager {
static private CdtVariableManager fDefault;
public static UserDefinedVariableSupplier fUserDefinedMacroSupplier = UserDefinedVariableSupplier.getInstance();
public static BuildSystemVariableSupplier fBuildSystemVariableSupplier = BuildSystemVariableSupplier.getInstance();
public static EnvironmentVariableSupplier fEnvironmentMacroSupplier = EnvironmentVariableSupplier.getInstance();
public static CdtMacroSupplier fCdtMacroSupplier = CdtMacroSupplier.getInstance();
public static EclipseVariablesVariableSupplier fEclipseVariablesMacroSupplier = EclipseVariablesVariableSupplier.getInstance();
@ -199,6 +200,12 @@ public class CdtVariableManager implements ICdtVariableManager {
public boolean isUserVariable(ICdtVariable variable,
ICConfigurationDescription cfg) {
return variable instanceof StorableCdtVariable;
if(!(variable instanceof StorableCdtVariable))
return false;
if(cfg != null)
return UserDefinedVariableSupplier.getInstance().containsVariable(ICoreVariableContextInfo.CONTEXT_CONFIGURATION, cfg, variable);
return UserDefinedVariableSupplier.getInstance().containsVariable(ICoreVariableContextInfo.CONTEXT_WORKSPACE, null, variable);
}
}

View file

@ -44,6 +44,7 @@ public class DefaultVariableContextInfo implements ICoreVariableContextInfo {
if(data instanceof ICConfigurationDescription){
return new ICdtVariableSupplier[]{
CdtVariableManager.fUserDefinedMacroSupplier,
CdtVariableManager.fBuildSystemVariableSupplier,
CdtVariableManager.fEnvironmentMacroSupplier,
CdtVariableManager.fCdtMacroSupplier
};

View file

@ -18,6 +18,7 @@ import java.util.Map;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.internal.core.cdtvariables.UserDefinedVariableSupplier.VarKey;
import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
@ -375,4 +376,16 @@ public class StorableCdtVariables {
}
return false;
}
public boolean contains(ICdtVariable var){
ICdtVariable curVar = getMacro(var.getName());
if(curVar == null)
return false;
if(new VarKey(curVar, false).equals(new VarKey(var, false)))
return true;
return false;
}
}

View file

@ -268,7 +268,7 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
}
}
private static class VarKey {
static class VarKey {
private ICdtVariable fVar;
private boolean fNameOnly;
@ -484,7 +484,7 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
StorableCdtVariables macros = loadNewStileWorkspaceMacros();
//now load PathEntry Variables from preferences
loadPathEntryVariables(macros);
return macros;
}
@ -672,4 +672,15 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
}
}
public boolean containsVariable(int context, Object data, ICdtVariable var){
ICdtVariable varContained = getMacro(var.getName(), context, data);
if(varContained == null)
return false;
if(new VarKey(varContained, false).equals(new VarKey(var, false)))
return true;
return false;
}
}