Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt')
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/activator/Activator.java5
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java12
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java1247
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCBuildOutputParserUtility.java829
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerFileBuildOutputParser.java244
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerProjectBuildOutputParser.java218
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java56
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsRunSIProvider.java12
-rw-r--r--xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/util/XLCCommandDSC.java12
9 files changed, 1294 insertions, 1341 deletions
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/activator/Activator.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/activator/Activator.java
index e76e86f2cde..bf0781bbfee 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/activator/Activator.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/activator/Activator.java
@@ -32,7 +32,7 @@ public class Activator extends Plugin {
*/
public Activator() {
super();
- if(fInstance == null) {
+ if (fInstance == null) {
fInstance = this;
}
}
@@ -47,8 +47,7 @@ public class Activator extends Plugin {
public static void log(String message, Throwable e) {
Throwable nestedException;
- if (e instanceof CModelException
- && (nestedException = ((CModelException)e).getException()) != null) {
+ if (e instanceof CModelException && (nestedException = ((CModelException) e).getException()) != null) {
e = nestedException;
}
log(createStatus(message, e));
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java
index 842604bd3de..e7ef4adde10 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java
@@ -84,8 +84,8 @@ public abstract class AbstractXLCBuildOutputParser implements IScannerInfoConsol
*/
protected String[] computeCompilerCommands() {
if (fProject != null) {
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(
- fProject, ScannerConfigProfileManager.NULL_PROFILE_ID);
+ SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(fProject,
+ ScannerConfigProfileManager.NULL_PROFILE_ID);
BuildOutputProvider boProvider = profileInstance.getProfile().getBuildOutputProviderElement();
if (boProvider != null) {
String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands();
@@ -140,9 +140,9 @@ public abstract class AbstractXLCBuildOutputParser implements IScannerInfoConsol
fSMultiline = ""; //$NON-NLS-1$
}
line = line.trim();
- try{
+ try {
TraceUtil.outputTrace("XLCBuildOutputParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }catch(NoClassDefFoundError e){
+ } catch (NoClassDefFoundError e) {
//no problem, as this may be called from a standalone indexer
}
// make\[[0-9]*\]: error_desc
@@ -202,7 +202,7 @@ public abstract class AbstractXLCBuildOutputParser implements IScannerInfoConsol
getUtility().reportProblems();
}
- if(fCollector != null && fCollector instanceof IScannerInfoCollector2) {
+ if (fCollector != null && fCollector instanceof IScannerInfoCollector2) {
IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
try {
collector.updateScannerConfiguration(null);
@@ -386,7 +386,7 @@ public abstract class AbstractXLCBuildOutputParser implements IScannerInfoConsol
abstract protected boolean processCommand(String[] tokens);
- protected List<String> getFileExtensionsList() {
+ protected List<String> getFileExtensionsList() {
IContentTypeManager manager = Platform.getContentTypeManager();
List<String> extensions = new LinkedList<String>();
IContentType cSource = manager.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE);
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java
index 3774867d42c..5ef88b40059 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/PerFileXLCScannerInfoCollector.java
@@ -98,7 +98,8 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
private boolean fIsDefaultContext;
private List<IResource> fChangedResources;
- public ScannerConfigUpdateJob(InfoContext context, IDiscoveredPathInfo pathInfo, boolean isDefaultContext, List<IResource> changedResources) {
+ public ScannerConfigUpdateJob(InfoContext context, IDiscoveredPathInfo pathInfo, boolean isDefaultContext,
+ List<IResource> changedResources) {
super(Messages.getString("PerFileXLCScannerInfoCollector.0")); //$NON-NLS-1$);
fContext = context;
fPathInfo = pathInfo;
@@ -108,9 +109,9 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
@Override
protected IStatus run(IProgressMonitor monitor) {
- try {
+ try {
- // get the scanner info profile ID
+ // get the scanner info profile ID
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
IConfiguration config = info.getDefaultConfiguration();
@@ -118,25 +119,28 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
String profileID = config.getToolChain().getScannerConfigDiscoveryProfileId();
IDiscoveredPathManager manager = MakeCorePlugin.getDefault().getDiscoveryManager();
- if(manager instanceof DiscoveredPathManager) {
- ((DiscoveredPathManager)manager).updateDiscoveredInfo(fContext, fPathInfo, fIsDefaultContext, fChangedResources, profileID);
+ if (manager instanceof DiscoveredPathManager) {
+ ((DiscoveredPathManager) manager).updateDiscoveredInfo(fContext, fPathInfo, fIsDefaultContext,
+ fChangedResources, profileID);
}
// reload project description to hopefully get the data to take
ICProjectDescriptionManager descriptionManager = CoreModel.getDefault().getProjectDescriptionManager();
- ICProjectDescription cProjectDescription = descriptionManager.getProjectDescription(project, true /* writable */);
+ ICProjectDescription cProjectDescription = descriptionManager.getProjectDescription(project,
+ true /* writable */);
ICConfigurationDescription configDes = cProjectDescription.getActiveConfiguration();
IToolChain toolchain = config.getToolChain();
- for(ITool tool : toolchain.getTools()) {
- for(IInputType inputType : tool.getInputTypes()) {
+ for (ITool tool : toolchain.getTools()) {
+ for (IInputType inputType : tool.getInputTypes()) {
IContentType contentType = inputType.getSourceContentType();
- if(contentType != null) {
- for(IResource resource : fChangedResources) {
+ if (contentType != null) {
+ for (IResource resource : fChangedResources) {
// get language settings for the resource
- ICLanguageSetting langSetting = configDes.getLanguageSettingForFile(resource.getProjectRelativePath(), false);
+ ICLanguageSetting langSetting = configDes
+ .getLanguageSettingForFile(resource.getProjectRelativePath(), false);
- if(langSetting == null) {
+ if (langSetting == null) {
continue;
}
@@ -145,14 +149,14 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
// if the setting doesn't handle our content type ID, then go to the next resource
boolean found = false;
- for(String id : contentTypeIDs) {
- if(id.equals(contentType.getId())) {
+ for (String id : contentTypeIDs) {
+ if (id.equals(contentType.getId())) {
found = true;
break;
}
}
- if(!found) {
+ if (!found) {
continue;
}
@@ -166,23 +170,22 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- descriptionManager.setProjectDescription(project, cProjectDescription, true /* force */, monitor);
+ descriptionManager.setProjectDescription(project, cProjectDescription, true /* force */, monitor);
} catch (CoreException e) {
Activator.log(e);
return Activator.createStatus(Messages.getString("PerFileXLCScannerInfoCollector.1")); //$NON-NLS-1$
}
- return Status.OK_STATUS;
+ return Status.OK_STATUS;
}
private boolean updateMacroSettings(ICLanguageSetting langSetting) {
ICLanguageSettingEntry[] entries = langSetting.getSettingEntries(ICSettingEntry.MACRO);
List<ICLanguageSettingEntry> newEntries = new LinkedList<ICLanguageSettingEntry>();
- for(ICLanguageSettingEntry entry : entries) {
+ for (ICLanguageSettingEntry entry : entries) {
newEntries.add(entry);
}
-
boolean entriesChanged = false;
// look for settings corresponding to each path we discovered
@@ -198,15 +201,16 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
// if we didn't find the path, add it
- if(!symbolFound) {
+ if (!symbolFound) {
entriesChanged = true;
- CMacroEntry newEntry = CDataUtil.createCMacroEntry(symbol, discSymbols.get(symbol), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
+ CMacroEntry newEntry = CDataUtil.createCMacroEntry(symbol, discSymbols.get(symbol),
+ ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
newEntries.add(newEntry);
}
}
// if we changed the entries, then set the new ones
- if(entriesChanged) {
+ if (entriesChanged) {
langSetting.setSettingEntries(ICSettingEntry.MACRO, newEntries.toArray(new ICLanguageSettingEntry[0]));
}
@@ -216,7 +220,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
private boolean updateIncludeSettings(ICLanguageSetting langSetting) {
ICLanguageSettingEntry[] entries = langSetting.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
List<ICLanguageSettingEntry> newEntries = new LinkedList<ICLanguageSettingEntry>();
- for(ICLanguageSettingEntry entry : entries) {
+ for (ICLanguageSettingEntry entry : entries) {
newEntries.add(entry);
}
@@ -235,16 +239,18 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
// if we didn't find the path, add it
- if(!pathFound) {
+ if (!pathFound) {
entriesChanged = true;
- CIncludePathEntry newEntry = CDataUtil.createCIncludePathEntry(path.toString(), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
+ CIncludePathEntry newEntry = CDataUtil.createCIncludePathEntry(path.toString(),
+ ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.RESOLVED);
newEntries.add(newEntry);
}
}
// if we changed the entries, then set the new ones
- if(entriesChanged) {
- langSetting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, newEntries.toArray(new ICLanguageSettingEntry[0]));
+ if (entriesChanged) {
+ langSetting.setSettingEntries(ICSettingEntry.INCLUDE_PATH,
+ newEntries.toArray(new ICLanguageSettingEntry[0]));
}
return entriesChanged;
@@ -261,7 +267,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
private IPerFileDiscoveredPathInfo2 getPerFileInfo1() {
- if(fInfo1 instanceof IPerFileDiscoveredPathInfo2) {
+ if (fInfo1 instanceof IPerFileDiscoveredPathInfo2) {
return (IPerFileDiscoveredPathInfo2) fInfo1;
}
@@ -460,176 +466,176 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
/**
- * Per file DPI object
- *
- * @author vhirsl
- */
- protected class PerFileDiscoveredPathInfo implements IPerFileDiscoveredPathInfo2 {
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludeFiles(org.eclipse.core.runtime.IPath)
- */
- @Override
+ * Per file DPI object
+ *
+ * @author vhirsl
+ */
+ protected class PerFileDiscoveredPathInfo implements IPerFileDiscoveredPathInfo2 {
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludeFiles(org.eclipse.core.runtime.IPath)
+ */
+ @Override
public IPath[] getIncludeFiles(IPath path) {
- synchronized (fLock) {
-
- Set<IPath> pathSet = new LinkedHashSet<IPath>();
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null) {
- IPath[] paths = stringListToPathArray(cmd.getIncludeFile());
- pathSet.addAll(Arrays.asList(paths));
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
-
- for(IPath path2 : psi.includeFiles) {
- pathSet.add(path2);
- }
-
- return pathSet.toArray(new IPath[0]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths()
- */
- @Override
+ synchronized (fLock) {
+
+ Set<IPath> pathSet = new LinkedHashSet<IPath>();
+ // get the command
+ CCommandDSC cmd = getCommand(path);
+ if (cmd != null) {
+ IPath[] paths = stringListToPathArray(cmd.getIncludeFile());
+ pathSet.addAll(Arrays.asList(paths));
+ }
+ // use project scope scanner info
+ if (psi == null) {
+ generateProjectScannerInfo();
+ }
+
+ for (IPath path2 : psi.includeFiles) {
+ pathSet.add(path2);
+ }
+
+ return pathSet.toArray(new IPath[0]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths()
+ */
+ @Override
public IPath[] getIncludePaths() {
- final IPath[] includepaths;
- final IPath[] quotepaths;
- synchronized (fLock) {
-// return new IPath[0];
- includepaths = getAllIncludePaths(INCLUDE_PATH);
- quotepaths = getAllIncludePaths(QUOTE_INCLUDE_PATH);
- }
- if (quotepaths == null || quotepaths.length == 0) {
- return includepaths;
- }
- if (includepaths == null || includepaths.length == 0) {
- return quotepaths;
- }
- ArrayList<IPath> result = new ArrayList<IPath>(includepaths.length + quotepaths.length);
- result.addAll(Arrays.asList(includepaths));
- result.addAll(Arrays.asList(quotepaths));
- return result.toArray(new IPath[result.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath)
- */
- @Override
+ final IPath[] includepaths;
+ final IPath[] quotepaths;
+ synchronized (fLock) {
+ // return new IPath[0];
+ includepaths = getAllIncludePaths(INCLUDE_PATH);
+ quotepaths = getAllIncludePaths(QUOTE_INCLUDE_PATH);
+ }
+ if (quotepaths == null || quotepaths.length == 0) {
+ return includepaths;
+ }
+ if (includepaths == null || includepaths.length == 0) {
+ return quotepaths;
+ }
+ ArrayList<IPath> result = new ArrayList<IPath>(includepaths.length + quotepaths.length);
+ result.addAll(Arrays.asList(includepaths));
+ result.addAll(Arrays.asList(quotepaths));
+ return result.toArray(new IPath[result.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath)
+ */
+ @Override
public IPath[] getIncludePaths(IPath path) {
- synchronized (fLock) {
- Set<IPath> pathSet = new LinkedHashSet<IPath>();
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null) {
- IPath[] paths = stringListToPathArray(cmd.getIncludes());
- pathSet.addAll(Arrays.asList(paths));
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
-
- for(IPath path2 : psi.includePaths) {
- pathSet.add(path2);
- }
-
- return pathSet.toArray(new IPath[0]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getMacroFiles(org.eclipse.core.runtime.IPath)
- */
- @Override
+ synchronized (fLock) {
+ Set<IPath> pathSet = new LinkedHashSet<IPath>();
+ // get the command
+ CCommandDSC cmd = getCommand(path);
+ if (cmd != null) {
+ IPath[] paths = stringListToPathArray(cmd.getIncludes());
+ pathSet.addAll(Arrays.asList(paths));
+ }
+ // use project scope scanner info
+ if (psi == null) {
+ generateProjectScannerInfo();
+ }
+
+ for (IPath path2 : psi.includePaths) {
+ pathSet.add(path2);
+ }
+
+ return pathSet.toArray(new IPath[0]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getMacroFiles(org.eclipse.core.runtime.IPath)
+ */
+ @Override
public IPath[] getMacroFiles(IPath path) {
- synchronized (fLock) {
- Set<IPath> pathSet = new LinkedHashSet<IPath>();
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null) {
- IPath[] paths = stringListToPathArray(cmd.getImacrosFile());
- pathSet.addAll(Arrays.asList(paths));
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
-
- for(IPath path2 : psi.macrosFiles) {
- pathSet.add(path2);
- }
-
- return pathSet.toArray(new IPath[0]);
- }
- }
-
- @Override
+ synchronized (fLock) {
+ Set<IPath> pathSet = new LinkedHashSet<IPath>();
+ // get the command
+ CCommandDSC cmd = getCommand(path);
+ if (cmd != null) {
+ IPath[] paths = stringListToPathArray(cmd.getImacrosFile());
+ pathSet.addAll(Arrays.asList(paths));
+ }
+ // use project scope scanner info
+ if (psi == null) {
+ generateProjectScannerInfo();
+ }
+
+ for (IPath path2 : psi.macrosFiles) {
+ pathSet.add(path2);
+ }
+
+ return pathSet.toArray(new IPath[0]);
+ }
+ }
+
+ @Override
public Map<IResource, PathInfo> getPathInfoMap() {
- synchronized (fLock) {
+ synchronized (fLock) {
//TODO: do we need to cache this?
return calculatePathInfoMap();
- }
+ }
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getProject()
- */
- @Override
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getProject()
+ */
+ @Override
public IProject getProject() {
- return project;
- }
+ return project;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getQuoteIncludePaths(org.eclipse.core.runtime.IPath)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getQuoteIncludePaths(org.eclipse.core.runtime.IPath)
+ */
+ @Override
public IPath[] getQuoteIncludePaths(IPath path) {
- synchronized (fLock) {
- Set<IPath> pathSet = new LinkedHashSet<IPath>();
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null) {
- IPath[] paths = stringListToPathArray(cmd.getQuoteIncludes());
- pathSet.addAll(Arrays.asList(paths));
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
-
- for(IPath path2 : psi.quoteIncludePaths) {
- pathSet.add(path2);
- }
-
- return pathSet.toArray(new IPath[0]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getSerializable()
- */
- @Override
+ synchronized (fLock) {
+ Set<IPath> pathSet = new LinkedHashSet<IPath>();
+ // get the command
+ CCommandDSC cmd = getCommand(path);
+ if (cmd != null) {
+ IPath[] paths = stringListToPathArray(cmd.getQuoteIncludes());
+ pathSet.addAll(Arrays.asList(paths));
+ }
+ // use project scope scanner info
+ if (psi == null) {
+ generateProjectScannerInfo();
+ }
+
+ for (IPath path2 : psi.quoteIncludePaths) {
+ pathSet.add(path2);
+ }
+
+ return pathSet.toArray(new IPath[0]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getSerializable()
+ */
+ @Override
public IDiscoveredScannerInfoSerializable getSerializable() {
- synchronized (fLock) {
- return sid;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols()
- */
- @Override
+ synchronized (fLock) {
+ return sid;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols()
+ */
+ @Override
public Map<String, String> getSymbols() {
-// return new HashMap();
- synchronized (fLock) {
- return getAllSymbols();
- }
- }
+ // return new HashMap();
+ synchronized (fLock) {
+ return getAllSymbols();
+ }
+ }
/*
* (non-Javadoc)
@@ -691,198 +697,195 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- }
+ }
public static class ProjectScannerInfo {
- public Map<String, String> definedSymbols;
- public IPath[] includeFiles;
- public IPath[] includePaths;
- public IPath[] macrosFiles;
- public IPath[] quoteIncludePaths;
+ public Map<String, String> definedSymbols;
+ public IPath[] includeFiles;
+ public IPath[] includePaths;
+ public IPath[] macrosFiles;
+ public IPath[] quoteIncludePaths;
+
public boolean isEmpty() {
- return (includePaths.length == 0 &&
- quoteIncludePaths.length == 0 &&
- includeFiles.length == 0 &&
- macrosFiles.length == 0 &&
- definedSymbols.size() == 0);
+ return (includePaths.length == 0 && quoteIncludePaths.length == 0 && includeFiles.length == 0
+ && macrosFiles.length == 0 && definedSymbols.size() == 0);
}
- }
+ }
public class ScannerInfoData implements IDiscoveredScannerInfoSerializable {
- public static final String DEFINED_SYMBOL = "definedSymbol"; //$NON-NLS-1$
- public static final String ID_ATTR = "id"; //$NON-NLS-1$
- public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$
+ public static final String DEFINED_SYMBOL = "definedSymbol"; //$NON-NLS-1$
+ public static final String ID_ATTR = "id"; //$NON-NLS-1$
+ public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$
- private static final String NAME = "name"; //$NON-NLS-1$
+ private static final String NAME = "name"; //$NON-NLS-1$
- public static final String PATH = "path"; //$NON-NLS-1$
- private static final String PROJECT = "project"; //$NON-NLS-1$
- public static final String REMOVED = "removed"; //$NON-NLS-1$
- public static final String SYMBOL = "symbol"; //$NON-NLS-1$
- public final Map<Integer, CCommandDSC> commandIdCommandMap; // map of all commands
+ public static final String PATH = "path"; //$NON-NLS-1$
+ private static final String PROJECT = "project"; //$NON-NLS-1$
+ public static final String REMOVED = "removed"; //$NON-NLS-1$
+ public static final String SYMBOL = "symbol"; //$NON-NLS-1$
+ public final Map<Integer, CCommandDSC> commandIdCommandMap; // map of all commands
public final Map<Integer, Set<IFile>> commandIdToFilesMap; // command id and set of files it applies to
- public final Map<IFile, Integer> fileToCommandIdMap; // maps each file to the corresponding command id
-
- public ScannerInfoData() {
- commandIdCommandMap = new LinkedHashMap<Integer, CCommandDSC>(); // [commandId, command]
- fileToCommandIdMap = new HashMap<IFile, Integer>(); // [file, commandId]
- commandIdToFilesMap = new HashMap<Integer, Set<IFile>>(); // [commandId, set of files]
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
- */
- @Override
+ public final Map<IFile, Integer> fileToCommandIdMap; // maps each file to the corresponding command id
+
+ public ScannerInfoData() {
+ commandIdCommandMap = new LinkedHashMap<Integer, CCommandDSC>(); // [commandId, command]
+ fileToCommandIdMap = new HashMap<IFile, Integer>(); // [file, commandId]
+ commandIdToFilesMap = new HashMap<Integer, Set<IFile>>(); // [commandId, set of files]
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
+ */
+ @Override
public void deserialize(Element collectorElem) {
- synchronized (fLock) {
+ synchronized (fLock) {
- for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) {
- if(child.getNodeName().equals(PROJECT)) {
- Element projectElement = (Element) child;
- String projectName = projectElement.getAttribute(NAME);
+ for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child.getNodeName().equals(PROJECT)) {
+ Element projectElement = (Element) child;
+ String projectName = projectElement.getAttribute(NAME);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- Map<ScannerInfoTypes, List<String>> scannerInfo = new HashMap<ScannerInfoTypes, List<String>>();
+ Map<ScannerInfoTypes, List<String>> scannerInfo = new HashMap<ScannerInfoTypes, List<String>>();
- List<String> includes = new LinkedList<String>();
- List<String> symbols = new LinkedList<String>();
+ List<String> includes = new LinkedList<String>();
+ List<String> symbols = new LinkedList<String>();
- // iterate over children
- for(Node projectChild = projectElement.getFirstChild(); projectChild != null; projectChild = projectChild.getNextSibling()) {
- if(projectChild.getNodeName().equals(INCLUDE_PATH)) {
- Element childElem = (Element) projectChild;
- String path = childElem.getAttribute(PATH);
- if(path != null) {
+ // iterate over children
+ for (Node projectChild = projectElement
+ .getFirstChild(); projectChild != null; projectChild = projectChild.getNextSibling()) {
+ if (projectChild.getNodeName().equals(INCLUDE_PATH)) {
+ Element childElem = (Element) projectChild;
+ String path = childElem.getAttribute(PATH);
+ if (path != null) {
includes.add(path);
}
- }
- else if(projectChild.getNodeName().equals(DEFINED_SYMBOL)) {
- Element childElem = (Element) projectChild;
- String symbol = childElem.getAttribute(SYMBOL);
+ } else if (projectChild.getNodeName().equals(DEFINED_SYMBOL)) {
+ Element childElem = (Element) projectChild;
+ String symbol = childElem.getAttribute(SYMBOL);
- if(symbol != null) {
+ if (symbol != null) {
symbols.add(symbol);
}
- }
- }
-
- // add loaded scanner info to project settings for this collector
- scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes);
- scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
- fProjectSettingsMap.put(project, scannerInfo);
- }
-
-
- else if (child.getNodeName().equals(CC_ELEM)) {
- Element cmdElem = (Element) child;
- boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++"); //$NON-NLS-1$
- XLCCommandDSC command = new XLCCommandDSC(cppFileType, project);
- command.setCommandId(Integer.parseInt(cmdElem.getAttribute(ID_ATTR)));
- // deserialize command
- command.deserialize(cmdElem);
- // get set of files the command applies to
- NodeList appliesList = cmdElem.getElementsByTagName(APPLIES_TO_ATTR);
- if (appliesList.getLength() > 0) {
- Element appliesElem = (Element) appliesList.item(0);
- NodeList fileList = appliesElem.getElementsByTagName(FILE_ELEM);
- for (int i = 0; i < fileList.getLength(); ++i) {
- Element fileElem = (Element) fileList.item(i);
- String fileName = fileElem.getAttribute(PATH_ATTR);
- IFile file = project.getFile(fileName);
- addCompilerCommand(file, command);
- }
+ }
+ }
+
+ // add loaded scanner info to project settings for this collector
+ scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes);
+ scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
+ fProjectSettingsMap.put(project, scannerInfo);
+ }
+
+ else if (child.getNodeName().equals(CC_ELEM)) {
+ Element cmdElem = (Element) child;
+ boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++"); //$NON-NLS-1$
+ XLCCommandDSC command = new XLCCommandDSC(cppFileType, project);
+ command.setCommandId(Integer.parseInt(cmdElem.getAttribute(ID_ATTR)));
+ // deserialize command
+ command.deserialize(cmdElem);
+ // get set of files the command applies to
+ NodeList appliesList = cmdElem.getElementsByTagName(APPLIES_TO_ATTR);
+ if (appliesList.getLength() > 0) {
+ Element appliesElem = (Element) appliesList.item(0);
+ NodeList fileList = appliesElem.getElementsByTagName(FILE_ELEM);
+ for (int i = 0; i < fileList.getLength(); ++i) {
+ Element fileElem = (Element) fileList.item(i);
+ String fileName = fileElem.getAttribute(PATH_ATTR);
+ IFile file = project.getFile(fileName);
+ addCompilerCommand(file, command);
+ }
applyFileDeltas();
- }
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#getCollectorId()
- */
- @Override
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#getCollectorId()
+ */
+ @Override
public String getCollectorId() {
- return COLLECTOR_ID;
- }
+ return COLLECTOR_ID;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element)
+ */
+ @Override
public void serialize(Element collectorElem) {
- try {
- synchronized (fLock) {
- Document doc = collectorElem.getOwnerDocument();
-
- // serialize project level info
- for (IProject project : fProjectSettingsMap.keySet()) {
- // create a project node
- Element projectElement = doc.createElement(PROJECT);
- projectElement.setAttribute(NAME, project.getName());
-
- Map<ScannerInfoTypes, List<String>> scannerInfo = (Map<ScannerInfoTypes, List<String>>) fProjectSettingsMap.get(project);
-
- List<String> includes = scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
- for(String include : includes) {
- Element pathElement = doc.createElement(INCLUDE_PATH);
- pathElement.setAttribute(PATH, include);
- //Boolean removed = (Boolean) includes.contains(include);
- //if (removed != null && removed.booleanValue() == true) {
- // pathElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
- //}
- pathElement.setAttribute(REMOVED, "false"); //$NON-NLS-1$
- projectElement.appendChild(pathElement);
- }
+ try {
+ synchronized (fLock) {
+ Document doc = collectorElem.getOwnerDocument();
+
+ // serialize project level info
+ for (IProject project : fProjectSettingsMap.keySet()) {
+ // create a project node
+ Element projectElement = doc.createElement(PROJECT);
+ projectElement.setAttribute(NAME, project.getName());
+
+ Map<ScannerInfoTypes, List<String>> scannerInfo = (Map<ScannerInfoTypes, List<String>>) fProjectSettingsMap
+ .get(project);
+
+ List<String> includes = scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
+ for (String include : includes) {
+ Element pathElement = doc.createElement(INCLUDE_PATH);
+ pathElement.setAttribute(PATH, include);
+ //Boolean removed = (Boolean) includes.contains(include);
+ //if (removed != null && removed.booleanValue() == true) {
+ // pathElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
+ //}
+ pathElement.setAttribute(REMOVED, "false"); //$NON-NLS-1$
+ projectElement.appendChild(pathElement);
+ }
- // Now do the same for the symbols
- List<String> symbols = scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
+ // Now do the same for the symbols
+ List<String> symbols = scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
- for(String symbol : symbols) {
+ for (String symbol : symbols) {
Element symbolElement = doc.createElement(DEFINED_SYMBOL);
symbolElement.setAttribute(SYMBOL, symbol);
projectElement.appendChild(symbolElement);
+ }
+ collectorElem.appendChild(projectElement);
+ }
+
+ // serialize file level info
+ List<Integer> commandIds = new ArrayList<Integer>(commandIdCommandMap.keySet());
+ Collections.sort(commandIds);
+ for (Iterator<Integer> i = commandIds.iterator(); i.hasNext();) {
+ Integer commandId = i.next();
+ CCommandDSC command = commandIdCommandMap.get(commandId);
+
+ Element cmdElem = doc.createElement(CC_ELEM);
+ collectorElem.appendChild(cmdElem);
+ cmdElem.setAttribute(ID_ATTR, commandId.toString());
+ cmdElem.setAttribute(FILE_TYPE_ATTR, command.appliesToCPPFileType() ? "c++" : "c"); //$NON-NLS-1$ //$NON-NLS-2$
+ // write command and scanner info
+ command.serialize(cmdElem);
+ // write files command applies to
+ Element filesElem = doc.createElement(APPLIES_TO_ATTR);
+ cmdElem.appendChild(filesElem);
+ Set<IFile> files = commandIdToFilesMap.get(commandId);
+ if (files != null) {
+ for (Iterator<IFile> j = files.iterator(); j.hasNext();) {
+ Element fileElem = doc.createElement(FILE_ELEM);
+ IFile file = j.next();
+ IPath path = file.getProjectRelativePath();
+ fileElem.setAttribute(PATH_ATTR, path.toString());
+ filesElem.appendChild(fileElem);
+ }
+ }
}
- collectorElem.appendChild(projectElement);
}
- // serialize file level info
- List<Integer> commandIds = new ArrayList<Integer>(commandIdCommandMap.keySet());
- Collections.sort(commandIds);
- for (Iterator<Integer> i = commandIds.iterator(); i.hasNext(); ) {
- Integer commandId = i.next();
- CCommandDSC command = commandIdCommandMap.get(commandId);
-
- Element cmdElem = doc.createElement(CC_ELEM);
- collectorElem.appendChild(cmdElem);
- cmdElem.setAttribute(ID_ATTR, commandId.toString());
- cmdElem.setAttribute(FILE_TYPE_ATTR, command.appliesToCPPFileType() ? "c++" : "c"); //$NON-NLS-1$ //$NON-NLS-2$
- // write command and scanner info
- command.serialize(cmdElem);
- // write files command applies to
- Element filesElem = doc.createElement(APPLIES_TO_ATTR);
- cmdElem.appendChild(filesElem);
- Set<IFile> files = commandIdToFilesMap.get(commandId);
- if (files != null) {
- for (Iterator<IFile> j = files.iterator(); j.hasNext(); ) {
- Element fileElem = doc.createElement(FILE_ELEM);
- IFile file = j.next();
- IPath path = file.getProjectRelativePath();
- fileElem.setAttribute(PATH_ATTR, path.toString());
- filesElem.appendChild(fileElem);
- }
- }
- }
- }
-
- }
- catch(Throwable e) {
- e.printStackTrace();
- }
- }
-
- }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
protected static final String APPLIES_TO_ATTR = "appliesToFiles"; //$NON-NLS-1$
@@ -896,34 +899,33 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
protected static final String ID_ATTR = "id"; //$NON-NLS-1$
- protected static final int INCLUDE_FILE = 3;
+ protected static final int INCLUDE_FILE = 3;
- protected static final int INCLUDE_PATH = 1;
+ protected static final int INCLUDE_PATH = 1;
-
-
- protected static final int MACROS_FILE = 4;
+ protected static final int MACROS_FILE = 4;
protected static final String PATH_ATTR = "path"; //$NON-NLS-1$
protected static final int QUOTE_INCLUDE_PATH = 2;
- protected static PathInfo createFilePathInfo(CCommandDSC cmd){
- IPath[] includes = stringListToPathArray(cmd.getIncludes());
- IPath[] quotedIncludes = stringListToPathArray(cmd.getQuoteIncludes());
- IPath[] incFiles = stringListToPathArray(cmd.getIncludeFile());
- IPath[] macroFiles = stringListToPathArray(cmd.getImacrosFile());
- List symbols = cmd.getSymbols();
- Map<String, String> definedSymbols = new HashMap<String, String>(symbols.size());
- for (Iterator i = symbols.iterator(); i.hasNext(); ) {
- String symbol = (String) i.next();
- String key = ScannerConfigUtil.getSymbolKey(symbol);
- String value = ScannerConfigUtil.getSymbolValue(symbol);
- definedSymbols.put(key, value);
- }
-
- return new PathInfo(includes, quotedIncludes, definedSymbols, incFiles, macroFiles);
- }
+ protected static PathInfo createFilePathInfo(CCommandDSC cmd) {
+ IPath[] includes = stringListToPathArray(cmd.getIncludes());
+ IPath[] quotedIncludes = stringListToPathArray(cmd.getQuoteIncludes());
+ IPath[] incFiles = stringListToPathArray(cmd.getIncludeFile());
+ IPath[] macroFiles = stringListToPathArray(cmd.getImacrosFile());
+ List symbols = cmd.getSymbols();
+ Map<String, String> definedSymbols = new HashMap<String, String>(symbols.size());
+ for (Iterator i = symbols.iterator(); i.hasNext();) {
+ String symbol = (String) i.next();
+ String key = ScannerConfigUtil.getSymbolKey(symbol);
+ String value = ScannerConfigUtil.getSymbolValue(symbol);
+ definedSymbols.put(key, value);
+ }
+
+ return new PathInfo(includes, quotedIncludes, definedSymbols, incFiles, macroFiles);
+ }
+
/**
* @param discovered
* @param allIncludes
@@ -931,48 +933,49 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
*/
protected static IPath[] stringListToPathArray(List<String> discovered) {
List<Path> allIncludes = new ArrayList<Path>(discovered.size());
- for (Iterator<String> j = discovered.iterator(); j.hasNext(); ) {
- String include = j.next();
- if (!allIncludes.contains(include)) {
- allIncludes.add(new Path(include));
- }
+ for (Iterator<String> j = discovered.iterator(); j.hasNext();) {
+ String include = j.next();
+ if (!allIncludes.contains(include)) {
+ allIncludes.add(new Path(include));
+ }
}
return allIncludes.toArray(new IPath[allIncludes.size()]);
}
+
protected int commandIdCounter = 0;
protected InfoContext context;
- /** monitor for data access */
- protected final Object fLock = new Object();
+ /** monitor for data access */
+ protected final Object fLock = new Object();
- private Map<IProject, Map<?, ?>> fProjectSettingsMap = new HashMap<IProject, Map<?, ?>>();
+ private Map<IProject, Map<?, ?>> fProjectSettingsMap = new HashMap<IProject, Map<?, ?>>();
- protected final SortedSet<Integer> freeCommandIdPool; // sorted set of free command ids
+ protected final SortedSet<Integer> freeCommandIdPool; // sorted set of free command ids
protected IProject project;
- protected ProjectScannerInfo psi = null; // sum of all scanner info
- protected final List<Integer> siChangedForCommandIdList; // list of command ids for which scanner info has changed
+ protected ProjectScannerInfo psi = null; // sum of all scanner info
+ protected final List<Integer> siChangedForCommandIdList; // list of command ids for which scanner info has changed
// protected List siChangedForFileList; // list of files for which scanner info has changed
- protected final Map<IResource, Integer> siChangedForFileMap; // (file, comandId) map for deltas
+ protected final Map<IResource, Integer> siChangedForFileMap; // (file, comandId) map for deltas
protected ScannerInfoData sid; // scanner info data
/**
- *
- */
- public PerFileXLCScannerInfoCollector() {
- sid = new ScannerInfoData();
+ *
+ */
+ public PerFileXLCScannerInfoCollector() {
+ sid = new ScannerInfoData();
-// siChangedForFileList = new ArrayList();
+ // siChangedForFileList = new ArrayList();
siChangedForFileMap = new HashMap<IResource, Integer>();
siChangedForCommandIdList = new ArrayList<Integer>();
- freeCommandIdPool = new TreeSet<Integer>();
- }
+ freeCommandIdPool = new TreeSet<Integer>();
+ }
- /**
- * @param file
- * @param object
- */
- protected void addCompilerCommand(IFile file, CCommandDSC cmd) {
+ /**
+ * @param file
+ * @param object
+ */
+ protected void addCompilerCommand(IFile file, CCommandDSC cmd) {
synchronized (fLock) {
List<CCommandDSC> existingCommands = new ArrayList<CCommandDSC>(sid.commandIdCommandMap.values());
int index = existingCommands.indexOf(cmd);
@@ -995,11 +998,11 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /**
- * @param commandId
- * @param scannerInfo
- */
- protected void addScannerInfo(Integer commandId, Map scannerInfo) {
+ /**
+ * @param commandId
+ * @param scannerInfo
+ */
+ protected void addScannerInfo(Integer commandId, Map scannerInfo) {
synchronized (fLock) {
CCommandDSC cmd = sid.commandIdCommandMap.get(commandId);
if (cmd != null) {
@@ -1019,15 +1022,16 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /**
- * @param type
- * @param object
- */
- protected void addScannerInfo(ScannerInfoTypes type, List delta) {
- // TODO Auto-generated method stub
+ /**
+ * @param type
+ * @param object
+ */
+ protected void addScannerInfo(ScannerInfoTypes type, List delta) {
+ // TODO Auto-generated method stub
+
+ }
- }
- /**
+ /**
* @param file
* @param cmd
*/
@@ -1077,7 +1081,6 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
-
protected Map<IResource, PathInfo> calculatePathInfoMap() {
synchronized (fLock) {
Map<IResource, PathInfo> map = new HashMap<IResource, PathInfo>(sid.fileToCommandIdMap.size() + 1);
@@ -1113,19 +1116,18 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
@Override
public void contributeToScannerConfig(Object resource, Map scannerInfo) {
- // check the resource
- String errorMessage = null;
- if (resource == null) {
- errorMessage = "resource is null";//$NON-NLS-1$
- }
- else if (resource instanceof Integer) {
- synchronized (fLock) {
- addScannerInfo(((Integer)resource), scannerInfo);
+ // check the resource
+ String errorMessage = null;
+ if (resource == null) {
+ errorMessage = "resource is null";//$NON-NLS-1$
+ } else if (resource instanceof Integer) {
+ synchronized (fLock) {
+ addScannerInfo(((Integer) resource), scannerInfo);
}
- return;
- }
+ return;
+ }
- if ((resource instanceof IFile)) {
+ if ((resource instanceof IFile)) {
if (((IFile) resource).getProject() == null) {
errorMessage = "project is null";//$NON-NLS-1$
@@ -1154,27 +1156,28 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- else if(resource instanceof IProject) {
- // save to project level settings
- synchronized (fLock) {
- fProjectSettingsMap.put(((IProject) resource), scannerInfo);
- }
- }
+ else if (resource instanceof IProject) {
+ // save to project level settings
+ synchronized (fLock) {
+ fProjectSettingsMap.put(((IProject) resource), scannerInfo);
+ }
+ }
- else { // error
- TraceUtil.outputError("PerFileSICollector.contributeToScannerConfig : ", "Not a project or file."); //$NON-NLS-1$ //$NON-NLS-2$
+ else { // error
+ TraceUtil.outputError("PerFileSICollector.contributeToScannerConfig : ", "Not a project or file."); //$NON-NLS-1$ //$NON-NLS-2$
return;
- }
- }
+ }
+ }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject()
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject()
+ */
+ @Override
public IDiscoveredPathInfo createPathInfoObject() {
- return new PerFileDiscoveredPathInfo();
- }
- /* (non-Javadoc)
+ return new PerFileDiscoveredPathInfo();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.PerFileSICollector#deleteAll(org.eclipse.core.resources.IResource)
*/
public void deleteAll(IResource resource) {
@@ -1185,32 +1188,32 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource)
- */
- public void deleteAll1(IResource resource) {
- if (resource.equals(project)) {
- synchronized (fLock) {
-// siChangedForFileList = new ArrayList();
- siChangedForFileMap.clear();
- Set<IFile> changedFiles = sid.fileToCommandIdMap.keySet();
- for (Iterator<IFile> i = changedFiles.iterator(); i.hasNext(); ) {
- IFile file = i.next();
-// IPath path = file.getFullPath();
-// siChangedForFileList.add(path);
- siChangedForFileMap.put(file, null);
- }
-
- sid = new ScannerInfoData();
- psi = null;
-
- commandIdCounter = 0;
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource)
+ */
+ public void deleteAll1(IResource resource) {
+ if (resource.equals(project)) {
+ synchronized (fLock) {
+ // siChangedForFileList = new ArrayList();
+ siChangedForFileMap.clear();
+ Set<IFile> changedFiles = sid.fileToCommandIdMap.keySet();
+ for (Iterator<IFile> i = changedFiles.iterator(); i.hasNext();) {
+ IFile file = i.next();
+ // IPath path = file.getFullPath();
+ // siChangedForFileList.add(path);
+ siChangedForFileMap.put(file, null);
+ }
+
+ sid = new ScannerInfoData();
+ psi = null;
+
+ commandIdCounter = 0;
freeCommandIdPool.clear();
- }
- }
- }
+ }
+ }
+ }
- /*
+ /*
* (non-Javadoc)
*
* @see
@@ -1225,7 +1228,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /*
+ /*
* (non-Javadoc)
*
* @see
@@ -1240,7 +1243,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /*
+ /*
* (non-Javadoc)
*
* @see
@@ -1270,7 +1273,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /**
+ /**
* @param file
* @param cmd
*/
@@ -1289,7 +1292,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- protected void generateProjectScannerInfo() {
+ protected void generateProjectScannerInfo() {
synchronized (fLock) {
psi = new ProjectScannerInfo();
psi.includePaths = getAllIncludePaths(INCLUDE_PATH);
@@ -1300,7 +1303,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /* (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.PerFileSICollector#getAllIncludePaths(int)
*/
protected IPath[] getAllIncludePaths(int type) {
@@ -1333,15 +1336,15 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
/**
- * @param type can be one of the following:
- * <li><code>INCLUDE_PATH</code>
- * <li><code>QUOTE_INCLUDE_PATH</code>
- * <li><code>INCLUDE_FILE</code>
- * <li><code>MACROS_FILE</code>
- *
- * @return list of IPath(s).
- */
- protected IPath[] getAllIncludePaths1(int type) {
+ * @param type can be one of the following:
+ * <li><code>INCLUDE_PATH</code>
+ * <li><code>QUOTE_INCLUDE_PATH</code>
+ * <li><code>INCLUDE_FILE</code>
+ * <li><code>MACROS_FILE</code>
+ *
+ * @return list of IPath(s).
+ */
+ protected IPath[] getAllIncludePaths1(int type) {
synchronized (fLock) {
List<String> allIncludes = new ArrayList<String>();
for (Iterator<Integer> i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext();) {
@@ -1404,7 +1407,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
for (String symbol : projectSymbols) {
if (symbol.matches("_Builtin")) //$NON-NLS-1$
- symbols.put(symbol,""); //$NON-NLS-1$
+ symbols.put(symbol, ""); //$NON-NLS-1$
else
symbols.put(symbol, "1"); //$NON-NLS-1$
}
@@ -1419,10 +1422,10 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /**
- * @return
- */
- protected Map<String, String> getAllSymbols1() {
+ /**
+ * @return
+ */
+ protected Map<String, String> getAllSymbols1() {
synchronized (fLock) {
Map<String, String> symbols = new HashMap<String, String>();
for (Iterator<Integer> i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext();) {
@@ -1442,75 +1445,71 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
- */
- @Override
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
+ */
+ @Override
public List<CCommandDSC> getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
- List<CCommandDSC> rv = new ArrayList<CCommandDSC>();
- // check the resource
- String errorMessage = null;
- if (resource == null) {
- errorMessage = "resource is null";//$NON-NLS-1$
- }
- else if (!(resource instanceof IResource)) {
- errorMessage = "resource is not an IResource";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() == null) {
- errorMessage = "project is null";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() != project) {
- errorMessage = "wrong project";//$NON-NLS-1$
- }
-
- if (errorMessage != null) {
- TraceUtil.outputError("PerProjectSICollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$
- return rv;
- }
- if (project.equals(((IResource)resource).getProject())) {
- if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) {
- synchronized (fLock) {
- for (Iterator<Integer> i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext(); ) {
- Integer cmdId = i.next();
- Set<IFile> fileSet = sid.commandIdToFilesMap.get(cmdId);
- if (fileSet != null && !fileSet.isEmpty()) {
- rv.add(sid.commandIdCommandMap.get(cmdId));
- }
- }
- }
- }
- else if (type.equals(ScannerInfoTypes.UNDISCOVERED_COMPILER_COMMAND)) {
-// if (!siChangedForFileList.isEmpty()) {
- synchronized (fLock) {
- if (scannerInfoChanged()) {
- if (siChangedForCommandIdList.isEmpty()) {
-// for (Iterator i = siChangedForFileList.iterator(); i.hasNext(); ) {
- for (Iterator<IResource> i = siChangedForFileMap.keySet().iterator(); i.hasNext(); ) {
-// IPath path = (IPath) i.next();
- IFile file = (IFile) i.next();
- Integer cmdId = siChangedForFileMap.get(file);
- if (cmdId != null) {
- if (!siChangedForCommandIdList.contains(cmdId)) {
- siChangedForCommandIdList.add(cmdId);
- }
- }
- }
- }
- Collections.sort(siChangedForCommandIdList);
- for (Iterator<Integer> i = siChangedForCommandIdList.iterator(); i.hasNext(); ) {
- Integer cmdId = i.next();
- CCommandDSC command = sid.commandIdCommandMap.get(cmdId);
- rv.add(command);
- }
- }
- }
- }
- }
- return rv;
- }
-
- protected CCommandDSC getCommand(IFile file) {
+ List<CCommandDSC> rv = new ArrayList<CCommandDSC>();
+ // check the resource
+ String errorMessage = null;
+ if (resource == null) {
+ errorMessage = "resource is null";//$NON-NLS-1$
+ } else if (!(resource instanceof IResource)) {
+ errorMessage = "resource is not an IResource";//$NON-NLS-1$
+ } else if (((IResource) resource).getProject() == null) {
+ errorMessage = "project is null";//$NON-NLS-1$
+ } else if (((IResource) resource).getProject() != project) {
+ errorMessage = "wrong project";//$NON-NLS-1$
+ }
+
+ if (errorMessage != null) {
+ TraceUtil.outputError("PerProjectSICollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$
+ return rv;
+ }
+ if (project.equals(((IResource) resource).getProject())) {
+ if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) {
+ synchronized (fLock) {
+ for (Iterator<Integer> i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext();) {
+ Integer cmdId = i.next();
+ Set<IFile> fileSet = sid.commandIdToFilesMap.get(cmdId);
+ if (fileSet != null && !fileSet.isEmpty()) {
+ rv.add(sid.commandIdCommandMap.get(cmdId));
+ }
+ }
+ }
+ } else if (type.equals(ScannerInfoTypes.UNDISCOVERED_COMPILER_COMMAND)) {
+ // if (!siChangedForFileList.isEmpty()) {
+ synchronized (fLock) {
+ if (scannerInfoChanged()) {
+ if (siChangedForCommandIdList.isEmpty()) {
+ // for (Iterator i = siChangedForFileList.iterator(); i.hasNext(); ) {
+ for (Iterator<IResource> i = siChangedForFileMap.keySet().iterator(); i.hasNext();) {
+ // IPath path = (IPath) i.next();
+ IFile file = (IFile) i.next();
+ Integer cmdId = siChangedForFileMap.get(file);
+ if (cmdId != null) {
+ if (!siChangedForCommandIdList.contains(cmdId)) {
+ siChangedForCommandIdList.add(cmdId);
+ }
+ }
+ }
+ }
+ Collections.sort(siChangedForCommandIdList);
+ for (Iterator<Integer> i = siChangedForCommandIdList.iterator(); i.hasNext();) {
+ Integer cmdId = i.next();
+ CCommandDSC command = sid.commandIdCommandMap.get(cmdId);
+ rv.add(command);
+ }
+ }
+ }
+ }
+ }
+ return rv;
+ }
+
+ protected CCommandDSC getCommand(IFile file) {
synchronized (fLock) {
CCommandDSC cmd = null;
if (file != null) {
@@ -1524,11 +1523,11 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /**
- * @param path
- * @return
- */
- protected CCommandDSC getCommand(IPath path) {
+ /**
+ * @param path
+ * @return
+ */
+ protected CCommandDSC getCommand(IPath path) {
synchronized (fLock) {
try {
IFile file = project.getWorkspace().getRoot().getFile(path);
@@ -1539,7 +1538,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /* (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector#getDefinedSymbols()
*/
@Override
@@ -1549,7 +1548,7 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- /* (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector#getIncludePaths()
*/
@Override
@@ -1568,11 +1567,11 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- protected InfoContext getInfoContext() {
+ protected InfoContext getInfoContext() {
return context;
}
- protected void removeUnusedCommands() {
+ protected void removeUnusedCommands() {
synchronized (fLock) {
for (Iterator i = sid.commandIdToFilesMap.entrySet().iterator(); i.hasNext();) {
Entry entry = (Entry) i.next();
@@ -1600,13 +1599,13 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
}
- protected boolean scannerInfoChanged() {
- synchronized (fLock) {
- return (!fProjectSettingsMap.isEmpty()) || !siChangedForFileMap.isEmpty();
- }
+ protected boolean scannerInfoChanged() {
+ synchronized (fLock) {
+ return (!fProjectSettingsMap.isEmpty()) || !siChangedForFileMap.isEmpty();
+ }
}
- @Override
+ @Override
public void setInfoContext(InfoContext context) {
synchronized (fLock) {
this.project = context.getProject();
@@ -1622,83 +1621,79 @@ public class PerFileXLCScannerInfoCollector implements IScannerInfoCollector3, I
}
/* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#setProject(org.eclipse.core.resources.IProject)
- */
- @Override
+ * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#setProject(org.eclipse.core.resources.IProject)
+ */
+ @Override
public void setProject(IProject project) {
- synchronized (fLock) {
+ synchronized (fLock) {
setInfoContext(new InfoContext(project));
}
- }
+ }
- @Override
+ @Override
public void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(Messages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
- monitor.subTask(Messages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
- ArrayList<IResource> changedResources = new ArrayList<IResource>();
- synchronized (fLock) {
- if (scannerInfoChanged()) {
- applyFileDeltas();
- removeUnusedCommands();
- changedResources.addAll(siChangedForFileMap.keySet());
- siChangedForFileMap.clear();
- }
- siChangedForCommandIdList.clear();
-
- // add in any projects that got project level info (from the specs provider)
- changedResources.addAll(fProjectSettingsMap.keySet());
-
- monitor.worked(50);
- if (!changedResources.isEmpty()) {
- // update outside monitor scope
- try {
- // update scanner configuration
- monitor.subTask(Messages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
- IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context);
- //IDiscoveredPathInfo pathInfo = new PerFileDiscoveredPathInfo();
- if (!(pathInfo instanceof IPerFileDiscoveredPathInfo)) {
- pathInfo = createPathInfoObject();
- }
- else {
- PerFileDiscoveredPathInfo perFilePathInfo = new PerFileDiscoveredPathInfo();
-
- // merge them
- if (!(pathInfo instanceof IPerFileDiscoveredPathInfo)) {
- pathInfo = new MergedPerFileDiscoveredPathInfo(pathInfo, perFilePathInfo);
- }
- else {
- pathInfo = perFilePathInfo;
- }
- }
-
-
- Job job = new ScannerConfigUpdateJob(context, pathInfo, context.isDefaultContext(), changedResources);
- ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
- job.setRule(rule);
- job.schedule();
-
-
-
-// } finally {
-// manager.endRule(rule);
-// }
-
- } catch (CoreException e) {
- MakeCorePlugin.log(e);
- }
-
- catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
-
-
- monitor.worked(50);
- monitor.done();
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(Messages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
+ monitor.subTask(Messages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
+ ArrayList<IResource> changedResources = new ArrayList<IResource>();
+ synchronized (fLock) {
+ if (scannerInfoChanged()) {
+ applyFileDeltas();
+ removeUnusedCommands();
+ changedResources.addAll(siChangedForFileMap.keySet());
+ siChangedForFileMap.clear();
+ }
+ siChangedForCommandIdList.clear();
+
+ // add in any projects that got project level info (from the specs provider)
+ changedResources.addAll(fProjectSettingsMap.keySet());
+
+ monitor.worked(50);
+ if (!changedResources.isEmpty()) {
+ // update outside monitor scope
+ try {
+ // update scanner configuration
+ monitor.subTask(Messages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
+ IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager()
+ .getDiscoveredInfo(project, context);
+ //IDiscoveredPathInfo pathInfo = new PerFileDiscoveredPathInfo();
+ if (!(pathInfo instanceof IPerFileDiscoveredPathInfo)) {
+ pathInfo = createPathInfoObject();
+ } else {
+ PerFileDiscoveredPathInfo perFilePathInfo = new PerFileDiscoveredPathInfo();
+
+ // merge them
+ if (!(pathInfo instanceof IPerFileDiscoveredPathInfo)) {
+ pathInfo = new MergedPerFileDiscoveredPathInfo(pathInfo, perFilePathInfo);
+ } else {
+ pathInfo = perFilePathInfo;
+ }
+ }
+
+ Job job = new ScannerConfigUpdateJob(context, pathInfo, context.isDefaultContext(),
+ changedResources);
+ ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
+ job.setRule(rule);
+ job.schedule();
+
+ // } finally {
+ // manager.endRule(rule);
+ // }
+
+ } catch (CoreException e) {
+ MakeCorePlugin.log(e);
+ }
+
+ catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ monitor.worked(50);
+ monitor.done();
}
} \ No newline at end of file
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCBuildOutputParserUtility.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCBuildOutputParserUtility.java
index 4fc81495911..6e7e3048fe1 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCBuildOutputParserUtility.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCBuildOutputParserUtility.java
@@ -47,49 +47,51 @@ import org.eclipse.core.runtime.Path;
*
*/
public class XLCBuildOutputParserUtility {
- protected class Problem {
- protected String description;
- protected IResource file;
- protected int lineNumber;
- protected int severity;
- protected String variableName;
-
- public Problem(IResource file, int lineNumber, String desciption, int severity, String variableName) {
- this.file = file;
- this.lineNumber = lineNumber;
- this.description = desciption;
- this.severity = severity;
- this.variableName = variableName;
- }
- }
- public static IPath convertCygpath(IPath path) {
- if (path.segmentCount() > 1 && path.segment(0).equals("cygdrive")) { //$NON-NLS-1$
- StringBuilder buf = new StringBuilder(2);
- buf.append(Character.toUpperCase(path.segment(1).charAt(0)));
- buf.append(':');
- path = path.removeFirstSegments(2);
- path = path.setDevice(buf.toString());
- path = path.makeAbsolute();
- }
- return path;
- }
- private List commandsList2;
- private int commandsN = 0;
- private List compiledFileList;
-
- private Map directoryCommandListMap;
-
- private IPath fBaseDirectory;
- private String fDefaultMacroDefinitionValue= "1"; //$NON-NLS-1$
- private Vector<IPath> fDirectoryStack;
- private ArrayList<Problem> fErrors;
- private int filesN = 0;
-
- private IMarkerGenerator fMarkerGenerator;
-
- private IProject project;
-
- private int workingDirsN = 0;
+ protected class Problem {
+ protected String description;
+ protected IResource file;
+ protected int lineNumber;
+ protected int severity;
+ protected String variableName;
+
+ public Problem(IResource file, int lineNumber, String desciption, int severity, String variableName) {
+ this.file = file;
+ this.lineNumber = lineNumber;
+ this.description = desciption;
+ this.severity = severity;
+ this.variableName = variableName;
+ }
+ }
+
+ public static IPath convertCygpath(IPath path) {
+ if (path.segmentCount() > 1 && path.segment(0).equals("cygdrive")) { //$NON-NLS-1$
+ StringBuilder buf = new StringBuilder(2);
+ buf.append(Character.toUpperCase(path.segment(1).charAt(0)));
+ buf.append(':');
+ path = path.removeFirstSegments(2);
+ path = path.setDevice(buf.toString());
+ path = path.makeAbsolute();
+ }
+ return path;
+ }
+
+ private List commandsList2;
+ private int commandsN = 0;
+ private List compiledFileList;
+
+ private Map directoryCommandListMap;
+
+ private IPath fBaseDirectory;
+ private String fDefaultMacroDefinitionValue = "1"; //$NON-NLS-1$
+ private Vector<IPath> fDirectoryStack;
+ private ArrayList<Problem> fErrors;
+ private int filesN = 0;
+
+ private IMarkerGenerator fMarkerGenerator;
+
+ private IProject project;
+
+ private int workingDirsN = 0;
/*
* For tracking the location of files being compiled
@@ -98,28 +100,28 @@ public class XLCBuildOutputParserUtility {
private List<String> fCollectedFiles;
private List<String> fNameConflicts;
- protected XLCBuildOutputParserUtility(IPath baseDirectory, IPath workingDirectory){
+ protected XLCBuildOutputParserUtility(IPath baseDirectory, IPath workingDirectory) {
fDirectoryStack = new Vector<IPath>();
- fErrors = new ArrayList<Problem>();
- this.fBaseDirectory = baseDirectory;
- if (workingDirectory != null) {
- pushDirectory(workingDirectory);
- }
+ fErrors = new ArrayList<Problem>();
+ this.fBaseDirectory = baseDirectory;
+ if (workingDirectory != null) {
+ pushDirectory(workingDirectory);
+ }
}
+
/**
- *
- */
- public XLCBuildOutputParserUtility(IProject project, IPath workingDirectory,
- IMarkerGenerator markerGenerator) {
- fDirectoryStack = new Vector<IPath>();
- fErrors = new ArrayList<Problem>();
- this.project = project;
- fBaseDirectory = getPathForResource(project);
- if (workingDirectory != null) {
- pushDirectory(workingDirectory);
- }
- }
+ *
+ */
+ public XLCBuildOutputParserUtility(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) {
+ fDirectoryStack = new Vector<IPath>();
+ fErrors = new ArrayList<Problem>();
+ this.project = project;
+ fBaseDirectory = getPathForResource(project);
+ if (workingDirectory != null) {
+ pushDirectory(workingDirectory);
+ }
+ }
private IPath getPathForResource(IResource resource) {
// TODO: when the file system utility stuff is in, this will have to call it to get the path
@@ -129,354 +131,339 @@ public class XLCBuildOutputParserUtility {
return path;
}
- /**
- * Adds a mapping filename, generic_command
- * @param longFileName
- * @param genericLine
- */
- void addGenericCommandForFile(String longFileName, String genericCommand) {
- // if a file name has already been added once, return
- if (compiledFileList.contains(longFileName))
- return;
- compiledFileList.add(longFileName);
-
- String workingDir = getWorkingDirectory().toString();
- List directoryCommandList = (List) directoryCommandListMap.get(workingDir);
- if (directoryCommandList == null) {
- directoryCommandList = new ArrayList();
- directoryCommandListMap.put(workingDir, directoryCommandList);
- ++workingDirsN;
- }
- Map command21FileListMap = null;
- for (Iterator i = directoryCommandList.iterator(); i.hasNext(); ) {
- command21FileListMap = (Map) i.next();
- List fileList = (List) command21FileListMap.get(genericCommand);
- if (fileList != null) {
- if (!fileList.contains(longFileName)) {
- fileList.add(longFileName);
- ++filesN;
- }
- return;
- }
- }
- command21FileListMap = new HashMap(1);
- directoryCommandList.add(command21FileListMap);
- ++commandsN;
- List fileList = new ArrayList();
- command21FileListMap.put(genericCommand, fileList);
- fileList.add(longFileName);
- ++filesN;
- }
-
- /**
- * Adds a mapping command line -> file, this time without a dir
- * @param longFileName
- * @param genericLine
- */
- void addGenericCommandForFile2(String longFileName, String genericLine) {
- // if a file name has already been added once, return
- if (compiledFileList.contains(longFileName))
- return;
- compiledFileList.add(longFileName);
-
- String[] tokens = genericLine.split("\\s+"); //$NON-NLS-1$
- CCommandDSC command = getNewCCommandDSC(tokens, 0, false); // assume .c file type
- int index = commandsList2.indexOf(command);
- if (index == -1) {
- commandsList2.add(command);
- ++commandsN;
- }
- else {
- command = (CCommandDSC) commandsList2.get(index);
- }
-// // add a file
-// command.addFile(longFileName);
-// ++filesN;
- }
-
- public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir) {
- if (enterDir) {
- /* Sometimes make screws up the output, so
- * "leave" events can't be seen. Double-check level
- * here.
- */
- for (int parseLevel = getDirectoryLevel(); dirLevel < parseLevel; parseLevel = getDirectoryLevel()) {
- popDirectory();
- }
- pushDirectory(new Path(dir));
- } else {
- popDirectory();
- /* Could check to see if they match */
- }
- }
-
- /**
- * Called by the console line parsers to generate a problem marker.
- */
- public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName) {
- // No need to collect markers if marker generator is not present
- if (fMarkerGenerator != null) {
- Problem problem = new Problem(file, lineNumber, desc, severity, varName);
- fErrors.add(problem);
- }
- }
-
- /**
- *
- */
- void generateReport() {
- TraceUtil.metricsTrace("Stats for directory ", //$NON-NLS-1$
- "Generic command: '", "' applicable for:", //$NON-NLS-1$ //$NON-NLS-2$
- directoryCommandListMap);
- TraceUtil.summaryTrace("Discovery summary", workingDirsN, commandsN, filesN); //$NON-NLS-1$
- }
-
- /**
- * @param filePath : String
- * @return filePath : IPath - not <code>null</code>
- */
- public IPath getAbsolutePath(String filePath) {
- IPath pFilePath;
- if (filePath.startsWith("/")) { //$NON-NLS-1$
- return convertCygpath(new Path(filePath));
- }
- else if (filePath.startsWith("\\") || //$NON-NLS-1$
- (!filePath.startsWith(".") && //$NON-NLS-1$
- filePath.length() > 2 && filePath.charAt(1) == ':' &&
- (filePath.charAt(2) == '\\' || filePath.charAt(2) == '/'))) {
- // absolute path
- pFilePath = new Path(filePath);
- }
- else {
- // relative path
- IPath cwd = getWorkingDirectory();
- if (!cwd.isAbsolute()) {
- cwd = getBaseDirectory().append(cwd);
- }
- if (filePath.startsWith("`pwd`")) { //$NON-NLS-1$
- if (filePath.length() > 5 && (filePath.charAt(5) == '/' || filePath.charAt(5) == '\\')) {
- filePath = filePath.substring(6);
- }
- else {
- filePath = filePath.substring(5);
- }
- }
- pFilePath = cwd.append(filePath);
- }
- return pFilePath;
- }
- /**
- * @return Returns the fBaseDirectory.
- */
- public IPath getBaseDirectory() {
- return fBaseDirectory;
- }
-
- /**
- * Returns all CCommandDSC collected so far.
- * Currently this list is not filled, so it will always return an empty list.
- * @return List of CCommandDSC
- */
- public List getCCommandDSCList() {
- return new ArrayList(commandsList2);
- }
-
- protected int getDirectoryLevel() {
- return fDirectoryStack.size();
- }
- /**
- * @return Returns the fDirectoryStack.
- */
- protected Vector<IPath> getDirectoryStack() {
- return fDirectoryStack;
- }
- /**
- * @return Returns the fErrors.
- */
- protected ArrayList<Problem> getErrors() {
- return fErrors;
- }
/**
- * @return Returns the fMarkerGenerator.
- */
- protected IMarkerGenerator getMarkerGenerator() {
- return fMarkerGenerator;
- }
-
- /**
- * @param genericLine
- * @param cppFileType
- * @return CCommandDSC compile command description
- */
- public CCommandDSC getNewCCommandDSC(String[] tokens, final int idxOfCompilerCommand, boolean cppFileType) {
+ * Adds a mapping filename, generic_command
+ * @param longFileName
+ * @param genericLine
+ */
+ void addGenericCommandForFile(String longFileName, String genericCommand) {
+ // if a file name has already been added once, return
+ if (compiledFileList.contains(longFileName))
+ return;
+ compiledFileList.add(longFileName);
+
+ String workingDir = getWorkingDirectory().toString();
+ List directoryCommandList = (List) directoryCommandListMap.get(workingDir);
+ if (directoryCommandList == null) {
+ directoryCommandList = new ArrayList();
+ directoryCommandListMap.put(workingDir, directoryCommandList);
+ ++workingDirsN;
+ }
+ Map command21FileListMap = null;
+ for (Iterator i = directoryCommandList.iterator(); i.hasNext();) {
+ command21FileListMap = (Map) i.next();
+ List fileList = (List) command21FileListMap.get(genericCommand);
+ if (fileList != null) {
+ if (!fileList.contains(longFileName)) {
+ fileList.add(longFileName);
+ ++filesN;
+ }
+ return;
+ }
+ }
+ command21FileListMap = new HashMap(1);
+ directoryCommandList.add(command21FileListMap);
+ ++commandsN;
+ List fileList = new ArrayList();
+ command21FileListMap.put(genericCommand, fileList);
+ fileList.add(longFileName);
+ ++filesN;
+ }
+
+ /**
+ * Adds a mapping command line -> file, this time without a dir
+ * @param longFileName
+ * @param genericLine
+ */
+ void addGenericCommandForFile2(String longFileName, String genericLine) {
+ // if a file name has already been added once, return
+ if (compiledFileList.contains(longFileName))
+ return;
+ compiledFileList.add(longFileName);
+
+ String[] tokens = genericLine.split("\\s+"); //$NON-NLS-1$
+ CCommandDSC command = getNewCCommandDSC(tokens, 0, false); // assume .c file type
+ int index = commandsList2.indexOf(command);
+ if (index == -1) {
+ commandsList2.add(command);
+ ++commandsN;
+ } else {
+ command = (CCommandDSC) commandsList2.get(index);
+ }
+ // // add a file
+ // command.addFile(longFileName);
+ // ++filesN;
+ }
+
+ public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir) {
+ if (enterDir) {
+ /* Sometimes make screws up the output, so
+ * "leave" events can't be seen. Double-check level
+ * here.
+ */
+ for (int parseLevel = getDirectoryLevel(); dirLevel < parseLevel; parseLevel = getDirectoryLevel()) {
+ popDirectory();
+ }
+ pushDirectory(new Path(dir));
+ } else {
+ popDirectory();
+ /* Could check to see if they match */
+ }
+ }
+
+ /**
+ * Called by the console line parsers to generate a problem marker.
+ */
+ public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName) {
+ // No need to collect markers if marker generator is not present
+ if (fMarkerGenerator != null) {
+ Problem problem = new Problem(file, lineNumber, desc, severity, varName);
+ fErrors.add(problem);
+ }
+ }
+
+ /**
+ *
+ */
+ void generateReport() {
+ TraceUtil.metricsTrace("Stats for directory ", //$NON-NLS-1$
+ "Generic command: '", "' applicable for:", //$NON-NLS-1$ //$NON-NLS-2$
+ directoryCommandListMap);
+ TraceUtil.summaryTrace("Discovery summary", workingDirsN, commandsN, filesN); //$NON-NLS-1$
+ }
+
+ /**
+ * @param filePath : String
+ * @return filePath : IPath - not <code>null</code>
+ */
+ public IPath getAbsolutePath(String filePath) {
+ IPath pFilePath;
+ if (filePath.startsWith("/")) { //$NON-NLS-1$
+ return convertCygpath(new Path(filePath));
+ } else if (filePath.startsWith("\\") || //$NON-NLS-1$
+ (!filePath.startsWith(".") && //$NON-NLS-1$
+ filePath.length() > 2 && filePath.charAt(1) == ':'
+ && (filePath.charAt(2) == '\\' || filePath.charAt(2) == '/'))) {
+ // absolute path
+ pFilePath = new Path(filePath);
+ } else {
+ // relative path
+ IPath cwd = getWorkingDirectory();
+ if (!cwd.isAbsolute()) {
+ cwd = getBaseDirectory().append(cwd);
+ }
+ if (filePath.startsWith("`pwd`")) { //$NON-NLS-1$
+ if (filePath.length() > 5 && (filePath.charAt(5) == '/' || filePath.charAt(5) == '\\')) {
+ filePath = filePath.substring(6);
+ } else {
+ filePath = filePath.substring(5);
+ }
+ }
+ pFilePath = cwd.append(filePath);
+ }
+ return pFilePath;
+ }
+
+ /**
+ * @return Returns the fBaseDirectory.
+ */
+ public IPath getBaseDirectory() {
+ return fBaseDirectory;
+ }
+
+ /**
+ * Returns all CCommandDSC collected so far.
+ * Currently this list is not filled, so it will always return an empty list.
+ * @return List of CCommandDSC
+ */
+ public List getCCommandDSCList() {
+ return new ArrayList(commandsList2);
+ }
+
+ protected int getDirectoryLevel() {
+ return fDirectoryStack.size();
+ }
+
+ /**
+ * @return Returns the fDirectoryStack.
+ */
+ protected Vector<IPath> getDirectoryStack() {
+ return fDirectoryStack;
+ }
+
+ /**
+ * @return Returns the fErrors.
+ */
+ protected ArrayList<Problem> getErrors() {
+ return fErrors;
+ }
+
+ /**
+ * @return Returns the fMarkerGenerator.
+ */
+ protected IMarkerGenerator getMarkerGenerator() {
+ return fMarkerGenerator;
+ }
+
+ /**
+ * @param genericLine
+ * @param cppFileType
+ * @return CCommandDSC compile command description
+ */
+ public CCommandDSC getNewCCommandDSC(String[] tokens, final int idxOfCompilerCommand, boolean cppFileType) {
ArrayList dirafter = new ArrayList();
ArrayList includes = new ArrayList();
- XLCCommandDSC command = new XLCCommandDSC(cppFileType, getProject());
- command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[idxOfCompilerCommand]));
- for (int i = idxOfCompilerCommand+1; i < tokens.length; ++i) {
- String token = tokens[i];
- //Target specific options: see GccScannerInfoConsoleParser
- if (token.startsWith("-m") || //$NON-NLS-1$
- token.equals("-ansi") || //$NON-NLS-1$
- token.equals("-posix") || //$NON-NLS-1$
- token.equals("-pthread") || //$NON-NLS-1$
- token.startsWith("-O") || //$NON-NLS-1$
- token.equals("-fno-inline") || //$NON-NLS-1$
- token.startsWith("-finline") || //$NON-NLS-1$
- token.equals("-fno-exceptions") || //$NON-NLS-1$
- token.equals("-fexceptions") || //$NON-NLS-1$
- token.equals("-fshort-wchar") || //$NON-NLS-1$
- token.equals("-fshort-double") || //$NON-NLS-1$
- token.equals("-fno-signed-char") || //$NON-NLS-1$
- token.equals("-fsigned-char") || //$NON-NLS-1$
- token.startsWith("-fabi-version=") //$NON-NLS-1$
+ XLCCommandDSC command = new XLCCommandDSC(cppFileType, getProject());
+ command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[idxOfCompilerCommand]));
+ for (int i = idxOfCompilerCommand + 1; i < tokens.length; ++i) {
+ String token = tokens[i];
+ //Target specific options: see GccScannerInfoConsoleParser
+ if (token.startsWith("-m") || //$NON-NLS-1$
+ token.equals("-ansi") || //$NON-NLS-1$
+ token.equals("-posix") || //$NON-NLS-1$
+ token.equals("-pthread") || //$NON-NLS-1$
+ token.startsWith("-O") || //$NON-NLS-1$
+ token.equals("-fno-inline") || //$NON-NLS-1$
+ token.startsWith("-finline") || //$NON-NLS-1$
+ token.equals("-fno-exceptions") || //$NON-NLS-1$
+ token.equals("-fexceptions") || //$NON-NLS-1$
+ token.equals("-fshort-wchar") || //$NON-NLS-1$
+ token.equals("-fshort-double") || //$NON-NLS-1$
+ token.equals("-fno-signed-char") || //$NON-NLS-1$
+ token.equals("-fsigned-char") || //$NON-NLS-1$
+ token.startsWith("-fabi-version=") //$NON-NLS-1$
) {
- command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), token));
+ command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), token));
continue;
- }
- for (int j = SCDOptionsEnum.MIN; j <= SCDOptionsEnum.MAX; ++j) {
- final SCDOptionsEnum optionKind = SCDOptionsEnum.getSCDOptionsEnum(j);
+ }
+ for (int j = SCDOptionsEnum.MIN; j <= SCDOptionsEnum.MAX; ++j) {
+ final SCDOptionsEnum optionKind = SCDOptionsEnum.getSCDOptionsEnum(j);
if (token.startsWith(optionKind.toString())) {
- String option = token.substring(
- optionKind.toString().length()).trim();
- if (option.length() > 0) {
- // ex. -I/dir
- }
- else if (optionKind.equals(SCDOptionsEnum.IDASH)) {
- for (Iterator iter=includes.iterator(); iter.hasNext(); ) {
- option = (String)iter.next();
- KVStringPair pair = new KVStringPair(SCDOptionsEnum.IQUOTE.toString(), option);
- command.addSCOption(pair);
- }
- includes = new ArrayList();
- // -I- has no parameter
- }
- else {
- // ex. -I /dir
- // take a next token
- if (i+1 < tokens.length && !tokens[i+1].startsWith("-")) { //$NON-NLS-1$
- option = tokens[++i];
- }
- else break;
- }
-
- if (option.length() > 0 && (
- optionKind.equals(SCDOptionsEnum.INCLUDE) ||
- optionKind.equals(SCDOptionsEnum.INCLUDE_FILE) ||
- optionKind.equals(SCDOptionsEnum.IMACROS_FILE) ||
- optionKind.equals(SCDOptionsEnum.IDIRAFTER) ||
- optionKind.equals(SCDOptionsEnum.ISYSTEM) ||
- optionKind.equals(SCDOptionsEnum.IQUOTE) )) {
- option = (getAbsolutePath(option)).toString();
- }
-
- if (optionKind.equals(SCDOptionsEnum.IDIRAFTER)) {
- KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option);
- dirafter.add(pair);
- }
- else if (optionKind.equals(SCDOptionsEnum.INCLUDE)) {
- includes.add(option);
- }
- else { // add the pair
- if (optionKind.equals(SCDOptionsEnum.DEFINE)) {
- if (option.indexOf('=') == -1) {
- option += '='+ fDefaultMacroDefinitionValue;
- }
- }
- KVStringPair pair = new KVStringPair(optionKind.toString(), option);
- command.addSCOption(pair);
- }
- break;
- }
- }
- }
- String option;
- for (Iterator iter=includes.iterator(); iter.hasNext(); ) {
- option = (String)iter.next();
- KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option);
- command.addSCOption(pair);
- }
- for (Iterator iter=dirafter.iterator(); iter.hasNext(); ) {
- command.addSCOption((KVStringPair)iter.next());
- }
- return command;
- }
-
- /**
- * @return Returns the project.
- */
- protected IProject getProject() {
- return project;
- }
-
- public IPath getWorkingDirectory() {
- if (fDirectoryStack.size() != 0) {
- return fDirectoryStack.lastElement();
- }
- // Fallback to the Project Location
- // FIXME: if the build did not start in the Project ?
- return fBaseDirectory;
- }
-
- protected IPath popDirectory() {
- int i = getDirectoryLevel();
- if (i != 0) {
- IPath dir = fDirectoryStack.lastElement();
- fDirectoryStack.removeElementAt(i - 1);
- return dir;
- }
- return new Path(""); //$NON-NLS-1$
- }
-
- protected void pushDirectory(IPath dir) {
- if (dir != null) {
- IPath pwd = null;
- if (fBaseDirectory != null && fBaseDirectory.isPrefixOf(dir)) {
- pwd = dir.removeFirstSegments(fBaseDirectory.segmentCount());
- } else {
- // check if it is a cygpath
- pwd= convertCygpath(dir);
- }
- fDirectoryStack.addElement(pwd);
- }
- }
+ String option = token.substring(optionKind.toString().length()).trim();
+ if (option.length() > 0) {
+ // ex. -I/dir
+ } else if (optionKind.equals(SCDOptionsEnum.IDASH)) {
+ for (Iterator iter = includes.iterator(); iter.hasNext();) {
+ option = (String) iter.next();
+ KVStringPair pair = new KVStringPair(SCDOptionsEnum.IQUOTE.toString(), option);
+ command.addSCOption(pair);
+ }
+ includes = new ArrayList();
+ // -I- has no parameter
+ } else {
+ // ex. -I /dir
+ // take a next token
+ if (i + 1 < tokens.length && !tokens[i + 1].startsWith("-")) { //$NON-NLS-1$
+ option = tokens[++i];
+ } else
+ break;
+ }
+
+ if (option.length() > 0 && (optionKind.equals(SCDOptionsEnum.INCLUDE)
+ || optionKind.equals(SCDOptionsEnum.INCLUDE_FILE)
+ || optionKind.equals(SCDOptionsEnum.IMACROS_FILE)
+ || optionKind.equals(SCDOptionsEnum.IDIRAFTER) || optionKind.equals(SCDOptionsEnum.ISYSTEM)
+ || optionKind.equals(SCDOptionsEnum.IQUOTE))) {
+ option = (getAbsolutePath(option)).toString();
+ }
+
+ if (optionKind.equals(SCDOptionsEnum.IDIRAFTER)) {
+ KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option);
+ dirafter.add(pair);
+ } else if (optionKind.equals(SCDOptionsEnum.INCLUDE)) {
+ includes.add(option);
+ } else { // add the pair
+ if (optionKind.equals(SCDOptionsEnum.DEFINE)) {
+ if (option.indexOf('=') == -1) {
+ option += '=' + fDefaultMacroDefinitionValue;
+ }
+ }
+ KVStringPair pair = new KVStringPair(optionKind.toString(), option);
+ command.addSCOption(pair);
+ }
+ break;
+ }
+ }
+ }
+ String option;
+ for (Iterator iter = includes.iterator(); iter.hasNext();) {
+ option = (String) iter.next();
+ KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option);
+ command.addSCOption(pair);
+ }
+ for (Iterator iter = dirafter.iterator(); iter.hasNext();) {
+ command.addSCOption((KVStringPair) iter.next());
+ }
+ return command;
+ }
+
+ /**
+ * @return Returns the project.
+ */
+ protected IProject getProject() {
+ return project;
+ }
+
+ public IPath getWorkingDirectory() {
+ if (fDirectoryStack.size() != 0) {
+ return fDirectoryStack.lastElement();
+ }
+ // Fallback to the Project Location
+ // FIXME: if the build did not start in the Project ?
+ return fBaseDirectory;
+ }
+
+ protected IPath popDirectory() {
+ int i = getDirectoryLevel();
+ if (i != 0) {
+ IPath dir = fDirectoryStack.lastElement();
+ fDirectoryStack.removeElementAt(i - 1);
+ return dir;
+ }
+ return new Path(""); //$NON-NLS-1$
+ }
+
+ protected void pushDirectory(IPath dir) {
+ if (dir != null) {
+ IPath pwd = null;
+ if (fBaseDirectory != null && fBaseDirectory.isPrefixOf(dir)) {
+ pwd = dir.removeFirstSegments(fBaseDirectory.segmentCount());
+ } else {
+ // check if it is a cygpath
+ pwd = convertCygpath(dir);
+ }
+ fDirectoryStack.addElement(pwd);
+ }
+ }
public boolean reportProblems() {
- boolean reset = false;
- for (Iterator<Problem> iter = fErrors.iterator(); iter.hasNext(); ) {
- Problem problem = iter.next();
- if (problem.severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) {
- reset = true;
- }
- if (problem.file == null) {
- fMarkerGenerator.addMarker(new ProblemMarkerInfo(
- project,
- problem.lineNumber,
- problem.description,
- problem.severity,
- problem.variableName));
- } else {
- fMarkerGenerator.addMarker(new ProblemMarkerInfo(
- problem.file,
- problem.lineNumber,
- problem.description,
- problem.severity,
- problem.variableName));
- }
- }
- fErrors.clear();
- return reset;
- }
-
- public void setDefaultMacroDefinitionValue(String val) {
- if (val != null) {
- fDefaultMacroDefinitionValue= val;
- }
- }
-
- public String getDefaultMacroDefinitionValue() {
- return fDefaultMacroDefinitionValue;
- }
+ boolean reset = false;
+ for (Iterator<Problem> iter = fErrors.iterator(); iter.hasNext();) {
+ Problem problem = iter.next();
+ if (problem.severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) {
+ reset = true;
+ }
+ if (problem.file == null) {
+ fMarkerGenerator.addMarker(new ProblemMarkerInfo(project, problem.lineNumber, problem.description,
+ problem.severity, problem.variableName));
+ } else {
+ fMarkerGenerator.addMarker(new ProblemMarkerInfo(problem.file, problem.lineNumber, problem.description,
+ problem.severity, problem.variableName));
+ }
+ }
+ fErrors.clear();
+ return reset;
+ }
+
+ public void setDefaultMacroDefinitionValue(String val) {
+ if (val != null) {
+ fDefaultMacroDefinitionValue = val;
+ }
+ }
+
+ public String getDefaultMacroDefinitionValue() {
+ return fDefaultMacroDefinitionValue;
+ }
public String normalizePath(String path) {
int column = path.indexOf(':');
@@ -485,25 +472,25 @@ public class XLCBuildOutputParserUtility {
if (Character.isLowerCase(driveLetter)) {
StringBuilder sb = new StringBuilder();
if (column - 1 > 0) {
- sb.append(path.substring(0, column-1));
+ sb.append(path.substring(0, column - 1));
}
sb.append(Character.toUpperCase(driveLetter));
sb.append(path.substring(column));
path = sb.toString();
}
}
- if (path.indexOf('.') == -1 || path.equals(".")) { //$NON-NLS-1$
- return (new Path(path)).toString(); // convert separators to '/'
+ if (path.indexOf('.') == -1 || path.equals(".")) { //$NON-NLS-1$
+ return (new Path(path)).toString(); // convert separators to '/'
}
// lose "./" segments since they confuse the Path normalization
StringBuilder buf = new StringBuilder(path);
int len = buf.length();
StringBuilder newBuf = new StringBuilder(buf.length());
int scp = 0; // starting copy point
- int ssp = 0; // starting search point
+ int ssp = 0; // starting search point
int sdot;
boolean validPrefix;
- while (ssp < len && (sdot = buf.indexOf(".", ssp)) != -1) { //$NON-NLS-1$
+ while (ssp < len && (sdot = buf.indexOf(".", ssp)) != -1) { //$NON-NLS-1$
validPrefix = false;
int ddot = buf.indexOf("..", ssp);//$NON-NLS-1$
if (sdot < ddot || ddot == -1) {
@@ -518,21 +505,18 @@ public class XLCBuildOutputParserUtility {
if (validPrefix && nextChar == '/') {
++ssp;
scp = ssp;
- }
- else if (validPrefix && nextChar == '\\') {
+ } else if (validPrefix && nextChar == '\\') {
++ssp;
if (ssp < len - 1 && buf.charAt(ssp) == '\\') {
++ssp;
}
scp = ssp;
- }
- else {
+ } else {
// no path delimiter, must be '.' inside the path
scp = ssp - 1;
}
}
- }
- else if (sdot == ddot) {
+ } else if (sdot == ddot) {
ssp = sdot + 2;
}
}
@@ -542,7 +526,6 @@ public class XLCBuildOutputParserUtility {
return orgPath.toString();
}
-
/**
* Called by the console line parsers to find a file with a given name.
* @param fileName
@@ -561,7 +544,7 @@ public class XLCBuildOutputParserUtility {
// Create a problem marker
final String error = MakeMessages.getString("ConsoleParser.Ambiguous_Filepath_Error_Message"); //$NON-NLS-1$
TraceUtil.outputError(error, fileName);
- generateMarker(getProject(), -1, error+fileName, IMarkerGenerator.SEVERITY_WARNING, null);
+ generateMarker(getProject(), -1, error + fileName, IMarkerGenerator.SEVERITY_WARNING, null);
}
}
}
@@ -666,10 +649,10 @@ public class XLCBuildOutputParserUtility {
public List translateRelativePaths(IFile file, String fileName, List includes) {
List translatedIncludes = new ArrayList(includes.size());
- for (Iterator i = includes.iterator(); i.hasNext(); ) {
+ for (Iterator i = includes.iterator(); i.hasNext();) {
String include = (String) i.next();
IPath includePath = new Path(include);
- if (!includePath.isAbsolute() && !includePath.isUNC()) { // do not translate UNC paths
+ if (!includePath.isAbsolute() && !includePath.isUNC()) { // do not translate UNC paths
// First try the current working directory
IPath cwd = getWorkingDirectory();
if (!cwd.isAbsolute()) {
@@ -685,22 +668,22 @@ public class XLCBuildOutputParserUtility {
if (!filePath.toString().equalsIgnoreCase(file.getLocation().toString())) {
// must be the cwd is wrong
// check if file name starts with ".."
- if (fileName.startsWith("..")) { //$NON-NLS-1$
+ if (fileName.startsWith("..")) { //$NON-NLS-1$
// probably multiple choices for cwd, hopeless
final String error = MakeMessages.getString("ConsoleParser.Working_Directory_Error_Message"); //$NON-NLS-1$
TraceUtil.outputError(error, fileName);
- generateMarker(file, -1, error, IMarkerGenerator.SEVERITY_WARNING, fileName);
+ generateMarker(file, -1, error, IMarkerGenerator.SEVERITY_WARNING, fileName);
break;
- }
- else {
+ } else {
// remove common segments at the end
IPath tPath = new Path(fileName);
- if (fileName.startsWith(".")) { //$NON-NLS-1$
+ if (fileName.startsWith(".")) { //$NON-NLS-1$
tPath = tPath.removeFirstSegments(1);
}
// get the file path from the file
filePath = file.getLocation();
- IPath lastFileSegment = filePath.removeFirstSegments(filePath.segmentCount() - tPath.segmentCount());
+ IPath lastFileSegment = filePath
+ .removeFirstSegments(filePath.segmentCount() - tPath.segmentCount());
if (lastFileSegment.matchingFirstSegments(tPath) == tPath.segmentCount()) {
cwd = filePath.removeLastSegments(tPath.segmentCount());
}
@@ -713,7 +696,7 @@ public class XLCBuildOutputParserUtility {
if (!dir.exists()) {
final String error = MakeMessages.getString("ConsoleParser.Nonexistent_Include_Path_Error_Message"); //$NON-NLS-1$
TraceUtil.outputError(error, include);
-// generateMarker(file, -1, error+include, IMarkerGenerator.SEVERITY_WARNING, fileName);
+ // generateMarker(file, -1, error+include, IMarkerGenerator.SEVERITY_WARNING, fileName);
}
}
// TODO VMIR for now add unresolved paths as well
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerFileBuildOutputParser.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerFileBuildOutputParser.java
index ebaf2d1d626..9f55f00aeb8 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerFileBuildOutputParser.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerFileBuildOutputParser.java
@@ -41,143 +41,143 @@ public class XLCPerFileBuildOutputParser extends AbstractXLCBuildOutputParser {
protected boolean processCommand(String[] tokens) {
try {
- // GCC C/C++ compiler invocation
- int compilerInvocationIndex = findCompilerInvocation(tokens);
- if (compilerInvocationIndex < 0) {
- return false;
- }
-
- // find a file name
- int extensionsIndex = -1;
- boolean found = false;
- String filePath = null;
-
- // check for automake format first
- // e.g. line will start with
- // source='/some/path/source.cpp'
- int automakeSrcIndex = findAutoMakeSourceIndex(tokens);
- if(automakeSrcIndex != -1) {
- filePath = getAutoMakeSourcePath(tokens[automakeSrcIndex]);
- int k = filePath.lastIndexOf('.');
- if (k != -1 && (filePath.length() - k < 5)) {
- String fileExtension = filePath.substring(k);
- extensionsIndex = getFileExtensionsList().indexOf(fileExtension);
- if (extensionsIndex != -1) {
- found = true;
- }
+ // GCC C/C++ compiler invocation
+ int compilerInvocationIndex = findCompilerInvocation(tokens);
+ if (compilerInvocationIndex < 0) {
+ return false;
}
- }
- if (!found) {
- for (int i = compilerInvocationIndex + 1; i < tokens.length; i++) {
- String token = tokens[i];
- int k = token.lastIndexOf('.');
- if (k != -1 && (token.length() - k < 5)) {
- String fileExtension = token.substring(k);
+ // find a file name
+ int extensionsIndex = -1;
+ boolean found = false;
+ String filePath = null;
+
+ // check for automake format first
+ // e.g. line will start with
+ // source='/some/path/source.cpp'
+ int automakeSrcIndex = findAutoMakeSourceIndex(tokens);
+ if (automakeSrcIndex != -1) {
+ filePath = getAutoMakeSourcePath(tokens[automakeSrcIndex]);
+ int k = filePath.lastIndexOf('.');
+ if (k != -1 && (filePath.length() - k < 5)) {
+ String fileExtension = filePath.substring(k);
extensionsIndex = getFileExtensionsList().indexOf(fileExtension);
if (extensionsIndex != -1) {
- filePath = token;
found = true;
- break;
}
}
}
- }
- if (!found) {
- TraceUtil.outputTrace("Error identifying file name :1", tokens, TraceUtil.EOL); //$NON-NLS-1$
- return false;
- }
- // sanity check
- if (filePath.indexOf(getFileExtensions()[extensionsIndex]) == -1) {
- TraceUtil.outputTrace("Error identifying file name :2", tokens, TraceUtil.EOL); //$NON-NLS-1$
- return false;
- }
- if (getUtility() != null) {
- IPath pFilePath = fUtility.getAbsolutePath(filePath);
- String shortFileName = pFilePath.removeFileExtension().lastSegment();
-
- // generalize occurrences of the file name
- for (int i = compilerInvocationIndex + 1; i < tokens.length; i++) {
- String token = tokens[i];
- if (token.equals("-include")) { //$NON-NLS-1$
- ++i;
- } else if (token.equals("-imacros")) { //$NON-NLS-1$
- ++i;
- } else if (token.equals(filePath)) {
- tokens[i] = "LONG_NAME"; //$NON-NLS-1$
- } else if (token.startsWith(shortFileName)) {
- tokens[i] = token.replaceFirst(shortFileName, "SHORT_NAME"); //$NON-NLS-1$
+ if (!found) {
+ for (int i = compilerInvocationIndex + 1; i < tokens.length; i++) {
+ String token = tokens[i];
+ int k = token.lastIndexOf('.');
+ if (k != -1 && (token.length() - k < 5)) {
+ String fileExtension = token.substring(k);
+ extensionsIndex = getFileExtensionsList().indexOf(fileExtension);
+ if (extensionsIndex != -1) {
+ filePath = token;
+ found = true;
+ break;
+ }
+ }
}
}
- IFile file = null;
- IPath baseDirectory = fUtility.getBaseDirectory();
- if (baseDirectory.isPrefixOf(pFilePath)) {
- IPath relPath = pFilePath.removeFirstSegments(baseDirectory.segmentCount());
- // Note: We add the scanner-config even if the resource doesn't
- // actually
- // exist below this project (which may happen when reading
- // existing
- // build logs, because resources can be created as part of the
- // build
- // and may not exist at the time of analyzing the config but
- // re-built
- // later on.
- // if (getProject().exists(relPath)) {
- file = getProject().getFile(relPath);
- } else {
- file = getUtility().findFileInWorkspace(pFilePath);
+ if (!found) {
+ TraceUtil.outputTrace("Error identifying file name :1", tokens, TraceUtil.EOL); //$NON-NLS-1$
+ return false;
+ }
+ // sanity check
+ if (filePath.indexOf(getFileExtensions()[extensionsIndex]) == -1) {
+ TraceUtil.outputTrace("Error identifying file name :2", tokens, TraceUtil.EOL); //$NON-NLS-1$
+ return false;
}
- if (true /*file != null*/) {
- CCommandDSC cmd = getUtility().getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0);
- List<CCommandDSC> cmdList = new CopyOnWriteArrayList<CCommandDSC>();
- cmdList.add(cmd);
- Map<ScannerInfoTypes, List<CCommandDSC>> sc = new HashMap<ScannerInfoTypes, List<CCommandDSC>>(1);
- sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList);
- getCollector().contributeToScannerConfig(file, sc);
- if (fCollector != null && fCollector instanceof IScannerInfoCollector2) {
- IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
- try {
- collector.updateScannerConfiguration(null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- Activator.log(e);
+ if (getUtility() != null) {
+ IPath pFilePath = fUtility.getAbsolutePath(filePath);
+ String shortFileName = pFilePath.removeFileExtension().lastSegment();
+
+ // generalize occurrences of the file name
+ for (int i = compilerInvocationIndex + 1; i < tokens.length; i++) {
+ String token = tokens[i];
+ if (token.equals("-include")) { //$NON-NLS-1$
+ ++i;
+ } else if (token.equals("-imacros")) { //$NON-NLS-1$
+ ++i;
+ } else if (token.equals(filePath)) {
+ tokens[i] = "LONG_NAME"; //$NON-NLS-1$
+ } else if (token.startsWith(shortFileName)) {
+ tokens[i] = token.replaceFirst(shortFileName, "SHORT_NAME"); //$NON-NLS-1$
}
}
- } else {
- /*
- //TraceUtil.outputError("Build command for file outside project: " + pFilePath.toString(), tokens); //$NON-NLS-1$
- // put the info on the project
- //CCommandDSC cmd = getUtility().getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0);
- //List<CCommandDSC> cmdList = new ArrayList<CCommandDSC>();
-// cmdList.add(cmd);
- Map<ScannerInfoTypes, List<?>> sc = new HashMap<ScannerInfoTypes, List<?>>();
-// sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList);
-
-
- // put in empty info for the other types
- sc.put(ScannerInfoTypes.INCLUDE_PATHS, new LinkedList<String>());
- sc.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, new LinkedList<String>());
-
- getCollector().contributeToScannerConfig(getProject(), sc);
- if (fCollector != null && fCollector instanceof IScannerInfoCollector2) {
- IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
- try {
- collector.updateScannerConfiguration(null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- Activator.log(e);
- }
+
+ IFile file = null;
+ IPath baseDirectory = fUtility.getBaseDirectory();
+ if (baseDirectory.isPrefixOf(pFilePath)) {
+ IPath relPath = pFilePath.removeFirstSegments(baseDirectory.segmentCount());
+ // Note: We add the scanner-config even if the resource doesn't
+ // actually
+ // exist below this project (which may happen when reading
+ // existing
+ // build logs, because resources can be created as part of the
+ // build
+ // and may not exist at the time of analyzing the config but
+ // re-built
+ // later on.
+ // if (getProject().exists(relPath)) {
+ file = getProject().getFile(relPath);
+ } else {
+ file = getUtility().findFileInWorkspace(pFilePath);
}
+ if (true /*file != null*/) {
+ CCommandDSC cmd = getUtility().getNewCCommandDSC(tokens, compilerInvocationIndex,
+ extensionsIndex > 0);
+ List<CCommandDSC> cmdList = new CopyOnWriteArrayList<CCommandDSC>();
+ cmdList.add(cmd);
+ Map<ScannerInfoTypes, List<CCommandDSC>> sc = new HashMap<ScannerInfoTypes, List<CCommandDSC>>(1);
+ sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList);
+ getCollector().contributeToScannerConfig(file, sc);
+ if (fCollector != null && fCollector instanceof IScannerInfoCollector2) {
+ IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
+ try {
+ collector.updateScannerConfiguration(null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ Activator.log(e);
+ }
+ }
+ } else {
+ /*
+ //TraceUtil.outputError("Build command for file outside project: " + pFilePath.toString(), tokens); //$NON-NLS-1$
+ // put the info on the project
+ //CCommandDSC cmd = getUtility().getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0);
+ //List<CCommandDSC> cmdList = new ArrayList<CCommandDSC>();
+ // cmdList.add(cmd);
+ Map<ScannerInfoTypes, List<?>> sc = new HashMap<ScannerInfoTypes, List<?>>();
+ // sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList);
+
+
+ // put in empty info for the other types
+ sc.put(ScannerInfoTypes.INCLUDE_PATHS, new LinkedList<String>());
+ sc.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, new LinkedList<String>());
+
+ getCollector().contributeToScannerConfig(getProject(), sc);
+ if (fCollector != null && fCollector instanceof IScannerInfoCollector2) {
+ IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
+ try {
+ collector.updateScannerConfiguration(null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ Activator.log(e);
+ }
+ }
- */
+ */
+ }
}
- }
- return true;
+ return true;
- }
- catch(Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
return false;
}
@@ -187,13 +187,13 @@ public class XLCPerFileBuildOutputParser extends AbstractXLCBuildOutputParser {
// path may be enclosed in single quotes
int firstQuoteIndex = string.indexOf('\'');
int lastQuoteIndex = string.lastIndexOf('\'');
- if(firstQuoteIndex != -1 && lastQuoteIndex != -1)
+ if (firstQuoteIndex != -1 && lastQuoteIndex != -1)
return string.substring(firstQuoteIndex, lastQuoteIndex);
else {
// just take everything after the equals sign
int equalsIndex = string.indexOf('=');
- if(equalsIndex != -1 && equalsIndex < string.length())
- return string.substring(equalsIndex+1);
+ if (equalsIndex != -1 && equalsIndex < string.length())
+ return string.substring(equalsIndex + 1);
}
return null;
@@ -202,7 +202,7 @@ public class XLCPerFileBuildOutputParser extends AbstractXLCBuildOutputParser {
protected int findAutoMakeSourceIndex(String[] tokens) {
for (int i = 0; i < tokens.length; i++) {
final String token = tokens[i].toLowerCase();
- if(token.indexOf("source=") != -1) //$NON-NLS-1$
+ if (token.indexOf("source=") != -1) //$NON-NLS-1$
return i;
}
return -1;
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerProjectBuildOutputParser.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerProjectBuildOutputParser.java
index 714f041a0f3..04a188f0ef2 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerProjectBuildOutputParser.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XLCPerProjectBuildOutputParser.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.cdt.make.xlc.core.scannerconfig;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -33,151 +32,142 @@ import org.eclipse.core.runtime.CoreException;
* @author crecoskie
*
*/
-public class XLCPerProjectBuildOutputParser extends
- AbstractXLCBuildOutputParser {
+public class XLCPerProjectBuildOutputParser extends AbstractXLCBuildOutputParser {
/* (non-Javadoc)
* @see org.eclipse.cdt.make.xlc.core.scannerconfig.AbstractXLCBuildOutputParser#processCommand(java.lang.String[])
*/
@Override
- protected boolean processCommand(String[] tokens) {
- int compilerInvocationIdx= findCompilerInvocation(tokens);
- if (compilerInvocationIdx<0) {
- return false;
- }
-
- if (compilerInvocationIdx+1 >= tokens.length) {
- return false;
- }
-
- // Recognized gcc or g++ compiler invocation
- List<String> includes = new CopyOnWriteArrayList<String>();
- List<String> symbols = new CopyOnWriteArrayList<String>();
- List<String> targetSpecificOptions = new CopyOnWriteArrayList<String>();
-
- String fileName = null;
- for (int j= compilerInvocationIdx+1; j < tokens.length; j++) {
+ protected boolean processCommand(String[] tokens) {
+ int compilerInvocationIdx = findCompilerInvocation(tokens);
+ if (compilerInvocationIdx < 0) {
+ return false;
+ }
+
+ if (compilerInvocationIdx + 1 >= tokens.length) {
+ return false;
+ }
+
+ // Recognized gcc or g++ compiler invocation
+ List<String> includes = new CopyOnWriteArrayList<String>();
+ List<String> symbols = new CopyOnWriteArrayList<String>();
+ List<String> targetSpecificOptions = new CopyOnWriteArrayList<String>();
+
+ String fileName = null;
+ for (int j = compilerInvocationIdx + 1; j < tokens.length; j++) {
String token = tokens[j];
if (token.equals(DASHIDASH)) {
- }
- else if (token.startsWith(DASHI)) {
- String candidate= null;
+ } else if (token.startsWith(DASHI)) {
+ String candidate = null;
if (token.length() > 2) {
- candidate= token.substring(2).trim();
- }
- else if (j+1 < tokens.length) {
- candidate= tokens[j+1];
+ candidate = token.substring(2).trim();
+ } else if (j + 1 < tokens.length) {
+ candidate = tokens[j + 1];
if (candidate.startsWith("-")) { //$NON-NLS-1$
- candidate= null;
- }
- else {
+ candidate = null;
+ } else {
j++;
}
}
if (candidate != null && candidate.length() > 0) {
if (getUtility() != null) {
- candidate= getUtility().normalizePath(candidate);
+ candidate = getUtility().normalizePath(candidate);
}
if (!includes.contains(candidate)) {
includes.add(candidate);
}
}
- }
- else if (token.startsWith(DASHD)) {
- String candidate= null;
+ } else if (token.startsWith(DASHD)) {
+ String candidate = null;
if (token.length() > 2) {
- candidate= token.substring(2).trim();
- }
- else if (j+1 < tokens.length) {
- candidate= tokens[j+1];
+ candidate = token.substring(2).trim();
+ } else if (j + 1 < tokens.length) {
+ candidate = tokens[j + 1];
if (candidate.startsWith("-")) { //$NON-NLS-1$
- candidate= null;
- }
- else {
+ candidate = null;
+ } else {
j++;
}
}
- if (candidate != null && candidate.length() > 0) {
- if (candidate.indexOf('=') == -1) {
- candidate+= '='+ getUtility().getDefaultMacroDefinitionValue();
- }
- if (!symbols.contains(candidate)) {
- symbols.add(candidate);
- }
- }
- }
-
- else if (fileName == null) {
- int extIndex = token.lastIndexOf('.');
- String extension=null;
-
- if(extIndex != -1)
- extension = token.substring(extIndex);
+ if (candidate != null && candidate.length() > 0) {
+ if (candidate.indexOf('=') == -1) {
+ candidate += '=' + getUtility().getDefaultMacroDefinitionValue();
+ }
+ if (!symbols.contains(candidate)) {
+ symbols.add(candidate);
+ }
+ }
+ }
- List<String> extensions = getFileExtensionsList();
- if(extension != null && extensions.contains(extension))
- fileName = token;
- }
- }
+ else if (fileName == null) {
+ int extIndex = token.lastIndexOf('.');
+ String extension = null;
- if (fileName == null) {
- return false; // return when no file was given (analogous to GCCPerFileBOPConsoleParser)
- }
+ if (extIndex != -1)
+ extension = token.substring(extIndex);
- IProject project = getProject();
- IFile file = null;
- List<String> translatedIncludes = includes;
- if (includes.size() > 0) {
- if (fileName != null) {
- if (getUtility() != null) {
- file = getUtility().findFile(fileName);
- if (file != null) {
- project = file.getProject();
- translatedIncludes = getUtility().translateRelativePaths(file, fileName, includes);
- }
- }
- }
- else {
- StringBuilder line= new StringBuilder();
- for (int j = 0; j < tokens.length; j++) {
+ List<String> extensions = getFileExtensionsList();
+ if (extension != null && extensions.contains(extension))
+ fileName = token;
+ }
+ }
+
+ if (fileName == null) {
+ return false; // return when no file was given (analogous to GCCPerFileBOPConsoleParser)
+ }
+
+ IProject project = getProject();
+ IFile file = null;
+ List<String> translatedIncludes = includes;
+ if (includes.size() > 0) {
+ if (fileName != null) {
+ if (getUtility() != null) {
+ file = getUtility().findFile(fileName);
+ if (file != null) {
+ project = file.getProject();
+ translatedIncludes = getUtility().translateRelativePaths(file, fileName, includes);
+ }
+ }
+ } else {
+ StringBuilder line = new StringBuilder();
+ for (int j = 0; j < tokens.length; j++) {
line.append(tokens[j]);
line.append(' ');
}
- final String error = MakeMessages.getString("ConsoleParser.Filename_Missing_Error_Message"); //$NON-NLS-1$
- TraceUtil.outputError(error, line.toString());
- if (getUtility() != null) {
- getUtility().generateMarker(getProject(), -1, error + line.toString(), IMarkerGenerator.SEVERITY_WARNING, null);
- }
- }
- if (file == null && getUtility() != null) { // real world case
- // remove include paths since there was no chance to translate them
- translatedIncludes.clear();
- }
- }
- // Contribute discovered includes and symbols to the ScannerInfoCollector
- if (translatedIncludes.size() > 0 || symbols.size() > 0) {
- Map<ScannerInfoTypes, List<String>> scannerInfo = new HashMap<ScannerInfoTypes, List<String>>();
- scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, translatedIncludes);
- scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
- scannerInfo.put(ScannerInfoTypes.TARGET_SPECIFIC_OPTION, targetSpecificOptions);
- getCollector().contributeToScannerConfig(project, scannerInfo);
- if(fCollector != null && fCollector instanceof IScannerInfoCollector2) {
- IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
- try {
- collector.updateScannerConfiguration(null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- Activator.log(e);
- }
- }
+ final String error = MakeMessages.getString("ConsoleParser.Filename_Missing_Error_Message"); //$NON-NLS-1$
+ TraceUtil.outputError(error, line.toString());
+ if (getUtility() != null) {
+ getUtility().generateMarker(getProject(), -1, error + line.toString(),
+ IMarkerGenerator.SEVERITY_WARNING, null);
+ }
+ }
+ if (file == null && getUtility() != null) { // real world case
+ // remove include paths since there was no chance to translate them
+ translatedIncludes.clear();
+ }
+ }
+ // Contribute discovered includes and symbols to the ScannerInfoCollector
+ if (translatedIncludes.size() > 0 || symbols.size() > 0) {
+ Map<ScannerInfoTypes, List<String>> scannerInfo = new HashMap<ScannerInfoTypes, List<String>>();
+ scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, translatedIncludes);
+ scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
+ scannerInfo.put(ScannerInfoTypes.TARGET_SPECIFIC_OPTION, targetSpecificOptions);
+ getCollector().contributeToScannerConfig(project, scannerInfo);
+ if (fCollector != null && fCollector instanceof IScannerInfoCollector2) {
+ IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
+ try {
+ collector.updateScannerConfiguration(null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ Activator.log(e);
+ }
+ }
- TraceUtil.outputTrace("Discovered scanner info for file \'" + fileName + '\'', //$NON-NLS-1$
- "Include paths", includes, translatedIncludes, "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ TraceUtil.outputTrace("Discovered scanner info for file \'" + fileName + '\'', //$NON-NLS-1$
+ "Include paths", includes, translatedIncludes, "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$
+ }
return true;
-}
-
-
+ }
}
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java
index a706896a615..65e96ccdbb9 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java
@@ -43,26 +43,23 @@ import org.eclipse.cdt.core.CProjectNature;
public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser {
// pattern for the output line of interest
- final Pattern linePattern = Pattern
- .compile("exec:\\s(?!export)(?:.*)\\((.*)\\)"); //$NON-NLS-1$
+ final Pattern linePattern = Pattern.compile("exec:\\s(?!export)(?:.*)\\((.*)\\)"); //$NON-NLS-1$
// pattern for the symbols arguments
final Pattern symbolPattern = Pattern.compile("-D(.*)"); //$NON-NLS-1$
// pattern for the includes arguments
- final Pattern includePattern = Pattern
- .compile("-(?:qgcc_c_stdinc|qc_stdinc|qgcc_cpp_stdinc|qcpp_stdinc)=(.*)"); //$NON-NLS-1$
+ final Pattern includePattern = Pattern.compile("-(?:qgcc_c_stdinc|qc_stdinc|qgcc_cpp_stdinc|qcpp_stdinc)=(.*)"); //$NON-NLS-1$
final Pattern C_includePattern = Pattern.compile("-(?:qgcc_c_stdinc|qc_stdinc)=(.*)"); //$NON-NLS-1$
final Pattern CXX_includePattern = Pattern.compile("-(?:qgcc_cpp_stdinc|qcpp_stdinc)=(.*)"); //$NON-NLS-1$
-
+
// xlC compiler constants
- protected final static String [] compilerConstants = {
- "_Builtin", //$NON-NLS-1$
+ protected final static String[] compilerConstants = { "_Builtin", //$NON-NLS-1$
"__IBMCPP__", //$NON-NLS-1$
- "__xlC__", //$NON-NLS-1$
- "__IBMC__", //$NON-NLS-1$
- "__xlc__" //$NON-NLS-1$
+ "__xlC__", //$NON-NLS-1$
+ "__IBMC__", //$NON-NLS-1$
+ "__xlc__" //$NON-NLS-1$
};
private IProject fProject = null;
@@ -71,11 +68,12 @@ public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser {
protected List<String> symbols = new ArrayList<String>();
- protected List<String> includes = new ArrayList<String>();
+ protected List<String> includes = new ArrayList<String>();
protected List<String> c_includes = new ArrayList<String>();
protected List<String> cpp_includes = new ArrayList<String>();
-
- boolean c_lang; // if language is C only search for the C include paths from the XL Compiler, otherwise get the C++ ones.
+
+ boolean c_lang; // if language is C only search for the C include paths from the XL Compiler, otherwise get the C++ ones.
+
public boolean isC_lang() {
return c_lang;
}
@@ -94,20 +92,19 @@ public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser {
* @since 1.0
*/
@Override
- public void startup(IProject project, IPath workingDirectory,
- IScannerInfoCollector collector, IMarkerGenerator markerGenerator) {
+ public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector,
+ IMarkerGenerator markerGenerator) {
this.fProject = project;
this.fCollector = collector;
-
+
try {
if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
// use C++ pattern
c_lang = false;
- }
- else {
+ } else {
// use C pattern
c_lang = true;
- }
+ }
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -129,10 +126,9 @@ public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser {
@Override
public boolean processLine(String line) {
boolean rc = false;
- TraceUtil.outputTrace(
- "XLCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$
+ TraceUtil.outputTrace("XLCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$
- line= line.trim();
+ line = line.trim();
if (line.length() == 0) {
return false;
}
@@ -147,18 +143,17 @@ public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser {
for (int i = 0; i < args.length; i++) {
// getting the arguments of interest
Matcher symbolMatcher = symbolPattern.matcher(args[i]);
- if (symbolMatcher.matches()
- && !symbols.contains(symbolMatcher.group(1))) {
+ if (symbolMatcher.matches() && !symbols.contains(symbolMatcher.group(1))) {
// if it is a symbol and it was not yet added
symbols.add(symbolMatcher.group(1));
} else {
// if it is not a symbol, check to see if it is an
// include
- Matcher includeMatcher = c_lang ? C_includePattern.matcher(args[i]) : CXX_includePattern.matcher(args[i]);
+ Matcher includeMatcher = c_lang ? C_includePattern.matcher(args[i])
+ : CXX_includePattern.matcher(args[i]);
if (includeMatcher.matches()) {
// if it is a set of include paths, split it
- String[] includePaths = includeMatcher.group(1).split(
- ":"); //$NON-NLS-1$
+ String[] includePaths = includeMatcher.group(1).split(":"); //$NON-NLS-1$
for (int j = 0; j < includePaths.length; j++) {
if (!includes.contains(includePaths[j])) {
// if the include path was not yet added
@@ -193,7 +188,7 @@ public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser {
scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
fCollector.contributeToScannerConfig(fProject, scannerInfo);
- if(fCollector != null && fCollector instanceof IScannerInfoCollector2) {
+ if (fCollector != null && fCollector instanceof IScannerInfoCollector2) {
IScannerInfoCollector2 collector = (IScannerInfoCollector2) fCollector;
try {
collector.updateScannerConfiguration(null);
@@ -202,9 +197,8 @@ public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser {
Activator.log(e);
}
}
- TraceUtil.outputTrace(
- "Scanner info from \'specs\' file", //$NON-NLS-1$
- "Include paths", includes, new ArrayList<String>(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$
+ TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$
+ "Include paths", includes, new ArrayList<String>(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsRunSIProvider.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsRunSIProvider.java
index df734de312e..453bf8f3afe 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsRunSIProvider.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsRunSIProvider.java
@@ -39,15 +39,9 @@ public class XlCSpecsRunSIProvider extends GCCSpecsRunSIProvider {
if (rc) {
try {
- this.fCompileCommand = new Path(ManagedBuildManager.getBuildMacroProvider()
- .resolveValue(
- this.fCompileCommand.toString(),
- EMPTY_STRING,
- null,
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- ManagedBuildManager.getBuildInfo(
- this.resource.getProject())
- .getDefaultConfiguration()));
+ this.fCompileCommand = new Path(ManagedBuildManager.getBuildMacroProvider().resolveValue(
+ this.fCompileCommand.toString(), EMPTY_STRING, null, IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ ManagedBuildManager.getBuildInfo(this.resource.getProject()).getDefaultConfiguration()));
} catch (BuildMacroException e) {
e.printStackTrace();
return false;
diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/util/XLCCommandDSC.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/util/XLCCommandDSC.java
index 1b029974410..cd4b6ad7262 100644
--- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/util/XLCCommandDSC.java
+++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/util/XLCCommandDSC.java
@@ -38,13 +38,11 @@ public class XLCCommandDSC extends CCommandDSC {
*/
@Override
public void addSCOption(KVStringPair option) {
- if (project != null &&
- (option.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString()) ||
- option.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) ||
- option.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) ||
- option.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) ||
- option.getKey().equals(SCDOptionsEnum.IQUOTE.toString())))
- {
+ if (project != null && (option.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())
+ || option.getKey().equals(SCDOptionsEnum.INCLUDE.toString())
+ || option.getKey().equals(SCDOptionsEnum.ISYSTEM.toString())
+ || option.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString())
+ || option.getKey().equals(SCDOptionsEnum.IQUOTE.toString()))) {
String value = option.getValue();
value = makeRelative(project, new Path(value)).toOSString();
option = new KVStringPair(option.getKey(), value);

Back to the top