1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Fix for [Bug 181021] [Project Model]Source location and "exlude from build" settings are inconsistent

This commit is contained in:
Mikhail Sennikovsky 2007-04-10 10:20:35 +00:00
parent 7f5644f01c
commit ead2da2599
45 changed files with 1401 additions and 670 deletions

View file

@ -18,7 +18,7 @@ import org.eclipse.cdt.core.settings.model.util.CDataSerializer;
import org.eclipse.cdt.core.settings.model.util.UserAndDiscoveredEntryDataSerializer; import org.eclipse.cdt.core.settings.model.util.UserAndDiscoveredEntryDataSerializer;
import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator; import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator;
import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoProcessor; import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoProcessor;
import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.IRcSettingInfo; import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.DiscoveredSettingInfo;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -65,9 +65,9 @@ public class MakeConfigurationDataProvider extends CDefaultConfigurationDataProv
CDataDiscoveredInfoCalculator calculator, CDataDiscoveredInfoCalculator calculator,
CDataDiscoveredInfoProcessor processor){ CDataDiscoveredInfoProcessor processor){
IRcSettingInfo rcInfos[] = calculator.getSettingInfos(project, cfgData); DiscoveredSettingInfo dsInfo = calculator.getSettingInfos(project, cfgData);
processor.applyDiscoveredInfo(cfgData, rcInfos); processor.applyDiscoveredInfo(cfgData, dsInfo);
} }
protected CDataDiscoveredInfoProcessor getInfoProcessor(){ protected CDataDiscoveredInfoProcessor getInfoProcessor(){

View file

@ -44,6 +44,24 @@ public class CDataDiscoveredInfoCalculator {
private static CDataDiscoveredInfoCalculator fInstance; private static CDataDiscoveredInfoCalculator fInstance;
public static class DiscoveredSettingInfo{
private boolean fIsPerFileDiscovery;
private IRcSettingInfo[] fInfos;
public DiscoveredSettingInfo(boolean isPerFileDiscovery, IRcSettingInfo[] infos){
fIsPerFileDiscovery = isPerFileDiscovery;
fInfos = infos;
}
public boolean isPerFileDiscovery(){
return fIsPerFileDiscovery;
}
public IRcSettingInfo[] getRcSettingInfos(){
return fInfos;
}
}
public interface IRcSettingInfo { public interface IRcSettingInfo {
CResourceData getResourceData(); CResourceData getResourceData();
@ -1099,14 +1117,15 @@ public class CDataDiscoveredInfoCalculator {
return fInstance; return fInstance;
} }
public IRcSettingInfo[] getSettingInfos(IProject project, public DiscoveredSettingInfo getSettingInfos(IProject project,
CConfigurationData cfgData){ CConfigurationData cfgData){
InfoContext context = createContext(project, cfgData); InfoContext context = createContext(project, cfgData);
try { try {
IDiscoveredPathManager.IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context); IDiscoveredPathManager.IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context);
if(info instanceof IDiscoveredPathManager.IPerFileDiscoveredPathInfo2){ if(info instanceof IDiscoveredPathManager.IPerFileDiscoveredPathInfo2){
IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 perFileInfo = (IDiscoveredPathManager.IPerFileDiscoveredPathInfo2)info; IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 perFileInfo = (IDiscoveredPathManager.IPerFileDiscoveredPathInfo2)info;
return getSettingInfos(project, cfgData, perFileInfo, true); DiscoveredSettingInfo dsInfo = new DiscoveredSettingInfo(true, getSettingInfos(project, cfgData, perFileInfo, true));
return dsInfo;
} }
IPath[] includes = info.getIncludePaths(); IPath[] includes = info.getIncludePaths();
Map symbols = info.getSymbols(); Map symbols = info.getSymbols();
@ -1114,11 +1133,11 @@ public class CDataDiscoveredInfoCalculator {
PathInfo pathInfo = new PathInfo(includes, null, symbols, null, null); PathInfo pathInfo = new PathInfo(includes, null, symbols, null, null);
CFolderData rootData = cfgData.getRootFolderData(); CFolderData rootData = cfgData.getRootFolderData();
IRcSettingInfo rcInfo = createRcSettingInfo(rootData, pathInfo); IRcSettingInfo rcInfo = createRcSettingInfo(rootData, pathInfo);
return new IRcSettingInfo[]{rcInfo}; return new DiscoveredSettingInfo(false, new IRcSettingInfo[]{rcInfo});
} catch (CoreException e) { } catch (CoreException e) {
MakeCorePlugin.log(e); MakeCorePlugin.log(e);
} }
return new IRcSettingInfo[0]; return new DiscoveredSettingInfo(false, new IRcSettingInfo[0]);
} }
protected InfoContext createContext(IProject project, CConfigurationData data){ protected InfoContext createContext(IProject project, CConfigurationData data){

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.settings.model.extension.CResourceData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.make.core.scannerconfig.PathInfo; import org.eclipse.cdt.make.core.scannerconfig.PathInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.DiscoveredSettingInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.ILangSettingInfo; import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.ILangSettingInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.IRcSettingInfo; import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoCalculator.IRcSettingInfo;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -30,12 +31,14 @@ import org.eclipse.core.runtime.Path;
public abstract class CDataDiscoveredInfoProcessor { public abstract class CDataDiscoveredInfoProcessor {
public void applyDiscoveredInfo(CConfigurationData cfgData, IRcSettingInfo[] infos){ public void applyDiscoveredInfo(CConfigurationData cfgData, DiscoveredSettingInfo dsIinfo){
Map map = CDataUtil.createPathRcDataMap(cfgData); Map map = CDataUtil.createPathRcDataMap(cfgData);
IRcSettingInfo info; IRcSettingInfo info;
PathSettingsContainer cr = PathSettingsContainer.createRootContainer(); PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
IRcSettingInfo[] infos = dsIinfo.getRcSettingInfos();
for(int i = 0; i < infos.length; i++){ for(int i = 0; i < infos.length; i++){
info = infos[i]; info = infos[i];
applyInfo(cfgData, info, cr); applyInfo(cfgData, info, cr);

View file

@ -189,7 +189,7 @@ public class CfgDiscoveredPathManager implements IResourceChangeListener {
return getCachedPathInfo(cInfo); return getCachedPathInfo(cInfo);
} }
cInfo.fLoadContext.getConfiguration().getRootFolderInfo().setExclude(false); ((FolderInfo)cInfo.fLoadContext.getConfiguration().getRootFolderInfo()).setContainsDiscoveredScannerInfo(true);
Map map = baseInfo.getSymbols(); Map map = baseInfo.getSymbols();
IPath paths[] = baseInfo.getIncludePaths(); IPath paths[] = baseInfo.getIncludePaths();
@ -232,7 +232,7 @@ public class CfgDiscoveredPathManager implements IResourceChangeListener {
} }
if(rootSettingFound && fileSettingFound) if(rootSettingFound && fileSettingFound)
data.getRootFolderData().setExcluded(true); ((BuildFolderData)data.getRootFolderData()).setContainsDiscoveredScannerInfo(false);
if(!rcDataMap.isEmpty()){ if(!rcDataMap.isEmpty()){
CResourceData tmpRcData; CResourceData tmpRcData;

View file

@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.core; package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
@ -50,7 +51,7 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont
public static final String BUILD_ARTEFACT_TYPE = "buildArtefactType"; //$NON-NLS-1$ public static final String BUILD_ARTEFACT_TYPE = "buildArtefactType"; //$NON-NLS-1$
public static final String IS_SYSTEM = "isSystem"; //$NON-NLS-1$ public static final String IS_SYSTEM = "isSystem"; //$NON-NLS-1$
public static final String SOURCE_ENTRIES = "sourceEntries"; //$NON-NLS-1$
@ -586,9 +587,9 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont
CConfigurationData getConfigurationData(); CConfigurationData getConfigurationData();
IPath[] getSourcePaths(); ICSourceEntry[] getSourceEntries();
void setSourcePaths(IPath[] paths); void setSourceEntries(ICSourceEntry[] entries);
CBuildData getBuildData(); CBuildData getBuildData();

View file

@ -22,6 +22,10 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager; import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
@ -59,7 +63,6 @@ import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
import org.eclipse.cdt.managedbuilder.makegen.gnu.ManagedBuildGnuToolInfo;
import org.eclipse.cdt.managedbuilder.pdomdepgen.PDOMDependencyGenerator; import org.eclipse.cdt.managedbuilder.pdomdepgen.PDOMDependencyGenerator;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -109,7 +112,7 @@ public class BuildDescription implements IBuildDescription {
private Set fToolInProcesSet = new HashSet(); private Set fToolInProcesSet = new HashSet();
private ITool fOrderedTools[]; private ITool fOrderedTools[];
private IPath[] fSourcePaths; private ICSourceEntry[] fSourceEntries;
// private Map fExtToToolAndTypeListMap = new HashMap(); // private Map fExtToToolAndTypeListMap = new HashMap();
@ -519,12 +522,14 @@ public class BuildDescription implements IBuildDescription {
} }
protected boolean isSource(IPath path){ protected boolean isSource(IPath path){
path = path.makeRelative(); return !CDataUtil.isExcluded(path, fSourceEntries);
for(int i = 0; i < fSourcePaths.length; i++){ //
if(fSourcePaths[i].isPrefixOf(path)) // path = path.makeRelative();
return true; // for(int i = 0; i < fSourcePaths.length; i++){
} // if(fSourcePaths[i].isPrefixOf(path))
return false; // return true;
// }
// return false;
} }
@ -705,9 +710,9 @@ public class BuildDescription implements IBuildDescription {
fInfo = ManagedBuildManager.getBuildInfo(fProject); fInfo = ManagedBuildManager.getBuildInfo(fProject);
fFlags = flags; fFlags = flags;
fSourcePaths = fCfg.getSourcePaths(); fSourceEntries = fCfg.getSourceEntries();
if(fSourcePaths.length == 0){ if(fSourceEntries.length == 0){
fSourcePaths = new IPath[]{Path.EMPTY}; fSourceEntries = new ICSourceEntry[]{new CSourceEntry(Path.EMPTY, null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH)};
} }
fInputStep = createStep(null,null); fInputStep = createStep(null,null);
fOutputStep = createStep(null,null); fOutputStep = createStep(null,null);

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.core.settings.model.COutputEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICOutputEntry; import org.eclipse.cdt.core.settings.model.ICOutputEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
@ -560,7 +561,7 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
IManagedConfigElement child = children[i]; IManagedConfigElement child = children[i];
String name = child.getName(); String name = child.getName();
if(OUTPUT_ENTRIES.equals(name)){ if(OUTPUT_ENTRIES.equals(name)){
ICLanguageSettingEntry entries[] = LanguageSettingEntriesSerializer.loadEntries(new ManagedConfigStorageElement(child)); ICSettingEntry entries[] = LanguageSettingEntriesSerializer.loadEntries(new ManagedConfigStorageElement(child));
if(entries.length == 0){ if(entries.length == 0){
outputEntries = new ICOutputEntry[0]; outputEntries = new ICOutputEntry[0];
} else { } else {
@ -702,7 +703,7 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
ICStorageElement child = children[i]; ICStorageElement child = children[i];
String name = child.getName(); String name = child.getName();
if(OUTPUT_ENTRIES.equals(name)){ if(OUTPUT_ENTRIES.equals(name)){
ICLanguageSettingEntry entries[] = LanguageSettingEntriesSerializer.loadEntries(child); ICSettingEntry entries[] = LanguageSettingEntriesSerializer.loadEntries(child);
if(entries.length == 0){ if(entries.length == 0){
outputEntries = new ICOutputEntry[0]; outputEntries = new ICOutputEntry[0];
} else { } else {

View file

@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -24,14 +25,19 @@ import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache; import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry; import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICLibraryPathEntry; import org.eclipse.cdt.core.settings.model.ICLibraryPathEntry;
import org.eclipse.cdt.core.settings.model.ICOutputEntry; import org.eclipse.cdt.core.settings.model.ICOutputEntry;
import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.LanguageSettingEntriesSerializer;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
@ -104,7 +110,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
private String preannouncebuildStep; private String preannouncebuildStep;
private String postannouncebuildStep; private String postannouncebuildStep;
private String description; private String description;
private IPath[] sourcePaths; private ICSourceEntry[] sourceEntries;
private BuildObjectProperties buildProperties; private BuildObjectProperties buildProperties;
private boolean isTest; private boolean isTest;
private SupportedProperties supportedProperties; private SupportedProperties supportedProperties;
@ -128,6 +134,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
// private Boolean isPerResourceDiscovery; // private Boolean isPerResourceDiscovery;
private ICfgScannerConfigBuilderInfo2Set cfgScannerInfo; private ICfgScannerConfigBuilderInfo2Set cfgScannerInfo;
private boolean isPreferenceConfig; private boolean isPreferenceConfig;
private List excludeList;
//property name for holding the rebuild state //property name for holding the rebuild state
private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$ private static final String REBUILD_STATE = "rebuildState"; //$NON-NLS-1$
@ -217,6 +224,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
// Load the children // Load the children
IManagedConfigElement[] configElements = element.getChildren(); IManagedConfigElement[] configElements = element.getChildren();
List srcPathList = new ArrayList(); List srcPathList = new ArrayList();
excludeList = new ArrayList();
for (int l = 0; l < configElements.length; ++l) { for (int l = 0; l < configElements.length; ++l) {
IManagedConfigElement configElement = configElements[l]; IManagedConfigElement configElement = configElements[l];
if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) { if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
@ -235,11 +243,15 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
srcPathList.add(p.getPath()); srcPathList.add(p.getPath());
} else if (configElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){ } else if (configElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){
loadProperties(configElement); loadProperties(configElement);
} else if (SOURCE_ENTRIES.equals(configElement.getName())){
List seList = LanguageSettingEntriesSerializer.loadEntriesList(new ManagedConfigStorageElement(configElement), ICSettingEntry.SOURCE_PATH);
sourceEntries = (ICSourceEntry[])seList.toArray(new ICSourceEntry[seList.size()]);
} }
} }
if(srcPathList.size() > 0) sourceEntries = createSourceEntries(sourceEntries, srcPathList, excludeList);
sourcePaths = (IPath[])srcPathList.toArray(new IPath[srcPathList.size()]);
excludeList = null;
if(rootFolderInfo == null) if(rootFolderInfo == null)
createRootFolderInfo(); createRootFolderInfo();
@ -278,6 +290,37 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
setDirty(false); setDirty(false);
} }
private static ICSourceEntry[] createSourceEntries(ICSourceEntry[] curEntries, List pathList, List excludeList){
for(int i = 0; i < excludeList.size(); i++){
IPath path = (IPath)excludeList.get(i);
if(path.segmentCount() == 0)
excludeList.remove(i);
}
if(pathList.size() == 0)
pathList.add(Path.EMPTY);
if(pathList.size() == 1
&& pathList.get(0).equals(Path.EMPTY)
&& excludeList.size() == 0)
return curEntries;
int pathSize = pathList.size();
Map map = new LinkedHashMap();
for(int i = 0; i < pathSize; i++){
IPath path = (IPath)pathList.get(i);
ICSourceEntry entry = (ICSourceEntry)map.get(path);
if(entry == null)
entry = new CSourceEntry(path, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
entry = CDataUtil.addExcludePaths(entry, excludeList, true);
if(entry != null)
map.put(path, entry);
}
return (ICSourceEntry[])map.values().toArray(new ICSourceEntry[map.size()]);
}
/** /**
* Create a new extension configuration based on one already defined. * Create a new extension configuration based on one already defined.
* *
@ -363,6 +406,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
ICStorageElement configElements[] = element.getChildren(); ICStorageElement configElements[] = element.getChildren();
List srcPathList = new ArrayList(); List srcPathList = new ArrayList();
excludeList = new ArrayList();
for (int i = 0; i < configElements.length; ++i) { for (int i = 0; i < configElements.length; ++i) {
ICStorageElement configElement = configElements[i]; ICStorageElement configElement = configElements[i];
if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) { if (configElement.getName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
@ -379,14 +423,17 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
SourcePath p = new SourcePath(configElement); SourcePath p = new SourcePath(configElement);
if(p.getPath() != null) if(p.getPath() != null)
srcPathList.add(p.getPath()); srcPathList.add(p.getPath());
} else if (SOURCE_ENTRIES.equals(configElement.getName())){
List seList = LanguageSettingEntriesSerializer.loadEntriesList(configElement, ICSettingEntry.SOURCE_PATH);
sourceEntries = (ICSourceEntry[])seList.toArray(new ICSourceEntry[seList.size()]);
} }
} }
resolveProjectReferences(true); resolveProjectReferences(true);
if(srcPathList.size() > 0) sourceEntries = createSourceEntries(sourceEntries, srcPathList, excludeList);
sourcePaths = (IPath[])srcPathList.toArray(new IPath[srcPathList.size()]);
excludeList = null;
PropertyManager mngr = PropertyManager.getInstance(); PropertyManager mngr = PropertyManager.getInstance();
String rebuild = mngr.getProperty(this, REBUILD_STATE); String rebuild = mngr.getProperty(this, REBUILD_STATE);
@ -462,8 +509,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
postannouncebuildStep = baseCfg.postannouncebuildStep; postannouncebuildStep = baseCfg.postannouncebuildStep;
if(baseCfg.sourcePaths != null) if(baseCfg.sourceEntries != null)
sourcePaths = (IPath[])baseCfg.sourcePaths.clone(); sourceEntries = (ICSourceEntry[])baseCfg.sourceEntries.clone();
// enableInternalBuilder(baseCfg.isInternalBuilderEnabled()); // enableInternalBuilder(baseCfg.isInternalBuilderEnabled());
// setInternalBuilderIgnoreErr(baseCfg.getInternalBuilderIgnoreErr()); // setInternalBuilderIgnoreErr(baseCfg.getInternalBuilderIgnoreErr());
@ -618,8 +665,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
if (cloneConfig.postannouncebuildStep != null) { if (cloneConfig.postannouncebuildStep != null) {
postannouncebuildStep = new String(cloneConfig.postannouncebuildStep); postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
} }
if(cloneConfig.sourcePaths != null) if(cloneConfig.sourceEntries != null)
sourcePaths = (IPath[])cloneConfig.sourcePaths.clone(); sourceEntries = (ICSourceEntry[])cloneConfig.sourceEntries.clone();
// enableInternalBuilder(cloneConfig.isInternalBuilderEnabled()); // enableInternalBuilder(cloneConfig.isInternalBuilderEnabled());
// setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr()); // setInternalBuilderIgnoreErr(cloneConfig.getInternalBuilderIgnoreErr());
@ -906,12 +953,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
PropertyManager.getInstance().serialize(this); PropertyManager.getInstance().serialize(this);
if(sourcePaths != null && sourcePaths.length > 0){ if(sourceEntries != null && sourceEntries.length > 0){
for(int i = 0; i < sourcePaths.length; i++){ ICStorageElement el = element.createChild(SOURCE_ENTRIES);
SourcePath p = new SourcePath(sourcePaths[i]); LanguageSettingEntriesSerializer.serializeEntries(sourceEntries, el);
ICStorageElement el = element.createChild(SourcePath.ELEMENT_NAME);
p.serialize(el);
}
} }
// I am clean now // I am clean now
isDirty = false; isDirty = false;
@ -2259,27 +2303,33 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return folderInfo; return folderInfo;
} }
public IPath[] getSourcePaths() { public ICSourceEntry[] getSourceEntries() {
if(sourcePaths == null){ if(sourceEntries == null){
if(parent != null) if(parent != null)
return parent.getSourcePaths(); return parent.getSourceEntries();
return new IPath[]{new Path("")}; //$NON-NLS-1$ return new ICSourceEntry[]{new CSourceEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED)}; //$NON-NLS-1$
} }
return (IPath[])sourcePaths.clone(); return (ICSourceEntry[])sourceEntries.clone();
} }
public void setSourcePaths(IPath[] paths) { public void setSourceEntries(ICSourceEntry[] entries) {
if(Arrays.equals(sourcePaths, paths)) setSourceEntries(entries, true);
}
public void setSourceEntries(ICSourceEntry[] entries, boolean setRebuildState) {
if(Arrays.equals(getSourceEntries(), entries))
return; return;
sourcePaths = (IPath[])paths.clone(); sourceEntries = entries != null ? (ICSourceEntry[])entries.clone() : null;
// for(int i = 0; i < sourcePaths.length; i++){ // for(int i = 0; i < sourcePaths.length; i++){
// sourcePaths[i] = sourcePaths[i].makeRelative(); // sourcePaths[i] = sourcePaths[i].makeRelative();
// } // }
exportArtifactInfo(); exportArtifactInfo();
if(setRebuildState){
setDirty(true); setDirty(true);
setRebuildState(true); setRebuildState(true);
} }
}
public void setErrorParserAttribute(String[] ids) { public void setErrorParserAttribute(String[] ids) {
if(ids == null){ if(ids == null){
@ -2893,4 +2943,26 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
throw new BuildException(e.getLocalizedMessage()); throw new BuildException(e.getLocalizedMessage());
} }
} }
boolean isExcluded(IPath path){
// if(path.segmentCount() == 0)
// return false;
ICSourceEntry[] entries = getSourceEntries();
return CDataUtil.isExcluded(path, entries);
}
void setExcluded(IPath path, boolean excluded){
// if(path.segmentCount() == 0)
// return;
if(excludeList == null) {
ICSourceEntry[] entries = getSourceEntries();
ICSourceEntry[] newEntries = CDataUtil.setExcluded(path, excluded, entries);
setSourceEntries(newEntries, false);
} else{
if(excluded)
excludeList.add(path);
}
}
} }

View file

@ -57,6 +57,7 @@ import org.eclipse.core.runtime.Path;
public class FolderInfo extends ResourceInfo implements IFolderInfo { public class FolderInfo extends ResourceInfo implements IFolderInfo {
private ToolChain toolChain; private ToolChain toolChain;
private boolean isExtensionElement; private boolean isExtensionElement;
private boolean containsDiscoveredScannerInfo = true;
public FolderInfo(FolderInfo folderInfo, String id, String resourceName, IPath path){ public FolderInfo(FolderInfo folderInfo, String id, String resourceName, IPath path){
super(folderInfo, path, id, resourceName); super(folderInfo, path, id, resourceName);
@ -245,6 +246,9 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
((ToolChain)newChain).setTargetPlatform(tp); ((ToolChain)newChain).setTargetPlatform(tp);
} }
if(isRoot())
containsDiscoveredScannerInfo = cloneInfo.containsDiscoveredScannerInfo;
if(copyIds){ if(copyIds){
isDirty = cloneInfo.isDirty; isDirty = cloneInfo.isDirty;
needsRebuild = cloneInfo.needsRebuild; needsRebuild = cloneInfo.needsRebuild;
@ -1354,4 +1358,15 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
public boolean hasCustomSettings(){ public boolean hasCustomSettings(){
return toolChain.hasCustomSettings(); return toolChain.hasCustomSettings();
} }
public boolean containsDiscoveredScannerInfo(){
if(!isRoot())
return true;
return containsDiscoveredScannerInfo;
}
public void setContainsDiscoveredScannerInfo(boolean contains){
containsDiscoveredScannerInfo = contains;
}
} }

View file

@ -798,8 +798,7 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
tool.removeOption(opts[j]); tool.removeOption(opts[j]);
} }
} }
// setExclude(false);
setExclude(false);
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -32,10 +32,10 @@ import org.eclipse.core.runtime.Path;
public abstract class ResourceInfo extends BuildObject implements IResourceInfo { public abstract class ResourceInfo extends BuildObject implements IResourceInfo {
// private IFolderInfo parentFolderInfo; // private IFolderInfo parentFolderInfo;
// private String parentFolderInfoId; // private String parentFolderInfoId;
private IConfiguration config; private Configuration config;
private IPath path; private IPath path;
boolean isDirty; boolean isDirty;
private boolean isExcluded; // private boolean isExcluded;
boolean needsRebuild; boolean needsRebuild;
private ResourceInfoContainer rcInfo; private ResourceInfoContainer rcInfo;
private CResourceData resourceData; private CResourceData resourceData;
@ -44,15 +44,15 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
// private String baseToolChainId; // private String baseToolChainId;
ResourceInfo(IConfiguration cfg, IManagedConfigElement element, boolean hasBody){ ResourceInfo(IConfiguration cfg, IManagedConfigElement element, boolean hasBody){
config = cfg; config = (Configuration)cfg;
if(hasBody) if(hasBody)
loadFromManifest(element); loadFromManifest(element);
} }
ResourceInfo(IConfiguration cfg, ResourceInfo base, String id) { ResourceInfo(IConfiguration cfg, ResourceInfo base, String id) {
config = cfg; config = (Configuration)cfg;
path = normalizePath(base.path); path = normalizePath(base.path);
internalSetExclude(base.isExcluded); // internalSetExclude(base.isExcluded);
setId(id); setId(id);
setName(base.getName()); setName(base.getName());
@ -88,7 +88,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
} }
ResourceInfo(IConfiguration cfg, IPath path, String id, String name) { ResourceInfo(IConfiguration cfg, IPath path, String id, String name) {
config = cfg; config = (Configuration)cfg;
path = normalizePath(path); path = normalizePath(path);
this.path = path; this.path = path;
@ -98,7 +98,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
} }
ResourceInfo(IFileInfo base, IPath path, String id, String name) { ResourceInfo(IFileInfo base, IPath path, String id, String name) {
config = base.getParent(); config = (Configuration)base.getParent();
setId(id); setId(id);
setName(name); setName(name);
@ -106,7 +106,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
path = normalizePath(path); path = normalizePath(path);
this.path = path; this.path = path;
internalSetExclude(base.isExcluded()); // internalSetExclude(base.isExcluded());
// parentFolderInfoId = base.getId(); // parentFolderInfoId = base.getId();
// parentFolderInfo = base; // parentFolderInfo = base;
// inheritParentInfo = false; // inheritParentInfo = false;
@ -115,7 +115,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
} }
ResourceInfo(FolderInfo base, IPath path, String id, String name) { ResourceInfo(FolderInfo base, IPath path, String id, String name) {
config = base.getParent(); config = (Configuration)base.getParent();
setId(id); setId(id);
setName(name); setName(name);
@ -123,7 +123,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
path = normalizePath(path); path = normalizePath(path);
this.path = path; this.path = path;
internalSetExclude(base.isExcluded()); // internalSetExclude(base.isExcluded());
// parentFolderInfoId = base.getId(); // parentFolderInfoId = base.getId();
// parentFolderInfo = base; // parentFolderInfo = base;
// inheritParentInfo = base.getPath().isPrefixOf(path); // inheritParentInfo = base.getPath().isPrefixOf(path);
@ -132,7 +132,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
} }
ResourceInfo(IConfiguration cfg, ICStorageElement element, boolean hasBody){ ResourceInfo(IConfiguration cfg, ICStorageElement element, boolean hasBody){
config = cfg; config = (Configuration)cfg;
if(hasBody) if(hasBody)
loadFromProject(element); loadFromProject(element);
} }
@ -165,7 +165,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
// exclude // exclude
String excludeStr = element.getAttribute(EXCLUDE); String excludeStr = element.getAttribute(EXCLUDE);
if (excludeStr != null){ if (excludeStr != null){
internalSetExclude("true".equals(excludeStr)); //$NON-NLS-1$ config.setExcluded(getPath(), ("true".equals(excludeStr))); //$NON-NLS-1$
} }
} }
@ -197,7 +197,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
if (element.getAttribute(EXCLUDE) != null) { if (element.getAttribute(EXCLUDE) != null) {
String excludeStr = element.getAttribute(EXCLUDE); String excludeStr = element.getAttribute(EXCLUDE);
if (excludeStr != null){ if (excludeStr != null){
internalSetExclude("true".equals(excludeStr)); //$NON-NLS-1$ config.setExcluded(getPath(), ("true".equals(excludeStr))); //$NON-NLS-1$
} }
} }
@ -232,7 +232,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
} }
public boolean isExcluded() { public boolean isExcluded() {
return isExcluded; return config.isExcluded(getPath());
} }
public boolean needsRebuild() { public boolean needsRebuild() {
@ -244,17 +244,20 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
} }
public void setExclude(boolean excluded) { public void setExclude(boolean excluded) {
if (isExcluded != internalSetExclude(excluded)) { if(isExcluded() == excluded)
return;
config.setExcluded(getPath(), excluded);
setDirty(true); setDirty(true);
setRebuildState(true); setRebuildState(true);
} }
}
private boolean internalSetExclude(boolean excluded){ // private boolean internalSetExclude(boolean excluded){
// if(excluded/* && isRoot()*/) //// if(excluded/* && isRoot()*/)
// return isExcluded; //// return isExcluded;
return isExcluded = excluded; // return isExcluded = excluded;
} // }
public void setPath(IPath p) { public void setPath(IPath p) {
p = normalizePath(p); p = normalizePath(p);
@ -287,9 +290,9 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
element.setAttribute(IBuildObject.NAME, name); element.setAttribute(IBuildObject.NAME, name);
} }
if (isExcluded) { // if (isExcluded) {
element.setAttribute(IResourceInfo.EXCLUDE, "true"); //$NON-NLS-1$ // element.setAttribute(IResourceInfo.EXCLUDE, "true"); //$NON-NLS-1$
} // }
if (path != null) { if (path != null) {
element.setAttribute(IResourceInfo.RESOURCE_PATH, path.toString()); element.setAttribute(IResourceInfo.RESOURCE_PATH, path.toString());

View file

@ -994,8 +994,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
for (j = 0; j < tools.length; j++) { for (j = 0; j < tools.length; j++) {
ITool superTool = tool.getSuperClass(); ITool superTool = tool.getSuperClass();
if(superTool != null){ if(superTool != null){
if(!superTool.isExtensionElement()) superTool = ManagedBuildManager.getExtensionTool(superTool);
superTool = superTool.getSuperClass(); // if(!superTool.isExtensionElement())
// superTool = superTool.getSuperClass();
if(superTool != null && superTool.getId().equals(tools[j].getId())){ if(superTool != null && superTool.getId().equals(tools[j].getId())){
tools[j] = tool; tools[j] = tool;

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.internal.dataprovider;
import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CFileData; import org.eclipse.cdt.core.settings.model.extension.CFileData;
@ -114,12 +115,12 @@ public class BuildConfigurationData extends CConfigurationData {
return fCfg.getToolChain().getTargetPlatformData(); return fCfg.getToolChain().getTargetPlatformData();
} }
public IPath[] getSourcePaths() { public ICSourceEntry[] getSourceEntries() {
return fCfg.getSourcePaths(); return fCfg.getSourceEntries();
} }
public void setSourcePaths(IPath[] paths) { public void setSourceEntries(ICSourceEntry[] entries) {
fCfg.setSourcePaths(paths); fCfg.setSourceEntries(entries);
} }
public CBuildData getBuildData() { public CBuildData getBuildData() {

View file

@ -30,13 +30,13 @@ public class BuildFileData extends CFileData {
return fFileInfo.getPath(); return fFileInfo.getPath();
} }
public boolean isExcluded() { // public boolean isExcluded() {
return fFileInfo.isExcluded(); // return fFileInfo.isExcluded();
} // }
//
public void setExcluded(boolean excluded) { // public void setExcluded(boolean excluded) {
fFileInfo.setExclude(excluded); // fFileInfo.setExclude(excluded);
} // }
public void setPath(IPath path) { public void setPath(IPath path) {
fFileInfo.setPath(path); fFileInfo.setPath(path);

View file

@ -34,13 +34,13 @@ public class BuildFolderData extends CFolderData {
return fFolderInfo.getPath(); return fFolderInfo.getPath();
} }
public boolean isExcluded() { // public boolean isExcluded() {
return fFolderInfo.isExcluded(); // return fFolderInfo.isExcluded();
} // }
//
public void setExcluded(boolean excluded) { // public void setExcluded(boolean excluded) {
fFolderInfo.setExclude(excluded); // fFolderInfo.setExclude(excluded);
} // }
public void setPath(IPath path) { public void setPath(IPath path) {
fFolderInfo.setPath(path); fFolderInfo.setPath(path);
@ -84,4 +84,13 @@ public class BuildFolderData extends CFolderData {
((BuildLanguageData)lDatas[i]).clearCachedData(); ((BuildLanguageData)lDatas[i]).clearCachedData();
} }
} }
public boolean containsScannerInfo() {
return fFolderInfo.containsDiscoveredScannerInfo();
}
public void setContainsDiscoveredScannerInfo(boolean contains) {
fFolderInfo.setContainsDiscoveredScannerInfo(contains);
}
} }

View file

@ -15,7 +15,9 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData; 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.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.IKindBasedInfo; import org.eclipse.cdt.core.settings.model.util.IKindBasedInfo;
import org.eclipse.cdt.core.settings.model.util.KindBasedStore; import org.eclipse.cdt.core.settings.model.util.KindBasedStore;
@ -28,6 +30,7 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
import org.eclipse.cdt.managedbuilder.internal.core.InputType; import org.eclipse.cdt.managedbuilder.internal.core.InputType;
import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration; import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ProfileInfoProvider.DiscoveredEntry; import org.eclipse.cdt.managedbuilder.internal.dataprovider.ProfileInfoProvider.DiscoveredEntry;
@ -523,4 +526,12 @@ public class BuildLanguageData extends CLanguageData {
void clearCachedData(){ void clearCachedData(){
fKindToEntryStore.clear(); fKindToEntryStore.clear();
} }
public boolean containsDiscoveredScannerInfo() {
IResourceInfo rcInfo = fTool.getParentResourceInfo();
if(rcInfo instanceof FolderInfo){
return ((FolderInfo)rcInfo).containsDiscoveredScannerInfo();
}
return true;
}
} }

View file

@ -30,6 +30,10 @@ import java.util.Set;
import java.util.Vector; import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor; import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.internal.core.model.Util; import org.eclipse.cdt.internal.core.model.Util;
@ -141,7 +145,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
fo = (IFolderInfo)rcInfo; fo = (IFolderInfo)rcInfo;
} }
// What kind of resource change has occurred // What kind of resource change has occurred
if(!rcInfo.isExcluded() && isSource){ if(/*!rcInfo.isExcluded() && */isSource){
if (resource.getType() == IResource.FILE) { if (resource.getType() == IResource.FILE) {
String ext = resource.getFileExtension(); String ext = resource.getFileExtension();
switch (delta.getKind()) { switch (delta.getKind()) {
@ -242,7 +246,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// if it has a file extension that one of the tools builds, add the sudirectory to the list // if it has a file extension that one of the tools builds, add the sudirectory to the list
// boolean willBuild = false; // boolean willBuild = false;
IResourceInfo rcInfo = config.getResourceInfo(resource.getProjectRelativePath(), false); IResourceInfo rcInfo = config.getResourceInfo(resource.getProjectRelativePath(), false);
if (isSource && !rcInfo.isExcluded()) { if (isSource/* && !rcInfo.isExcluded()*/) {
boolean willBuild = false; boolean willBuild = false;
if(rcInfo instanceof IFolderInfo){ if(rcInfo instanceof IFolderInfo){
String ext = resource.getFileExtension(); String ext = resource.getFileExtension();
@ -364,7 +368,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Dependency file variables // Dependency file variables
// private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute // private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute
private IPath srcPaths[]; private ICSourceEntry srcEntries[];
public GnuMakefileGenerator() { public GnuMakefileGenerator() {
@ -513,12 +517,13 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
} }
protected boolean isSource(IPath path){ protected boolean isSource(IPath path){
path = path.makeRelative(); return !CDataUtil.isExcluded(path, srcEntries);
for(int i = 0; i < srcPaths.length; i++){ // path = path.makeRelative();
if(srcPaths[i].isPrefixOf(path)) // for(int i = 0; i < srcPaths.length; i++){
return true; // if(srcPaths[i].isPrefixOf(path))
} // return true;
return false; // }
// return false;
} }
private class DepInfo { private class DepInfo {
@ -1982,9 +1987,12 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
IResource resource = resources[i]; IResource resource = resources[i];
if (resource.getType() == IResource.FILE) { if (resource.getType() == IResource.FILE) {
// Check whether this resource is excluded from build // Check whether this resource is excluded from build
rcInfo = config.getResourceInfo(resource.getProjectRelativePath(), false); IPath rcProjRelPath = resource.getProjectRelativePath();
if( (rcInfo.isExcluded()) ) if(!isSource(rcProjRelPath))
continue; continue;
rcInfo = config.getResourceInfo(rcProjRelPath, false);
// if( (rcInfo.isExcluded()) )
// continue;
addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer, addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer,
folder, relativePath, resource, resource.getLocation(), rcInfo, null, false); folder, relativePath, resource, resource.getLocation(), rcInfo, null, false);
} }
@ -4658,9 +4666,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
//set the top build dir path //set the top build dir path
topBuildDir = project.getFolder(cfg.getName()).getFullPath(); topBuildDir = project.getFolder(cfg.getName()).getFullPath();
srcPaths = config.getSourcePaths(); srcEntries = config.getSourceEntries();
if(srcPaths.length == 0){ if(srcEntries.length == 0){
srcPaths = new IPath[]{new Path("")}; //$NON-NLS-1$ srcEntries = new ICSourceEntry[]{new CSourceEntry(Path.EMPTY, null, ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH)};
} else { } else {
} }
} }

View file

@ -1,5 +1,6 @@
package org.eclipse.cdt.managedbuilder.ui.tests.util; package org.eclipse.cdt.managedbuilder.ui.tests.util;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
@ -538,5 +539,15 @@ public class TestConfiguration implements IConfiguration {
} }
public ICSourceEntry[] getSourceEntries() {
// TODO Auto-generated method stub
return null;
}
public void setSourceEntries(ICSourceEntry[] entries) {
// TODO Auto-generated method stub
}
} }

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.internal.core.model.OutputEntry;
import org.eclipse.cdt.internal.core.model.PathEntryManager; import org.eclipse.cdt.internal.core.model.PathEntryManager;
import org.eclipse.cdt.internal.core.model.ProjectEntry; import org.eclipse.cdt.internal.core.model.ProjectEntry;
import org.eclipse.cdt.internal.core.model.SourceEntry; import org.eclipse.cdt.internal.core.model.SourceEntry;
import org.eclipse.cdt.internal.core.settings.model.CLanguageSettingCache;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -1238,6 +1239,10 @@ public class CoreModel {
return oldIsScannerInformationEmpty(resource); return oldIsScannerInformationEmpty(resource);
} }
ICLanguageSetting lSetting = indexCfg.getLanguageSettingForFile(resource.getProjectRelativePath(), false); ICLanguageSetting lSetting = indexCfg.getLanguageSettingForFile(resource.getProjectRelativePath(), false);
if(lSetting != null && lSetting instanceof CLanguageSettingCache){
if(!((CLanguageSettingCache)lSetting).containsDiscoveredScannerInfo())
lSetting = null;
}
if(lSetting != null){ if(lSetting != null){
ICLanguageSettingEntry[] entries = lSetting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH); ICLanguageSettingEntry[] entries = lSetting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
if(entries.length != 0) if(entries.length != 0)

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.core.settings.model.extension; package org.eclipse.cdt.core.settings.model.extension;
import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -48,9 +49,9 @@ public abstract class CConfigurationData extends CDataObject {
public abstract CTargetPlatformData getTargetPlatformData(); public abstract CTargetPlatformData getTargetPlatformData();
public abstract IPath[] getSourcePaths(); public abstract ICSourceEntry[] getSourceEntries();
public abstract void setSourcePaths(IPath[] paths); public abstract void setSourceEntries(ICSourceEntry[] entries);
public abstract CBuildData getBuildData(); public abstract CBuildData getBuildData();

View file

@ -22,14 +22,6 @@ public abstract class CFolderData extends CResourceData {
return ICSettingBase.SETTING_FOLDER; return ICSettingBase.SETTING_FOLDER;
} }
// public abstract CResourceData[] getNestedResourceDatas(int kind);
// public abstract CResourceData getNestedResourceData(IPath path);
// public abstract CDataObject[] getChildrenOfKind(int kind);
// public abstract CDataObject getChildById(String id);
public abstract CLanguageData[] getLanguageDatas(); public abstract CLanguageData[] getLanguageDatas();
public abstract CLanguageData createLanguageDataForContentTypes(String languageId, String cTypesIds[]); public abstract CLanguageData createLanguageDataForContentTypes(String languageId, String cTypesIds[]);

View file

@ -50,4 +50,8 @@ public abstract class CLanguageData extends CDataObject {
public abstract void setSourceContentTypeIds(String ids[]); public abstract void setSourceContentTypeIds(String ids[]);
public abstract void setSourceExtensions(String exts[]); public abstract void setSourceExtensions(String exts[]);
public boolean containsDiscoveredScannerInfo(){
return true;
}
} }

View file

@ -19,11 +19,11 @@ public abstract class CResourceData extends CDataObject {
public abstract IPath getPath(); public abstract IPath getPath();
public abstract boolean isExcluded(); // public abstract boolean isExcluded();
public abstract void setPath(IPath path) ; public abstract void setPath(IPath path) ;
public abstract void setExcluded(boolean excluded); // public abstract void setExcluded(boolean excluded);
public abstract boolean hasCustomSettings(); public abstract boolean hasCustomSettings();
} }

View file

@ -15,6 +15,7 @@ import java.util.HashMap;
import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CFileData; import org.eclipse.cdt.core.settings.model.extension.CFileData;
@ -35,7 +36,7 @@ public class CDefaultConfigurationData extends CConfigurationData {
protected String fId; protected String fId;
protected CTargetPlatformData fTargetPlatformData; protected CTargetPlatformData fTargetPlatformData;
protected CBuildData fBuildData; protected CBuildData fBuildData;
protected IPath[] fSourcePaths; protected ICSourceEntry[] fSourceEntries;
private CDataFacroty fFactory; private CDataFacroty fFactory;
protected boolean fIsModified; protected boolean fIsModified;
@ -99,7 +100,7 @@ public class CDefaultConfigurationData extends CConfigurationData {
fDescription = base.getDescription(); fDescription = base.getDescription();
fTargetPlatformData = copyTargetPlatformData(base.getTargetPlatformData(), clone); fTargetPlatformData = copyTargetPlatformData(base.getTargetPlatformData(), clone);
fSourcePaths = base.getSourcePaths(); fSourceEntries = base.getSourceEntries();
fBuildData = copyBuildData(base.getBuildData(), clone); fBuildData = copyBuildData(base.getBuildData(), clone);
CFolderData baseRootFolderData = base.getRootFolderData(); CFolderData baseRootFolderData = base.getRootFolderData();
@ -237,15 +238,15 @@ public class CDefaultConfigurationData extends CConfigurationData {
return fTargetPlatformData; return fTargetPlatformData;
} }
public IPath[] getSourcePaths() { public ICSourceEntry[] getSourceEntries() {
return fSourcePaths != null ? (IPath[])fSourcePaths.clone() : null; return fSourceEntries != null ? (ICSourceEntry[])fSourceEntries.clone() : null;
} }
public void setSourcePaths(IPath[] paths) { public void setSourceEntries(ICSourceEntry[] entries) {
if(Arrays.equals(paths, fSourcePaths)) if(Arrays.equals(entries, fSourceEntries))
return; return;
fSourcePaths = paths != null ? (IPath[])paths.clone() : null; fSourceEntries = entries != null ? (ICSourceEntry[])entries.clone() : null;
setModified(true); setModified(true);
} }

View file

@ -18,7 +18,7 @@ import org.eclipse.core.runtime.IPath;
public class CDefaultFileData extends CFileData { public class CDefaultFileData extends CFileData {
protected IPath fPath; protected IPath fPath;
protected boolean fIsExcluded; // protected boolean fIsExcluded;
protected String fName; protected String fName;
protected String fId; protected String fId;
protected CLanguageData fLanguageData; protected CLanguageData fLanguageData;
@ -57,11 +57,11 @@ public class CDefaultFileData extends CFileData {
if(baseLanguageData != null) if(baseLanguageData != null)
fLanguageData = copyLanguageData(baseLanguageData, clone); fLanguageData = copyLanguageData(baseLanguageData, clone);
fIsExcluded = base.isExcluded(); // fIsExcluded = base.isExcluded();
} }
protected void copyDataFrom(CFolderData base, CLanguageData baseLanguageData){ protected void copyDataFrom(CFolderData base, CLanguageData baseLanguageData){
fIsExcluded = base != null ? base.isExcluded() : false; // fIsExcluded = base != null ? base.isExcluded() : false;
if(baseLanguageData != null) if(baseLanguageData != null)
fLanguageData = copyLanguageData(baseLanguageData, false); fLanguageData = copyLanguageData(baseLanguageData, false);
} }
@ -75,16 +75,16 @@ public class CDefaultFileData extends CFileData {
return fPath; return fPath;
} }
public boolean isExcluded() { // public boolean isExcluded() {
return fIsExcluded; // return fIsExcluded;
} // }
public void setExcluded(boolean excluded) { // public void setExcluded(boolean excluded) {
if(excluded == fIsExcluded) // if(excluded == fIsExcluded)
return; // return;
//
fIsExcluded = excluded; // fIsExcluded = excluded;
} // }
public void setPath(IPath path) { public void setPath(IPath path) {
fPath = path; fPath = path;

View file

@ -21,7 +21,7 @@ import org.eclipse.core.runtime.IPath;
public class CDefaultFolderData extends CFolderData { public class CDefaultFolderData extends CFolderData {
protected IPath fPath; protected IPath fPath;
protected boolean fIsExcluded; // protected boolean fIsExcluded;
protected List fLanguageDatas = new ArrayList(); protected List fLanguageDatas = new ArrayList();
protected String fName; protected String fName;
protected String fId; protected String fId;
@ -56,7 +56,7 @@ public class CDefaultFolderData extends CFolderData {
fLanguageDatas.add(copyLanguageData(lDatas[i], clone)); fLanguageDatas.add(copyLanguageData(lDatas[i], clone));
} }
fIsExcluded = base.isExcluded(); // fIsExcluded = base.isExcluded();
} }
} }
@ -72,17 +72,17 @@ public class CDefaultFolderData extends CFolderData {
return fPath; return fPath;
} }
public boolean isExcluded() { // public boolean isExcluded() {
return fIsExcluded; // return fIsExcluded;
} // }
//
public void setExcluded(boolean excluded) { // public void setExcluded(boolean excluded) {
if(excluded == fIsExcluded) // if(excluded == fIsExcluded)
return; // return;
//
fIsExcluded = excluded; // fIsExcluded = excluded;
setModified(true); // setModified(true);
} // }
public void setPath(IPath path) { public void setPath(IPath path) {
if(CDataUtil.objectsEqual(path, fPath)) if(CDataUtil.objectsEqual(path, fPath))

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICOutputEntry; import org.eclipse.cdt.core.settings.model.ICOutputEntry;
import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
@ -37,7 +38,7 @@ public class CDataSerializer {
protected static final String NAME = "name"; protected static final String NAME = "name";
protected static final String ID = "id"; protected static final String ID = "id";
protected static final String DESCRIPTION = "description"; protected static final String DESCRIPTION = "description";
protected static final String SOURCE_PATHS = "sourcePaths"; protected static final String SOURCE_ENTRIES = "sourceEntries";
protected static final String PATH = "path"; protected static final String PATH = "path";
protected static final String LANGUAGE_ID = "languageId"; protected static final String LANGUAGE_ID = "languageId";
protected static final String CONTENT_TYPE_IDS = "contentTypeIds"; protected static final String CONTENT_TYPE_IDS = "contentTypeIds";
@ -48,7 +49,7 @@ public class CDataSerializer {
protected static final String BUILD_DATA = "buildData"; protected static final String BUILD_DATA = "buildData";
protected static final String TARGET_PLATFORM_DATA = "targetPlatformData"; protected static final String TARGET_PLATFORM_DATA = "targetPlatformData";
protected static final String LANGUAGE_DATA = "languageData"; protected static final String LANGUAGE_DATA = "languageData";
protected static final String EXCLUDED = "excluded"; // protected static final String EXCLUDED = "excluded";
protected static final String OUTPUT_ENTRIES = "outputEntries"; protected static final String OUTPUT_ENTRIES = "outputEntries";
protected static final String ERROR_PARSERS = "errorParsers"; protected static final String ERROR_PARSERS = "errorParsers";
protected static final String BINARY_PARSERS = "binaryParsers"; protected static final String BINARY_PARSERS = "binaryParsers";
@ -78,15 +79,15 @@ public class CDataSerializer {
if(tmp != null) if(tmp != null)
data.setDescription(tmp); data.setDescription(tmp);
tmp = el.getAttribute(SOURCE_PATHS); // tmp = el.getAttribute(SOURCE_PATHS);
if(tmp != null){ // if(tmp != null){
String[] strPaths = CDataUtil.stringToArray(tmp, DELIMITER); // String[] strPaths = CDataUtil.stringToArray(tmp, DELIMITER);
IPath[] paths = new IPath[strPaths.length]; // IPath[] paths = new IPath[strPaths.length];
for(int i = 0; i < paths.length; i++){ // for(int i = 0; i < paths.length; i++){
paths[i] = new Path(strPaths[i]); // paths[i] = new Path(strPaths[i]);
} // }
data.setSourcePaths(paths); // data.setSourcePaths(paths);
} // }
ICStorageElement[] children = el.getChildren(); ICStorageElement[] children = el.getChildren();
ICStorageElement child; ICStorageElement child;
@ -110,6 +111,10 @@ public class CDataSerializer {
CTargetPlatformData tpData = loadTargetPlatformData(data, factory, child); CTargetPlatformData tpData = loadTargetPlatformData(data, factory, child);
if(tpData != null) if(tpData != null)
factory.link(data, tpData); factory.link(data, tpData);
} else if (SOURCE_ENTRIES.equals(childName)){
List list = LanguageSettingEntriesSerializer.loadEntriesList(child, ICSettingEntry.SOURCE_PATH);
ICSourceEntry[] entries = (ICSourceEntry[])list.toArray(new ICSourceEntry[list.size()]);
data.setSourceEntries(entries);
} }
} }
return data; return data;
@ -133,11 +138,11 @@ public class CDataSerializer {
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create folder data")); throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create folder data"));
} }
tmp = el.getAttribute(EXCLUDED); // tmp = el.getAttribute(EXCLUDED);
if(tmp != null){ // if(tmp != null){
boolean b = Boolean.valueOf(tmp).booleanValue(); // boolean b = Boolean.valueOf(tmp).booleanValue();
foData.setExcluded(b); // foData.setExcluded(b);
} // }
ICStorageElement[] children = el.getChildren(); ICStorageElement[] children = el.getChildren();
ICStorageElement child; ICStorageElement child;
@ -171,11 +176,11 @@ public class CDataSerializer {
if(fiData == null) if(fiData == null)
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create file data")); throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "failed to create file data"));
tmp = el.getAttribute(EXCLUDED); // tmp = el.getAttribute(EXCLUDED);
if(tmp != null){ // if(tmp != null){
boolean b = Boolean.valueOf(tmp).booleanValue(); // boolean b = Boolean.valueOf(tmp).booleanValue();
fiData.setExcluded(b); // fiData.setExcluded(b);
} // }
ICStorageElement[] children = el.getChildren(); ICStorageElement[] children = el.getChildren();
ICStorageElement child; ICStorageElement child;
@ -327,14 +332,16 @@ public class CDataSerializer {
setAttribute(el, NAME, data.getName()); setAttribute(el, NAME, data.getName());
setAttribute(el, DESCRIPTION, data.getDescription()); setAttribute(el, DESCRIPTION, data.getDescription());
IPath[] paths = data.getSourcePaths(); ICSourceEntry[] entries = data.getSourceEntries();
if(paths != null && paths.length != 0){ ICStorageElement child = el.createChild(SOURCE_ENTRIES);
setAttribute(el, SOURCE_PATHS, CDataUtil.arrayToString(paths, DELIMITER)); LanguageSettingEntriesSerializer.serializeEntries(entries, child);
} // if(paths != null && paths.length != 0){
// setAttribute(el, SOURCE_PATHS, CDataUtil.arrayToString(paths, DELIMITER));
// }
CResourceData[] rcDatas = data.getResourceDatas(); CResourceData[] rcDatas = data.getResourceDatas();
CResourceData rcData; CResourceData rcData;
ICStorageElement child; // ICStorageElement child;
for(int i = 0; i < rcDatas.length; i++){ for(int i = 0; i < rcDatas.length; i++){
rcData = rcDatas[i]; rcData = rcDatas[i];
if(rcData.getType() == ICSettingBase.SETTING_FILE){ if(rcData.getType() == ICSettingBase.SETTING_FILE){
@ -368,7 +375,7 @@ public class CDataSerializer {
setAttribute(el, PATH, path.toString()); setAttribute(el, PATH, path.toString());
} }
setAttribute(el, EXCLUDED, Boolean.valueOf(data.isExcluded()).toString()); // setAttribute(el, EXCLUDED, Boolean.valueOf(data.isExcluded()).toString());
CLanguageData lDatas[] = data.getLanguageDatas(); CLanguageData lDatas[] = data.getLanguageDatas();
ICStorageElement child; ICStorageElement child;
@ -387,7 +394,7 @@ public class CDataSerializer {
setAttribute(el, PATH, path.toString()); setAttribute(el, PATH, path.toString());
} }
setAttribute(el, EXCLUDED, Boolean.valueOf(data.isExcluded()).toString()); // setAttribute(el, EXCLUDED, Boolean.valueOf(data.isExcluded()).toString());
CLanguageData lData = data.getLanguageData(); CLanguageData lData = data.getLanguageData();
if(lData != null){ if(lData != null){

View file

@ -12,8 +12,12 @@ package org.eclipse.cdt.core.settings.model.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
@ -23,6 +27,7 @@ import java.util.StringTokenizer;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.model.CoreModelUtil;
import org.eclipse.cdt.core.model.ILanguageDescriptor; import org.eclipse.cdt.core.model.ILanguageDescriptor;
import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
@ -37,6 +42,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CFolderData; import org.eclipse.cdt.core.settings.model.extension.CFolderData;
@ -488,4 +494,210 @@ public class CDataUtil {
} }
} }
public static boolean isExcluded(IPath path, ICSourceEntry[] entries){
for(int i = 0; i < entries.length; i++){
if(!isExcluded(path, entries[i]))
return false;
}
return true;
}
public static boolean isExcluded(IPath path, ICSourceEntry entry){
IPath entryPath = new Path(entry.getName());
if(!entryPath.isPrefixOf(path))
return true;
if(path.segmentCount() == 0)
return false;
char[][] exclusions = entry.fullExclusionPatternChars();
return CoreModelUtil.isExcluded(path, exclusions);
}
public static ICSourceEntry[] setExcluded(IPath path, boolean excluded, ICSourceEntry[] entries){
if(isExcluded(path, entries) == excluded)
return entries;
ICSourceEntry[] newEntries;
if(excluded){
List includeList = new ArrayList(entries.length);
List excludeList = new ArrayList(entries.length);
sortEntries(path, entries, includeList, excludeList);
for(int i = 0; i < includeList.size(); i++){
ICSourceEntry oldEntry = (ICSourceEntry)includeList.get(i);
List tmp = new ArrayList(1);
tmp.add(path);
ICSourceEntry newEntry = addExcludePaths(oldEntry, tmp, true);
if(newEntry != null)
excludeList.add(newEntry);
}
newEntries = (ICSourceEntry[])excludeList.toArray(new ICSourceEntry[excludeList.size()]);
} else {
newEntries = new ICSourceEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
newEntries[entries.length] = new CSourceEntry(path, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
}
return newEntries;
}
public static ICSourceEntry[] adjustEntries(ICSourceEntry entries[]){
return adjustEntries(entries, false, null);
}
private static ICSourceEntry[] getDefaultEntries(boolean absolute, IProject project){
ICSourceEntry entry;
if(absolute){
if(project != null)
entry = new CSourceEntry(project.getFullPath(), null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSourceEntry.RESOLVED);
else
entry = new CSourceEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSourceEntry.RESOLVED);
} else {
entry = new CSourceEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSourceEntry.RESOLVED);
}
return new ICSourceEntry[]{entry};
}
public static ICSourceEntry[] adjustEntries(ICSourceEntry entries[], boolean makeAbsolute, IProject project){
if(entries == null)
return getDefaultEntries(makeAbsolute, project);
ICSourceEntry ei, ej;
LinkedHashMap map = new LinkedHashMap();
for(int i = 0; i < entries.length; i++){
ei = entries[i];
List list = null;
for(int j = 0; j < entries.length; j++){
ej = entries[j];
if(ei == ej)
continue;
IPath ejPath = new Path(ej.getName());
if(!isExcluded(ejPath, ei)){
if(list == null)
list = new ArrayList();
list.add(ejPath);
}
}
map.put(ei, list);
}
List resultList = new ArrayList(entries.length);
for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){
Map.Entry entry = (Map.Entry)iter.next();
List list = (List)entry.getValue();
if(list == null)
resultList.add(entry.getKey());
else {
ICSourceEntry se = (ICSourceEntry)entry.getKey();
se = addExcludePaths(se, list, true);
if(se != null)
resultList.add(se);
}
}
if(makeAbsolute){
if(project != null)
resultList = makeAbsolute(project, resultList);
} else {
resultList = makeRelative(project, resultList);
}
return (ICSourceEntry[])resultList.toArray(new ICSourceEntry[resultList.size()]);
}
private static List makeRelative(IProject project, List list){
int size = list.size();
for(int i = 0; i < size; i++){
list.set(i, makeRelative(project, (ICSourceEntry)list.get(i)));
}
return list;
}
private static List makeAbsolute(IProject project, List list){
int size = list.size();
for(int i = 0; i < size; i++){
list.set(i, makeAbsolute(project, (ICSourceEntry)list.get(i)));
}
return list;
}
public static ICSourceEntry makeAbsolute(IProject project, ICSourceEntry entry){
if(project == null)
return entry;
IPath path = new Path(entry.getName());
if(path.isAbsolute())
return entry;
path = project.getFullPath().append(path);
return new CSourceEntry(path, entry.getExclusionPatterns(), entry.getFlags());
}
public static ICSourceEntry makeRelative(IProject project, ICSourceEntry entry){
IPath path = new Path(entry.getName());
if(!path.isAbsolute())
return entry;
// if(project != null){
//
// IPath projPath = project.getFullPath();
//
// }
// if(pro)
return new CSourceEntry(path.removeFirstSegments(1).makeRelative(), entry.getExclusionPatterns(), entry.getFlags());
}
private static Collection removePrefix(IPath prefix, Collection paths, Collection result){
if(result == null)
result = new ArrayList(paths.size());
for(Iterator iter = paths.iterator(); iter.hasNext(); ){
IPath path = (IPath)iter.next();
if(prefix.isPrefixOf(path))
result.add(path.removeFirstSegments(prefix.segmentCount()));
// else
// result.add(path);
}
return result;
}
public static ICSourceEntry addExcludePaths(ICSourceEntry entry, Collection paths, boolean removePrefix){
IPath entryPath = new Path(entry.getName());
IPath[] oldExclusions = entry.getExclusionPatterns();
// List newExList = new ArrayList(oldExclusions.length + paths.size());
LinkedHashSet newSet = new LinkedHashSet();
if(removePrefix){
removePrefix(entryPath, paths, newSet);
} else {
newSet.addAll(paths);
}
for(Iterator iter = newSet.iterator(); iter.hasNext();){
IPath path = (IPath)iter.next();
if(path.segmentCount() == 0)
return null;
}
newSet.addAll(Arrays.asList(oldExclusions));
IPath[] newExclusions = (IPath[])newSet.toArray(new IPath[newSet.size()]);
return new CSourceEntry(entry.getName(), newExclusions, entry.getFlags());
}
private static void sortEntries(IPath path, ICSourceEntry[] entries, List included, List excluded){
for(int i = 0; i < entries.length; i++){
if(isExcluded(path, entries[i])){
if(excluded != null)
excluded.add(entries[i]);
} else {
if(included != null)
included.add(entries[i]);
}
}
}
} }

View file

@ -26,6 +26,15 @@ public class KindBasedStore implements Cloneable {
private static final int INDEX_OUPUT_PATH = 7; private static final int INDEX_OUPUT_PATH = 7;
private static final int ALL_STORAGE_SIZE = 8; private static final int ALL_STORAGE_SIZE = 8;
public static final int ORED_LANG_ENTRY_KINDS =
ICLanguageSettingEntry.INCLUDE_PATH
| ICLanguageSettingEntry.INCLUDE_FILE
| ICLanguageSettingEntry.MACRO
| ICLanguageSettingEntry.MACRO_FILE
| ICLanguageSettingEntry.LIBRARY_PATH
| ICLanguageSettingEntry.LIBRARY_FILE;
private static final int LANG_ENTRY_KINDS[] = new int[]{ private static final int LANG_ENTRY_KINDS[] = new int[]{
ICLanguageSettingEntry.INCLUDE_PATH, ICLanguageSettingEntry.INCLUDE_PATH,
ICLanguageSettingEntry.INCLUDE_FILE, ICLanguageSettingEntry.INCLUDE_FILE,

View file

@ -58,28 +58,38 @@ public class LanguageSettingEntriesSerializer {
public static final String FLAGS_SEPARATOR = "|"; //$NON-NLS-1$ public static final String FLAGS_SEPARATOR = "|"; //$NON-NLS-1$
public static ICLanguageSettingEntry[] loadEntries(ICStorageElement el){ public static ICSettingEntry[] loadEntries(ICStorageElement el){
List list = loadEntriesList(el); return loadEntries(el, 0);
return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]); }
public static ICSettingEntry[] loadEntries(ICStorageElement el, int kindFilter){
List list = loadEntriesList(el, kindFilter);
return (ICSettingEntry[])list.toArray(new ICSettingEntry[list.size()]);
} }
public static List loadEntriesList(ICStorageElement el){ public static List loadEntriesList(ICStorageElement el){
return loadEntriesList(el, 0);
}
public static List loadEntriesList(ICStorageElement el, int kindFilter){
ICStorageElement children[] = el.getChildren(); ICStorageElement children[] = el.getChildren();
ICStorageElement child; ICStorageElement child;
List list = new ArrayList(); List list = new ArrayList();
ICLanguageSettingEntry entry; ICSettingEntry entry;
for(int i = 0; i < children.length; i++){ for(int i = 0; i < children.length; i++){
child = children[i]; child = children[i];
if(ELEMENT_ENTRY.equals(child.getName())){ if(ELEMENT_ENTRY.equals(child.getName())){
entry = loadEntry(child); entry = loadEntry(child);
if(entry != null) if(entry != null
&& (kindFilter == 0
|| (kindFilter & entry.getKind()) != 0))
list.add(entry); list.add(entry);
} }
} }
return list; return list;
} }
public static ICLanguageSettingEntry loadEntry(ICStorageElement el){ public static ICSettingEntry loadEntry(ICStorageElement el){
int kind = stringToKind(el.getAttribute(ATTRIBUTE_KIND)); int kind = stringToKind(el.getAttribute(ATTRIBUTE_KIND));
if(kind == 0) if(kind == 0)
return null; return null;

View file

@ -16,6 +16,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -34,6 +35,7 @@ import org.eclipse.cdt.core.model.ILibraryEntry;
import org.eclipse.cdt.core.model.IMacroEntry; import org.eclipse.cdt.core.model.IMacroEntry;
import org.eclipse.cdt.core.model.IMacroFileEntry; import org.eclipse.cdt.core.model.IMacroFileEntry;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.cdt.core.resources.IPathEntryVariableManager; import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
@ -336,7 +338,7 @@ public class PathEntryTranslator {
ResourceInfo fRcInfo; ResourceInfo fRcInfo;
List fResolvedEntries; List fResolvedEntries;
KindBasedStore fLangEntries; KindBasedStore fLangEntries;
boolean fIsExcluded; // boolean fIsExcluded;
private RcDesInfo(ResourceInfo rcInfo){ private RcDesInfo(ResourceInfo rcInfo){
this.fRcInfo = rcInfo; this.fRcInfo = rcInfo;
@ -344,13 +346,13 @@ public class PathEntryTranslator {
fLangEntries = new KindBasedStore(); fLangEntries = new KindBasedStore();
} }
public boolean isExcluded(){ // public boolean isExcluded(){
return fIsExcluded; // return fIsExcluded;
} // }
//
public void setExcluded(boolean excluded){ // public void setExcluded(boolean excluded){
fIsExcluded = excluded; // fIsExcluded = excluded;
} // }
public ResolvedEntry[] getResolvedEntries(){ public ResolvedEntry[] getResolvedEntries(){
return (ResolvedEntry[])fResolvedEntries.toArray(new ResolvedEntry[fResolvedEntries.size()]); return (ResolvedEntry[])fResolvedEntries.toArray(new ResolvedEntry[fResolvedEntries.size()]);
@ -1271,184 +1273,184 @@ public class PathEntryTranslator {
return addPathEntries(rEntries, op); return addPathEntries(rEntries, op);
} }
public static ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, PathSettingsContainer rcDatas, IPath paths[]){ // public static ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, PathSettingsContainer rcDatas, IPath paths[]){
if(paths == null || paths.length == 0) // if(paths == null || paths.length == 0)
paths = new IPath[]{new Path("")}; //$NON-NLS-1$ // paths = new IPath[]{new Path("")}; //$NON-NLS-1$
//
// Set set = new HashSet(paths.length); //// Set set = new HashSet(paths.length);
PathSettingsContainer cr = PathSettingsContainer.createRootContainer(); // PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
IPath pi, pj; // IPath pi, pj;
List entriesList = new ArrayList(paths.length); // List entriesList = new ArrayList(paths.length);
IPath projPath = project != null ? project.getFullPath() : null; // IPath projPath = project != null ? project.getFullPath() : null;
//
for(int i = 0; i < paths.length; i++){ // for(int i = 0; i < paths.length; i++){
pi = paths[i]; // pi = paths[i];
// set.clear(); //// set.clear();
cr.removeChildren(); // cr.removeChildren();
cr.setValue(null); // cr.setValue(null);
for(int j = 0; j < paths.length; j++){ // for(int j = 0; j < paths.length; j++){
pj = paths[j]; // pj = paths[j];
if(pi != pj && pi.isPrefixOf(pj)){ // if(pi != pj && pi.isPrefixOf(pj)){
// set.add(pj); //// set.add(pj);
cr.getChildContainer(pj, true, true); // cr.getChildContainer(pj, true, true);
} // }
} // }
//
PathSettingsContainer children[] = rcDatas.getDirectChildrenForPath(pi); // PathSettingsContainer children[] = rcDatas.getDirectChildrenForPath(pi);
for(int k = 0; k < children.length; k++){ // for(int k = 0; k < children.length; k++){
PathSettingsContainer child = children[k]; // PathSettingsContainer child = children[k];
IPath childPath = child.getPath(); // IPath childPath = child.getPath();
PathSettingsContainer parentExclusion = cr.getChildContainer(childPath, false, false); // PathSettingsContainer parentExclusion = cr.getChildContainer(childPath, false, false);
IPath parentExclusionPath = parentExclusion.getPath(); // IPath parentExclusionPath = parentExclusion.getPath();
if(parentExclusionPath.segmentCount() > 0 && !parentExclusionPath.equals(childPath) && parentExclusionPath.isPrefixOf(childPath)) // if(parentExclusionPath.segmentCount() > 0 && !parentExclusionPath.equals(childPath) && parentExclusionPath.isPrefixOf(childPath))
continue; // continue;
//
CResourceData rcData = (CResourceData)child.getValue(); // CResourceData rcData = (CResourceData)child.getValue();
if(rcData.isExcluded()){ // if(rcData.isExcluded()){
// set.add(rcDes.getPath()); //// set.add(rcDes.getPath());
cr.getChildContainer(childPath, true, true); // cr.getChildContainer(childPath, true, true);
} // }
} // }
//
PathSettingsContainer exclusions[] = cr.getChildren(false); // PathSettingsContainer exclusions[] = cr.getChildren(false);
// IPath exlusionPaths[] = new IPath[set.size()]; //// IPath exlusionPaths[] = new IPath[set.size()];
IPath exlusionPaths[] = new IPath[exclusions.length]; // IPath exlusionPaths[] = new IPath[exclusions.length];
// int k = 0; //// int k = 0;
int segCount = pi.segmentCount(); // int segCount = pi.segmentCount();
// for(Iterator iter = set.iterator(); iter.hasNext(); k++) { //// for(Iterator iter = set.iterator(); iter.hasNext(); k++) {
// IPath path = (IPath)iter.next(); //// IPath path = (IPath)iter.next();
// exlusionPaths[k] = path.removeFirstSegments(segCount).makeRelative(); //// exlusionPaths[k] = path.removeFirstSegments(segCount).makeRelative();
//// }
// for(int k = 0; k < exlusionPaths.length; k++) {
// exlusionPaths[k] = exclusions[k].getPath().removeFirstSegments(segCount).makeRelative();
// }
// if(projPath != null)
// pi = projPath.append(pi);
// entriesList.add(new CSourceEntry(pi, exlusionPaths, 0));
// }
//
// return (ICSourceEntry[])entriesList.toArray(new ICSourceEntry[entriesList.size()]);
// } // }
for(int k = 0; k < exlusionPaths.length; k++) {
exlusionPaths[k] = exclusions[k].getPath().removeFirstSegments(segCount).makeRelative();
}
if(projPath != null)
pi = projPath.append(pi);
entriesList.add(new CSourceEntry(pi, exlusionPaths, 0));
}
return (ICSourceEntry[])entriesList.toArray(new ICSourceEntry[entriesList.size()]); // private IPath[] setSourceEntries(PathSettingsContainer crontainer, List res) {
} //// ICSourceEntry entry;
// IPath entryPath;
private IPath[] setSourceEntries(PathSettingsContainer crontainer, List res) { //// IPath paths[];
// ICSourceEntry entry; // Set srcPathSet = new HashSet();
IPath entryPath; // IPath projPath = fProject != null ? fProject.getFullPath() : null;
// IPath paths[]; // PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
Set srcPathSet = new HashSet(); // cr.setValue(Boolean.TRUE);
IPath projPath = fProject != null ? fProject.getFullPath() : null; //
PathSettingsContainer cr = PathSettingsContainer.createRootContainer(); //// Map exclusionMap = new HashMap();
cr.setValue(Boolean.TRUE); //
//// HashSet pathSet = new HashSet();
// Map exclusionMap = new HashMap(); // for(Iterator iter = res.iterator(); iter.hasNext();){
// ResolvedEntry re = (ResolvedEntry)iter.next();
// HashSet pathSet = new HashSet(); // ResourceInfo rcInfo = re.getResourceInfo();
for(Iterator iter = res.iterator(); iter.hasNext();){ // entryPath = rcInfo.fRc.getFullPath();
ResolvedEntry re = (ResolvedEntry)iter.next(); // if(projPath != null){
ResourceInfo rcInfo = re.getResourceInfo(); // if(projPath.isPrefixOf(entryPath)){
entryPath = rcInfo.fRc.getFullPath(); // entryPath = entryPath.removeFirstSegments(projPath.segmentCount());
if(projPath != null){ // } else {
if(projPath.isPrefixOf(entryPath)){
entryPath = entryPath.removeFirstSegments(projPath.segmentCount());
} else {
continue;
}
}
// else {
// if(entryPath.segmentCount() > 0)
// entryPath = entryPath.removeFirstSegments(1);
// else
// continue; // continue;
// } // }
if(srcPathSet.add(entryPath)){
// exclusionMap.put(entryPath, Boolean.TRUE);
PathSettingsContainer entryCr = cr.getChildContainer(entryPath, true, true);
entryCr.setValue(Boolean.TRUE);
ResourceInfo[] filters = re.getFilterInfos();
// paths = entry.getExclusionPatterns();
for(int j = 0; j < filters.length; j++){
IPath path = filters[j].fRc.getFullPath();
path = path.removeFirstSegments(entryPath.segmentCount());
PathSettingsContainer exclusion = entryCr.getChildContainer(path, true, true);
if(exclusion.getValue() == null)
exclusion.setValue(Boolean.FALSE);
// if(null == exclusionMap.get(path))
// exclusionMap.put(path, Boolean.FALSE);
}
}
}
// CConfigurationData data = getConfigurationData(true);
// data.setSourcePaths((IPath[])srcPathSet.toArray(new IPath[srcPathSet.size()]));
// ICResourceDescription rcDess[] = getResourceDescriptions();
// ICResourceDescription rcDes;
Set pathSet = new HashSet();
PathSettingsContainer children[] = crontainer.getChildren(true);
for(int i = 0; i < children.length; i++){
PathSettingsContainer child = children[i];
RcDesInfo rcDesInfo = (RcDesInfo)child.getValue();
// rcDes = rcDess[i];
IPath path = child.getPath();
pathSet.add(path);
// Boolean b = (Boolean)exclusionMap.remove(path);
Boolean b = (Boolean)cr.getChildContainer(path, false, false).getValue();
assert (b != null);
if(Boolean.TRUE == b) {
if(rcDesInfo.isExcluded())
rcDesInfo.setExcluded(false);
} else {
if(path.segmentCount() != 0)
rcDesInfo.setExcluded(true);
}
}
PathSettingsContainer crs[] = cr.getChildren(true);
for(int i= 0; i < crs.length; i++){
PathSettingsContainer c = crs[i];
IPath path = c.getPath();
if(!pathSet.remove(path)){
Boolean b = (Boolean)c.getValue();
assert (b != null);
PathSettingsContainer baseCr = crontainer.getChildContainer(path, false, false);
RcDesInfo baseInfo = (RcDesInfo)baseCr.getValue();
if(b == Boolean.TRUE){
if(baseInfo.isExcluded()){
RcDesInfo newInfo = new RcDesInfo(findResourceInfo(fProject, path, true));
PathSettingsContainer newCr = crontainer.getChildContainer(path, true, true);
newCr.setValue(newInfo);
// if(newInfo == null){
// ICResourceDescription fo = getResourceDescription(path, false);
// if(fo.getType() == ICSettingBase.SETTING_FILE){
// fo = getResourceDescription(path.removeLastSegments(1), false);
// } // }
// newDes = createFolderDescription(path, (ICFolderDescription)fo); //// else {
//// if(entryPath.segmentCount() > 0)
//// entryPath = entryPath.removeFirstSegments(1);
//// else
//// continue;
//// }
// if(srcPathSet.add(entryPath)){
// // exclusionMap.put(entryPath, Boolean.TRUE);
// PathSettingsContainer entryCr = cr.getChildContainer(entryPath, true, true);
// entryCr.setValue(Boolean.TRUE);
//
// ResourceInfo[] filters = re.getFilterInfos();
//
//// paths = entry.getExclusionPatterns();
//
// for(int j = 0; j < filters.length; j++){
// IPath path = filters[j].fRc.getFullPath();
// path = path.removeFirstSegments(entryPath.segmentCount());
// PathSettingsContainer exclusion = entryCr.getChildContainer(path, true, true);
// if(exclusion.getValue() == null)
// exclusion.setValue(Boolean.FALSE);
// // if(null == exclusionMap.get(path))
// // exclusionMap.put(path, Boolean.FALSE);
// } // }
newInfo.setExcluded(false);
}
} else {
if(!baseInfo.isExcluded()){
// ICResourceDescription newDes = createResourceDescription(path, base);
RcDesInfo newInfo = new RcDesInfo(findResourceInfo(fProject, path, true));
PathSettingsContainer newCr = crontainer.getChildContainer(path, true, true);
newCr.setValue(newInfo);
// if(newDes == null){
// ICResourceDescription fo = getResourceDescription(path, false);
// if(fo.getType() == ICSettingBase.SETTING_FILE){
// fo = getResourceDescription(path.removeLastSegments(1), false);
// } // }
// newDes = createFolderDescription(path, (ICFolderDescription)fo);
// } // }
newInfo.setExcluded(true); //
} //// CConfigurationData data = getConfigurationData(true);
} //// data.setSourcePaths((IPath[])srcPathSet.toArray(new IPath[srcPathSet.size()]));
} //// ICResourceDescription rcDess[] = getResourceDescriptions();
} //// ICResourceDescription rcDes;
return (IPath[])pathSet.toArray(new IPath[pathSet.size()]); // Set pathSet = new HashSet();
} // PathSettingsContainer children[] = crontainer.getChildren(true);
//
// for(int i = 0; i < children.length; i++){
// PathSettingsContainer child = children[i];
// RcDesInfo rcDesInfo = (RcDesInfo)child.getValue();
//// rcDes = rcDess[i];
// IPath path = child.getPath();
// pathSet.add(path);
//// Boolean b = (Boolean)exclusionMap.remove(path);
// Boolean b = (Boolean)cr.getChildContainer(path, false, false).getValue();
// assert (b != null);
// if(Boolean.TRUE == b) {
// if(rcDesInfo.isExcluded())
// rcDesInfo.setExcluded(false);
// } else {
// if(path.segmentCount() != 0)
// rcDesInfo.setExcluded(true);
// }
// }
//
// PathSettingsContainer crs[] = cr.getChildren(true);
// for(int i= 0; i < crs.length; i++){
// PathSettingsContainer c = crs[i];
// IPath path = c.getPath();
// if(!pathSet.remove(path)){
// Boolean b = (Boolean)c.getValue();
// assert (b != null);
// PathSettingsContainer baseCr = crontainer.getChildContainer(path, false, false);
// RcDesInfo baseInfo = (RcDesInfo)baseCr.getValue();
// if(b == Boolean.TRUE){
// if(baseInfo.isExcluded()){
// RcDesInfo newInfo = new RcDesInfo(findResourceInfo(fProject, path, true));
// PathSettingsContainer newCr = crontainer.getChildContainer(path, true, true);
// newCr.setValue(newInfo);
//// if(newInfo == null){
//// ICResourceDescription fo = getResourceDescription(path, false);
//// if(fo.getType() == ICSettingBase.SETTING_FILE){
//// fo = getResourceDescription(path.removeLastSegments(1), false);
//// }
//// newDes = createFolderDescription(path, (ICFolderDescription)fo);
//// }
// newInfo.setExcluded(false);
// }
// } else {
// if(!baseInfo.isExcluded()){
//// ICResourceDescription newDes = createResourceDescription(path, base);
// RcDesInfo newInfo = new RcDesInfo(findResourceInfo(fProject, path, true));
// PathSettingsContainer newCr = crontainer.getChildContainer(path, true, true);
// newCr.setValue(newInfo);
//
//// if(newDes == null){
//// ICResourceDescription fo = getResourceDescription(path, false);
//// if(fo.getType() == ICSettingBase.SETTING_FILE){
//// fo = getResourceDescription(path.removeLastSegments(1), false);
//// }
//// newDes = createFolderDescription(path, (ICFolderDescription)fo);
//// }
// newInfo.setExcluded(true);
// }
// }
// }
// }
// return (IPath[])pathSet.toArray(new IPath[pathSet.size()]);
// }
private ReferenceSettingsInfo addPathEntries(ResolvedEntry[] rEntries, int op){ private ReferenceSettingsInfo addPathEntries(ResolvedEntry[] rEntries, int op){
PathSettingsContainer cr = PathSettingsContainer.createRootContainer(); PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
@ -1457,7 +1459,7 @@ public class PathEntryTranslator {
List outList = new ArrayList(); List outList = new ArrayList();
List projList = new ArrayList(); List projList = new ArrayList();
List exportSettingsList = new ArrayList(); List exportSettingsList = new ArrayList();
IPath srcPaths[] = null; ICSourceEntry srcEntries[] = null;
PathSettingsContainer child; PathSettingsContainer child;
ResolvedEntry rEntry; ResolvedEntry rEntry;
IPath projPath; IPath projPath;
@ -1468,7 +1470,7 @@ public class PathEntryTranslator {
if(toLanguageEntryKind(rEntry.fEntry.getEntryKind()) == 0){ if(toLanguageEntryKind(rEntry.fEntry.getEntryKind()) == 0){
switch(rEntry.fEntry.getEntryKind()){ switch(rEntry.fEntry.getEntryKind()){
case IPathEntry.CDT_SOURCE: case IPathEntry.CDT_SOURCE:
srcList.add(rEntry); srcList.add(rEntry.fEntry);
break; break;
case IPathEntry.CDT_OUTPUT: case IPathEntry.CDT_OUTPUT:
outList.add(rEntry); outList.add(rEntry);
@ -1497,7 +1499,7 @@ public class PathEntryTranslator {
} }
if(srcList.size() != 0){ if(srcList.size() != 0){
srcPaths = setSourceEntries(cr, srcList); srcEntries = toCSourceEntries(srcList);
} else { } else {
// srcPaths = new IPath[]{new Path("")}; //$NON-NLS-1$ // srcPaths = new IPath[]{new Path("")}; //$NON-NLS-1$
} }
@ -1522,7 +1524,8 @@ public class PathEntryTranslator {
//applying settings //applying settings
applySourcePaths(srcPaths, op); //applySourcePaths(srcPaths, op);
applySourceEntries(srcEntries, op);
applyLangSettings(cr, op); applyLangSettings(cr, op);
IPath refProjPaths[] = new IPath[projList.size()]; IPath refProjPaths[] = new IPath[projList.size()];
@ -1550,32 +1553,50 @@ public class PathEntryTranslator {
return new ReferenceSettingsInfo(refProjPaths, extSettings); return new ReferenceSettingsInfo(refProjPaths, extSettings);
} }
private void applySourcePaths(IPath srcPaths[], int op){ private static ICSourceEntry[] toCSourceEntries(List list){
ICSourceEntry[] entries = new ICSourceEntry[list.size()];
for(int i = 0; i < entries.length; i++){
entries[i] = toCSourceEntry((ISourceEntry)list.get(i), true);
}
return entries;
}
private static ICSourceEntry toCSourceEntry(ISourceEntry entry, boolean makeProjRelative){
IPath path = entry.getPath();
if(makeProjRelative && path.isAbsolute())
path = path.removeFirstSegments(1);
return new CSourceEntry(path,
entry.getExclusionPatterns(),
ICSettingEntry.VALUE_WORKSPACE_PATH
| ICSourceEntry.RESOLVED);
}
private void applySourceEntries(ICSourceEntry entries[], int op){
switch (op) { switch (op) {
case OP_ADD: case OP_ADD:
if(srcPaths != null){ if(entries != null && entries.length != 0){
IPath curPaths[] = fCfgData.getSourcePaths(); ICSourceEntry curEntries[] = fCfgData.getSourceEntries();
Set set = new HashSet(); Set set = new LinkedHashSet();
set.addAll(Arrays.asList(curPaths)); set.addAll(Arrays.asList(curEntries));
set.addAll(Arrays.asList(srcPaths)); set.addAll(Arrays.asList(entries));
fCfgData.setSourcePaths((IPath[])set.toArray(new IPath[set.size()])); fCfgData.setSourceEntries((ICSourceEntry[])set.toArray(new ICSourceEntry[set.size()]));
} }
break; break;
case OP_REMOVE: case OP_REMOVE:
if(srcPaths != null){ if(entries != null && entries.length != 0){
IPath curPaths[] = fCfgData.getSourcePaths(); ICSourceEntry curEntries[] = fCfgData.getSourceEntries();
Set set = new HashSet(); Set set = new HashSet();
set.addAll(Arrays.asList(curPaths)); set.addAll(Arrays.asList(curEntries));
set.removeAll(Arrays.asList(srcPaths)); set.removeAll(Arrays.asList(entries));
fCfgData.setSourcePaths((IPath[])set.toArray(new IPath[set.size()])); fCfgData.setSourceEntries((ICSourceEntry[])set.toArray(new ICSourceEntry[set.size()]));
} }
break; break;
case OP_REPLACE: case OP_REPLACE:
default: default:
if(srcPaths != null){ if(entries != null){
fCfgData.setSourcePaths(srcPaths); fCfgData.setSourceEntries(entries);
} else { } else {
fCfgData.setSourcePaths(new IPath[0]); fCfgData.setSourceEntries(new ICSourceEntry[0]);
} }
break; break;
} }
@ -1603,7 +1624,7 @@ public class PathEntryTranslator {
} }
RcDesInfo desInfo = (RcDesInfo)c.getValue(); RcDesInfo desInfo = (RcDesInfo)c.getValue();
rcData.setExcluded(desInfo.isExcluded()); // rcData.setExcluded(desInfo.isExcluded());
applyEntries(rcData, desInfo, op); applyEntries(rcData, desInfo, op);
} }
@ -2274,8 +2295,8 @@ public class PathEntryTranslator {
// public static PathEntryCollector collectEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo){ // public static PathEntryCollector collectEntries(IProject project, CConfigurationData data, ReferenceSettingsInfo refInfo){
final PathEntryCollector cr = new PathEntryCollector(project/*, des*/); final PathEntryCollector cr = new PathEntryCollector(project/*, des*/);
PathSettingsContainer rcDatas = createRcDataHolder(data); PathSettingsContainer rcDatas = createRcDataHolder(data);
IPath srcPaths[] = data.getSourcePaths(); ICSourceEntry sEntries[] = data.getSourceEntries();
ICSourceEntry sEntries[] = calculateSourceEntriesFromPaths(project, rcDatas, srcPaths); // ICSourceEntry sEntries[] = calculateSourceEntriesFromPaths(project, rcDatas, srcPaths);
if(sEntries != null && sEntries.length != 0){ if(sEntries != null && sEntries.length != 0){
cr.setSourceOutputEntries(ICSettingEntry.SOURCE_PATH, sEntries); cr.setSourceOutputEntries(ICSettingEntry.SOURCE_PATH, sEntries);
} }

View file

@ -14,12 +14,15 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
public class PathSettingsContainer { public class PathSettingsContainer {
private static final Object INEXISTENT_VALUE = new Object(); private static final Object INEXISTENT_VALUE = new Object();
private static final String ROOY_PATH_NAME = Path.ROOT.toString();
// private static final boolean DEBUG = true;
// private static final int INIT_CHILDREN_MAP_CAPACITY = 2; // private static final int INIT_CHILDREN_MAP_CAPACITY = 2;
// private Map fChildrenMap; // private Map fChildrenMap;
@ -39,6 +42,10 @@ public class PathSettingsContainer {
private static final int VALUE_CHANGED = 3; private static final int VALUE_CHANGED = 3;
private static final int PATH_CHANGED = 4; private static final int PATH_CHANGED = 4;
private static class PatternSearchInfo {
Set fStoreSet;
int fNumDoubleStarEls;
}
public static PathSettingsContainer createRootContainer(){ public static PathSettingsContainer createRootContainer(){
return createRootContainer(false); return createRootContainer(false);
@ -49,7 +56,7 @@ public class PathSettingsContainer {
} }
private PathSettingsContainer(boolean pattternMode){ private PathSettingsContainer(boolean pattternMode){
this(null, null, "", pattternMode); //$NON-NLS-1$ this(null, null, ROOY_PATH_NAME, pattternMode);
} }
private PathSettingsContainer(PathSettingsContainer root, PathSettingsContainer parent, String name, boolean patternMode){ private PathSettingsContainer(PathSettingsContainer root, PathSettingsContainer parent, String name, boolean patternMode){
@ -84,6 +91,18 @@ public class PathSettingsContainer {
return null; return null;
} }
private boolean isDoubleStarName(){
return PatternNameMap.DOUBLE_STAR_PATTERN.equals(getName());
}
private PathSettingsContainer getDoubleStarChild(){
PatternNameMap pMap = getPatternChildrenMap(false);
if(pMap != null){
return pMap.containsDoubleStar() ? (PathSettingsContainer)pMap.get(PatternNameMap.DOUBLE_STAR_PATTERN) : null;
}
return null;
}
private List getChildren(String name){ private List getChildren(String name){
PatternNameMap pMap = getPatternChildrenMap(false); PatternNameMap pMap = getPatternChildrenMap(false);
if(pMap != null){ if(pMap != null){
@ -131,7 +150,11 @@ public class PathSettingsContainer {
} }
public PathSettingsContainer getChildContainer(IPath path, boolean create, boolean exactPath){ public PathSettingsContainer getChildContainer(IPath path, boolean create, boolean exactPath){
PathSettingsContainer container = findContainer(path, create, exactPath); return getChildContainer(path, create, exactPath, fIsPatternMode);
}
public PathSettingsContainer getChildContainer(IPath path, boolean create, boolean exactPath, boolean patternSearch){
PathSettingsContainer container = findContainer(path, create, exactPath, patternSearch, -1, null);
if(container != null && container.internalGetValue() == INEXISTENT_VALUE){ if(container != null && container.internalGetValue() == INEXISTENT_VALUE){
if(create){ if(create){
container.internalSetValue(null); container.internalSetValue(null);
@ -148,6 +171,10 @@ public class PathSettingsContainer {
return container; return container;
} }
static IPath toNormalizedContainerPath(IPath path){
return Path.ROOT.append(path);
}
public PathSettingsContainer[] getChildren(final boolean includeThis){ public PathSettingsContainer[] getChildren(final boolean includeThis){
final List list = new ArrayList(); final List list = new ArrayList();
accept(new IPathSettingsContainerVisitor(){ accept(new IPathSettingsContainerVisitor(){
@ -163,19 +190,45 @@ public class PathSettingsContainer {
} }
public PathSettingsContainer[] getChildrenForPath(IPath path, boolean includePath){ public PathSettingsContainer[] getChildrenForPath(IPath path, boolean includePath){
PathSettingsContainer cr = findContainer(path, false, true); PathSettingsContainer cr = findContainer(path, false, true, fIsPatternMode, -1, null);
if(cr != null) if(cr != null)
return cr.getChildren(includePath); return cr.getChildren(includePath);
return new PathSettingsContainer[0]; return new PathSettingsContainer[0];
} }
public PathSettingsContainer[] getDirectChildrenForPath(IPath path){ public PathSettingsContainer[] getDirectChildrenForPath(IPath path){
PathSettingsContainer cr = findContainer(path, false, true); PathSettingsContainer cr = findContainer(path, false, true, fIsPatternMode, -1, null);
if(cr != null) if(cr != null)
return cr.getDirectChildren(); return cr.getDirectChildren();
return new PathSettingsContainer[0]; return new PathSettingsContainer[0];
} }
/* public PathSettingsContainer[] getDirectChildrenForPath(IPath path, boolean searchPatterns){
if(!searchPatterns)
return getDirectChildrenForPath(path);
if(!isRoot() && !PatternNameMap.isPatternName(fName)){
return getDirectParentContainer().getDirectChildrenForPath(
new Path(fName).append(path), true);
}
return searchPatternsDirectChildrenForPath(path);
}
private PathSettingsContainer[] searchPatternsDirectChildrenForPath(IPath path){
Set set = new HashSet();
findContainer(path, false, false, path.segmentCount(), set);
if(DEBUG){
for(Iterator iter = set.iterator(); iter.hasNext();){
PathSettingsContainer child = (PathSettingsContainer)iter.next();
if(child.fValue == INEXISTENT_VALUE)
throw new IllegalStateException();
}
}
return (PathSettingsContainer[])set.toArray(new PathSettingsContainer[set.size()]);
}
*/
public PathSettingsContainer[] getDirectChildren(){ public PathSettingsContainer[] getDirectChildren(){
List list = doGetDirectChildren(null); List list = doGetDirectChildren(null);
if(list == null || list.size() == 0) if(list == null || list.size() == 0)
@ -292,39 +345,167 @@ public class PathSettingsContainer {
return fName; return fName;
} }
private PathSettingsContainer findContainer(IPath path, boolean create, boolean exactPath){ private PathSettingsContainer findContainer(IPath path, boolean create, boolean exactPath, boolean patternSearch, int matchDepth, PatternSearchInfo psi){
PathSettingsContainer container = null; PathSettingsContainer container = null;
if(path.segmentCount() == 0) if(path.segmentCount() == 0)
container = this; container = this;
else if (create || exactPath || !fIsPatternMode) { else if (create || exactPath || !patternSearch || !fIsPatternMode) {
PathSettingsContainer child = getExacChild(path.segment(0), create); PathSettingsContainer child = getExacChild(path.segment(0), create);
if(child != null) if(child != null)
container = child.findContainer(path.removeFirstSegments(1), create, exactPath); container = child.findContainer(path.removeFirstSegments(1), create, exactPath, patternSearch, stepDepth(matchDepth), psi);
else if(!exactPath) else if(!exactPath)
container = this; container = this;
} else { } else {
//looking for container using patterns in read mode (i.e. not creating new container) //looking for container using patterns in read mode (i.e. not creating new container)
List list = getChildren(path.segment(0)); if(psi == null)
psi = new PatternSearchInfo();
container = processPatterns(path, matchDepth, 0, psi);
// do {
// List list = getChildren(path.segment(0));
// if(list != null){
// int size = list.size();
// PathSettingsContainer child, childFound;
//
// for(int i = 0; i < size; i++){
// child = (PathSettingsContainer)list.get(i);
// if(directChildren && child.fValue != INEXISTENT_VALUE){
// childFound = child;
// } else {
// childFound = child.findContainer(path.removeFirstSegments(1), false, false, directChildren, storeSet);
// }
//
// if(childFound.fValue != INEXISTENT_VALUE){
// if(container == null
// || container.getValue() == INEXISTENT_VALUE
// || container.getPath().segmentCount() < childFound.getPath().segmentCount()){
// container = childFound;
// }
// if(storeSet != null)
// storeSet.add(container);
// }
// }
// }
// if(container == null || storeSet != null){
// PathSettingsContainer dsChild = getDoubleStarChild();
// if(dsChild != null && !storeSet.contains(dsChild)){
// container = dsChild.findContainer(path, false, false, directChildren, storeSet);
// }
//
// if(container == null){
// if(isDoubleStarName()){
// if(path.segmentCount() != 0){
// path = path.removeFirstSegments(1);
// continue;
// }
// } else {
// container = this;
// }
// }
// }
// break;
// } while(true);
}
return container;
}
static boolean pathsEqual(IPath p1, IPath p2) {
if (p1 == p2)
return true;
int i = p1.segmentCount();
if(i != p2.segmentCount())
return false;
while (--i >= 0)
if (!p1.segment(i).equals(p2.segment(i)))
return false;
return true;
}
private PathSettingsContainer processPatterns(IPath path, int matchDepth, int depth, PatternSearchInfo psi){
Set storeSet = psi.fStoreSet;
PathSettingsContainer container = null;
String name = path.segment(0);
List list = getChildren(name);
PathSettingsContainer child, childFound;
boolean exactPathFound = false;
if(list != null){ if(list != null){
int size = list.size(); int size = list.size();
PathSettingsContainer child, childFound;
for(int i = 0; i < size; i++){ for(int i = 0; i < size; i++){
child = (PathSettingsContainer)list.get(i); child = (PathSettingsContainer)list.get(i);
childFound = child.findContainer(path.removeFirstSegments(1), false, false); if(matchDepth == 0 && child.fValue != INEXISTENT_VALUE){
if(container == null) childFound = child;
} else {
childFound = child.findContainer(path.removeFirstSegments(1), false, false, true, stepDepth(matchDepth), psi);
}
if(childFound != null && childFound.fValue != INEXISTENT_VALUE){
if(!exactPathFound
&& path.segmentCount() == 1
&& child != childFound
&& name.equals(childFound.fName)){
container = childFound; container = childFound;
else if(container.getPath().segmentCount() < childFound.getPath().segmentCount()){ exactPathFound = true;
} else if(container == null
|| container.getValue() == INEXISTENT_VALUE
|| container.getPath().segmentCount() < childFound.getPath().segmentCount()){
container = childFound; container = childFound;
} }
if(storeSet != null)
storeSet.add(container);
else if(exactPathFound)
break;
} }
} }
if(container == null) }
if(!exactPathFound || storeSet != null){
child = getDoubleStarChild();
if(child != null/* && !storeSet.contains(child)*/){
if(matchDepth == 0 && child.fValue != INEXISTENT_VALUE){
childFound = child;
} else {
childFound = child.findContainer(path, false, false, true, matchDepth, psi);
}
if(childFound != null && childFound.fValue != INEXISTENT_VALUE){
psi.fNumDoubleStarEls++;
if(container == null
|| container.getValue() == INEXISTENT_VALUE
|| container.getPath().segmentCount() < childFound.getPath().segmentCount() + depth - psi.fNumDoubleStarEls){
container = childFound;
}
if(storeSet != null)
storeSet.add(container);
}
}
if(container == null){
if(isDoubleStarName()){
if(path.segmentCount() > 1){
childFound = processPatterns(path.removeFirstSegments(1), stepDepth(matchDepth), depth + 1, psi);
if(childFound != null && childFound.fValue != INEXISTENT_VALUE){
container = childFound;
if(storeSet != null)
storeSet.add(container);
}
}
} else if (matchDepth < 0 && fValue != INEXISTENT_VALUE){
container = this; container = this;
if(storeSet != null)
storeSet.add(container);
}
}
} }
return container; return container;
} }
private int stepDepth(int depth){
return depth == 0 ? depth : depth-1;
}
public void accept(IPathSettingsContainerVisitor visitor){ public void accept(IPathSettingsContainerVisitor visitor){
doAccept(visitor); doAccept(visitor);
} }
@ -377,7 +558,7 @@ public class PathSettingsContainer {
} }
PathSettingsContainer newParent = fRootContainer.findContainer(path.removeLastSegments(1), true, true); PathSettingsContainer newParent = fRootContainer.findContainer(path.removeLastSegments(1), true, true, false, -1, null);
PathSettingsContainer oldParent = fDirectParentContainer; PathSettingsContainer oldParent = fDirectParentContainer;
fName = path.segment(path.segmentCount()-1); fName = path.segment(path.segmentCount()-1);
fPath = path; fPath = path;
@ -442,4 +623,33 @@ public class PathSettingsContainer {
private void setParent(PathSettingsContainer parent){ private void setParent(PathSettingsContainer parent){
fDirectParentContainer = parent; fDirectParentContainer = parent;
} }
public String toString() {
return contributeToString(new StringBuffer(), 0).toString();
}
private StringBuffer contributeToString(StringBuffer buf, int depth){
for (int i= 0; i < depth; i++) {
buf.append('\t');
}
buf.append('[').append(getPath()).append(']').append('\n');
PathSettingsContainer[] directChildren = getDirectChildren();
if(directChildren.length != 0){
int nextDepth = depth + 1;
for(int i = 0; i < directChildren.length; i++){
directChildren[i].contributeToString(buf, nextDepth);
}
}
return buf;
}
static boolean hasSpecChars(IPath path){
int count = path.segmentCount();
for(int i = 0; i < count; i++){
if(PatternNameMap.isPatternName(path.segment(i)))
return true;
}
return false;
}
} }

View file

@ -23,10 +23,12 @@ import org.eclipse.cdt.core.model.CoreModelUtil;
public class PatternNameMap { public class PatternNameMap {
private static final char[] SPEC_CHARS = new char[]{'*', '?'}; private static final char[] SPEC_CHARS = new char[]{'*', '?'};
static final String DOUBLE_STAR_PATTERN = "**";
private Map fChildrenMap; private Map fChildrenMap;
private Map fPatternMap; private Map fPatternMap;
private Collection fValues; private Collection fValues;
private boolean fContainsDoubleStar;
private static class StringCharArray { private static class StringCharArray {
private String fString; private String fString;
@ -98,9 +100,13 @@ public class PatternNameMap {
public void remove() { public void remove() {
fEntrySetIter.remove(); fEntrySetIter.remove();
removePattern((String)fCur.getKey()); String name = (String)fCur.getKey();
if(DOUBLE_STAR_PATTERN.equals(name)){
fContainsDoubleStar = false;
} else {
removePattern(name);
}
} }
} }
public Iterator iterator() { public Iterator iterator() {
@ -128,8 +134,16 @@ public class PatternNameMap {
return fChildrenMap != null ? fChildrenMap.size() : 0; return fChildrenMap != null ? fChildrenMap.size() : 0;
} }
public boolean isEmpty(){
return fChildrenMap == null || fChildrenMap.isEmpty();
}
public boolean hasPatterns(){ public boolean hasPatterns(){
return fPatternMap != null && fPatternMap.size() != 0; return fContainsDoubleStar || hasPatternsMap();
}
public boolean hasPatternsMap(){
return (fPatternMap != null && fPatternMap.size() != 0);
} }
public List getValues(String name){ public List getValues(String name){
@ -137,7 +151,7 @@ public class PatternNameMap {
return null; return null;
Object val = fChildrenMap.get(name); Object val = fChildrenMap.get(name);
if(hasPatterns()){ if(hasPatternsMap()){
List list; List list;
if(val != null){ if(val != null){
list = new ArrayList(3); list = new ArrayList(3);
@ -167,6 +181,10 @@ public class PatternNameMap {
return null; return null;
} }
public boolean containsDoubleStar(){
return fContainsDoubleStar;
}
public Object put(String name, Object value){ public Object put(String name, Object value){
if(value == null) if(value == null)
return remove(name); return remove(name);
@ -181,7 +199,9 @@ public class PatternNameMap {
fChildrenMap.put(name, value); fChildrenMap.put(name, value);
if(isPatternName(name)){ if(DOUBLE_STAR_PATTERN.equals(name)){
fContainsDoubleStar = true;
} else if(isPatternName(name)){
StringCharArray strCA = new StringCharArray(name); StringCharArray strCA = new StringCharArray(name);
if(fPatternMap == null) if(fPatternMap == null)
fPatternMap = new HashMap(); fPatternMap = new HashMap();
@ -198,6 +218,9 @@ public class PatternNameMap {
if(fChildrenMap.size() == 0){ if(fChildrenMap.size() == 0){
fChildrenMap = null; fChildrenMap = null;
fPatternMap = null; fPatternMap = null;
fContainsDoubleStar = false;
} else if(DOUBLE_STAR_PATTERN.equals(name)){
fContainsDoubleStar = false;
} else { } else {
removePattern(name); removePattern(name);
} }
@ -230,6 +253,7 @@ public class PatternNameMap {
public void clear(){ public void clear(){
fChildrenMap = null; fChildrenMap = null;
fPatternMap = null; fPatternMap = null;
fContainsDoubleStar = false;
} }
public Collection values(){ public Collection values(){

View file

@ -12,14 +12,11 @@ package org.eclipse.cdt.internal.core.settings.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICBuildSetting; import org.eclipse.cdt.core.settings.model.ICBuildSetting;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -43,12 +40,11 @@ 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.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.CResourceData; 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.CTargetPlatformData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
public class CConfigurationDescription extends CDataProxyContainer implements ICConfigurationDescription, IProxyFactory, IInternalCCfgInfo { public class CConfigurationDescription extends CDataProxyContainer implements ICConfigurationDescription, IProxyFactory, IInternalCCfgInfo {
@ -471,151 +467,159 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
public ICSourceEntry[] getSourceEntries() { public ICSourceEntry[] getSourceEntries() {
CConfigurationData data = getConfigurationData(false); CConfigurationData data = getConfigurationData(false);
IPath[] srcPaths = data.getSourcePaths(); ICSourceEntry[] srcEntries = data.getSourceEntries();
IProject proj = fIsPreference ? null : getProjectDescription().getProject(); IProject proj = fIsPreference ? null : getProjectDescription().getProject();
return getRcHolder().calculateSourceEntriesFromPaths(proj, srcPaths); return CDataUtil.adjustEntries(srcEntries, true, proj);
// return getRcHolder().calculateSourceEntriesFromPaths(proj, srcPaths);
} }
public void setSourceEntries(ICSourceEntry[] entries) throws CoreException { public void setSourceEntries(ICSourceEntry[] entries) throws CoreException {
ICSourceEntry entry; CConfigurationData data = getConfigurationData(true);
IPath entryPath;
IPath paths[];
PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
cr.setValue(Boolean.valueOf(getRootFolderDescription().isExcluded()));
Set srcPathSet = new HashSet();
IProject project = fIsPreference ? null : getProjectDescription().getProject(); IProject project = fIsPreference ? null : getProjectDescription().getProject();
IPath projPath = project != null ? project.getFullPath() : null; if(entries != null && entries.length == 0)
// Map exclusionMap = new HashMap(); entries = null;
entries = CDataUtil.adjustEntries(entries, false, project);
data.setSourceEntries(entries);
// HashSet pathSet = new HashSet(); // ICSourceEntry entry;
// IPath entryPath;
if(entries == null){ // IPath paths[];
IPath pasePath = projPath != null ? projPath : Path.EMPTY; // PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
entries = new ICSourceEntry[]{new CSourceEntry(pasePath, null, ICLanguageSettingEntry.RESOLVED | ICLanguageSettingEntry.VALUE_WORKSPACE_PATH)}; // cr.setValue(Boolean.valueOf(getRootFolderDescription().isExcluded()));
} // Set srcPathSet = new HashSet();
// IProject project = fIsPreference ? null : getProjectDescription().getProject();
for(int i = 0 ; i < entries.length; i++){ // IPath projPath = project != null ? project.getFullPath() : null;
entry = entries[i]; //// Map exclusionMap = new HashMap();
entryPath = entry.getFullPath(); //
if(projPath != null){ //// HashSet pathSet = new HashSet();
if(projPath.isPrefixOf(entryPath)){ //
entryPath = entryPath.removeFirstSegments(projPath.segmentCount()); // if(entries == null){
} else { // IPath pasePath = projPath != null ? projPath : Path.EMPTY;
continue; // entries = new ICSourceEntry[]{new CSourceEntry(pasePath, null, ICLanguageSettingEntry.RESOLVED | ICLanguageSettingEntry.VALUE_WORKSPACE_PATH)};
} // }
} //
// else { // for(int i = 0 ; i < entries.length; i++){
// if(entryPath.segmentCount() > 0) // entry = entries[i];
// entryPath = entryPath.removeFirstSegments(1); // entryPath = entry.getFullPath();
// else // if(projPath != null){
// if(projPath.isPrefixOf(entryPath)){
// entryPath = entryPath.removeFirstSegments(projPath.segmentCount());
// } else {
// continue; // continue;
// } // }
if(srcPathSet.add(entryPath)){ // }
// exclusionMap.put(entryPath, Boolean.TRUE); //// else {
PathSettingsContainer entryCr = cr.getChildContainer(entryPath, true, true); //// if(entryPath.segmentCount() > 0)
entryCr.setValue(Boolean.TRUE); //// entryPath = entryPath.removeFirstSegments(1);
//// else
//// continue;
paths = entry.getExclusionPatterns(); //// }
// if(srcPathSet.add(entryPath)){
// // exclusionMap.put(entryPath, Boolean.TRUE);
for(int j = 0; j < paths.length; j++){ // PathSettingsContainer entryCr = cr.getChildContainer(entryPath, true, true);
IPath path = paths[j]; // entryCr.setValue(Boolean.TRUE);
PathSettingsContainer exclusion = entryCr.getChildContainer(path, true, true); //
if(exclusion.getValue() == null) //
exclusion.setValue(Boolean.FALSE); // paths = entry.getExclusionPatterns();
// if(null == exclusionMap.get(path)) //
// exclusionMap.put(path, Boolean.FALSE); //
} // for(int j = 0; j < paths.length; j++){
} // IPath path = paths[j];
// PathSettingsContainer exclusion = entryCr.getChildContainer(path, true, true);
// if(exclusion.getValue() == null)
// exclusion.setValue(Boolean.FALSE);
// // if(null == exclusionMap.get(path))
// // exclusionMap.put(path, Boolean.FALSE);
// }
// }
// }
//
// CConfigurationData data = getConfigurationData(true);
// data.setSourcePaths((IPath[])srcPathSet.toArray(new IPath[srcPathSet.size()]));
// ICResourceDescription rcDess[] = getResourceDescriptions();
// ICResourceDescription rcDes;
// Set pathSet = new HashSet();
//
// for(int i = 0; i < rcDess.length; i++){
// rcDes = rcDess[i];
// IPath path = rcDes.getPath();
// pathSet.add(path);
//// Boolean b = (Boolean)exclusionMap.remove(path);
// Boolean b = (Boolean)cr.getChildContainer(path, false, false).getValue();
// assert (b != null);
// if(Boolean.TRUE == b) {
// if(rcDes.isExcluded())
// rcDes.setExcluded(false);
// } else {
// if(/*(rcDes.getType() == ICSettingBase.SETTING_FILE
// || !((ICFolderDescription)rcDes).isRoot())
// &&*/ !rcDes.isExcluded())
// rcDes.setExcluded(true);
// }
// }
//
// PathSettingsContainer crs[] = cr.getChildren(true);
// for(int i= 0; i < crs.length; i++){
// PathSettingsContainer c = crs[i];
// IPath path = c.getPath();
// if(!pathSet.remove(path)){
// Boolean b = (Boolean)c.getValue();
// assert (b != null);
// ICResourceDescription base = getResourceDescription(path, false);
// if(b == Boolean.TRUE){
// if(base.isExcluded()){
// ICResourceDescription newDes = createResourceDescription(path, base);
// if(newDes == null){
// ICResourceDescription fo = getResourceDescription(path, false);
// if(fo.getType() == ICSettingBase.SETTING_FILE){
// fo = getResourceDescription(path.removeLastSegments(1), false);
// }
// newDes = createFolderDescription(path, (ICFolderDescription)fo);
// }
// newDes.setExcluded(false);
// }
// } else {
// if(!base.isExcluded()){
// ICResourceDescription newDes = createResourceDescription(path, base);
// if(newDes == null){
// ICResourceDescription fo = getResourceDescription(path, false);
// if(fo.getType() == ICSettingBase.SETTING_FILE){
// fo = getResourceDescription(path.removeLastSegments(1), false);
// }
// newDes = createFolderDescription(path, (ICFolderDescription)fo);
// }
// newDes.setExcluded(true);
// }
// }
// }
// }
//
} }
CConfigurationData data = getConfigurationData(true); // private ICResourceDescription createResourceDescription(IPath path, ICResourceDescription base){
data.setSourcePaths((IPath[])srcPathSet.toArray(new IPath[srcPathSet.size()])); // if(fIsPreference)
ICResourceDescription rcDess[] = getResourceDescriptions(); // return null;
ICResourceDescription rcDes; // IProject project = getProjectDescription().getProject();
Set pathSet = new HashSet(); // IResource rc = project.findMember(path);
// ICResourceDescription des = null;
for(int i = 0; i < rcDess.length; i++){ // if(rc != null){
rcDes = rcDess[i]; // if(rc.getType() == IResource.FILE) {
IPath path = rcDes.getPath(); // try {
pathSet.add(path); // des = createFileDescription(path, base);
// Boolean b = (Boolean)exclusionMap.remove(path); // } catch (WriteAccessException e) {
Boolean b = (Boolean)cr.getChildContainer(path, false, false).getValue(); // } catch (CoreException e) {
assert (b != null); // }
if(Boolean.TRUE == b) { // } else if (rc.getType() == IResource.FOLDER) {
if(rcDes.isExcluded()) // try {
rcDes.setExcluded(false); // des = createFolderDescription(path, (ICFolderDescription)base);
} else { // } catch (WriteAccessException e) {
if(/*(rcDes.getType() == ICSettingBase.SETTING_FILE // } catch (CoreException e) {
|| !((ICFolderDescription)rcDes).isRoot()) // }
&&*/ !rcDes.isExcluded()) // }
rcDes.setExcluded(true); // }
} //
} // return des;
// }
PathSettingsContainer crs[] = cr.getChildren(true);
for(int i= 0; i < crs.length; i++){
PathSettingsContainer c = crs[i];
IPath path = c.getPath();
if(!pathSet.remove(path)){
Boolean b = (Boolean)c.getValue();
assert (b != null);
ICResourceDescription base = getResourceDescription(path, false);
if(b == Boolean.TRUE){
if(base.isExcluded()){
ICResourceDescription newDes = createResourceDescription(path, base);
if(newDes == null){
ICResourceDescription fo = getResourceDescription(path, false);
if(fo.getType() == ICSettingBase.SETTING_FILE){
fo = getResourceDescription(path.removeLastSegments(1), false);
}
newDes = createFolderDescription(path, (ICFolderDescription)fo);
}
newDes.setExcluded(false);
}
} else {
if(!base.isExcluded()){
ICResourceDescription newDes = createResourceDescription(path, base);
if(newDes == null){
ICResourceDescription fo = getResourceDescription(path, false);
if(fo.getType() == ICSettingBase.SETTING_FILE){
fo = getResourceDescription(path.removeLastSegments(1), false);
}
newDes = createFolderDescription(path, (ICFolderDescription)fo);
}
newDes.setExcluded(true);
}
}
}
}
}
private ICResourceDescription createResourceDescription(IPath path, ICResourceDescription base){
if(fIsPreference)
return null;
IProject project = getProjectDescription().getProject();
IResource rc = project.findMember(path);
ICResourceDescription des = null;
if(rc != null){
if(rc.getType() == IResource.FILE) {
try {
des = createFileDescription(path, base);
} catch (WriteAccessException e) {
} catch (CoreException e) {
}
} else if (rc.getType() == IResource.FOLDER) {
try {
des = createFolderDescription(path, (ICFolderDescription)base);
} catch (WriteAccessException e) {
} catch (CoreException e) {
}
}
}
return des;
}
public Map getReferenceInfo() { public Map getReferenceInfo() {
try { try {
@ -737,4 +741,52 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExcludeStatus) { public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExcludeStatus) {
return CProjectDescriptionManager.getLanguageSettingForFile(this, path, ignoreExcludeStatus); return CProjectDescriptionManager.getLanguageSettingForFile(this, path, ignoreExcludeStatus);
} }
boolean isExcluded(IPath path){
// if(path.segmentCount() == 0)
// return false;
IProject project = fIsPreference ? null : getProjectDescription().getProject();
ICSourceEntry[] entries = getSourceEntries();
if(project != null)
path = project.getFullPath().append(path);
return CDataUtil.isExcluded(path, entries);
}
void setExcluded(IPath path, boolean exclude){
// if(path.segmentCount() == 0)
// return;
if(isExcluded(path) == exclude)
return;
IProject project = fIsPreference ? null : getProjectDescription().getProject();
if(project != null)
path = project.getFullPath().append(path);
CConfigurationData data = getConfigurationData(false);
ICSourceEntry[] newEntries = null;
if(project != null){
if(!(data instanceof CConfigurationDescriptionCache)){
ICProjectDescription roDes = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
if(roDes != null){
ICConfigurationDescription roCfg = roDes.getConfigurationById(getId());
if(roCfg != null){
newEntries = roCfg.getSourceEntries();
if(CDataUtil.isExcluded(path, newEntries) != exclude)
newEntries = null;
}
}
}
}
if(newEntries == null){
newEntries = CDataUtil.setExcluded(path, exclude, getSourceEntries());
}
try {
setSourceEntries(newEntries);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
} }

View file

@ -41,10 +41,12 @@ 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.CResourceData;
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData; 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.extension.impl.CDefaultConfigurationData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory; import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager; import org.eclipse.cdt.internal.core.cdtvariables.CdtVariableManager;
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables; import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
@ -57,7 +59,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
private List fChildList = new ArrayList(); private List fChildList = new ArrayList();
private CConfigurationSpecSettings fSpecSettings; private CConfigurationSpecSettings fSpecSettings;
private CConfigurationData fData; private CConfigurationData fData;
private ICSourceEntry fSourceEntries[]; private ICSourceEntry fProjSourceEntries[];
private StorableCdtVariables fMacros; private StorableCdtVariables fMacros;
private boolean fDataLoadded; private boolean fDataLoadded;
private boolean fInitializing; private boolean fInitializing;
@ -346,11 +348,19 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
} }
public ICSourceEntry[] getSourceEntries() { public ICSourceEntry[] getSourceEntries() {
if(fSourceEntries == null){ initSourceEntries();
IPath[] paths = getSourcePaths(); return (ICSourceEntry[])fProjSourceEntries.clone();
fSourceEntries = fRcHolder.calculateSourceEntriesFromPaths(getProjectDescription().getProject(), paths);
} }
return fSourceEntries;
private void initSourceEntries(){
if(fProjSourceEntries == null){
IProject project = getProject();
fProjSourceEntries = CDataUtil.adjustEntries(fSourceEntries, true, project);
}
}
private IProject getProject(){
return isPreferenceConfiguration() ? null : getProjectDescription().getProject();
} }
public void setSourceEntries(ICSourceEntry[] entries) { public void setSourceEntries(ICSourceEntry[] entries) {
@ -451,4 +461,15 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
return super.filterRcDatasToCopy(base); return super.filterRcDatasToCopy(base);
} }
boolean isExcluded(IPath path){
// if(path.segmentCount() == 0)
// return false;
initSourceEntries();
IProject project = getProject();
if(project != null)
path = project.getFullPath().append(path);
return CDataUtil.isExcluded(path, fProjSourceEntries);
}
} }

View file

@ -51,8 +51,8 @@ public class CExternalSetting implements ICExternalSetting {
if(tmp != null) if(tmp != null)
fExtensions = tmp.split(ATTRIBUTE_EXTENSIONS); fExtensions = tmp.split(ATTRIBUTE_EXTENSIONS);
ICLanguageSettingEntry entries[] = LanguageSettingEntriesSerializer.loadEntries(element); List entriesList = LanguageSettingEntriesSerializer.loadEntriesList(element, KindBasedStore.ORED_LANG_ENTRY_KINDS);
ICLanguageSettingEntry[] entries = (ICLanguageSettingEntry[])entriesList.toArray(new ICLanguageSettingEntry[entriesList.size()]);
initEntryStore(entries); initEntryStore(entries);
} }

View file

@ -37,16 +37,13 @@ public class CFileDescription extends CDataProxyContainer implements
} }
public boolean isExcluded() { public boolean isExcluded() {
CResourceData data = (CResourceData)getData(false); CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration();
return data.isExcluded(); return cfg.isExcluded(getPath());
} }
public void setExcluded(boolean excluded) { public void setExcluded(boolean excluded) {
if(isExcluded() == excluded) CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration();
return; cfg.setExcluded(getPath(), excluded);
CResourceData data = (CResourceData)getData(true);
data.setExcluded(excluded);
} }
public void setPath(IPath path) { public void setPath(IPath path) {

View file

@ -90,4 +90,8 @@ public class CFileDescriptionCache extends CDefaultFileData implements
public boolean hasCustomSettings() { public boolean hasCustomSettings() {
return true; return true;
} }
public boolean isExcluded() {
return fCfg.isExcluded(getPath());
}
} }

View file

@ -39,16 +39,13 @@ public class CFolderDescription extends CDataProxyContainer implements
} }
public boolean isExcluded() { public boolean isExcluded() {
CResourceData data = (CResourceData)getData(false); CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration();
return data.isExcluded(); return cfg.isExcluded(getPath());
} }
public void setExcluded(boolean excluded) { public void setExcluded(boolean excluded) {
if(isExcluded() == excluded) CConfigurationDescription cfg = (CConfigurationDescription)getConfiguration();
return; cfg.setExcluded(getPath(), excluded);
CResourceData data = (CResourceData)getData(true);
data.setExcluded(excluded);
} }
public void setPath(IPath path) { public void setPath(IPath path) {

View file

@ -18,10 +18,8 @@ import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSettingContainer; import org.eclipse.cdt.core.settings.model.ICSettingContainer;
import org.eclipse.cdt.core.settings.model.ICSettingObject; import org.eclipse.cdt.core.settings.model.ICSettingObject;
import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CFolderData; 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.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.impl.CDataFacroty;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFolderData; import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFolderData;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -139,5 +137,7 @@ public class CFolderDescriptionCache extends CDefaultFolderData implements
return true; return true;
} }
public boolean isExcluded() {
return fCfg.isExcluded(getPath());
}
} }

View file

@ -29,6 +29,7 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements
private ICResourceDescription fParent; private ICResourceDescription fParent;
protected EntryStore fResolvedEntriesStore; protected EntryStore fResolvedEntriesStore;
private String fCachedExtensions[]; private String fCachedExtensions[];
private boolean fContainsDiscoveredScannerInfo = true;
public CLanguageSettingCache(CLanguageData base, CFolderDescriptionCache folderCache) { public CLanguageSettingCache(CLanguageData base, CFolderDescriptionCache folderCache) {
fId = base.getId(); fId = base.getId();
@ -42,6 +43,11 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements
copySettingsFrom(base); copySettingsFrom(base);
} }
protected void copySettingsFrom(CLanguageData data) {
super.copySettingsFrom(data);
fContainsDiscoveredScannerInfo = data.containsDiscoveredScannerInfo();
}
/* public ICLanguageSettingEntry[] getResolvedSettingEntries() { /* public ICLanguageSettingEntry[] getResolvedSettingEntries() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return getSettingEntries(); return getSettingEntries();
@ -171,4 +177,7 @@ public class CLanguageSettingCache extends CDefaultLanguageData implements
return entries; return entries;
} }
public boolean containsDiscoveredScannerInfo() {
return fContainsDiscoveredScannerInfo;
}
} }

View file

@ -3211,8 +3211,8 @@ public class CProjectDescriptionManager {
} }
private static boolean baseSettingsCustomized(CResourceData parent, CResourceData child){ private static boolean baseSettingsCustomized(CResourceData parent, CResourceData child){
if(parent.isExcluded() != child.isExcluded()) // if(parent.isExcluded() != child.isExcluded())
return true; // return true;
if(child.hasCustomSettings()) if(child.hasCustomSettings())
return true; return true;

View file

@ -54,9 +54,9 @@ public class ProviderBasedRcDesHolder extends ResourceDescriptionHolder {
return super.getDirectChildren(); return super.getDirectChildren();
} }
public ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, IPath[] paths) { // public ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, IPath[] paths) {
fProvider.cacheValues(); // fProvider.cacheValues();
return super.calculateSourceEntriesFromPaths(project, paths); // return super.calculateSourceEntriesFromPaths(project, paths);
} // }
} }

View file

@ -13,17 +13,13 @@ package org.eclipse.cdt.internal.core.settings.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICFileDescription; import org.eclipse.cdt.core.settings.model.ICFileDescription;
import org.eclipse.cdt.core.settings.model.ICFolderDescription; import org.eclipse.cdt.core.settings.model.ICFolderDescription;
import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor; import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class ResourceDescriptionHolder { public class ResourceDescriptionHolder {
private PathSettingsContainer fPathSettingContainer; private PathSettingsContainer fPathSettingContainer;
@ -111,64 +107,64 @@ public class ResourceDescriptionHolder {
return rcDess; return rcDess;
} }
public ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, IPath paths[]){ // public ICSourceEntry[] calculateSourceEntriesFromPaths(IProject project, IPath paths[]){
if(paths == null || paths.length == 0) // if(paths == null || paths.length == 0)
paths = new IPath[]{new Path("")}; //$NON-NLS-1$ // paths = new IPath[]{new Path("")}; //$NON-NLS-1$
//
// Set set = new HashSet(paths.length); //// Set set = new HashSet(paths.length);
PathSettingsContainer cr = PathSettingsContainer.createRootContainer(); // PathSettingsContainer cr = PathSettingsContainer.createRootContainer();
IPath pi, pj; // IPath pi, pj;
List entriesList = new ArrayList(paths.length); // List entriesList = new ArrayList(paths.length);
IPath projPath = project != null ? project.getFullPath() : null; // IPath projPath = project != null ? project.getFullPath() : null;
//
for(int i = 0; i < paths.length; i++){ // for(int i = 0; i < paths.length; i++){
pi = paths[i]; // pi = paths[i];
// set.clear(); //// set.clear();
cr.removeChildren(); // cr.removeChildren();
cr.setValue(null); // cr.setValue(null);
for(int j = 0; j < paths.length; j++){ // for(int j = 0; j < paths.length; j++){
pj = paths[j]; // pj = paths[j];
if(pi != pj && pi.isPrefixOf(pj)){ // if(pi != pj && pi.isPrefixOf(pj)){
// set.add(pj); //// set.add(pj);
cr.getChildContainer(pj, true, true); // cr.getChildContainer(pj, true, true);
} // }
} // }
//
PathSettingsContainer children[] = fPathSettingContainer.getDirectChildrenForPath(pi); // PathSettingsContainer children[] = fPathSettingContainer.getDirectChildrenForPath(pi);
for(int k = 0; k < children.length; k++){ // for(int k = 0; k < children.length; k++){
PathSettingsContainer child = children[k]; // PathSettingsContainer child = children[k];
IPath childPath = child.getPath(); // IPath childPath = child.getPath();
PathSettingsContainer parentExclusion = cr.getChildContainer(childPath, false, false); // PathSettingsContainer parentExclusion = cr.getChildContainer(childPath, false, false);
IPath parentExclusionPath = parentExclusion.getPath(); // IPath parentExclusionPath = parentExclusion.getPath();
if(parentExclusionPath.segmentCount() > 0 && !parentExclusionPath.equals(childPath) && parentExclusionPath.isPrefixOf(childPath)) // if(parentExclusionPath.segmentCount() > 0 && !parentExclusionPath.equals(childPath) && parentExclusionPath.isPrefixOf(childPath))
continue; // continue;
//
ICResourceDescription rcDes = (ICResourceDescription)child.getValue(); // ICResourceDescription rcDes = (ICResourceDescription)child.getValue();
if(rcDes.isExcluded()){ // if(rcDes.isExcluded()){
// set.add(rcDes.getPath()); //// set.add(rcDes.getPath());
cr.getChildContainer(childPath, true, true); // cr.getChildContainer(childPath, true, true);
} // }
} // }
//
PathSettingsContainer exclusions[] = cr.getChildren(false); // PathSettingsContainer exclusions[] = cr.getChildren(false);
// IPath exlusionPaths[] = new IPath[set.size()]; //// IPath exlusionPaths[] = new IPath[set.size()];
IPath exlusionPaths[] = new IPath[exclusions.length]; // IPath exlusionPaths[] = new IPath[exclusions.length];
// int k = 0; //// int k = 0;
int segCount = pi.segmentCount(); // int segCount = pi.segmentCount();
// for(Iterator iter = set.iterator(); iter.hasNext(); k++) { //// for(Iterator iter = set.iterator(); iter.hasNext(); k++) {
// IPath path = (IPath)iter.next(); //// IPath path = (IPath)iter.next();
// exlusionPaths[k] = path.removeFirstSegments(segCount).makeRelative(); //// exlusionPaths[k] = path.removeFirstSegments(segCount).makeRelative();
//// }
// for(int k = 0; k < exlusionPaths.length; k++) {
// exlusionPaths[k] = exclusions[k].getPath().removeFirstSegments(segCount).makeRelative();
// }
// if(projPath != null)
// pi = projPath.append(pi);
// entriesList.add(new CSourceEntry(pi, exlusionPaths, 0));
// }
//
// return (ICSourceEntry[])entriesList.toArray(new ICSourceEntry[entriesList.size()]);
// } // }
for(int k = 0; k < exlusionPaths.length; k++) {
exlusionPaths[k] = exclusions[k].getPath().removeFirstSegments(segCount).makeRelative();
}
if(projPath != null)
pi = projPath.append(pi);
entriesList.add(new CSourceEntry(pi, exlusionPaths, 0));
}
return (ICSourceEntry[])entriesList.toArray(new ICSourceEntry[entriesList.size()]);
}
public ICFolderDescription getParentFolderDescription(){ public ICFolderDescription getParentFolderDescription(){
PathSettingsContainer parent = fPathSettingContainer.getParentContainer(); PathSettingsContainer parent = fPathSettingContainer.getParentContainer();

View file

@ -352,7 +352,7 @@ public class StructureTreeTab extends AbstractCPropertyTab {
create(ti, "getName()", cd.getName()); //$NON-NLS-1$ create(ti, "getName()", cd.getName()); //$NON-NLS-1$
expand(ti, "getResourceDatas()", cd.getResourceDatas()); //$NON-NLS-1$ expand(ti, "getResourceDatas()", cd.getResourceDatas()); //$NON-NLS-1$
update(ti, "getRootFolderData()", cd.getRootFolderData()); //$NON-NLS-1$ update(ti, "getRootFolderData()", cd.getRootFolderData()); //$NON-NLS-1$
expand(ti, "getSourcePaths()", cd.getSourcePaths()); //$NON-NLS-1$ // expand(ti, "getSourcePaths()", cd.getSourcePaths()); //$NON-NLS-1$
update(ti, "getTargetPlatformData()", cd.getTargetPlatformData()); //$NON-NLS-1$ update(ti, "getTargetPlatformData()", cd.getTargetPlatformData()); //$NON-NLS-1$
create(ti,"getType()",cd.getType()); //$NON-NLS-1$ create(ti,"getType()",cd.getType()); //$NON-NLS-1$
create(ti,"isValid()",cd.isValid()); //$NON-NLS-1$ create(ti,"isValid()",cd.isValid()); //$NON-NLS-1$
@ -388,7 +388,7 @@ public class StructureTreeTab extends AbstractCPropertyTab {
create(ti, "getName()", bd.getName()); //$NON-NLS-1$ create(ti, "getName()", bd.getName()); //$NON-NLS-1$
update(ti,"getPath()",bd.getPath()); //$NON-NLS-1$ update(ti,"getPath()",bd.getPath()); //$NON-NLS-1$
create(ti,"getType()",bd.getType()); //$NON-NLS-1$ create(ti,"getType()",bd.getType()); //$NON-NLS-1$
create(ti,"isExcluded()",bd.isExcluded()); //$NON-NLS-1$ // create(ti,"isExcluded()",bd.isExcluded()); //$NON-NLS-1$
create(ti,"isValid()",bd.isValid()); //$NON-NLS-1$ create(ti,"isValid()",bd.isValid()); //$NON-NLS-1$
return ti; return ti;
} }