From 170e654b4796bad1453ae85a427b97317d67a69a Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Tue, 20 Nov 2018 16:20:42 +0000 Subject: Bug 540373: Cleanup: Format & Remove trailing whitespace This was done by selecting all projects in Eclipse then Source -> Clean Up... -> choosing: - Format source code - Remove trailing white spaces on all lines and completing the wizard Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394 --- .../cdt/make/internal/core/BuildInfoFactory.java | 51 +- .../cdt/make/internal/core/ListenerList.java | 4 +- .../cdt/make/internal/core/MakeMessages.java | 12 +- .../eclipse/cdt/make/internal/core/MakeRecon.java | 14 +- .../eclipse/cdt/make/internal/core/MakeTarget.java | 33 +- .../cdt/make/internal/core/MakeTargetManager.java | 49 +- .../make/internal/core/PreferenceInitializer.java | 54 +- .../cdt/make/internal/core/ProjectTargets.java | 14 +- .../core/dataprovider/MakeCDataFactory.java | 19 +- .../MakeConfigurationDataProvider.java | 13 +- .../dataprovider/MakeDiscoveredInfoProcessor.java | 11 +- .../core/dataprovider/MakeLanguageData.java | 19 +- .../internal/core/makefile/AbstractMakefile.java | 2 +- .../cdt/make/internal/core/makefile/Command.java | 4 +- .../internal/core/makefile/MacroDefinition.java | 2 +- .../internal/core/makefile/MakeFileConstants.java | 15 +- .../internal/core/makefile/MakefileMessages.java | 23 +- .../internal/core/makefile/MakefileReader.java | 4 +- .../make/internal/core/makefile/NullMakefile.java | 1 + .../cdt/make/internal/core/makefile/Util.java | 4 +- .../core/makefile/gnu/AutomaticVariable.java | 3 +- .../core/makefile/gnu/BuiltinFunction.java | 1 - .../internal/core/makefile/gnu/Conditional.java | 3 +- .../internal/core/makefile/gnu/DefineVariable.java | 1 - .../cdt/make/internal/core/makefile/gnu/Else.java | 1 - .../cdt/make/internal/core/makefile/gnu/Endef.java | 7 +- .../cdt/make/internal/core/makefile/gnu/Endif.java | 8 +- .../internal/core/makefile/gnu/ExportVariable.java | 1 - .../internal/core/makefile/gnu/GNUMakefile.java | 116 +- .../core/makefile/gnu/GNUMakefileChecker.java | 5 +- .../core/makefile/gnu/GNUMakefileConstants.java | 55 +- .../core/makefile/gnu/GNUMakefileUtil.java | 50 +- .../core/makefile/gnu/GNUMakefileValidator.java | 24 +- .../internal/core/makefile/gnu/GNUTargetRule.java | 4 +- .../cdt/make/internal/core/makefile/gnu/Ifdef.java | 5 +- .../cdt/make/internal/core/makefile/gnu/Ifeq.java | 1 - .../make/internal/core/makefile/gnu/Ifndef.java | 4 +- .../cdt/make/internal/core/makefile/gnu/Ifneq.java | 1 - .../make/internal/core/makefile/gnu/Include.java | 6 +- .../internal/core/makefile/gnu/OverrideDefine.java | 4 +- .../core/makefile/gnu/OverrideVariable.java | 1 - .../core/makefile/gnu/StaticTargetRule.java | 4 +- .../internal/core/makefile/gnu/TargetVariable.java | 3 +- .../core/makefile/gnu/VariableDefinition.java | 4 +- .../core/makefile/posix/PosixMakefile.java | 15 +- .../CDataDiscoveredInfoCalculator.java | 606 ++++---- .../CDataDiscoveredInfoProcessor.java | 88 +- .../scannerconfig/DiscoveredPathContainer.java | 97 +- .../core/scannerconfig/DiscoveredPathInfo.java | 25 +- .../scannerconfig/DiscoveredPathInitializer.java | 36 +- .../core/scannerconfig/DiscoveredPathManager.java | 417 +++--- .../scannerconfig/DiscoveredScannerInfoStore.java | 414 +++--- .../PerFileDiscoveredPathContainer.java | 3 +- .../scannerconfig/ScannerConfigInfoFactory.java | 46 +- .../core/scannerconfig/ScannerConfigUtil.java | 62 +- .../ScannerInfoConsoleParserFactory.java | 155 +-- .../gnu/AbstractGCCBOPConsoleParser.java | 364 +++-- .../gnu/AbstractGCCBOPConsoleParserUtility.java | 330 +++-- .../gnu/GCCPerFileBOPConsoleParser.java | 177 ++- .../gnu/GCCPerFileBOPConsoleParserUtility.java | 465 ++++--- .../gnu/GCCPerFileSIPConsoleParser.java | 180 ++- .../scannerconfig/gnu/GCCScannerConfigUtil.java | 11 +- .../gnu/GCCScannerInfoConsoleParser.java | 296 ++-- .../scannerconfig/gnu/GCCSpecsConsoleParser.java | 20 +- .../gnu/ScannerInfoConsoleParserUtility.java | 78 +- .../scannerconfig/jobs/BuildOutputReaderJob.java | 57 +- .../core/scannerconfig/jobs/SCJobsUtil.java | 304 ++--- .../core/scannerconfig/util/CCommandDSC.java | 528 ++++--- .../core/scannerconfig/util/CygpathTranslator.java | 29 +- .../core/scannerconfig/util/KVStringPair.java | 13 +- .../core/scannerconfig/util/LogWriter.java | 44 +- .../util/PathInfoToLangSettingsConverter.java | 31 +- .../core/scannerconfig/util/SCDOptionsEnum.java | 113 +- .../core/scannerconfig/util/SymbolEntry.java | 34 +- .../core/scannerconfig/util/TraceUtil.java | 41 +- .../core/scannerconfig2/DefaultRunSIProvider.java | 64 +- .../core/scannerconfig2/DefaultSIFileReader.java | 169 ++- .../core/scannerconfig2/GCCSpecsRunSIProvider.java | 119 +- .../MakeConfigurationDataProviderMessages.java | 3 +- .../core/scannerconfig2/PerFileSICollector.java | 1443 ++++++++++---------- .../core/scannerconfig2/PerProjectSICollector.java | 465 ++++--- .../core/scannerconfig2/SCDMakefileGenerator.java | 225 ++- .../core/scannerconfig2/SCMarkerGenerator.java | 34 +- .../core/scannerconfig2/SCProfileInstance.java | 82 +- .../scannerconfig2/ScannerConfigInfoFactory2.java | 960 +++++++------ .../core/scannerconfig2/ScannerConfigProfile.java | 149 +- .../ScannerConfigProfileManager.java | 152 ++- .../core/templateengine/AddMakeTarget.java | 23 +- 88 files changed, 4783 insertions(+), 4844 deletions(-) (limited to 'build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal') diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java index 709c3936515..50507fe40a3 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java @@ -88,7 +88,7 @@ public class BuildInfoFactory { @Override public String getBuildAttribute(String name, String defaultValue) { String value = getString(name); - if (value == null ) { + if (value == null) { if (IMakeCommonBuildInfo.BUILD_COMMAND.equals(name)) { value = getString(BuildInfoFactory.BUILD_COMMAND); } else if (IMakeCommonBuildInfo.BUILD_ARGUMENTS.equals(name)) { @@ -127,7 +127,8 @@ public class BuildInfoFactory { // translate any string substitution variables String translated = value; try { - translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value, false); + translated = VariablesPlugin.getDefault().getStringVariableManager() + .performStringSubstitution(value, false); } catch (CoreException e) { } envMap.put(key, translated); @@ -150,9 +151,11 @@ public class BuildInfoFactory { } return new Path(command); } - String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, getString(BuildInfoFactory.BUILD_COMMAND)); + String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, + getString(BuildInfoFactory.BUILD_COMMAND)); try { - result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false); + result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, + false); } catch (CoreException e) { } return new Path(result); @@ -187,9 +190,11 @@ public class BuildInfoFactory { @Override public IPath getBuildLocation() { - String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, getString(BuildInfoFactory.BUILD_LOCATION)); + String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, + getString(BuildInfoFactory.BUILD_LOCATION)); try { - result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false); + result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, + false); } catch (CoreException e) { } return new Path(result); @@ -197,12 +202,14 @@ public class BuildInfoFactory { @Override public String getBuildArguments() { - String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, getString(BuildInfoFactory.BUILD_ARGUMENTS)); + String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, + getString(BuildInfoFactory.BUILD_ARGUMENTS)); if (result == null) { return ""; //$NON-NLS-1$ } try { - result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false); + result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, + false); } catch (CoreException e) { } return result; @@ -232,9 +239,11 @@ public class BuildInfoFactory { @Override public String getAutoBuildTarget() { - String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, getString(BuildInfoFactory.BUILD_TARGET_AUTO)); + String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, + getString(BuildInfoFactory.BUILD_TARGET_AUTO)); try { - result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false); + result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, + false); } catch (CoreException e) { } return result; @@ -251,7 +260,8 @@ public class BuildInfoFactory { String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL)); try { - result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false); + result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, + false); } catch (CoreException e) { } return result; @@ -264,9 +274,11 @@ public class BuildInfoFactory { @Override public String getFullBuildTarget() { - String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL)); + String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, + getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL)); try { - result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false); + result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, + false); } catch (CoreException e) { } return result; @@ -280,9 +292,11 @@ public class BuildInfoFactory { @Override public String getCleanBuildTarget() { - String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, getString(BuildInfoFactory.BUILD_TARGET_CLEAN)); + String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, + getString(BuildInfoFactory.BUILD_TARGET_CLEAN)); try { - result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false); + result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, + false); } catch (CoreException e) { } return result; @@ -446,8 +460,9 @@ public class BuildInfoFactory { } protected abstract void putString(String name, String value) throws CoreException; + protected abstract String getString(String property); - } + } private static class BuildInfoPreference extends AbstractBuildInfo { @@ -507,7 +522,7 @@ public class BuildInfoFactory { // first, give the build-system a chance to return the build-command overlayed with data managed by it ICProjectDescription cProjectDescription = CoreModel.getDefault().getProjectDescription(project, false); - if(cProjectDescription != null) { + if (cProjectDescription != null) { ICConfigurationDescription cConfigDescription = cProjectDescription.getActiveConfiguration(); CConfigurationData configurationData = cConfigDescription.getConfigurationData(); if (configurationData != null) { @@ -518,7 +533,7 @@ public class BuildInfoFactory { } } - if(builder == null) { + if (builder == null) { builder = MakeProjectNature.getBuildSpec(project.getDescription(), builderID); if (builder == null) { throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ListenerList.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ListenerList.java index 3d24d9cc264..d49945a2071 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ListenerList.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ListenerList.java @@ -20,7 +20,7 @@ package org.eclipse.cdt.make.internal.core; * It is a fairly lightweight object, occupying minimal space when * no listeners are registered. *

- * Note that the add method checks for and eliminates + * Note that the add method checks for and eliminates * duplicates based on identity (not equality). Likewise, the * remove method compares based on identity. *

@@ -72,7 +72,7 @@ public class ListenerList { /** * Creates a listener list with the given initial capacity. * - * @param capacity the number of listeners which this list can initially accept + * @param capacity the number of listeners which this list can initially accept * without growing its internal representation; must be at least 1 */ public ListenerList(int capacity) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.java index f8e2a685ccc..5d154052fca 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.java @@ -19,7 +19,7 @@ import java.util.ResourceBundle; public class MakeMessages { - private static final String RESOURCE_BUNDLE= MakeMessages.class.getName(); + private static final String RESOURCE_BUNDLE = MakeMessages.class.getName(); private static ResourceBundle fgResourceBundle; static { try { @@ -28,10 +28,10 @@ public class MakeMessages { fgResourceBundle = null; } } - + private MakeMessages() { } - + public static String getString(String key) { try { return fgResourceBundle.getString(key); @@ -41,10 +41,10 @@ public class MakeMessages { return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ } } - + /** * Gets a string from the resource bundle and formats it with the argument - * + * * @param key the string used to get the bundle value, must not be null */ public static String getFormattedString(String key, Object arg) { @@ -53,7 +53,7 @@ public class MakeMessages { /** * Gets a string from the resource bundle and formats it with arguments - */ + */ public static String getFormattedString(String key, Object[] args) { return MessageFormat.format(getString(key), args); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeRecon.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeRecon.java index 63ced2109c3..47cd1297388 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeRecon.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeRecon.java @@ -38,24 +38,24 @@ public class MakeRecon extends OutputStream { class MyList extends ArrayList { private static final long serialVersionUID = 1L; - public void removeInterval (int start, int len) { + public void removeInterval(int start, int len) { removeRange(start, len); } } - public MakeRecon(IPath buildCommand, String[] buildArguments, - String[] env, IPath workingDirectory, IProgressMonitor mon, OutputStream cos) { - this(buildCommand, new String[]{"-n"}, buildArguments, env, workingDirectory, mon, cos); //$NON-NLS-1$ + public MakeRecon(IPath buildCommand, String[] buildArguments, String[] env, IPath workingDirectory, + IProgressMonitor mon, OutputStream cos) { + this(buildCommand, new String[] { "-n" }, buildArguments, env, workingDirectory, mon, cos); //$NON-NLS-1$ } - public MakeRecon(IPath buildCommand, String[] options, String[] buildArguments, - String[] env, IPath workingDirectory, IProgressMonitor mon, OutputStream cos) { + public MakeRecon(IPath buildCommand, String[] options, String[] buildArguments, String[] env, + IPath workingDirectory, IProgressMonitor mon, OutputStream cos) { make = buildCommand; args = new String[0]; if (options != null) { - String[]array = new String[args.length + options.length]; + String[] array = new String[args.length + options.length]; System.arraycopy(args, 0, array, 0, args.length); System.arraycopy(options, 0, array, args.length, options.length); args = array; diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java index 73f44215043..3648088fa56 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java @@ -54,14 +54,17 @@ public class MakeTarget extends PlatformObject implements IMakeTarget { private Map buildEnvironment = new HashMap<>(); private final Map targetAttributes = new HashMap<>(); - public MakeTarget(MakeTargetManager manager, IProject project, String targetBuilderID, String name) throws CoreException { + public MakeTarget(MakeTargetManager manager, IProject project, String targetBuilderID, String name) + throws CoreException { this.manager = manager; this.project = project; this.targetBuilderID = targetBuilderID; this.name = name; IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(project, manager.getBuilderID(targetBuilderID)); - setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$ - setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$ + setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, + info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$ + setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, + info.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$ isDefaultBuildCmd = info.isDefaultBuildCmd(); isStopOnError = info.isStopOnError(); } @@ -253,7 +256,8 @@ public class MakeTarget extends PlatformObject implements IMakeTarget { String value = entry.getValue(); // translate any string substitution variables String translated = value; - translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value, false); + translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value, + false); envMap.put(key, translated); } return envMap; @@ -288,7 +292,7 @@ public class MakeTarget extends PlatformObject implements IMakeTarget { @Override public boolean appendEnvironment() { - return appendEnvironment == USE_PROJECT_ENV_SETTING ? getProjectEnvSetting(): appendEnvironment == 1; + return appendEnvironment == USE_PROJECT_ENV_SETTING ? getProjectEnvSetting() : appendEnvironment == 1; } private boolean getProjectEnvSetting() { @@ -311,15 +315,16 @@ public class MakeTarget extends PlatformObject implements IMakeTarget { if (obj == this) return true; if (obj instanceof MakeTarget) { - MakeTarget other = (MakeTarget)obj; - return (container != null ? container.equals(other.getContainer()) : other.getContainer() == null) && name.equals(other.getName()); + MakeTarget other = (MakeTarget) obj; + return (container != null ? container.equals(other.getContainer()) : other.getContainer() == null) + && name.equals(other.getName()); } return false; } @Override public int hashCode() { - return container.hashCode() * 17 + name != null ? name.hashCode(): 0; + return container.hashCode() * 17 + name != null ? name.hashCode() : 0; } @Override @@ -328,12 +333,15 @@ public class MakeTarget extends PlatformObject implements IMakeTarget { final HashMap infoMap = new HashMap<>(); IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(infoMap, builderID); - info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$ - info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$ + info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, + getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$ + info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, + getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, "")); //$NON-NLS-1$ info.setUseDefaultBuildCmd(isDefaultBuildCmd()); info.setStopOnError(isStopOnError()); info.setIncrementalBuildEnable(true); - info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, getBuildAttribute(IMakeTarget.BUILD_TARGET, "")); //$NON-NLS-1$ + info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, + getBuildAttribute(IMakeTarget.BUILD_TARGET, "")); //$NON-NLS-1$ info.setCleanBuildEnable(false); info.setEnvironment(getExpandedEnvironment()); info.setAppendEnvironment(appendEnvironment()); @@ -356,7 +364,8 @@ public class MakeTarget extends PlatformObject implements IMakeTarget { SubMonitor subMonitor = SubMonitor.convert(monitor, commands.length); for (ICommand command : commands) { if (command.getBuilderName().equals(builderID)) { - project.build(IncrementalProjectBuilder.FULL_BUILD, builderID, infoMap, subMonitor.newChild(1)); + project.build(IncrementalProjectBuilder.FULL_BUILD, builderID, infoMap, + subMonitor.newChild(1)); } else { project.build(IncrementalProjectBuilder.FULL_BUILD, command.getBuilderName(), command.getArguments(), subMonitor.newChild(1)); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java index 51474b5409b..ef8a33ccb67 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java @@ -71,7 +71,8 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis @Override public void addTarget(IContainer container, IMakeTarget target) throws CoreException { if (container instanceof IWorkspaceRoot) { - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeMessages.getString("MakeTargetManager.add_to_workspace_root"), null)); //$NON-NLS-1$ + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, + MakeMessages.getString("MakeTargetManager.add_to_workspace_root"), null)); //$NON-NLS-1$ } ProjectTargets projectTargets = projectMap.get(target.getProject()); if (projectTargets == null) { @@ -91,7 +92,8 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis @Override public void setTargets(IContainer container, IMakeTarget[] targets) throws CoreException { if (container instanceof IWorkspaceRoot) { - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeMessages.getString("MakeTargetManager.add_to_workspace_root"), null)); //$NON-NLS-1$ + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, + MakeMessages.getString("MakeTargetManager.add_to_workspace_root"), null)); //$NON-NLS-1$ } ProjectTargets projectTargets = projectMap.get(targets[0].getProject()); if (projectTargets == null) { @@ -251,39 +253,45 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis } IResource resource = delta.getResource(); if (resource.getType() == IResource.PROJECT) { - IProject project = (IProject)resource; + IProject project = (IProject) resource; int flags = delta.getFlags(); int deltaKind = delta.getKind(); if (deltaKind == IResourceDelta.ADDED) { if (hasTargetBuilder(project) && !fProjects.contains(project)) { fProjects.add(project); - notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_ADDED, project)); + notifyListeners( + new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_ADDED, project)); } } else if (deltaKind == IResourceDelta.REMOVED) { if (fProjects.contains(project)) { deleteTargets(project); fProjects.remove(project); - notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project)); + notifyListeners( + new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project)); } } else if (deltaKind == IResourceDelta.CHANGED) { if (0 != (flags & IResourceDelta.DESCRIPTION)) { if (fProjects.contains(project) && !hasTargetBuilder(project)) { fProjects.remove(project); projectMap.remove(project); - notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project)); + notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, + project)); } else if (!fProjects.contains(project) && hasTargetBuilder(project)) { fProjects.add(project); - notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_ADDED, project)); + notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_ADDED, + project)); } } if (0 != (flags & IResourceDelta.OPEN)) { if (!project.isOpen() && fProjects.contains(project)) { fProjects.remove(project); projectMap.remove(project); - notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, project)); + notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_REMOVED, + project)); } else if (project.isOpen() && hasTargetBuilder(project) && !fProjects.contains(project)) { fProjects.add(project); - notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_ADDED, project)); + notifyListeners(new MakeTargetEvent(MakeTargetManager.this, MakeTargetEvent.PROJECT_ADDED, + project)); } } } @@ -294,14 +302,14 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis } protected void updateTarget(IMakeTarget target) throws CoreException { - if (target.getContainer() != null ) { // target has not been added to manager. + if (target.getContainer() != null) { // target has not been added to manager. ProjectTargets projectTargets = projectMap.get(target.getProject()); - if (projectTargets == null || !projectTargets.contains(target)) { - return; // target has not been added to manager. - } - writeTargets(projectTargets); - notifyListeners(new MakeTargetEvent(this, MakeTargetEvent.TARGET_CHANGED, target)); - } + if (projectTargets == null || !projectTargets.contains(target)) { + return; // target has not been added to manager. + } + writeTargets(projectTargets); + notifyListeners(new MakeTargetEvent(this, MakeTargetEvent.TARGET_CHANGED, target)); + } } protected void writeTargets(ProjectTargets projectTargets) throws CoreException { @@ -316,8 +324,8 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis protected void deleteTargets(IProject project) { //Historical: We clean up after all other parts. - IPath targetFilePath = - MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT); + IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(project.getName()) + .addFileExtension(TARGETS_EXT); File targetFile = targetFilePath.toFile(); if (targetFile.exists()) { targetFile.delete(); @@ -327,7 +335,8 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis protected void initializeBuilders() { builderMap = new HashMap(); - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.PLUGIN_ID, MakeTargetManager.TARGET_BUILD_EXT); + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.PLUGIN_ID, + MakeTargetManager.TARGET_BUILD_EXT); IExtension[] extensions = point.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] cfgElements = extension.getConfigurationElements(); @@ -343,7 +352,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis protected void notifyListeners(MakeTargetEvent event) { for (Object listener : listeners.getListeners()) { - ((IMakeTargetListener)listener).targetChanged(event); + ((IMakeTargetListener) listener).targetChanged(event); } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java index d332338a392..31b5022031f 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/PreferenceInitializer.java @@ -27,7 +27,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; - public class PreferenceInitializer extends AbstractPreferenceInitializer { /* (non-Javadoc) @@ -35,7 +34,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { */ @Override public void initializeDefaultPreferences() { - IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true); + IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), + MakeBuilder.BUILDER_ID, true); try { info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make"); //$NON-NLS-1$ info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, ""); //$NON-NLS-1$ @@ -52,45 +52,45 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { info.setErrorParsers(CCorePlugin.getDefault().getAllErrorParsersIDs()); } catch (CoreException e) { } - MakeCorePlugin.getDefault().getPluginPreferences().setDefault(CCorePlugin.PREF_BINARY_PARSER, CCorePlugin.PLUGIN_ID + ".ELF"); //$NON-NLS-1$ + MakeCorePlugin.getDefault().getPluginPreferences().setDefault(CCorePlugin.PREF_BINARY_PARSER, + CCorePlugin.PLUGIN_ID + ".ELF"); //$NON-NLS-1$ // default plugin preferences for scanner configuration discovery - IScannerConfigBuilderInfo scInfo = MakeCorePlugin.createScannerConfigBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), ScannerConfigBuilder.BUILDER_ID, true); + IScannerConfigBuilderInfo scInfo = MakeCorePlugin.createScannerConfigBuildInfo( + MakeCorePlugin.getDefault().getPluginPreferences(), ScannerConfigBuilder.BUILDER_ID, true); try { scInfo.setAutoDiscoveryEnabled(true); scInfo.setMakeBuilderConsoleParserEnabled(true); scInfo.setESIProviderCommandEnabled(true); scInfo.setUseDefaultESIProviderCmd(true); scInfo.setESIProviderCommand(new Path("gcc")); //$NON-NLS-1$ - scInfo.setESIProviderArguments("-E -P -v -dD ${plugin_state_location}/${specs_file}"); //$NON-NLS-1$ + scInfo.setESIProviderArguments("-E -P -v -dD ${plugin_state_location}/${specs_file}"); //$NON-NLS-1$ scInfo.setESIProviderConsoleParserId(MakeCorePlugin.GCC_SPECS_CONSOLE_PARSER_ID); scInfo.setMakeBuilderConsoleParserId(MakeCorePlugin.GCC_SCANNER_INFO_CONSOLE_PARSER_ID); scInfo.setSIProblemGenerationEnabled(true); } catch (CoreException e) { } - // default plugin preferences for new scanner configuration discovery - IScannerConfigBuilderInfo2 scInfo2 = ScannerConfigProfileManager. - createScannerConfigBuildInfo2(MakeCorePlugin.getDefault().getPluginPreferences(), - ScannerConfigProfileManager.NULL_PROFILE_ID, true); - scInfo2.setAutoDiscoveryEnabled(true); - scInfo2.setProblemReportingEnabled(true); - scInfo2.setSelectedProfileId(ScannerConfigProfileManager.DEFAULT_SI_PROFILE_ID); - scInfo2.setBuildOutputFileActionEnabled(true); - scInfo2.setBuildOutputFilePath(""); //$NON-NLS-1$ - scInfo2.setBuildOutputParserEnabled(true); - String providerId = "specsFile"; //$NON-NLS-1$ - scInfo2.setProviderOpenFilePath(providerId, "");//$NON-NLS-1$ - scInfo2.setProviderRunCommand(providerId, "gcc"); //$NON-NLS-1$ - scInfo2.setProviderRunArguments(providerId, "-E -P -v -dD ${plugin_state_location}/${specs_file}");//$NON-NLS-1$ - scInfo2.setProviderOutputParserEnabled(providerId, true); - scInfo2.setProblemReportingEnabled(true); - try { - scInfo2.save(); - } - catch (CoreException e) { - } - + // default plugin preferences for new scanner configuration discovery + IScannerConfigBuilderInfo2 scInfo2 = ScannerConfigProfileManager.createScannerConfigBuildInfo2( + MakeCorePlugin.getDefault().getPluginPreferences(), ScannerConfigProfileManager.NULL_PROFILE_ID, true); + scInfo2.setAutoDiscoveryEnabled(true); + scInfo2.setProblemReportingEnabled(true); + scInfo2.setSelectedProfileId(ScannerConfigProfileManager.DEFAULT_SI_PROFILE_ID); + scInfo2.setBuildOutputFileActionEnabled(true); + scInfo2.setBuildOutputFilePath(""); //$NON-NLS-1$ + scInfo2.setBuildOutputParserEnabled(true); + String providerId = "specsFile"; //$NON-NLS-1$ + scInfo2.setProviderOpenFilePath(providerId, "");//$NON-NLS-1$ + scInfo2.setProviderRunCommand(providerId, "gcc"); //$NON-NLS-1$ + scInfo2.setProviderRunArguments(providerId, "-E -P -v -dD ${plugin_state_location}/${specs_file}");//$NON-NLS-1$ + scInfo2.setProviderOutputParserEnabled(providerId, true); + scInfo2.setProblemReportingEnabled(true); + try { + scInfo2.save(); + } catch (CoreException e) { + } + // Store default for makefile MakeCorePlugin.getDefault().getPluginPreferences().setDefault(MakeCorePlugin.MAKEFILE_STYLE, "GNU"); //$NON-NLS-1$ } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java index cad5db05273..47258024a0c 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java @@ -76,8 +76,8 @@ public class ProjectTargets { //Historical ... fall back to the workspace and look in previous XML file location if (rootElement.getChildren().length == 0) { - IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension( - TARGETS_EXT); + IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(project.getName()) + .addFileExtension(TARGETS_EXT); targetFile = targetFilePath.toFile(); try { InputStream input = new FileInputStream(targetFile); @@ -174,7 +174,7 @@ public class ProjectTargets { /** * Persist the MakeTarget as a child of parent - * + * * @return created ICStorageElement */ private ICStorageElement createTargetElement(ICStorageElement parent, IMakeTarget target) { @@ -186,7 +186,7 @@ public class ProjectTargets { elem.setValue(target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make")); //$NON-NLS-1$ String targetAttr = target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null); - if ( targetAttr != null) { + if (targetAttr != null) { elem = targetElem.createChild(TARGET_ARGUMENTS); elem.setValue(targetAttr); } @@ -232,7 +232,7 @@ public class ProjectTargets { /** * This method loads an old style XML document provided in the input stream * and returns an ICStorageElemnt wrapping it. - * + * * @return ICStorageElement or null */ protected ICStorageElement translateInputStreamToDocument(InputStream input) { @@ -272,11 +272,11 @@ public class ProjectTargets { if (option.length > 0) { target.setStopOnError(Boolean.valueOf(option[0].getValue()).booleanValue()); } - option = node.getChildrenByName(TARGET_USE_DEFAULT_CMD); + option = node.getChildrenByName(TARGET_USE_DEFAULT_CMD); if (option.length > 0) { target.setUseDefaultBuildCmd(Boolean.valueOf(option[0].getValue()).booleanValue()); } - option = node.getChildrenByName(TARGET_COMMAND); + option = node.getChildrenByName(TARGET_COMMAND); if (option.length > 0) { target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, option[0].getValue()); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeCDataFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeCDataFactory.java index 023a4d08288..e0fe16e5b63 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeCDataFactory.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeCDataFactory.java @@ -21,27 +21,26 @@ import org.eclipse.cdt.core.settings.model.util.CDataUtil; public class MakeCDataFactory extends CDataFactory { private static MakeCDataFactory fInstance; - - public static CDataFactory getDefault(){ - if(fInstance == null){ + + public static CDataFactory getDefault() { + if (fInstance == null) { fInstance = new MakeCDataFactory(); } return fInstance; } @Override - public CLanguageData createLanguageData(CConfigurationData cfg, - CResourceData rcBase, CLanguageData base, String id, boolean clone) { - if(id == null) + public CLanguageData createLanguageData(CConfigurationData cfg, CResourceData rcBase, CLanguageData base, String id, + boolean clone) { + if (id == null) id = clone ? base.getId() : CDataUtil.genId(rcBase.getId()); return new MakeLanguageData(id, base); } @Override - public CLanguageData createLanguageData(CConfigurationData cfg, - CResourceData rcBase, String id, String name, String languageId, - int supportedKinds, String[] rcTypes, boolean isContentTypes) { - if(id == null) + public CLanguageData createLanguageData(CConfigurationData cfg, CResourceData rcBase, String id, String name, + String languageId, int supportedKinds, String[] rcTypes, boolean isContentTypes) { + if (id == null) id = CDataUtil.genId(rcBase.getId()); MakeLanguageData lData = new MakeLanguageData(id, name, languageId, supportedKinds, rcTypes, isContentTypes); return lData; diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeConfigurationDataProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeConfigurationDataProvider.java index a9143f4124d..1e547d93e5c 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeConfigurationDataProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeConfigurationDataProvider.java @@ -46,19 +46,20 @@ public class MakeConfigurationDataProvider extends CDefaultConfigurationDataProv @Override public CConfigurationData applyConfiguration(ICConfigurationDescription cfgDescription, - ICConfigurationDescription baseCfgDescription, CConfigurationData baseData, - IProgressMonitor monitor) throws CoreException { + ICConfigurationDescription baseCfgDescription, CConfigurationData baseData, IProgressMonitor monitor) + throws CoreException { CConfigurationData result = super.applyConfiguration(cfgDescription, baseCfgDescription, baseData, monitor); - if(!cfgDescription.isPreferenceConfiguration()) + if (!cfgDescription.isPreferenceConfiguration()) updateDiscoveredInfo(cfgDescription.getProjectDescription().getProject(), result); return result; } @Override - public CConfigurationData loadConfiguration(ICConfigurationDescription cfgDescription, IProgressMonitor monitor) throws CoreException { + public CConfigurationData loadConfiguration(ICConfigurationDescription cfgDescription, IProgressMonitor monitor) + throws CoreException { CConfigurationData result = super.loadConfiguration(cfgDescription, monitor); - if(!cfgDescription.isPreferenceConfiguration()) + if (!cfgDescription.isPreferenceConfiguration()) updateDiscoveredInfo(cfgDescription.getProjectDescription().getProject(), result); return result; } @@ -74,7 +75,7 @@ public class MakeConfigurationDataProvider extends CDefaultConfigurationDataProv processor.applyDiscoveredInfo(cfgData, dsInfo); } - protected CDataDiscoveredInfoProcessor getInfoProcessor( ){ + protected CDataDiscoveredInfoProcessor getInfoProcessor() { return MakeDiscoveredInfoProcessor.getDefault(); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeDiscoveredInfoProcessor.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeDiscoveredInfoProcessor.java index 42d6896a4ac..dbb30bb59f1 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeDiscoveredInfoProcessor.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeDiscoveredInfoProcessor.java @@ -21,18 +21,17 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.CDataDiscoveredInfoProce public class MakeDiscoveredInfoProcessor extends CDataDiscoveredInfoProcessor { private static MakeDiscoveredInfoProcessor fInstance; - - public static MakeDiscoveredInfoProcessor getDefault(){ - if(fInstance == null) + + public static MakeDiscoveredInfoProcessor getDefault() { + if (fInstance == null) fInstance = new MakeDiscoveredInfoProcessor(); return fInstance; } @Override - protected void setInfoForData(CConfigurationData cfgData, - CResourceData rcData, CLanguageData data, PathInfo pi, + protected void setInfoForData(CConfigurationData cfgData, CResourceData rcData, CLanguageData data, PathInfo pi, CResourceData baseRcData, CLanguageData baseLangData) { - MakeLanguageData mld = (MakeLanguageData)data; + MakeLanguageData mld = (MakeLanguageData) data; mld.setDiscoveredInfo(pi); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeLanguageData.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeLanguageData.java index 67b9ae1fc85..6ee4e67a1ec 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeLanguageData.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/dataprovider/MakeLanguageData.java @@ -21,7 +21,7 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.util.PathInfoToLangSetti public class MakeLanguageData extends UserAndDiscoveredEntryLanguageData { private PathInfo fDiscoveredCache; - + public MakeLanguageData() { super(); } @@ -40,25 +40,22 @@ public class MakeLanguageData extends UserAndDiscoveredEntryLanguageData { @Override protected void copySettingsFrom(CLanguageData data) { super.copySettingsFrom(data); - if(data instanceof MakeLanguageData){ - fDiscoveredCache = ((MakeLanguageData)data).fDiscoveredCache; + if (data instanceof MakeLanguageData) { + fDiscoveredCache = ((MakeLanguageData) data).fDiscoveredCache; } } @Override protected ICLanguageSettingEntry[] getAllDiscoveredEntries(int kind) { - if(fDiscoveredCache != null){ + if (fDiscoveredCache != null) { int roFlag = canDisableDiscoveredEntries(kind) ? 0 : ICLanguageSettingEntry.READONLY; - return PathInfoToLangSettingsConverter.entriesForKind(kind, - roFlag - | ICLanguageSettingEntry.BUILTIN - | ICLanguageSettingEntry.RESOLVED, - fDiscoveredCache); + return PathInfoToLangSettingsConverter.entriesForKind(kind, + roFlag | ICLanguageSettingEntry.BUILTIN | ICLanguageSettingEntry.RESOLVED, fDiscoveredCache); } return null; } - - protected void setDiscoveredInfo(PathInfo info){ + + protected void setDiscoveredInfo(PathInfo info) { fDiscoveredCache = info; } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/AbstractMakefile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/AbstractMakefile.java index c8c9d9356c3..d61d5947e53 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/AbstractMakefile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/AbstractMakefile.java @@ -226,7 +226,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { StringBuilder macroName = new StringBuilder(); for (int i = 0; i < len; i++) { char c = line.charAt(i); - switch(c) { + switch (c) { case '$': // '$$' --> '$' if (foundDollar) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/Command.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/Command.java index 7feadb00a31..69f4e9d92b9 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/Command.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/Command.java @@ -84,7 +84,7 @@ public class Command extends Directive implements ICommand { @Override public String toString() { StringBuilder cmd = new StringBuilder(); - cmd.append( '\t'); + cmd.append('\t'); if (getPrefix() != 0) { cmd.append(getPrefix()); } @@ -116,7 +116,7 @@ public class Command extends Directive implements ICommand { */ @Override public Process execute(String shell, String[] envp, File dir) throws IOException { - String[] cmdArray = new String[] { shell, "-c", command}; //$NON-NLS-1$ + String[] cmdArray = new String[] { shell, "-c", command }; //$NON-NLS-1$ return Runtime.getRuntime().exec(cmdArray, envp, dir); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MacroDefinition.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MacroDefinition.java index c230cf5f6a3..f435da77ca5 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MacroDefinition.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MacroDefinition.java @@ -38,7 +38,7 @@ public class MacroDefinition extends Directive implements IMacroDefinition { } public void setName(String n) { - name = (n == null) ? "" : n.trim() ; //$NON-NLS-1$ + name = (n == null) ? "" : n.trim(); //$NON-NLS-1$ } @Override diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakeFileConstants.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakeFileConstants.java index ab873b2c053..fe44c962603 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakeFileConstants.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakeFileConstants.java @@ -13,15 +13,14 @@ *******************************************************************************/ package org.eclipse.cdt.make.internal.core.makefile; - public class MakeFileConstants { - public static final String RULE_DEFAULT = ".DEFAULT"; //$NON-NLS-1$ - public static final String RULE_IGNORE =".IGNORE"; //$NON-NLS-1$ - public static final String RULE_POSIX = ".POSIX"; //$NON-NLS-1$ - public static final String RULE_PRECIOUS = ".PRECIOUS"; //$NON-NLS-1$ - public static final String RULE_SCCS_GET = ".SCCS_GET"; //$NON-NLS-1$ - public static final String RULE_SILENT = ".SILENT"; //$NON-NLS-1$ - public static final String RULE_SUFFIXES = ".SUFFIXES"; //$NON-NLS-1$ + public static final String RULE_DEFAULT = ".DEFAULT"; //$NON-NLS-1$ + public static final String RULE_IGNORE = ".IGNORE"; //$NON-NLS-1$ + public static final String RULE_POSIX = ".POSIX"; //$NON-NLS-1$ + public static final String RULE_PRECIOUS = ".PRECIOUS"; //$NON-NLS-1$ + public static final String RULE_SCCS_GET = ".SCCS_GET"; //$NON-NLS-1$ + public static final String RULE_SILENT = ".SILENT"; //$NON-NLS-1$ + public static final String RULE_SUFFIXES = ".SUFFIXES"; //$NON-NLS-1$ } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakefileMessages.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakefileMessages.java index a93360addd7..f9079b416c0 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakefileMessages.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakefileMessages.java @@ -18,19 +18,18 @@ import java.util.ResourceBundle; public class MakefileMessages { - private static final String BUNDLE_NAME = "org.eclipse.cdt.make.internal.core.makefile.MakeFileResources";//$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.eclipse.cdt.make.internal.core.makefile.MakeFileResources";//$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - private MakefileMessages() { - } + private MakefileMessages() { + } - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakefileReader.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakefileReader.java index 37e95bb189d..601a186bdb4 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakefileReader.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakefileReader.java @@ -21,7 +21,6 @@ import java.io.Reader; */ public class MakefileReader extends LineNumberReader { - public MakefileReader(Reader reader) { super(reader); } @@ -30,7 +29,6 @@ public class MakefileReader extends LineNumberReader { super(reader, sz); } - @Override public String readLine() throws IOException { boolean done = false; @@ -47,7 +45,7 @@ public class MakefileReader extends LineNumberReader { // Eat the spaces at the beginning. int i = 0; while (i < line.length() && (Util.isSpace(line.charAt(i)))) { - i++ ; + i++; } line = line.substring(i); } else if (escapedCommand && line.length() > 0) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/NullMakefile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/NullMakefile.java index 52f15dbd29b..58970fc0805 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/NullMakefile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/NullMakefile.java @@ -79,6 +79,7 @@ public class NullMakefile extends AbstractMakefile { public void parse(String name, IMakefileReaderProvider makefileReaderProvider) throws IOException { } + @Override public void parse(URI fileURI, Reader makefile) throws IOException { } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/Util.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/Util.java index 238321687d6..40af6a7b6b7 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/Util.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/Util.java @@ -45,7 +45,7 @@ public class Util { } public static boolean isSpace(char c) { - return (c == ' ' || c == '\t' || c == '\r' || c == '\n'); + return (c == ' ' || c == '\t' || c == '\r' || c == '\n'); } public static int indexOf(String line, char c) { @@ -65,7 +65,7 @@ public class Util { char ch = line.charAt(i); if (ch == '(' && prev == '$' && pprev != '\\') { paren++; - } else if (ch == '{' && prev == '$' && pprev != '\\') { + } else if (ch == '{' && prev == '$' && pprev != '\\') { bracket++; } else if (ch == ')' && prev != '\\') { if (paren > 0) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/AutomaticVariable.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/AutomaticVariable.java index 47ad418802f..bd32d5afc77 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/AutomaticVariable.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/AutomaticVariable.java @@ -16,11 +16,10 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.core.makefile.IAutomaticVariable; import org.eclipse.cdt.make.internal.core.makefile.Directive; - /** * Represents an automatic variable. Automatic variables are implicit and * computed for each rule that is applied. - * + * * @author Sebastian Bauer * @see "http://www.gnu.org/software/make/manual/make.html#Automatic-Variables" */ diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/BuiltinFunction.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/BuiltinFunction.java index 21c512c0b2e..4a92e580d38 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/BuiltinFunction.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/BuiltinFunction.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.make.core.makefile.IDirective; import org.eclipse.cdt.make.core.makefile.IMakefile; import org.eclipse.cdt.make.internal.core.makefile.Directive; - /** * Represents GNUmakefile built-in internal functions. */ diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Conditional.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Conditional.java index 7e519dacd30..28f6041ea21 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Conditional.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Conditional.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.make.internal.core.makefile.Parent; public abstract class Conditional extends Parent implements IConditional { - private static final String EMPTY = ""; //$NON-NLS-1$ + private static final String EMPTY = ""; //$NON-NLS-1$ String cond; String arg1; String arg2; @@ -41,7 +41,6 @@ public abstract class Conditional extends Parent implements IConditional { cond = conditional; } - @Override public String getConditional() { return cond; diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/DefineVariable.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/DefineVariable.java index 6958122c513..417f7de4103 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/DefineVariable.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/DefineVariable.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class DefineVariable extends VariableDefinition { public DefineVariable(Directive parent, String name, StringBuffer value) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Else.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Else.java index 8b04ca05004..084f37af7a7 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Else.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Else.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class Else extends Conditional { public Else(Directive parent) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Endef.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Endef.java index 3139689af63..6a4bad09da2 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Endef.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Endef.java @@ -17,7 +17,6 @@ import org.eclipse.cdt.make.internal.core.makefile.Directive; public class Endef extends Terminal { - public Endef(Directive parent) { super(parent); } @@ -26,9 +25,9 @@ public class Endef extends Terminal { public boolean isEndef() { return true; } - + @Override public String toString() { - return GNUMakefileConstants.TERMINAL_ENDEF; - } + return GNUMakefileConstants.TERMINAL_ENDEF; + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Endif.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Endif.java index fed01dde7b8..6694633cf06 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Endif.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Endif.java @@ -25,9 +25,9 @@ public class Endif extends Terminal { public boolean isEndif() { return true; } - - @Override + + @Override public String toString() { - return GNUMakefileConstants.TERMINAL_ENDIF; - } + return GNUMakefileConstants.TERMINAL_ENDIF; + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/ExportVariable.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/ExportVariable.java index 8bd7b088e79..d3d3a35b059 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/ExportVariable.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/ExportVariable.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class ExportVariable extends VariableDefinition { public ExportVariable(Directive parent, String name, StringBuffer value, int type) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefile.java index 234948257d8..c173fe8aee2 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefile.java @@ -81,68 +81,46 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { private String[] includeDirectories = new String[0]; private IDirective[] builtins = new IDirective[0]; @SuppressWarnings("nls") - private IAutomaticVariable[] autoVariables = new IAutomaticVariable[]{ - new AutomaticVariable(this, "@", MakefileMessages.getString("GNUMakefile.automaticVariable.at")), - new AutomaticVariable(this, "%", MakefileMessages.getString("GNUMakefile.automaticVariable.percent")), - new AutomaticVariable(this, "<", MakefileMessages.getString("GNUMakefile.automaticVariable.less")), - new AutomaticVariable(this, "?", MakefileMessages.getString("GNUMakefile.automaticVariable.question")), - new AutomaticVariable(this, "^", MakefileMessages.getString("GNUMakefile.automaticVariable.carrot")), - new AutomaticVariable(this, "+", MakefileMessages.getString("GNUMakefile.automaticVariable.plus")), - new AutomaticVariable(this, "|", MakefileMessages.getString("GNUMakefile.automaticVariable.pipe")), - new AutomaticVariable(this, "*", MakefileMessages.getString("GNUMakefile.automaticVariable.star")), - }; + private IAutomaticVariable[] autoVariables = new IAutomaticVariable[] { + new AutomaticVariable(this, "@", MakefileMessages.getString("GNUMakefile.automaticVariable.at")), + new AutomaticVariable(this, "%", MakefileMessages.getString("GNUMakefile.automaticVariable.percent")), + new AutomaticVariable(this, "<", MakefileMessages.getString("GNUMakefile.automaticVariable.less")), + new AutomaticVariable(this, "?", MakefileMessages.getString("GNUMakefile.automaticVariable.question")), + new AutomaticVariable(this, "^", MakefileMessages.getString("GNUMakefile.automaticVariable.carrot")), + new AutomaticVariable(this, "+", MakefileMessages.getString("GNUMakefile.automaticVariable.plus")), + new AutomaticVariable(this, "|", MakefileMessages.getString("GNUMakefile.automaticVariable.pipe")), + new AutomaticVariable(this, "*", MakefileMessages.getString("GNUMakefile.automaticVariable.star")), }; @SuppressWarnings("nls") - private final static String[] functions = { - "subst", "patsubst", "strip", "findstring", - "filter", "filter-out", "sort", - "word", "words", "wordlist", "firstword", "lastword", - "dir", "notdir", - "suffix", "basename", "addsuffix", "addprefix", - "join", "wildcard", "realpath", "abspath", - "if", "or", "and", "foreach", - "call", "value", "eval", "origin", "flavor", - "shell", "error", "warning", "info", - }; + private final static String[] functions = { "subst", "patsubst", "strip", "findstring", "filter", "filter-out", + "sort", "word", "words", "wordlist", "firstword", "lastword", "dir", "notdir", "suffix", "basename", + "addsuffix", "addprefix", "join", "wildcard", "realpath", "abspath", "if", "or", "and", "foreach", "call", + "value", "eval", "origin", "flavor", "shell", "error", "warning", "info", }; @SuppressWarnings("nls") - private IBuiltinFunction[] builtinFunctions = new IBuiltinFunction[]{ - new BuiltinFunction(this, "$(subst from,to,text)"), - new BuiltinFunction(this, "$(patsubst pattern,replacement,text)"), - new BuiltinFunction(this, "$(strip string)"), - new BuiltinFunction(this, "$(findstring find,in)"), - new BuiltinFunction(this, "$(filter pattern,text)"), - new BuiltinFunction(this, "$(filter-out pattern,text)"), - new BuiltinFunction(this, "$(sort list)"), - new BuiltinFunction(this, "$(word n,text)"), - new BuiltinFunction(this, "$(words text)"), - new BuiltinFunction(this, "$(wordlist s,e,text)"), - new BuiltinFunction(this, "$(firstword names)"), - new BuiltinFunction(this, "$(lastword names)"), - new BuiltinFunction(this, "$(dir names)"), - new BuiltinFunction(this, "$(notdir names)"), - new BuiltinFunction(this, "$(suffix names)"), - new BuiltinFunction(this, "$(basename names)"), - new BuiltinFunction(this, "$(addsuffix suffix,names)"), - new BuiltinFunction(this, "$(addprefix prefix,names)"), - new BuiltinFunction(this, "$(join list1,list2)"), - new BuiltinFunction(this, "$(wildcard pattern)"), - new BuiltinFunction(this, "$(realpath names)"), - new BuiltinFunction(this, "$(abspath names)"), - new BuiltinFunction(this, "$(if condition,then-part,else-part)"), - new BuiltinFunction(this, "$(or condition1,condition2,...)"), - new BuiltinFunction(this, "$(and condition1,condition2,...)"), - new BuiltinFunction(this, "$(foreach var,list,text)"), - new BuiltinFunction(this, "$(call variable,param,...)"), - new BuiltinFunction(this, "$(value variable)"), - new BuiltinFunction(this, "$(eval expression)"), - new BuiltinFunction(this, "$(origin variable)"), - new BuiltinFunction(this, "$(flavor variable)"), - new BuiltinFunction(this, "$(shell command)"), - new BuiltinFunction(this, "$(error error: text)"), - new BuiltinFunction(this, "$(warning warning: text)"), - new BuiltinFunction(this, "$(info info: text)"), - }; + private IBuiltinFunction[] builtinFunctions = new IBuiltinFunction[] { + new BuiltinFunction(this, "$(subst from,to,text)"), + new BuiltinFunction(this, "$(patsubst pattern,replacement,text)"), + new BuiltinFunction(this, "$(strip string)"), new BuiltinFunction(this, "$(findstring find,in)"), + new BuiltinFunction(this, "$(filter pattern,text)"), + new BuiltinFunction(this, "$(filter-out pattern,text)"), new BuiltinFunction(this, "$(sort list)"), + new BuiltinFunction(this, "$(word n,text)"), new BuiltinFunction(this, "$(words text)"), + new BuiltinFunction(this, "$(wordlist s,e,text)"), new BuiltinFunction(this, "$(firstword names)"), + new BuiltinFunction(this, "$(lastword names)"), new BuiltinFunction(this, "$(dir names)"), + new BuiltinFunction(this, "$(notdir names)"), new BuiltinFunction(this, "$(suffix names)"), + new BuiltinFunction(this, "$(basename names)"), new BuiltinFunction(this, "$(addsuffix suffix,names)"), + new BuiltinFunction(this, "$(addprefix prefix,names)"), new BuiltinFunction(this, "$(join list1,list2)"), + new BuiltinFunction(this, "$(wildcard pattern)"), new BuiltinFunction(this, "$(realpath names)"), + new BuiltinFunction(this, "$(abspath names)"), + new BuiltinFunction(this, "$(if condition,then-part,else-part)"), + new BuiltinFunction(this, "$(or condition1,condition2,...)"), + new BuiltinFunction(this, "$(and condition1,condition2,...)"), + new BuiltinFunction(this, "$(foreach var,list,text)"), + new BuiltinFunction(this, "$(call variable,param,...)"), new BuiltinFunction(this, "$(value variable)"), + new BuiltinFunction(this, "$(eval expression)"), new BuiltinFunction(this, "$(origin variable)"), + new BuiltinFunction(this, "$(flavor variable)"), new BuiltinFunction(this, "$(shell command)"), + new BuiltinFunction(this, "$(error error: text)"), new BuiltinFunction(this, "$(warning warning: text)"), + new BuiltinFunction(this, "$(info info: text)"), }; private IMakefileReaderProvider makefileReaderProvider; @@ -161,8 +139,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { } @Override - public void parse(URI fileURI, - IMakefileReaderProvider makefileReaderProvider) throws IOException { + public void parse(URI fileURI, IMakefileReaderProvider makefileReaderProvider) throws IOException { this.makefileReaderProvider = makefileReaderProvider; MakefileReader reader; if (makefileReaderProvider == null) { @@ -173,8 +150,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { throw new IOException(); } - reader = new MakefileReader(new InputStreamReader( - store.openInputStream(EFS.NONE, null))); + reader = new MakefileReader(new InputStreamReader(store.openInputStream(EFS.NONE, null))); } catch (CoreException e) { MakeCorePlugin.log(e); throw new IOException(e.getMessage()); @@ -190,7 +166,6 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { parse(filePath, new MakefileReader(reader)); } - protected void parse(URI fileURI, MakefileReader reader) throws IOException { String line; Rule[] rules = null; @@ -485,7 +460,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { protected SpecialRule parseSpecialRule(String line) { line = line.trim(); - String keyword = null; + String keyword = null; String[] reqs = null; SpecialRule special = null; int index = Util.indexOf(line, ':'); @@ -693,7 +668,8 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { GNUTargetRule[] rules = new GNUTargetRule[targetNames.length]; for (int i = 0; i < targetNames.length; i++) { - rules[i] = new GNUTargetRule(this, new Target(targetNames[i]), doubleColon, normalReqs, orderReqs, new Command[0]); + rules[i] = new GNUTargetRule(this, new Target(targetNames[i]), doubleColon, normalReqs, orderReqs, + new Command[0]); if (cmd != null) { rules[i].addDirective(new Command(this, cmd)); } @@ -773,8 +749,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { // Check for "+=", ":=", "?=" if (index > 0) { type = line.charAt(index - 1); - if (type == VariableDefinition.TYPE_SIMPLE_EXPAND - || type == VariableDefinition.TYPE_APPEND + if (type == VariableDefinition.TYPE_SIMPLE_EXPAND || type == VariableDefinition.TYPE_APPEND || type == VariableDefinition.TYPE_CONDITIONAL) { separator = index - 1; } else { @@ -836,7 +811,8 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { StaticTargetRule[] staticRules = new StaticTargetRule[targets.length]; for (int i = 0; i < targets.length; i++) { - staticRules[i] = new StaticTargetRule(this, new Target(targets[i]), targetPattern, prereqPatterns, new Command[0]); + staticRules[i] = new StaticTargetRule(this, new Target(targets[i]), targetPattern, prereqPatterns, + new Command[0]); } return staticRules; } @@ -861,12 +837,12 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { public IAutomaticVariable[] getAutomaticVariables() { return autoVariables; } - + @Override public IBuiltinFunction[] getBuiltinFunctions() { return builtinFunctions; } - + @Override public void setIncludeDirectories(String[] dirs) { includeDirectories = dirs; diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileChecker.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileChecker.java index 74d189d6d59..c22fa966e3a 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileChecker.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileChecker.java @@ -70,7 +70,8 @@ public class GNUMakefileChecker extends ACBuilder { * @see IncrementalProjectBuilder#build */ @Override - protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) throws CoreException { + protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) + throws CoreException { if (DEBUG_EVENTS) { @SuppressWarnings("unchecked") Map pargs = args; @@ -135,7 +136,7 @@ public class GNUMakefileChecker extends ACBuilder { // FIXME: Find the candidate in the store somewhere. IFile defaultMakefile = proj.getFile(new Path("Makefile")); //$NON-NLS-1$ if (defaultMakefile.exists()) { - return new IFile[] {defaultMakefile}; + return new IFile[] { defaultMakefile }; } return new IFile[0]; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileConstants.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileConstants.java index 5144963fded..a33dc7ee27e 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileConstants.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileConstants.java @@ -15,33 +15,32 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.MakeFileConstants; - public class GNUMakefileConstants extends MakeFileConstants { - public static final String CONDITIONAL_ELSE = "else"; //$NON-NLS-1$ - public static final String CONDITIONAL_IFNEQ = "ifneq"; //$NON-NLS-1$ - public static final String CONDITIONAL_IFNDEF = "ifndef"; //$NON-NLS-1$ - public static final String CONDITIONAL_IFEQ = "ifeq"; //$NON-NLS-1$ - public static final String CONDITIONAL_IFDEF = "ifdef"; //$NON-NLS-1$ - - public static final String TERMINAL_ENDEF = "endef"; //$NON-NLS-1$ - public static final String TERMINAL_ENDIF = "endif"; //$NON-NLS-1$ - - public static final String DIRECTIVE_VPATH = "vpath"; //$NON-NLS-1$ - public static final String DIRECTIVE_UNEXPORT = "unexport"; //$NON-NLS-1$ - - public static final String VARIABLE_DEFINE = "define"; //$NON-NLS-1$ - public static final String VARIABLE_EXPORT = "export"; //$NON-NLS-1$ - public static final String VARIABLE_OVERRIDE = "override"; //$NON-NLS-1$ - - public static final String FUNCTION_CALL = "call"; //$NON-NLS-1$ - - public static final String DIRECTIVE_INCLUDE = "include"; //$NON-NLS-1$ - - public static final String RULE_DELETE_ON_ERROR = ".DELETE_ON_ERROR"; //$NON-NLS-1$ - public static final String RULE_PHONY = ".PHONY"; //$NON-NLS-1$ - public static final String RULE_SECONDARY = ".SECONDARY"; //$NON-NLS-1$ - public static final String RULE_LOW_RESOLUTION_TIME = ".LOW_RESOLUTION_TIME"; //$NON-NLS-1$ - public static final String RULE_NOT_PARALLEL = ".NOTPARALLEL"; //$NON-NLS-1$ - public static final String RULE_EXPORT_ALL_VARIABLES = ".EXPORT_ALL_VARIABLES"; //$NON-NLS-1$ - public static final String RULE_INTERMEDIATE = ".INTERMEDIATE"; //$NON-NLS-1$ + public static final String CONDITIONAL_ELSE = "else"; //$NON-NLS-1$ + public static final String CONDITIONAL_IFNEQ = "ifneq"; //$NON-NLS-1$ + public static final String CONDITIONAL_IFNDEF = "ifndef"; //$NON-NLS-1$ + public static final String CONDITIONAL_IFEQ = "ifeq"; //$NON-NLS-1$ + public static final String CONDITIONAL_IFDEF = "ifdef"; //$NON-NLS-1$ + + public static final String TERMINAL_ENDEF = "endef"; //$NON-NLS-1$ + public static final String TERMINAL_ENDIF = "endif"; //$NON-NLS-1$ + + public static final String DIRECTIVE_VPATH = "vpath"; //$NON-NLS-1$ + public static final String DIRECTIVE_UNEXPORT = "unexport"; //$NON-NLS-1$ + + public static final String VARIABLE_DEFINE = "define"; //$NON-NLS-1$ + public static final String VARIABLE_EXPORT = "export"; //$NON-NLS-1$ + public static final String VARIABLE_OVERRIDE = "override"; //$NON-NLS-1$ + + public static final String FUNCTION_CALL = "call"; //$NON-NLS-1$ + + public static final String DIRECTIVE_INCLUDE = "include"; //$NON-NLS-1$ + + public static final String RULE_DELETE_ON_ERROR = ".DELETE_ON_ERROR"; //$NON-NLS-1$ + public static final String RULE_PHONY = ".PHONY"; //$NON-NLS-1$ + public static final String RULE_SECONDARY = ".SECONDARY"; //$NON-NLS-1$ + public static final String RULE_LOW_RESOLUTION_TIME = ".LOW_RESOLUTION_TIME"; //$NON-NLS-1$ + public static final String RULE_NOT_PARALLEL = ".NOTPARALLEL"; //$NON-NLS-1$ + public static final String RULE_EXPORT_ALL_VARIABLES = ".EXPORT_ALL_VARIABLES"; //$NON-NLS-1$ + public static final String RULE_INTERMEDIATE = ".INTERMEDIATE"; //$NON-NLS-1$ } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileUtil.java index 2dda288c899..9f14100a01b 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileUtil.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileUtil.java @@ -23,30 +23,39 @@ public class GNUMakefileUtil extends PosixMakefileUtil { public static boolean isInclude(String line) { line = line.trim(); - boolean isInclude = line.startsWith(GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 7 && Character.isWhitespace(line.charAt(7)); - boolean isDashInclude = line.startsWith("-" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); //$NON-NLS-1$ - boolean isSInclude = line.startsWith("s" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); //$NON-NLS-1$ + boolean isInclude = line.startsWith(GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 7 + && Character.isWhitespace(line.charAt(7)); + boolean isDashInclude = line.startsWith("-" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 //$NON-NLS-1$ + && Character.isWhitespace(line.charAt(8)); + boolean isSInclude = line.startsWith("s" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 //$NON-NLS-1$ + && Character.isWhitespace(line.charAt(8)); return isInclude || isDashInclude || isSInclude; } public static boolean isVPath(String line) { line = line.trim(); - return line.equals(GNUMakefileConstants.DIRECTIVE_VPATH) || line.startsWith(GNUMakefileConstants.DIRECTIVE_VPATH) && line.length() > 5 && Character.isWhitespace(line.charAt(5)); + return line.equals(GNUMakefileConstants.DIRECTIVE_VPATH) + || line.startsWith(GNUMakefileConstants.DIRECTIVE_VPATH) && line.length() > 5 + && Character.isWhitespace(line.charAt(5)); } public static boolean isExport(String line) { line = line.trim(); - return line.equals(GNUMakefileConstants.VARIABLE_EXPORT) || line.startsWith(GNUMakefileConstants.VARIABLE_EXPORT) && line.length() > 6 && Character.isWhitespace(line.charAt(6)); + return line.equals(GNUMakefileConstants.VARIABLE_EXPORT) + || line.startsWith(GNUMakefileConstants.VARIABLE_EXPORT) && line.length() > 6 + && Character.isWhitespace(line.charAt(6)); } public static boolean isUnExport(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.DIRECTIVE_UNEXPORT) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); + return line.startsWith(GNUMakefileConstants.DIRECTIVE_UNEXPORT) && line.length() > 8 + && Character.isWhitespace(line.charAt(8)); } public static boolean isDefine(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.VARIABLE_DEFINE) && line.length() > 6 && Character.isWhitespace(line.charAt(6)); + return line.startsWith(GNUMakefileConstants.VARIABLE_DEFINE) && line.length() > 6 + && Character.isWhitespace(line.charAt(6)); } public static boolean isEndef(String line) { @@ -55,27 +64,32 @@ public class GNUMakefileUtil extends PosixMakefileUtil { public static boolean isOverride(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.VARIABLE_OVERRIDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); + return line.startsWith(GNUMakefileConstants.VARIABLE_OVERRIDE) && line.length() > 8 + && Character.isWhitespace(line.charAt(8)); } public static boolean isIfeq(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFEQ) && line.length() > 4 && Character.isWhitespace(line.charAt(4)); + return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFEQ) && line.length() > 4 + && Character.isWhitespace(line.charAt(4)); } public static boolean isIfneq(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNEQ) && line.length() > 5 && Character.isWhitespace(line.charAt(5)); + return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNEQ) && line.length() > 5 + && Character.isWhitespace(line.charAt(5)); } public static boolean isIfdef(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFDEF) && line.length() > 5 && Character.isWhitespace(line.charAt(5)); + return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFDEF) && line.length() > 5 + && Character.isWhitespace(line.charAt(5)); } public static boolean isIfndef(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNDEF) && line.length() > 6 && Character.isWhitespace(line.charAt(6)); + return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNDEF) && line.length() > 6 + && Character.isWhitespace(line.charAt(6)); } public static boolean isElse(String line) { @@ -90,7 +104,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil { line = line.trim(); if (line.startsWith(GNUMakefileConstants.VARIABLE_OVERRIDE)) { int i = 8; - while(i < line.length() && Character.isWhitespace(line.charAt(i))) { + while (i < line.length() && Character.isWhitespace(line.charAt(i))) { i++; } if (line.startsWith(GNUMakefileConstants.VARIABLE_DEFINE, i)) { @@ -114,12 +128,8 @@ public class GNUMakefileUtil extends PosixMakefileUtil { } public static boolean isVariableDefinition(String line) { - return isOverrideDefine(line) - || isTargetVariable(line) - || isDefine(line) - || isOverride(line) - || isExport(line) - || isMacroDefinition(line); + return isOverrideDefine(line) || isTargetVariable(line) || isDefine(line) || isOverride(line) || isExport(line) + || isMacroDefinition(line); } public static boolean isStaticTargetRule(String line) { @@ -128,7 +138,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil { if (colon1 > 0) { // move pass colon1 line = line.substring(colon1 + 1); - int colon2 = Util.indexOf(line, ':'); + int colon2 = Util.indexOf(line, ':'); // Catch operator "::" not a static pattern rule return (colon2 > 0); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileValidator.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileValidator.java index 49ebafc8034..d5ffa304e9c 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileValidator.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefileValidator.java @@ -55,12 +55,11 @@ public class GNUMakefileValidator implements IMakefileValidator { @Override public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) { - ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(file, lineNumber, errorDesc, severity, errorVar, null); + ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(file, lineNumber, errorDesc, severity, + errorVar, null); addMarker(problemMarkerInfo); } - - /* (non-Javadoc) * @see org.eclipse.cdt.core.IMarkerGenerator#addMarker(org.eclipse.cdt.core.ProblemMarkerInfo) */ @@ -71,14 +70,15 @@ public class GNUMakefileValidator implements IMakefileValidator { name = problemMarkerInfo.file.getName(); } StringBuilder sb = new StringBuilder(name); - sb.append(':').append(problemMarkerInfo.lineNumber).append(':').append(getSeverity(problemMarkerInfo.severity)); + sb.append(':').append(problemMarkerInfo.lineNumber).append(':') + .append(getSeverity(problemMarkerInfo.severity)); if (problemMarkerInfo.description != null) { sb.append(':').append(problemMarkerInfo.description); } - if (problemMarkerInfo.variableName != null ) { + if (problemMarkerInfo.variableName != null) { sb.append(':').append(problemMarkerInfo.variableName); } - if (problemMarkerInfo.externalPath != null ) { + if (problemMarkerInfo.externalPath != null) { sb.append(':').append(problemMarkerInfo.externalPath); } sb.append('\n'); @@ -86,8 +86,6 @@ public class GNUMakefileValidator implements IMakefileValidator { } - - public String getSeverity(int severity) { if (severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) { return MakefileMessages.getString("MakefileValidator.errorBuild"); //$NON-NLS-1$ @@ -141,7 +139,7 @@ public class GNUMakefileValidator implements IMakefileValidator { for (int i = 0; i < directives.length; i++) { directive = directives[i]; if (directive instanceof IConditional) { - IConditional condition = (IConditional)directive; + IConditional condition = (IConditional) directive; validateCondition(condition); if (!condition.isElse()) { conditionCount++; @@ -156,7 +154,7 @@ public class GNUMakefileValidator implements IMakefileValidator { } } } else if (directive instanceof ITerminal) { - ITerminal terminal = (ITerminal)directive; + ITerminal terminal = (ITerminal) directive; if (terminal.isEndif()) { if (conditionCount == 0) { // ERROR missing condition. @@ -181,7 +179,7 @@ public class GNUMakefileValidator implements IMakefileValidator { } } } else if (directive instanceof IVariableDefinition) { - IVariableDefinition definition = (IVariableDefinition)directive; + IVariableDefinition definition = (IVariableDefinition) directive; if (definition.isMultiLine()) { defineCount++; } @@ -193,7 +191,7 @@ public class GNUMakefileValidator implements IMakefileValidator { String varName = directive.toString().trim(); marker.addMarker(res, startLine, msg, severity, varName); } else if (directive instanceof ISpecialRule) { - validateSpecialRule((ISpecialRule)directive); + validateSpecialRule((ISpecialRule) directive); } } if (conditionCount > 0) { @@ -218,7 +216,7 @@ public class GNUMakefileValidator implements IMakefileValidator { int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; for (int i = directives.length - 1; i >= 0; i--) { if (directives[i] instanceof IVariableDefinition) { - IVariableDefinition definition = (IVariableDefinition)directives[i]; + IVariableDefinition definition = (IVariableDefinition) directives[i]; if (definition.isMultiLine()) { startLine = definition.getStartLine(); varName = definition.toString().trim(); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUTargetRule.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUTargetRule.java index 65678c3c968..e518ff0c2e0 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUTargetRule.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUTargetRule.java @@ -26,7 +26,8 @@ public class GNUTargetRule extends TargetRule { String[] orderOnlyPrerequisites; boolean doubleColon; - public GNUTargetRule(Directive parent, Target target, boolean double_colon, String[] normal_prereqs, String[] order_prereqs, Command[] commands) { + public GNUTargetRule(Directive parent, Target target, boolean double_colon, String[] normal_prereqs, + String[] order_prereqs, Command[] commands) { super(parent, target, normal_prereqs, commands); orderOnlyPrerequisites = order_prereqs; doubleColon = double_colon; @@ -44,7 +45,6 @@ public class GNUTargetRule extends TargetRule { return orderOnlyPrerequisites; } - /** * @see java.lang.Object#toString() */ diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifdef.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifdef.java index 5189eefe781..4324e4a96b7 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifdef.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifdef.java @@ -15,10 +15,9 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class Ifdef extends Conditional { - private static final String EMPTY = ""; //$NON-NLS-1$ - + private static final String EMPTY = ""; //$NON-NLS-1$ + public Ifdef(Directive parent, String var) { super(parent, var, EMPTY, EMPTY); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifeq.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifeq.java index abad73fe7f7..9fd7cec7eb7 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifeq.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifeq.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class Ifeq extends Conditional { public Ifeq(Directive parent, String cond) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifndef.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifndef.java index ac0bce611ff..d5fcfea45be 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifndef.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifndef.java @@ -15,10 +15,10 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class Ifndef extends Conditional { - private static final String EMPTY = ""; //$NON-NLS-1$ + private static final String EMPTY = ""; //$NON-NLS-1$ + public Ifndef(Directive parent, String var) { super(parent, var, EMPTY, EMPTY); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifneq.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifneq.java index 4d6dc748091..51897b8b642 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifneq.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Ifneq.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class Ifneq extends Conditional { public Ifneq(Directive parent, String cond) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Include.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Include.java index 13c99a38bba..8ba67ddcae5 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Include.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/Include.java @@ -65,7 +65,6 @@ public class Include extends Parent implements IInclude { return null; } - @Override public IDirective[] getDirectives() { clearDirectives(); @@ -95,13 +94,14 @@ public class Include extends Parent implements IInclude { } else if (dirs != null) { for (int j = 0; j < dirs.length; j++) { try { - IPath testIncludeFilePath= new Path(dirs[j]).append(includeFilePath); + IPath testIncludeFilePath = new Path(dirs[j]).append(includeFilePath); String uriPath = testIncludeFilePath.toString(); if (testIncludeFilePath.getDevice() != null) { // special case: device prefix is seen as relative path by URI uriPath = '/' + uriPath; } - URI includeURI = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uriPath, null, null); + URI includeURI = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), + uriPath, null, null); if (!isAlreadyIncluded(includeURI)) { GNUMakefile gnu = new GNUMakefile(); gnu.parse(includeURI, makefileReaderProvider); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/OverrideDefine.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/OverrideDefine.java index 5e93da101f6..6209a23b647 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/OverrideDefine.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/OverrideDefine.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class OverrideDefine extends DefineVariable { public OverrideDefine(Directive parent, String name, StringBuffer value) { @@ -24,7 +23,8 @@ public class OverrideDefine extends DefineVariable { @Override public String toString() { - StringBuffer sb = new StringBuffer(GNUMakefileConstants.VARIABLE_OVERRIDE + " " + GNUMakefileConstants.VARIABLE_DEFINE); //$NON-NLS-1$ + StringBuffer sb = new StringBuffer( + GNUMakefileConstants.VARIABLE_OVERRIDE + " " + GNUMakefileConstants.VARIABLE_DEFINE); //$NON-NLS-1$ sb.append(getName()).append('\n'); sb.append(getValue()); sb.append(GNUMakefileConstants.TERMINAL_ENDEF); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/OverrideVariable.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/OverrideVariable.java index 3e803e14246..747f392a2d2 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/OverrideVariable.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/OverrideVariable.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.make.internal.core.makefile.gnu; import org.eclipse.cdt.make.internal.core.makefile.Directive; - public class OverrideVariable extends VariableDefinition { public OverrideVariable(Directive parent, String name, StringBuffer value, int type) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/StaticTargetRule.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/StaticTargetRule.java index 418821ed4b8..33f8e2d17f1 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/StaticTargetRule.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/StaticTargetRule.java @@ -20,7 +20,6 @@ import org.eclipse.cdt.make.internal.core.makefile.Directive; import org.eclipse.cdt.make.internal.core.makefile.InferenceRule; import org.eclipse.cdt.make.internal.core.makefile.Target; - /** * Here is the syntax of a static pattern rule: * @@ -33,7 +32,8 @@ public class StaticTargetRule extends InferenceRule implements IInferenceRule { String targetPattern; String[] prereqPatterns; - public StaticTargetRule(Directive parent, Target target, String target_pattern, String[] prereq_patterns, Command[] commands) { + public StaticTargetRule(Directive parent, Target target, String target_pattern, String[] prereq_patterns, + Command[] commands) { super(parent, target, commands); targetPattern = target_pattern; prereqPatterns = prereq_patterns; diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/TargetVariable.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/TargetVariable.java index 72835ee3593..6435d2ff295 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/TargetVariable.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/TargetVariable.java @@ -25,7 +25,8 @@ public class TargetVariable extends VariableDefinition { boolean override; - public TargetVariable(Directive parent, String target, String name, StringBuffer value, boolean override, int type) { + public TargetVariable(Directive parent, String target, String name, StringBuffer value, boolean override, + int type) { super(parent, target, name, value, type); this.override = override; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/VariableDefinition.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/VariableDefinition.java index 03501766ec4..52ed0318d2f 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/VariableDefinition.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/VariableDefinition.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.make.internal.core.makefile.MacroDefinition; /** */ -public class VariableDefinition extends MacroDefinition implements IVariableDefinition { +public class VariableDefinition extends MacroDefinition implements IVariableDefinition { /** * ? is Conditional @@ -39,7 +39,7 @@ public class VariableDefinition extends MacroDefinition implements IVariableDefi } public VariableDefinition(Directive parent, String name, StringBuffer value, int type) { - this(parent, "", name, value, type); //$NON-NLS-1$ + this(parent, "", name, value, type); //$NON-NLS-1$ } public VariableDefinition(Directive parent, String target, String name, StringBuffer value, int type) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/posix/PosixMakefile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/posix/PosixMakefile.java index ad1e6664a05..18017728947 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/posix/PosixMakefile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/posix/PosixMakefile.java @@ -86,14 +86,13 @@ public class PosixMakefile extends AbstractMakefile { } @Override - public void parse(URI fileURI, - IMakefileReaderProvider makefileReaderProvider) throws IOException { + public void parse(URI fileURI, IMakefileReaderProvider makefileReaderProvider) throws IOException { this.makefileReaderProvider = makefileReaderProvider; MakefileReader reader; if (makefileReaderProvider == null) { try { - reader = new MakefileReader(new InputStreamReader( - EFS.getStore(fileURI).openInputStream(EFS.NONE, null))); + reader = new MakefileReader( + new InputStreamReader(EFS.getStore(fileURI).openInputStream(EFS.NONE, null))); } catch (CoreException e) { MakeCorePlugin.log(e); throw new IOException(e.getMessage()); @@ -165,7 +164,7 @@ public class PosixMakefile extends AbstractMakefile { // 3- Empty lines ? if (Util.isEmptyLine(line)) { - Directive empty = new EmptyLine(this); + Directive empty = new EmptyLine(this); empty.setLines(startLine, endLine); if (rules != null) { for (Rule rule : rules) { @@ -197,7 +196,7 @@ public class PosixMakefile extends AbstractMakefile { InferenceRule irule = parseInferenceRule(line); irule.setLines(startLine, endLine); addDirective(irule); - rules = new Rule[]{irule}; + rules = new Rule[] { irule }; continue; } @@ -235,15 +234,15 @@ public class PosixMakefile extends AbstractMakefile { public IDirective[] getBuiltins() { return builtins; } + @Override public IAutomaticVariable[] getAutomaticVariables() { return automaticVariables; } - protected SpecialRule processSpecialRule(String line) { line = line.trim(); - String keyword = null; + String keyword = null; String[] reqs = null; SpecialRule special = null; int index = Util.indexOf(line, ':'); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoCalculator.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoCalculator.java index 70be3adfd9d..68e7bbfb379 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoCalculator.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoCalculator.java @@ -43,26 +43,25 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; - public class CDataDiscoveredInfoCalculator { - private static final String[] EMPTY_STRING_ARRAY = new String[0]; + private static final String[] EMPTY_STRING_ARRAY = new String[0]; private static CDataDiscoveredInfoCalculator fInstance; - public static class DiscoveredSettingInfo{ + public static class DiscoveredSettingInfo { private boolean fIsPerFileDiscovery; private IRcSettingInfo[] fInfos; - public DiscoveredSettingInfo(boolean isPerFileDiscovery, IRcSettingInfo[] infos){ + public DiscoveredSettingInfo(boolean isPerFileDiscovery, IRcSettingInfo[] infos) { fIsPerFileDiscovery = isPerFileDiscovery; fInfos = infos; } - public boolean isPerFileDiscovery(){ + public boolean isPerFileDiscovery() { return fIsPerFileDiscovery; } - public IRcSettingInfo[] getRcSettingInfos(){ + public IRcSettingInfo[] getRcSettingInfos() { return fInfos; } } @@ -79,17 +78,17 @@ public class CDataDiscoveredInfoCalculator { PathInfo getFilePathInfo(); } - private static class RcSettingInfo implements IRcSettingInfo{ + private static class RcSettingInfo implements IRcSettingInfo { private ArrayList fLangInfoList; private CResourceData fRcData; - RcSettingInfo(CResourceData rcData){ + RcSettingInfo(CResourceData rcData) { fRcData = rcData; } @Override public ILangSettingInfo[] getLangInfos() { - if(fLangInfoList != null && fLangInfoList.size() != 0) + if (fLangInfoList != null && fLangInfoList.size() != 0) return fLangInfoList.toArray(new ILangSettingInfo[fLangInfoList.size()]); return new ILangSettingInfo[0]; } @@ -99,8 +98,8 @@ public class CDataDiscoveredInfoCalculator { return fRcData; } - void add(ILangSettingInfo info){ - if(fLangInfoList == null) + void add(ILangSettingInfo info) { + if (fLangInfoList == null) fLangInfoList = new ArrayList(); fLangInfoList.add(info); } @@ -110,7 +109,7 @@ public class CDataDiscoveredInfoCalculator { private CLanguageData fLangData; private PathInfo fPathInfo; - LangSettingInfo(CLanguageData langData, PathInfo info){ + LangSettingInfo(CLanguageData langData, PathInfo info) { fLangData = langData; fPathInfo = info; } @@ -131,8 +130,8 @@ public class CDataDiscoveredInfoCalculator { private int fMaxIndex; private List[] fStore; - public ListIndexStore(int size){ - if(size < 0) + public ListIndexStore(int size) { + if (size < 0) size = 0; @SuppressWarnings("unchecked") @@ -140,25 +139,25 @@ public class CDataDiscoveredInfoCalculator { fStore = lists; } - public void add(int index, PathFilePathInfo value){ + public void add(int index, PathFilePathInfo value) { List list = checkResize(index) ? new ArrayList() : fStore[index]; - if(list == null){ + if (list == null) { list = new ArrayList(); fStore[index] = list; } - if(fMaxIndex < index) + if (fMaxIndex < index) fMaxIndex = index; list.add(value); } - private boolean checkResize(int index){ - if(index >= fStore.length){ + private boolean checkResize(int index) { + if (index >= fStore.length) { int newSize = ++index; @SuppressWarnings("unchecked") List resized[] = new List[newSize]; - if(fStore != null && fStore.length != 0){ + if (fStore != null && fStore.length != 0) { System.arraycopy(fStore, 0, resized, 0, fStore.length); } fStore = resized; @@ -167,13 +166,13 @@ public class CDataDiscoveredInfoCalculator { return false; } - public List[] getLists(){ + public List[] getLists() { int size = fMaxIndex + 1; List> list = new ArrayList>(size); List l; - for(int i = 0; i < size; i++){ + for (int i = 0; i < size; i++) { l = fStore[i]; - if(l != null) + if (l != null) list.add(l); } @@ -187,15 +186,15 @@ public class CDataDiscoveredInfoCalculator { IPath fPath; PathInfo fInfo; - PathFilePathInfo(IPath path, PathInfo info){ + PathFilePathInfo(IPath path, PathInfo info) { fPath = path; fInfo = info; } } private static class ExtsSetSettings { -// String[] fExts; -// HashSet fExtsSet; + // String[] fExts; + // HashSet fExtsSet; private ExtsSet fExtsSet; Map> fPathFilePathInfoMap; CLanguageData fBaseLangData; @@ -210,8 +209,8 @@ public class CDataDiscoveredInfoCalculator { fIsDerived = isDerived; } - void add(ExtsSetSettings setting){ - if(setting.fPathFilePathInfoMap != null){ + void add(ExtsSetSettings setting) { + if (setting.fPathFilePathInfoMap != null) { Collection> infoLists = setting.fPathFilePathInfoMap.values(); for (List infoList : infoLists) { for (PathFilePathInfo info : infoList) { @@ -221,26 +220,27 @@ public class CDataDiscoveredInfoCalculator { } } - public void add(PathFilePathInfo pInfo){ - if(fPathFilePathInfoMap == null) + public void add(PathFilePathInfo pInfo) { + if (fPathFilePathInfoMap == null) fPathFilePathInfoMap = new HashMap>(3); PathInfo fileInfo = pInfo.fInfo; - List list = fileInfo == fMaxMatchInfo ? fMaxMatchInfoList : fPathFilePathInfoMap.get(fileInfo); - if(list == null){ + List list = fileInfo == fMaxMatchInfo ? fMaxMatchInfoList + : fPathFilePathInfoMap.get(fileInfo); + if (list == null) { list = new ArrayList(); fPathFilePathInfoMap.put(fileInfo, list); - if(fMaxMatchInfo == null){ + if (fMaxMatchInfo == null) { fMaxMatchInfo = fileInfo; fMaxMatchInfoList = list; } -// else { -// fIsMultiple = true; -// } - } else if(fMaxMatchInfoList != list){ -// fIsMultiple = true; + // else { + // fIsMultiple = true; + // } + } else if (fMaxMatchInfoList != list) { + // fIsMultiple = true; - if(fMaxMatchInfoList.size() == list.size()){ + if (fMaxMatchInfoList.size() == list.size()) { fMaxMatchInfoList = list; fMaxMatchInfo = fileInfo; } @@ -248,29 +248,29 @@ public class CDataDiscoveredInfoCalculator { list.add(pInfo); } - public boolean isMultiple(){ + public boolean isMultiple() { return fPathFilePathInfoMap != null && fPathFilePathInfoMap.size() > 1; } @Override public boolean equals(Object obj) { - if(obj == this) + if (obj == this) return true; - if(isMultiple()) + if (isMultiple()) return false; - if(!(obj instanceof ExtsSetSettings)) + if (!(obj instanceof ExtsSetSettings)) return false; - ExtsSetSettings other = (ExtsSetSettings)obj; - if(other.isMultiple()) + ExtsSetSettings other = (ExtsSetSettings) obj; + if (other.isMultiple()) return false; - if(!fExtsSet.equals(other.fExtsSet)) + if (!fExtsSet.equals(other.fExtsSet)) return false; - if(!CDataUtil.objectsEqual(fMaxMatchInfo, other.fMaxMatchInfo)) + if (!CDataUtil.objectsEqual(fMaxMatchInfo, other.fMaxMatchInfo)) return false; return true; @@ -279,13 +279,13 @@ public class CDataDiscoveredInfoCalculator { @Override public int hashCode() { int hash = fHash; - if(hash == 0){ - if(isMultiple()) + if (hash == 0) { + if (isMultiple()) hash = super.hashCode(); else { hash = fExtsSet.hashCode(); - if(fMaxMatchInfo != null) + if (fMaxMatchInfo != null) hash += fMaxMatchInfo.hashCode(); } @@ -301,27 +301,27 @@ public class CDataDiscoveredInfoCalculator { private HashSet fExtsSet; private int fHash; - public ExtsSet(String[] exts){ - fExts = exts == null || exts.length == 0 ? EMPTY_STRING_ARRAY : (String[])exts.clone(); + public ExtsSet(String[] exts) { + fExts = exts == null || exts.length == 0 ? EMPTY_STRING_ARRAY : (String[]) exts.clone(); } @Override public boolean equals(Object obj) { - if(this == obj) + if (this == obj) return true; - if(!(obj instanceof ExtsSet)) + if (!(obj instanceof ExtsSet)) return false; - ExtsSet other = (ExtsSet)obj; - if(fExts.length != other.fExts.length) + ExtsSet other = (ExtsSet) obj; + if (fExts.length != other.fExts.length) return false; - if(fExts.length != 0){ + if (fExts.length != 0) { @SuppressWarnings("unchecked") - HashSet set = (HashSet)calcExtsSet().clone(); + HashSet set = (HashSet) calcExtsSet().clone(); set.removeAll(other.calcExtsSet()); - if(set.size() != 0) + if (set.size() != 0) return false; } return true; @@ -330,9 +330,9 @@ public class CDataDiscoveredInfoCalculator { @Override public int hashCode() { int hash = fHash; - if(hash == 0){ + if (hash == 0) { hash = 47; - for(int i = 0; i < fExts.length; i++){ + for (int i = 0; i < fExts.length; i++) { hash += fExts[i].hashCode(); } fHash = hash; @@ -340,21 +340,21 @@ public class CDataDiscoveredInfoCalculator { return hash; } - private HashSet calcExtsSet(){ - if(fExtsSet == null) + private HashSet calcExtsSet() { + if (fExtsSet == null) fExtsSet = new HashSet(Arrays.asList(fExts)); return fExtsSet; } @Override public String toString() { - if(fExts.length == 0) + if (fExts.length == 0) return ""; //$NON-NLS-1$ StringBuilder buf = new StringBuilder(); - for(int i = 0; i < fExts.length; i++){ - if(i != 0) + for (int i = 0; i < fExts.length; i++) { + if (i != 0) buf.append(","); //$NON-NLS-1$ buf.append(fExts[i]); } @@ -369,78 +369,78 @@ public class CDataDiscoveredInfoCalculator { private PathSettingsContainer fContainer; private boolean fIsDerived; - RcSetSettings(PathSettingsContainer cr, CResourceData rcData, boolean isDerived){ + RcSetSettings(PathSettingsContainer cr, CResourceData rcData, boolean isDerived) { this.fContainer = cr; this.fRcData = rcData; this.fIsDerived = isDerived; cr.setValue(this); } - public RcSetSettings getChild(IPath path, boolean exactPath){ + public RcSetSettings getChild(IPath path, boolean exactPath) { PathSettingsContainer cr = fContainer.getChildContainer(path, false, exactPath); - if(cr != null) - return (RcSetSettings)cr.getValue(); + if (cr != null) + return (RcSetSettings) cr.getValue(); return null; } - public RcSetSettings getChild(IPath path){ + public RcSetSettings getChild(IPath path) { PathSettingsContainer cr = fContainer.getChildContainer(path, false, true); - if(cr != null) - return (RcSetSettings)cr.getValue(); + if (cr != null) + return (RcSetSettings) cr.getValue(); return null; } - public RcSetSettings createChild(IPath path, CResourceData data, boolean isDerived){ + public RcSetSettings createChild(IPath path, CResourceData data, boolean isDerived) { PathSettingsContainer cr = fContainer.getChildContainer(path, true, true); - RcSetSettings child = (RcSetSettings)cr.getValue(); - if(child == null){ + RcSetSettings child = (RcSetSettings) cr.getValue(); + if (child == null) { child = new RcSetSettings(cr, data, isDerived); -// cr.setValue(child); + // cr.setValue(child); } return child; } - void updateRcData(CResourceData data, boolean isDerived){ + void updateRcData(CResourceData data, boolean isDerived) { fRcData = data; fIsDerived = data != null ? isDerived : false; updateLangDatas(); } - private void updateLangDatas(){ - if(fRcData.getType() == ICSettingBase.SETTING_FILE){ - CLanguageData lData = ((CFileData)fRcData).getLanguageData(); + private void updateLangDatas() { + if (fRcData.getType() == ICSettingBase.SETTING_FILE) { + CLanguageData lData = ((CFileData) fRcData).getLanguageData(); ExtsSetSettings extSetting = fExtToExtsSetMap.get(getFileExt(fRcData.getPath())); - if(extSetting != null){ + if (extSetting != null) { extSetting.fBaseLangData = lData; extSetting.fIsDerived = lData != null ? fIsDerived : false; } - if(extSetting != null ? - fExtsSetToExtsSetSettingsMap.size() > 1 - : fExtsSetToExtsSetSettingsMap.size() > 0){ + if (extSetting != null ? fExtsSetToExtsSetSettingsMap.size() > 1 + : fExtsSetToExtsSetSettingsMap.size() > 0) { for (ExtsSetSettings s : fExtsSetToExtsSetSettingsMap.values()) { - if(s != extSetting){ + if (s != extSetting) { s.fBaseLangData = null; s.fIsDerived = false; } } } } else { - CLanguageData[] lDatas = ((CFolderData)fRcData).getLanguageDatas(); + CLanguageData[] lDatas = ((CFolderData) fRcData).getLanguageDatas(); @SuppressWarnings("unchecked") - Map map = (HashMap)fExtsSetToExtsSetSettingsMap.clone(); + Map map = (HashMap) fExtsSetToExtsSetSettingsMap + .clone(); CLanguageData lData; - for(int i = 0; i < lDatas.length; i++){ + for (int i = 0; i < lDatas.length; i++) { lData = lDatas[i]; ExtsSetSettings extSetting = map.remove(new ExtsSet(lData.getSourceExtensions())); - if(extSetting != null){ + if (extSetting != null) { extSetting.fBaseLangData = lData; extSetting.fIsDerived = this.fIsDerived; } } - if(map.size() != 0){ + if (map.size() != 0) { Collection extSettings = map.values(); for (ExtsSetSettings extSetting : extSettings) { extSetting.fBaseLangData = null; @@ -450,29 +450,29 @@ public class CDataDiscoveredInfoCalculator { } } - public IPath getPath(){ + public IPath getPath() { return fContainer.getPath(); } - public RcSetSettings getParent(){ + public RcSetSettings getParent() { PathSettingsContainer cr = fContainer.getParentContainer(); - if(cr != null) - return (RcSetSettings)cr.getValue(); + if (cr != null) + return (RcSetSettings) cr.getValue(); return null; } - void internalSetSettingsMap(HashMap map){ + void internalSetSettingsMap(HashMap map) { fExtsSetToExtsSetSettingsMap = map; fExtToExtsSetMap = calcExtToExtSetSettingsMap(map); } - void internalAdd(ExtsSetSettings setting){ - if(fExtsSetToExtsSetSettingsMap == null){ + void internalAdd(ExtsSetSettings setting) { + if (fExtsSetToExtsSetSettingsMap == null) { fExtsSetToExtsSetSettingsMap = new HashMap(); } ExtsSetSettings cur = fExtsSetToExtsSetSettingsMap.get(setting.fExtsSet); - if(cur != null){ + if (cur != null) { cur.add(setting); } else { fExtsSetToExtsSetSettingsMap.put(setting.fExtsSet, setting); @@ -480,29 +480,29 @@ public class CDataDiscoveredInfoCalculator { } } - void internalAddSettingsMap(HashMap map){ + void internalAddSettingsMap(HashMap map) { Collection settings = map.values(); for (ExtsSetSettings setting : settings) { internalAdd(setting); -// ExtsSet extsSet; -// extsSet = setting.fExtsSet; -// thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(extsSet); -// if(thisSetting != null){ -// thisSetting.add(setting); -// } else { -// fExtsSetToExtsSetSettingsMap.put(extsSet, setting); -// fExtToExtsSetMap = addExtsInfoToMap(setting, fExtToExtsSetMap); -// } + // ExtsSet extsSet; + // extsSet = setting.fExtsSet; + // thisSetting = (ExtsSetSettings)fExtsSetToExtsSetSettingsMap.get(extsSet); + // if(thisSetting != null){ + // thisSetting.add(setting); + // } else { + // fExtsSetToExtsSetSettingsMap.put(extsSet, setting); + // fExtToExtsSetMap = addExtsInfoToMap(setting, fExtToExtsSetMap); + // } } } - public RcSetSettings[] getChildren(final boolean includeCurrent){ + public RcSetSettings[] getChildren(final boolean includeCurrent) { final List list = new ArrayList(); - fContainer.accept(new IPathSettingsContainerVisitor(){ + fContainer.accept(new IPathSettingsContainerVisitor() { @Override public boolean visit(PathSettingsContainer container) { - if(includeCurrent || container != fContainer){ + if (includeCurrent || container != fContainer) { list.add(container.getValue()); } return true; @@ -513,31 +513,31 @@ public class CDataDiscoveredInfoCalculator { return list.toArray(new RcSetSettings[list.size()]); } - public boolean containsEqualMaxMatches(RcSetSettings other, boolean ignoreGenerated){ - if(!ignoreGenerated && fExtsSetToExtsSetSettingsMap.size() < other.fExtsSetToExtsSetSettingsMap.size()) + public boolean containsEqualMaxMatches(RcSetSettings other, boolean ignoreGenerated) { + if (!ignoreGenerated && fExtsSetToExtsSetSettingsMap.size() < other.fExtsSetToExtsSetSettingsMap.size()) return false; Set> entrySet = other.fExtsSetToExtsSetSettingsMap.entrySet(); for (Entry entry : entrySet) { ExtsSetSettings otherSetting = entry.getValue(); - if(ignoreGenerated && otherSetting.fBaseLangData == null) + if (ignoreGenerated && otherSetting.fBaseLangData == null) continue; ExtsSetSettings thisSetting = fExtsSetToExtsSetSettingsMap.get(entry.getKey()); - if(thisSetting == null) + if (thisSetting == null) return false; - if(otherSetting.fMaxMatchInfo != null && !otherSetting.fMaxMatchInfo.equals(thisSetting.fMaxMatchInfo)) + if (otherSetting.fMaxMatchInfo != null && !otherSetting.fMaxMatchInfo.equals(thisSetting.fMaxMatchInfo)) return false; } return true; } - void removeChild(RcSetSettings setting){ + void removeChild(RcSetSettings setting) { IPath path = setting.fContainer.getPath(); IPath thisPath = fContainer.getPath(); - if(!thisPath.isPrefixOf(path)) + if (!thisPath.isPrefixOf(path)) throw new IllegalArgumentException(); path = path.removeFirstSegments(thisPath.segmentCount()); @@ -545,7 +545,8 @@ public class CDataDiscoveredInfoCalculator { } } - private static HashMap calcExtToExtSetSettingsMap(Map extsSetMap){ + private static HashMap calcExtToExtSetSettingsMap( + Map extsSetMap) { HashMap result = null; Collection settings = extsSetMap.values(); for (ExtsSetSettings setting : settings) { @@ -554,31 +555,32 @@ public class CDataDiscoveredInfoCalculator { return result; } - private static HashMap addExtsInfoToMap(ExtsSetSettings setting, HashMap map){ + private static HashMap addExtsInfoToMap(ExtsSetSettings setting, + HashMap map) { boolean forceAdd = false; String[] exts = setting.fExtsSet.fExts; String ext; - if(map == null){ + if (map == null) { map = new HashMap(); forceAdd = true; } - for(int i = 0; i < exts.length; i++){ + for (int i = 0; i < exts.length; i++) { ext = exts[i]; - if(forceAdd || !map.containsKey(ext)){ + if (forceAdd || !map.containsKey(ext)) { map.put(ext, setting); } } return map; } - private RcSetSettings createRcSetInfo (CConfigurationData data){ + private RcSetSettings createRcSetInfo(CConfigurationData data) { CFolderData rootData = data.getRootFolderData(); PathSettingsContainer container = PathSettingsContainer.createRootContainer(); RcSetSettings rcSet = new RcSetSettings(container, rootData, false); rcSet.internalSetSettingsMap(createExtsSetSettingsMap(rootData)); -// rcSet.fExtToExtsSetMap = new HashMap(); -// rcSet.fExtsSetToExtsSetSettingsMap = new HashMap(); + // rcSet.fExtToExtsSetMap = new HashMap(); + // rcSet.fExtsSetToExtsSetSettingsMap = new HashMap(); CResourceData[] rcDatas = data.getResourceDatas(); CResourceData rcData; @@ -587,46 +589,49 @@ public class CDataDiscoveredInfoCalculator { ExtsSetSettings fileSetting; IPath path; - for(int i = 0; i < rcDatas.length; i++){ + for (int i = 0; i < rcDatas.length; i++) { rcData = rcDatas[i]; - if(rcData == rootData) + if (rcData == rootData) continue; - if(!includeRcDataInCalculation(data, rcData)) + if (!includeRcDataInCalculation(data, rcData)) continue; path = rcData.getPath(); curRcSet = rcSet.createChild(path, rcData, false); - if(rcData.getType() == ICSettingBase.SETTING_FILE){ + if (rcData.getType() == ICSettingBase.SETTING_FILE) { fileMap = new HashMap(1); - fileSetting = createExtsSetSettings(path, (CFileData)rcData); + fileSetting = createExtsSetSettings(path, (CFileData) rcData); fileMap.put(fileSetting.fExtsSet, fileSetting); curRcSet.internalSetSettingsMap(fileMap); } else { - curRcSet.internalSetSettingsMap(createExtsSetSettingsMap((CFolderData)rcData)); + curRcSet.internalSetSettingsMap(createExtsSetSettingsMap((CFolderData) rcData)); } } return rcSet; } - protected boolean includeRcDataInCalculation(CConfigurationData cfgData, CResourceData rcData){ + protected boolean includeRcDataInCalculation(CConfigurationData cfgData, CResourceData rcData) { return true; } - protected CFileData createFileData(CConfigurationData cfgData, IPath path, CFileData base) throws CoreException{ + protected CFileData createFileData(CConfigurationData cfgData, IPath path, CFileData base) throws CoreException { return cfgData.createFileData(path, base); } - protected CFileData createFileData(CConfigurationData cfgData, IPath path, CFolderData base, CLanguageData langBase) throws CoreException{ + protected CFileData createFileData(CConfigurationData cfgData, IPath path, CFolderData base, CLanguageData langBase) + throws CoreException { return cfgData.createFileData(path, base, langBase); } - protected CFolderData createFolderData(CConfigurationData cfgData, IPath path, CFolderData base) throws CoreException{ + protected CFolderData createFolderData(CConfigurationData cfgData, IPath path, CFolderData base) + throws CoreException { return cfgData.createFolderData(path, base); } - private RcSetSettings createRcSetSettings(CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo){ + private RcSetSettings createRcSetSettings(CConfigurationData data, + IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo) { RcSetSettings rcSet = createRcSetInfo(data); Map map = discoveredInfo.getPathInfoMap(); PathFilePathInfo pInfos[] = createOrderedInfo(map); @@ -638,11 +643,11 @@ public class CDataDiscoveredInfoCalculator { /* * utility method for creating empty IRcSettingInfo */ - public static IRcSettingInfo createEmptyRcSettingInfo(CFolderData data){ + public static IRcSettingInfo createEmptyRcSettingInfo(CFolderData data) { return createRcSettingInfo(data, PathInfo.EMPTY_INFO); } - public static IRcSettingInfo createRcSettingInfo(CFolderData data, PathInfo info){ + public static IRcSettingInfo createRcSettingInfo(CFolderData data, PathInfo info) { RcSettingInfo rcInfo = new RcSettingInfo(data); CLanguageData[] lDatas = data.getLanguageDatas(); addLanguageInfos(rcInfo, lDatas, info); @@ -652,38 +657,39 @@ public class CDataDiscoveredInfoCalculator { /* * utility method for creating empty IRcSettingInfo */ - public static IRcSettingInfo createEmptyRcSettingInfo(CFileData data){ + public static IRcSettingInfo createEmptyRcSettingInfo(CFileData data) { return createRcSettingInfo(data, PathInfo.EMPTY_INFO); } - public static IRcSettingInfo createRcSettingInfo(CFileData data, PathInfo info){ + public static IRcSettingInfo createRcSettingInfo(CFileData data, PathInfo info) { RcSettingInfo rcInfo = new RcSettingInfo(data); CLanguageData lData = data.getLanguageData(); - if(lData != null) - addLanguageInfos(rcInfo, new CLanguageData[]{lData}, info); + if (lData != null) + addLanguageInfos(rcInfo, new CLanguageData[] { lData }, info); return rcInfo; } - private static void addLanguageInfos(RcSettingInfo rcInfo, CLanguageData[] lDatas, PathInfo info){ + private static void addLanguageInfos(RcSettingInfo rcInfo, CLanguageData[] lDatas, PathInfo info) { ArrayList list = rcInfo.fLangInfoList; - if(list == null){ + if (list == null) { list = new ArrayList(lDatas.length); rcInfo.fLangInfoList = list; } else { list.ensureCapacity(lDatas.length); } - for(int i = 0; i < lDatas.length; i++){ + for (int i = 0; i < lDatas.length; i++) { list.add(new LangSettingInfo(lDatas[i], info)); } } - private IRcSettingInfo[] mapFileDiscoveredInfo(IProject project, CConfigurationData data, RcSetSettings rcSet, PathFilePathInfo[] pfpis){ -// IResource rc; + private IRcSettingInfo[] mapFileDiscoveredInfo(IProject project, CConfigurationData data, RcSetSettings rcSet, + PathFilePathInfo[] pfpis) { + // IResource rc; PathInfo pInfo; IPath projRelPath; CResourceData rcData; -// RcSetSettings dataSetting; + // RcSetSettings dataSetting; List list = new ArrayList(pfpis.length); RcSettingInfo rcInfo; ILangSettingInfo lInfo; @@ -691,15 +697,15 @@ public class CDataDiscoveredInfoCalculator { ArrayList tmpList; PathFilePathInfo pfpi; - for(int i = 0; i < pfpis.length; i++){ + for (int i = 0; i < pfpis.length; i++) { pfpi = pfpis[i]; projRelPath = pfpi.fPath; pInfo = pfpi.fInfo; - if(pInfo.isEmpty()) + if (pInfo.isEmpty()) continue; - if(projRelPath.segmentCount() == 0){ - CFolderData rootData = (CFolderData)rcSet.fRcData; + if (projRelPath.segmentCount() == 0) { + CFolderData rootData = (CFolderData) rcSet.fRcData; CLanguageData lDatas[] = rootData.getLanguageDatas(); IPath[] incPaths = pInfo.getIncludePaths(); IPath[] quotedIncPaths = pInfo.getQuoteIncludePaths(); @@ -708,22 +714,22 @@ public class CDataDiscoveredInfoCalculator { Map symbolMap = pInfo.getSymbols(); int kinds = 0; - if(incPaths.length != 0 || quotedIncPaths.length != 0) + if (incPaths.length != 0 || quotedIncPaths.length != 0) kinds |= ICLanguageSettingEntry.INCLUDE_PATH; - if(incFiles.length != 0) + if (incFiles.length != 0) kinds |= ICLanguageSettingEntry.INCLUDE_FILE; - if(macroFiles.length != 0) + if (macroFiles.length != 0) kinds |= ICLanguageSettingEntry.MACRO_FILE; - if(symbolMap.size() != 0) + if (symbolMap.size() != 0) kinds |= ICLanguageSettingEntry.MACRO; rcInfo = null; - for(int k = 0; k < lDatas.length; k++){ + for (int k = 0; k < lDatas.length; k++) { lData = lDatas[k]; - if((lData.getSupportedEntryKinds() & kinds) == 0) + if ((lData.getSupportedEntryKinds() & kinds) == 0) continue; - if(rcInfo == null){ + if (rcInfo == null) { rcInfo = new RcSettingInfo(rootData); tmpList = new ArrayList(lDatas.length - k); rcInfo.fLangInfoList = tmpList; @@ -733,68 +739,69 @@ public class CDataDiscoveredInfoCalculator { rcInfo.add(lInfo); } - if(rcInfo != null) + if (rcInfo != null) list.add(rcInfo); continue; } -// switch(rc.getType()){ -// case IResource.FILE: -// projRelPath = rc.getProjectRelativePath(); -// dataSetting = rcSet.getChild(projRelPath, false); -// rcData = dataSetting.fRcData; - rcData = rcSet.getChild(projRelPath, false).fRcData; - if(!rcData.getPath().equals(projRelPath)){ - if(rcData.getType() == ICSettingBase.SETTING_FOLDER){ - CFolderData foData = (CFolderData)rcData; - lData = CDataUtil.findLanguagDataForFile(projRelPath.lastSegment(), project, (CFolderData)rcData); - try { - rcData = createFileData(data, projRelPath, foData, lData); - } catch (CoreException e) { - rcData = null; - MakeCorePlugin.log(e); - } - } else { - try { - rcData = createFileData(data, projRelPath, (CFileData)rcData); - } catch (CoreException e) { - rcData = null; - MakeCorePlugin.log(e); - } + // switch(rc.getType()){ + // case IResource.FILE: + // projRelPath = rc.getProjectRelativePath(); + // dataSetting = rcSet.getChild(projRelPath, false); + // rcData = dataSetting.fRcData; + rcData = rcSet.getChild(projRelPath, false).fRcData; + if (!rcData.getPath().equals(projRelPath)) { + if (rcData.getType() == ICSettingBase.SETTING_FOLDER) { + CFolderData foData = (CFolderData) rcData; + lData = CDataUtil.findLanguagDataForFile(projRelPath.lastSegment(), project, (CFolderData) rcData); + try { + rcData = createFileData(data, projRelPath, foData, lData); + } catch (CoreException e) { + rcData = null; + MakeCorePlugin.log(e); + } + } else { + try { + rcData = createFileData(data, projRelPath, (CFileData) rcData); + } catch (CoreException e) { + rcData = null; + MakeCorePlugin.log(e); } -// if(rcData != null) -// dataSetting = rcSet.createChild(projRelPath, rcData, false); -// else -// dataSetting = null; } + // if(rcData != null) + // dataSetting = rcSet.createChild(projRelPath, rcData, false); + // else + // dataSetting = null; + } - if(rcData != null){ - if(rcData.getType() == ICSettingBase.SETTING_FILE){ - lData = ((CFileData)rcData).getLanguageData(); - } else { - lData = CDataUtil.findLanguagDataForFile(projRelPath.lastSegment(), project, (CFolderData)rcData); - - } + if (rcData != null) { + if (rcData.getType() == ICSettingBase.SETTING_FILE) { + lData = ((CFileData) rcData).getLanguageData(); + } else { + lData = CDataUtil.findLanguagDataForFile(projRelPath.lastSegment(), project, (CFolderData) rcData); - if(lData != null){ - rcInfo = new RcSettingInfo(rcData); - lInfo = new LangSettingInfo(lData, pInfo); - tmpList = new ArrayList(1); - tmpList.add(lInfo); - rcInfo.fLangInfoList = tmpList; - list.add(rcInfo); - } + } + if (lData != null) { + rcInfo = new RcSettingInfo(rcData); + lInfo = new LangSettingInfo(lData, pInfo); + tmpList = new ArrayList(1); + tmpList.add(lInfo); + rcInfo.fLangInfoList = tmpList; + list.add(rcInfo); } -// break; -// } + } + + // break; + // } } return list.toArray(new RcSettingInfo[list.size()]); } - public IRcSettingInfo[] getSettingInfos(IProject project, CConfigurationData data, IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo, boolean fileDataMode){ - if(fileDataMode){ + public IRcSettingInfo[] getSettingInfos(IProject project, CConfigurationData data, + IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 discoveredInfo, boolean fileDataMode) { + if (fileDataMode) { RcSetSettings rcSettings = createRcSetInfo(data); PathFilePathInfo pInfos[] = createOrderedInfo(discoveredInfo.getPathInfoMap()); return mapFileDiscoveredInfo(project, data, rcSettings, pInfos); @@ -803,7 +810,7 @@ public class CDataDiscoveredInfoCalculator { return createInfos(data, settings); } - private IRcSettingInfo[] createInfos(CConfigurationData data, RcSetSettings rootSetting){ + private IRcSettingInfo[] createInfos(CConfigurationData data, RcSetSettings rootSetting) { RcSetSettings settings[] = rootSetting.getChildren(true); RcSetSettings setting; CResourceData rcData; @@ -811,20 +818,20 @@ public class CDataDiscoveredInfoCalculator { LangSettingInfo langInfo; RcSettingInfo rcInfo; PathInfo pathInfo; - for(int i = 0; i < settings.length; i++){ + for (int i = 0; i < settings.length; i++) { setting = settings[i]; rcData = setting.fRcData; - if(rcData == null) + if (rcData == null) continue; - if(setting.fIsDerived){ -// rcData = null; + if (setting.fIsDerived) { + // rcData = null; try { rcData = createFolderData(data, rcData, setting); } catch (CoreException e) { rcData = null; MakeCorePlugin.log(e); } - if(rcData != null){ + if (rcData != null) { setting.updateRcData(rcData, false); } else { //TODO: @@ -832,50 +839,51 @@ public class CDataDiscoveredInfoCalculator { } } - if(rcData.getType() == ICSettingBase.SETTING_FILE){ + if (rcData.getType() == ICSettingBase.SETTING_FILE) { ExtsSetSettings extSetting = setting.fExtToExtsSetMap.get(getFileExt(rcData.getPath())); - if(extSetting != null){ + if (extSetting != null) { pathInfo = extSetting.fMaxMatchInfo; - if(pathInfo != null){ + if (pathInfo != null) { langInfo = new LangSettingInfo(extSetting.fBaseLangData, pathInfo); rcInfo = new RcSettingInfo(rcData); - rcInfo.fLangInfoList = new ArrayList (1); + rcInfo.fLangInfoList = new ArrayList(1); rcInfo.fLangInfoList.add(langInfo); resultList.add(rcInfo); } } } else { - if(setting.fExtsSetToExtsSetSettingsMap.size() != 0 ){ + if (setting.fExtsSetToExtsSetSettingsMap.size() != 0) { rcInfo = new RcSettingInfo(rcData); rcInfo.fLangInfoList = new ArrayList(setting.fExtsSetToExtsSetSettingsMap.size()); resultList.add(rcInfo); Collection extSettings = setting.fExtsSetToExtsSetSettingsMap.values(); for (ExtsSetSettings extSetting : extSettings) { - if(extSetting.fMaxMatchInfo == null) + if (extSetting.fMaxMatchInfo == null) continue; - if(extSetting.fBaseLangData == null) + if (extSetting.fBaseLangData == null) continue; - if(extSetting.fIsDerived){ + if (extSetting.fIsDerived) { throw new IllegalStateException(); } - rcInfo.add(new LangSettingInfo(extSetting.fBaseLangData, extSetting.fMaxMatchInfo)); - if(extSetting.isMultiple()){ - Set>> entries = extSetting.fPathFilePathInfoMap.entrySet(); + if (extSetting.isMultiple()) { + Set>> entries = extSetting.fPathFilePathInfoMap + .entrySet(); for (Entry> entry : entries) { - if(entry.getKey().equals(extSetting.fMaxMatchInfo)) + if (entry.getKey().equals(extSetting.fMaxMatchInfo)) continue; List piList = entry.getValue(); for (PathFilePathInfo pi : piList) { try { - CFileData fiData = createFileData(data, pi.fPath, (CFolderData)rcData, extSetting.fBaseLangData); + CFileData fiData = createFileData(data, pi.fPath, (CFolderData) rcData, + extSetting.fBaseLangData); CLanguageData fiLangData = fiData.getLanguageData(); - if(fiLangData != null){ + if (fiLangData != null) { RcSettingInfo fiInfo = new RcSettingInfo(fiData); fiInfo.add(new LangSettingInfo(fiLangData, pi.fInfo)); resultList.add(fiInfo); @@ -890,57 +898,58 @@ public class CDataDiscoveredInfoCalculator { } } } -// } + // } return resultList.toArray(new RcSettingInfo[resultList.size()]); } - private CFolderData createFolderData(CConfigurationData cfg, CResourceData base, RcSetSettings setting) throws CoreException{ - if(base.getType() == ICSettingBase.SETTING_FOLDER) - return createFolderData(cfg, setting.getPath(), (CFolderData)base); + private CFolderData createFolderData(CConfigurationData cfg, CResourceData base, RcSetSettings setting) + throws CoreException { + if (base.getType() == ICSettingBase.SETTING_FOLDER) + return createFolderData(cfg, setting.getPath(), (CFolderData) base); //should not be here throw new IllegalStateException(); } - private static void checkRemoveDups(RcSetSettings rcSet){ + private static void checkRemoveDups(RcSetSettings rcSet) { RcSetSettings settings[] = rcSet.getChildren(true); RcSetSettings setting, parent; - for(int i = 0; i < settings.length; i++){ + for (int i = 0; i < settings.length; i++) { setting = settings[i]; - if(!setting.fIsDerived) + if (!setting.fIsDerived) continue; parent = setting.getParent(); - if(parent == null) + if (parent == null) continue; - if(parent.containsEqualMaxMatches(setting, true)) + if (parent.containsEqualMaxMatches(setting, true)) removeChildAddingChildSettings(parent, setting); } } - private static void removeChildAddingChildSettings(RcSetSettings parent, RcSetSettings child){ + private static void removeChildAddingChildSettings(RcSetSettings parent, RcSetSettings child) { parent.internalAddSettingsMap(child.fExtsSetToExtsSetSettingsMap); parent.removeChild(child); } - private static void mapDiscoveredInfo(RcSetSettings rcSet, PathFilePathInfo[] pInfos){ + private static void mapDiscoveredInfo(RcSetSettings rcSet, PathFilePathInfo[] pInfos) { PathFilePathInfo pInfo; RcSetSettings child, parent; String ext; ExtsSetSettings extsSet; -// boolean isDerived; + // boolean isDerived; IPath dirPath; - for(int i = 0; i < pInfos.length; i++){ + for (int i = 0; i < pInfos.length; i++) { pInfo = pInfos[i]; child = rcSet.getChild(pInfo.fPath); - if(child == null) { + if (child == null) { dirPath = pInfo.fPath.removeLastSegments(1); child = rcSet.getChild(dirPath); - if(child == null){ + if (child == null) { child = rcSet.createChild(dirPath, null, true); - if(child.fExtToExtsSetMap == null){ + if (child.fExtToExtsSetMap == null) { parent = child.getParent(); child.fRcData = parent.fRcData; child.internalSetSettingsMap(createEmptyExtSetMapCopy(parent.fExtsSetToExtsSetSettingsMap)); @@ -948,40 +957,40 @@ public class CDataDiscoveredInfoCalculator { } } -// isDerived = child.fIsDerived; + // isDerived = child.fIsDerived; - if(pInfo.fPath.segmentCount() == 0){ + if (pInfo.fPath.segmentCount() == 0) { processProjectPaths(child, pInfo); } else { ext = getFileExt(pInfo.fPath); extsSet = child.fExtToExtsSetMap.get(ext); - if(extsSet == null){ - extsSet = new ExtsSetSettings(null, new ExtsSet(new String[]{ext}), false); + if (extsSet == null) { + extsSet = new ExtsSetSettings(null, new ExtsSet(new String[] { ext }), false); child.internalAdd(extsSet); -// child.fExtToExtsSetMap.put(ext, extsSet); + // child.fExtToExtsSetMap.put(ext, extsSet); } extsSet.add(pInfo); } } } - private static void processProjectPaths(RcSetSettings rcSet, PathFilePathInfo pfpi){ + private static void processProjectPaths(RcSetSettings rcSet, PathFilePathInfo pfpi) { Collection settings = rcSet.fExtsSetToExtsSetSettingsMap.values(); for (ExtsSetSettings setting : settings) { setting.add(pfpi); } } - private static String getFileExt(IPath path){ + private static String getFileExt(IPath path) { String ext = path.getFileExtension(); - if(ext != null) + if (ext != null) return ext; return ""; //$NON-NLS-1$ } - private static HashMap createEmptyExtSetMapCopy(HashMap base){ + private static HashMap createEmptyExtSetMapCopy(HashMap base) { @SuppressWarnings("unchecked") - HashMap map = (HashMap)base.clone(); + HashMap map = (HashMap) base.clone(); Set> entries = map.entrySet(); for (Entry entry : entries) { ExtsSetSettings extsSet = entry.getValue(); @@ -991,55 +1000,55 @@ public class CDataDiscoveredInfoCalculator { return map; } - private static ExtsSetSettings createExtsSetSettings(IPath path, CFileData data){ + private static ExtsSetSettings createExtsSetSettings(IPath path, CFileData data) { CLanguageData lData = data.getLanguageData(); - if(lData != null){ + if (lData != null) { String ext = getFileExt(path); - return createExtsSetSettings(lData, new String[]{ext}); + return createExtsSetSettings(lData, new String[] { ext }); } return new ExtsSetSettings(null, new ExtsSet(EMPTY_STRING_ARRAY), false); } - private static ExtsSetSettings createExtsSetSettings(CLanguageData lData, String exts[]){ + private static ExtsSetSettings createExtsSetSettings(CLanguageData lData, String exts[]) { return new ExtsSetSettings(lData, new ExtsSet(exts), false); } - private static HashMap createExtsSetSettingsMap(CFolderData data){ + private static HashMap createExtsSetSettingsMap(CFolderData data) { CLanguageData[] lDatas = data.getLanguageDatas(); HashMap map = new HashMap(lDatas.length); ExtsSetSettings settings; - if(lDatas.length != 0) { + if (lDatas.length != 0) { CLanguageData lData; - for( int i = 0; i < lDatas.length; i++){ + for (int i = 0; i < lDatas.length; i++) { lData = lDatas[i]; - settings = createExtsSetSettings(lData, lData.getSourceExtensions()); - map.put(settings.fExtsSet, settings); + settings = createExtsSetSettings(lData, lData.getSourceExtensions()); + map.put(settings.fExtsSet, settings); } } return map; } - private static PathFilePathInfo[] createOrderedInfo(Map map){ + private static PathFilePathInfo[] createOrderedInfo(Map map) { ListIndexStore store = new ListIndexStore(10); HashMap infoMap = new HashMap(); -// LinkedHashMap result; + // LinkedHashMap result; Set> entries = map.entrySet(); for (Entry entry : entries) { IResource rc = entry.getKey(); IPath path = rc.getProjectRelativePath(); int segCount = path.segmentCount(); -// if(segCount < 1) -// continue; + // if(segCount < 1) + // continue; -// path = path.removeFirstSegments(1); -// segCount--; + // path = path.removeFirstSegments(1); + // segCount--; PathInfo info = entry.getValue(); PathInfo storedInfo = infoMap.get(info); - if(storedInfo == null){ + if (storedInfo == null) { storedInfo = info; infoMap.put(storedInfo, storedInfo); } @@ -1048,23 +1057,23 @@ public class CDataDiscoveredInfoCalculator { } List lists[] = store.getLists(); -// result = new LinkedHashMap(map.size()); -// List l; -// int lSize; -// PathFilePathInfo pfpi; -// for(int i = 0; i < lists.length; i++){ -// l = lists[i]; -// lSize = l.size(); -// if(lSize != 0){ -// for(int k = 0; k < lSize; k++){ -// pfpi = (PathFilePathInfo)l.get(k); -// result.put(pfpi.fPath, pfpi.fInfo); -// } -// } -// } + // result = new LinkedHashMap(map.size()); + // List l; + // int lSize; + // PathFilePathInfo pfpi; + // for(int i = 0; i < lists.length; i++){ + // l = lists[i]; + // lSize = l.size(); + // if(lSize != 0){ + // for(int k = 0; k < lSize; k++){ + // pfpi = (PathFilePathInfo)l.get(k); + // result.put(pfpi.fPath, pfpi.fInfo); + // } + // } + // } int size = 0; PathFilePathInfo infos[]; - for(int i = 0; i < lists.length; i++){ + for (int i = 0; i < lists.length; i++) { size += lists[i].size(); } @@ -1072,10 +1081,10 @@ public class CDataDiscoveredInfoCalculator { int num = 0; int listSize; List list; - for(int i = 0; i < lists.length; i++){ + for (int i = 0; i < lists.length; i++) { list = lists[i]; listSize = list.size(); - for(int k = 0; k < listSize; k++){ + for (int k = 0; k < listSize; k++) { infos[num++] = list.get(k); } } @@ -1083,20 +1092,21 @@ public class CDataDiscoveredInfoCalculator { return infos; } - public static CDataDiscoveredInfoCalculator getDefault(){ - if(fInstance == null) + public static CDataDiscoveredInfoCalculator getDefault() { + if (fInstance == null) fInstance = new CDataDiscoveredInfoCalculator(); return fInstance; } - public DiscoveredSettingInfo getSettingInfos(IProject project, - CConfigurationData cfgData){ + public DiscoveredSettingInfo getSettingInfos(IProject project, CConfigurationData cfgData) { InfoContext context = createContext(project, cfgData); try { - IDiscoveredPathManager.IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context); - if(info instanceof IDiscoveredPathManager.IPerFileDiscoveredPathInfo2){ - IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 perFileInfo = (IDiscoveredPathManager.IPerFileDiscoveredPathInfo2)info; - DiscoveredSettingInfo dsInfo = new DiscoveredSettingInfo(true, getSettingInfos(project, cfgData, perFileInfo, true)); + IDiscoveredPathManager.IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager() + .getDiscoveredInfo(project, context); + if (info instanceof IDiscoveredPathManager.IPerFileDiscoveredPathInfo2) { + IDiscoveredPathManager.IPerFileDiscoveredPathInfo2 perFileInfo = (IDiscoveredPathManager.IPerFileDiscoveredPathInfo2) info; + DiscoveredSettingInfo dsInfo = new DiscoveredSettingInfo(true, + getSettingInfos(project, cfgData, perFileInfo, true)); return dsInfo; } IPath[] includes = info.getIncludePaths(); @@ -1105,18 +1115,18 @@ public class CDataDiscoveredInfoCalculator { PathInfo pathInfo = new PathInfo(includes, null, symbols, null, null); CFolderData rootData = cfgData.getRootFolderData(); IRcSettingInfo rcInfo = createRcSettingInfo(rootData, pathInfo); - return new DiscoveredSettingInfo(false, new IRcSettingInfo[]{rcInfo}); + return new DiscoveredSettingInfo(false, new IRcSettingInfo[] { rcInfo }); } catch (CoreException e) { MakeCorePlugin.log(e); } return new DiscoveredSettingInfo(false, new IRcSettingInfo[0]); } - protected InfoContext createContext(IProject project, CConfigurationData data){ + protected InfoContext createContext(IProject project, CConfigurationData data) { return new InfoContext(project, idForData(data)); } - protected String idForData(CDataObject data){ + protected String idForData(CDataObject data) { return data.getId(); } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoProcessor.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoProcessor.java index 1965cfbf58e..a3ab5b5cf0d 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoProcessor.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/CDataDiscoveredInfoProcessor.java @@ -35,106 +35,102 @@ import org.eclipse.core.runtime.Path; public abstract class CDataDiscoveredInfoProcessor { - public void applyDiscoveredInfo(CConfigurationData cfgData, DiscoveredSettingInfo dsIinfo){ + public void applyDiscoveredInfo(CConfigurationData cfgData, DiscoveredSettingInfo dsIinfo) { Map map = CDataUtil.createPathRcDataMap(cfgData); IRcSettingInfo info; PathSettingsContainer cr = PathSettingsContainer.createRootContainer(); - + IRcSettingInfo[] infos = dsIinfo.getRcSettingInfos(); - - for(int i = 0; i < infos.length; i++){ + + for (int i = 0; i < infos.length; i++) { info = infos[i]; applyInfo(cfgData, info, cr); map.remove(info.getResourceData().getPath()); } - - if(map.size() != 0){ + + if (map.size() != 0) { CResourceData rcData = map.get(Path.EMPTY); - if(rcData != null){ - info = CDataDiscoveredInfoCalculator.createEmptyRcSettingInfo((CFolderData)rcData); + if (rcData != null) { + info = CDataDiscoveredInfoCalculator.createEmptyRcSettingInfo((CFolderData) rcData); applyInfo(cfgData, info, cr); map.remove(Path.EMPTY); } - - if(map.size() != 0){ + + if (map.size() != 0) { Set> entries = map.entrySet(); for (Entry entry : entries) { IPath path = entry.getKey(); PathSettingsContainer curCr = cr.getChildContainer(path, false, false); rcData = entry.getValue(); - info = (IRcSettingInfo)curCr.getValue(); + info = (IRcSettingInfo) curCr.getValue(); applyInfo(cfgData, rcData, info); } } } } - protected void applyInfo(CConfigurationData cfgData, CResourceData rcData, IRcSettingInfo info){ + protected void applyInfo(CConfigurationData cfgData, CResourceData rcData, IRcSettingInfo info) { CLanguageData[] lDatas = getLangDatas(rcData); ILangSettingInfo lInfo; ILangSettingInfo lInfos[] = info.getLangInfos(); CLanguageData lData; - for(int k = 0; k < lDatas.length; k++){ + for (int k = 0; k < lDatas.length; k++) { lData = lDatas[k]; lInfo = getMatch(lData, lInfos); - if(lInfo != null){ - setInfoForData(cfgData, - rcData, - lData, - lInfo.getFilePathInfo(), - info.getResourceData(), + if (lInfo != null) { + setInfoForData(cfgData, rcData, lData, lInfo.getFilePathInfo(), info.getResourceData(), lInfo.getLanguageData()); } else { setInfoForData(cfgData, rcData, lData, null, null, null); } } } - - protected CLanguageData[] getLangDatas(CResourceData rcData){ - if(rcData.getType() == ICSettingBase.SETTING_FILE){ - CLanguageData lData = ((CFileData)rcData).getLanguageData(); - if(lData != null) - return new CLanguageData[]{lData}; + + protected CLanguageData[] getLangDatas(CResourceData rcData) { + if (rcData.getType() == ICSettingBase.SETTING_FILE) { + CLanguageData lData = ((CFileData) rcData).getLanguageData(); + if (lData != null) + return new CLanguageData[] { lData }; return new CLanguageData[0]; } - return ((CFolderData)rcData).getLanguageDatas(); + return ((CFolderData) rcData).getLanguageDatas(); } - protected ILangSettingInfo getMatch(CLanguageData lData, ILangSettingInfo lInfos[]){ + protected ILangSettingInfo getMatch(CLanguageData lData, ILangSettingInfo lInfos[]) { ILangSettingInfo lInfo; - for(int i = 0; i < lInfos.length; i++){ + for (int i = 0; i < lInfos.length; i++) { lInfo = lInfos[i]; - if(langDatasMatch(lData, lInfo.getLanguageData())) + if (langDatasMatch(lData, lInfo.getLanguageData())) return lInfo; } return null; } - protected CLanguageData getMatch(CLanguageData lData, CLanguageData[] datas){ - for(int i = 0; i < datas.length; i++){ - if(langDatasMatch(lData, datas[i])) + protected CLanguageData getMatch(CLanguageData lData, CLanguageData[] datas) { + for (int i = 0; i < datas.length; i++) { + if (langDatasMatch(lData, datas[i])) return datas[i]; } return null; } - protected boolean langDatasMatch(CLanguageData lData1, CLanguageData lData2){ - if(!CDataUtil.objectsEqual(lData1.getLanguageId(), lData2.getLanguageId())) + protected boolean langDatasMatch(CLanguageData lData1, CLanguageData lData2) { + if (!CDataUtil.objectsEqual(lData1.getLanguageId(), lData2.getLanguageId())) return false; - + String[] tmp = lData1.getSourceContentTypeIds(); - if(tmp != null && tmp.length != 0){ - if(!Arrays.equals(tmp, lData2.getSourceContentTypeIds())) + if (tmp != null && tmp.length != 0) { + if (!Arrays.equals(tmp, lData2.getSourceContentTypeIds())) return false; } else { - if(!Arrays.equals(lData1.getSourceExtensions(), lData2.getSourceExtensions())) + if (!Arrays.equals(lData1.getSourceExtensions(), lData2.getSourceExtensions())) return false; } return true; } - protected void applyInfo(CConfigurationData cfgData, IRcSettingInfo info, PathSettingsContainer cr){ + protected void applyInfo(CConfigurationData cfgData, IRcSettingInfo info, PathSettingsContainer cr) { CResourceData rcData; CLanguageData lData; ILangSettingInfo lInfo; @@ -143,18 +139,14 @@ public abstract class CDataDiscoveredInfoProcessor { PathSettingsContainer curCr = cr.getChildContainer(path, true, true); curCr.setValue(info); ILangSettingInfo lInfos[] = info.getLangInfos(); - for(int k = 0; k < lInfos.length; k++){ + for (int k = 0; k < lInfos.length; k++) { lInfo = lInfos[k]; lData = lInfo.getLanguageData(); setInfoForData(cfgData, rcData, lData, lInfo.getFilePathInfo(), null, null); } } - - protected abstract void setInfoForData(CConfigurationData cfgData, - CResourceData rcData, - CLanguageData lData, - PathInfo pi, - CResourceData baseRcData, - CLanguageData baseLangData); - + + protected abstract void setInfoForData(CConfigurationData cfgData, CResourceData rcData, CLanguageData lData, + PathInfo pi, CResourceData baseRcData, CLanguageData baseLangData); + } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java index b52ffe110ea..4fccc0ade94 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java @@ -31,64 +31,63 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; public class DiscoveredPathContainer implements IPathEntryContainer { - public static final IPath CONTAINER_ID = new Path("org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"); //$NON-NLS-1$ + public static final IPath CONTAINER_ID = new Path("org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"); //$NON-NLS-1$ - protected final IProject fProject; - private IPathEntry[] fPathEntries; + protected final IProject fProject; + private IPathEntry[] fPathEntries; - public DiscoveredPathContainer(IProject project) { - fProject = project; - fPathEntries = null; - } + public DiscoveredPathContainer(IProject project) { + fProject = project; + fPathEntries = null; + } -// public IPathEntry[] getPathEntries() { -// IPathEntry[] fPathEntries; -// try { -// fPathEntries = getPathEntries(getPathEntryMap()); -// } catch (CoreException e) { -// MakeCorePlugin.log(e); -// return new IPathEntry[0]; -// } -// return fPathEntries; -// } + // public IPathEntry[] getPathEntries() { + // IPathEntry[] fPathEntries; + // try { + // fPathEntries = getPathEntries(getPathEntryMap()); + // } catch (CoreException e) { + // MakeCorePlugin.log(e); + // return new IPathEntry[0]; + // } + // return fPathEntries; + // } - @Override + @Override public String getDescription() { - return MakeMessages.getString("DiscoveredContainer.description"); //$NON-NLS-1$ - } + return MakeMessages.getString("DiscoveredContainer.description"); //$NON-NLS-1$ + } - @Override + @Override public IPath getPath() { - return CONTAINER_ID; - } + return CONTAINER_ID; + } - @Override + @Override public IPathEntry[] getPathEntries() { - if (fPathEntries == null) { - try { - fPathEntries = computeNewPathEntries(); - } - catch (CoreException e) { - MakeCorePlugin.log(e); - return new IPathEntry[0]; - } - } - return fPathEntries; - } + if (fPathEntries == null) { + try { + fPathEntries = computeNewPathEntries(); + } catch (CoreException e) { + MakeCorePlugin.log(e); + return new IPathEntry[0]; + } + } + return fPathEntries; + } - private IPathEntry[] computeNewPathEntries() throws CoreException { - IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject); - IPath[] includes = info.getIncludePaths(); - Map syms = info.getSymbols(); - List entries = new ArrayList(includes.length + syms.size()); - for (IPath inc : includes) { - entries.add(CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, inc, true)); - } - Set> entrySet = syms.entrySet(); - for (Entry entry : entrySet) { - entries.add(CoreModel.newMacroEntry(Path.EMPTY, entry.getKey(), entry.getValue())); - } - return entries.toArray(new IPathEntry[entries.size()]); - } + private IPathEntry[] computeNewPathEntries() throws CoreException { + IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject); + IPath[] includes = info.getIncludePaths(); + Map syms = info.getSymbols(); + List entries = new ArrayList(includes.length + syms.size()); + for (IPath inc : includes) { + entries.add(CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, inc, true)); + } + Set> entrySet = syms.entrySet(); + for (Entry entry : entrySet) { + entries.add(CoreModel.newMacroEntry(Path.EMPTY, entry.getKey(), entry.getValue())); + } + return entries.toArray(new IPathEntry[entries.size()]); + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java index 961174379a4..308a6564a3c 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java @@ -33,7 +33,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; - public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDiscoveredScannerInfoSerializable { public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$ public static final String PATH = "path"; //$NON-NLS-1$ @@ -70,7 +69,7 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco @Override public synchronized IPath[] getIncludePaths() { - if ( activePaths == null) { + if (activePaths == null) { createPathLists(); } return activePaths.toArray(new IPath[activePaths.size()]); @@ -161,8 +160,7 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco Set symbolsSet = symbols.keySet(); for (String symbol : symbolsSet) { SymbolEntry se = symbols.get(symbol); - if (se != null) - { + if (se != null) { List activeValues = se.getActiveRaw(); for (String value : activeValues) { Element symbolElement = doc.createElement(DEFINED_SYMBOL); @@ -192,11 +190,12 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco while (child != null) { if (child.getNodeName().equals(INCLUDE_PATH)) { // Add the path to the property list - includes.put( SafeStringInterner.safeIntern(((Element)child).getAttribute(PATH)), Boolean.valueOf( ((Element)child).getAttribute(REMOVED))); + includes.put(SafeStringInterner.safeIntern(((Element) child).getAttribute(PATH)), + Boolean.valueOf(((Element) child).getAttribute(REMOVED))); } else if (child.getNodeName().equals(DEFINED_SYMBOL)) { // Add the symbol to the symbol list - String symbol = SafeStringInterner.safeIntern(((Element)child).getAttribute(SYMBOL)); - String removed = ((Element)child).getAttribute(REMOVED); + String symbol = SafeStringInterner.safeIntern(((Element) child).getAttribute(SYMBOL)); + String removed = ((Element) child).getAttribute(REMOVED); boolean bRemoved = (removed != null && removed.equals("true")); //$NON-NLS-1$ ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol, !bRemoved); } @@ -215,12 +214,12 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco return PerProjectSICollector.COLLECTOR_ID; } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable() + */ + @Override public IDiscoveredScannerInfoSerializable getSerializable() { - return this; - } + return this; + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java index d86428fbc1e..7504b298376 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java @@ -27,29 +27,27 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; - public class DiscoveredPathInitializer extends PathEntryContainerInitializer { @Override public void initialize(IPath containerPath, ICProject cProject) throws CoreException { - IProject project = cProject.getProject(); - IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project); - String selectedProfileId = buildInfo.getSelectedProfileId(); - if (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(selectedProfileId)) - return; - - ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance(). - getSCProfileConfiguration(selectedProfileId).getProfileScope(); - if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) { - CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new DiscoveredPathContainer(project), null); - } - else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) { - CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new PerFileDiscoveredPathContainer(project), null); - } - else { - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), 1, - MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$ - } + IProject project = cProject.getProject(); + IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project); + String selectedProfileId = buildInfo.getSelectedProfileId(); + if (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(selectedProfileId)) + return; + + ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance() + .getSCProfileConfiguration(selectedProfileId).getProfileScope(); + if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) { + CoreModel.setPathEntryContainer(new ICProject[] { cProject }, new DiscoveredPathContainer(project), null); + } else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) { + CoreModel.setPathEntryContainer(new ICProject[] { cProject }, new PerFileDiscoveredPathContainer(project), + null); + } else { + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), 1, + MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$ + } } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java index f52b35361a9..61800a1a04c 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java @@ -53,47 +53,48 @@ import org.eclipse.core.runtime.Status; public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceChangeListener { private Map fDiscoveredInfoHolderMap = new HashMap(); - private List listeners = Collections.synchronizedList(new ArrayList()); + private List listeners = Collections + .synchronizedList(new ArrayList()); private static final int INFO_CHANGED = 1; private static final int INFO_REMOVED = 2; private static class DiscoveredInfoHolder { Map fInfoMap = new HashMap(); -// PathSettingsContainer fContainer = PathSettingsContainer.createRootContainer(); + // PathSettingsContainer fContainer = PathSettingsContainer.createRootContainer(); - public IDiscoveredPathInfo getInfo(InfoContext context){ + public IDiscoveredPathInfo getInfo(InfoContext context) { return fInfoMap.get(context); } -// private Map getMap(IPath path, boolean create, boolean exactPath){ -// PathSettingsContainer child = fContainer.getChildContainer(path, create, exactPath); -// Map map = null; -// if(child != null){ -// map = (Map)child.getValue(); -// if(map == null && create){ -// map = new HashMap(); -// child.setValue(map); -// } -// } -// -// return map; -// } - -// public IDiscoveredPathInfo getInfo(IFile file, String instanceId){ -// IPath path = file.getProjectRelativePath(); -// Map map = getMap(path, false, false); -// for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ -// Map.Entry entry = (Map.Entry)iter.next(); -// InfoContext context = (InfoContext)entry.getKey(); -// if(context.matches(file)) -// return (IDiscoveredPathInfo)entry.getValue(); -// } -// return null; -// } - - public IDiscoveredPathInfo setInfo(InfoContext context, IDiscoveredPathInfo info){ - if(info != null) + // private Map getMap(IPath path, boolean create, boolean exactPath){ + // PathSettingsContainer child = fContainer.getChildContainer(path, create, exactPath); + // Map map = null; + // if(child != null){ + // map = (Map)child.getValue(); + // if(map == null && create){ + // map = new HashMap(); + // child.setValue(map); + // } + // } + // + // return map; + // } + + // public IDiscoveredPathInfo getInfo(IFile file, String instanceId){ + // IPath path = file.getProjectRelativePath(); + // Map map = getMap(path, false, false); + // for(Iterator iter = map.entrySet().iterator(); iter.hasNext();){ + // Map.Entry entry = (Map.Entry)iter.next(); + // InfoContext context = (InfoContext)entry.getKey(); + // if(context.matches(file)) + // return (IDiscoveredPathInfo)entry.getValue(); + // } + // return null; + // } + + public IDiscoveredPathInfo setInfo(InfoContext context, IDiscoveredPathInfo info) { + if (info != null) return fInfoMap.put(context, info); return fInfoMap.remove(context); } @@ -121,39 +122,38 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC IResource resource = event.getResource(); switch (event.getType()) { - case IResourceChangeEvent.POST_CHANGE : - DiscoveredScannerInfoStore.getInstance().updateScannerConfigStore(event.getDelta()); - break; - case IResourceChangeEvent.PRE_DELETE : - case IResourceChangeEvent.PRE_CLOSE : - if (resource.getType() == IResource.PROJECT) { - //TODO: better handlind of resource remove/rename - fDiscoveredInfoHolderMap.remove(resource); - ScannerConfigProfileManager.getInstance().handleProjectRemoved(resource.getProject()); - } - break; + case IResourceChangeEvent.POST_CHANGE: + DiscoveredScannerInfoStore.getInstance().updateScannerConfigStore(event.getDelta()); + break; + case IResourceChangeEvent.PRE_DELETE: + case IResourceChangeEvent.PRE_CLOSE: + if (resource.getType() == IResource.PROJECT) { + //TODO: better handlind of resource remove/rename + fDiscoveredInfoHolderMap.remove(resource); + ScannerConfigProfileManager.getInstance().handleProjectRemoved(resource.getProject()); + } + break; } } } - - @Override public IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException { return getDiscoveredInfo(project, new InfoContext(project)); } @Override - public IDiscoveredPathInfo getDiscoveredInfo(IProject project, InfoContext context) throws CoreException{ + public IDiscoveredPathInfo getDiscoveredInfo(IProject project, InfoContext context) throws CoreException { return getDiscoveredInfo(project, context, true); } @Override - public IDiscoveredPathInfo getDiscoveredInfo(IProject project, InfoContext context, boolean defaultToProjectSettings) throws CoreException{ + public IDiscoveredPathInfo getDiscoveredInfo(IProject project, InfoContext context, + boolean defaultToProjectSettings) throws CoreException { DiscoveredInfoHolder holder = getHolder(project, true); IDiscoveredPathInfo info = holder.getInfo(context); - if(info == null){ + if (info == null) { info = loadPathInfo(project, context, defaultToProjectSettings); holder.setInfo(context, info); } @@ -161,63 +161,61 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC return info; } - private DiscoveredInfoHolder getHolder(IProject project, boolean create){ + private DiscoveredInfoHolder getHolder(IProject project, boolean create) { DiscoveredInfoHolder holder = fDiscoveredInfoHolderMap.get(project); - if(holder == null && create){ + if (holder == null && create) { holder = new DiscoveredInfoHolder(); fDiscoveredInfoHolderMap.put(project, holder); } return holder; } - private IDiscoveredPathInfo loadPathInfo(IProject project, InfoContext context, boolean defaultToProjectSettings) throws CoreException { - IDiscoveredPathInfo pathInfo = null; - - IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project); - IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context); - if(buildInfo == null && defaultToProjectSettings) - buildInfo = container.getInfo(new InfoContext(project)); - - if(buildInfo != null){ - String profileId = buildInfo.getSelectedProfileId(); - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(project, context, profileId); - IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); - - if (collector instanceof IScannerInfoCollector2) { - IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; - pathInfo = collector2.createPathInfoObject(); - } - } - if(pathInfo == null) { - pathInfo = new DiscoveredPathInfo(project); - } - return pathInfo; - } - + private IDiscoveredPathInfo loadPathInfo(IProject project, InfoContext context, boolean defaultToProjectSettings) + throws CoreException { + IDiscoveredPathInfo pathInfo = null; + IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project); + IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context); + if (buildInfo == null && defaultToProjectSettings) + buildInfo = container.getInfo(new InfoContext(project)); + if (buildInfo != null) { + String profileId = buildInfo.getSelectedProfileId(); + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, + context, profileId); + IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); -// private DiscoveredInfoHolder getHolder + if (collector instanceof IScannerInfoCollector2) { + IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; + pathInfo = collector2.createPathInfoObject(); + } + } + if (pathInfo == null) { + pathInfo = new DiscoveredPathInfo(project); + } + return pathInfo; + } -// private IDiscoveredPathInfo loadPathInfo(IProject project) throws CoreException { -// IDiscoveredPathInfo pathInfo = null; -// -// IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project); -// String profileId = buildInfo.getSelectedProfileId(); -// SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). -// getSCProfileInstance(project, profileId); -// IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); -// -// if (collector instanceof IScannerInfoCollector2) { -// IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; -// pathInfo = collector2.createPathInfoObject(); -// } -// else { -// pathInfo = new DiscoveredPathInfo(project); -// } -// return pathInfo; -// } + // private DiscoveredInfoHolder getHolder + + // private IDiscoveredPathInfo loadPathInfo(IProject project) throws CoreException { + // IDiscoveredPathInfo pathInfo = null; + // + // IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project); + // String profileId = buildInfo.getSelectedProfileId(); + // SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). + // getSCProfileInstance(project, profileId); + // IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); + // + // if (collector instanceof IScannerInfoCollector2) { + // IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; + // pathInfo = collector2.createPathInfoObject(); + // } + // else { + // pathInfo = new DiscoveredPathInfo(project); + // } + // return pathInfo; + // } @Override public void removeDiscoveredInfo(IProject project) { @@ -227,7 +225,7 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC @Override public void removeDiscoveredInfo(IProject project, InfoContext context) { DiscoveredInfoHolder holder = getHolder(project, false); - if(holder != null){ + if (holder != null) { IDiscoveredPathInfo info = holder.setInfo(context, null); if (info != null) { fireUpdate(INFO_REMOVED, info); @@ -235,144 +233,145 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC } } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#updateDiscoveredInfo(org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo, java.util.List) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#updateDiscoveredInfo(org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo, java.util.List) + */ + @Override public void updateDiscoveredInfo(IDiscoveredPathInfo info, List changedResources) throws CoreException { - updateDiscoveredInfo(new InfoContext(info.getProject()), info, true, changedResources); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#updateDiscoveredInfo(org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo, java.util.List) - */ - @Override - public void updateDiscoveredInfo(InfoContext context, IDiscoveredPathInfo info, boolean updateContainer, List changedResources) throws CoreException { - DiscoveredInfoHolder holder = getHolder(info.getProject(), true); - IDiscoveredPathInfo oldInfo = holder.getInfo(context); + updateDiscoveredInfo(new InfoContext(info.getProject()), info, true, changedResources); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#updateDiscoveredInfo(org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo, java.util.List) + */ + @Override + public void updateDiscoveredInfo(InfoContext context, IDiscoveredPathInfo info, boolean updateContainer, + List changedResources) throws CoreException { + DiscoveredInfoHolder holder = getHolder(info.getProject(), true); + IDiscoveredPathInfo oldInfo = holder.getInfo(context); if (oldInfo != null) { - IDiscoveredScannerInfoSerializable serializable = info.getSerializable(); + IDiscoveredScannerInfoSerializable serializable = info.getSerializable(); if (serializable != null) { holder.setInfo(context, info); - IProject project = info.getProject(); - DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, context, serializable); + IProject project = info.getProject(); + DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, context, + serializable); fireUpdate(INFO_CHANGED, info); - if(updateContainer){ + if (updateContainer) { - IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project); - String profileId = buildInfo.getSelectedProfileId(); - ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance(). - getSCProfileConfiguration(profileId).getProfileScope(); - changeDiscoveredContainer(project, profileScope, changedResources); + IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager + .createScannerConfigBuildInfo2(project); + String profileId = buildInfo.getSelectedProfileId(); + ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance() + .getSCProfileConfiguration(profileId).getProfileScope(); + changeDiscoveredContainer(project, profileScope, changedResources); } - } - else { - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, - MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$ + } else { + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, + MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$ } } } - /** - * Allows one to update the discovered information for a particular scanner discovery profile ID. - * TODO: This should be made API in IDiscoveredPathManager, or in an interface derived there from. - * - * @param context - * @param info - * @param updateContainer - * @param changedResources - * @param profileId - * @throws CoreException - */ - public void updateDiscoveredInfo(InfoContext context, IDiscoveredPathInfo info, boolean updateContainer, List changedResources, String profileId) throws CoreException { - DiscoveredInfoHolder holder = getHolder(info.getProject(), true); - IDiscoveredPathInfo oldInfo = holder.getInfo(context); + /** + * Allows one to update the discovered information for a particular scanner discovery profile ID. + * TODO: This should be made API in IDiscoveredPathManager, or in an interface derived there from. + * + * @param context + * @param info + * @param updateContainer + * @param changedResources + * @param profileId + * @throws CoreException + */ + public void updateDiscoveredInfo(InfoContext context, IDiscoveredPathInfo info, boolean updateContainer, + List changedResources, String profileId) throws CoreException { + DiscoveredInfoHolder holder = getHolder(info.getProject(), true); + IDiscoveredPathInfo oldInfo = holder.getInfo(context); if (oldInfo != null) { - IDiscoveredScannerInfoSerializable serializable = info.getSerializable(); + IDiscoveredScannerInfoSerializable serializable = info.getSerializable(); if (serializable != null) { holder.setInfo(context, info); - IProject project = info.getProject(); - DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, context, serializable); + IProject project = info.getProject(); + DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, context, + serializable); fireUpdate(INFO_CHANGED, info); - if(updateContainer){ + if (updateContainer) { - IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project); + IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager + .createScannerConfigBuildInfo2(project); - ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance(). - getSCProfileConfiguration(profileId).getProfileScope(); - changeDiscoveredContainer(project, profileScope, changedResources); + ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance() + .getSCProfileConfiguration(profileId).getProfileScope(); + changeDiscoveredContainer(project, profileScope, changedResources); } - } - else { - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, - MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$ + } else { + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, + MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$ } } } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#changeDiscoveredContainer(org.eclipse.core.resources.IProject, java.lang.String) - */ - @Override - public void changeDiscoveredContainer(final IProject project, final ScannerConfigScope profileScope, final List changedResources) { - // order here is of essence - // 1. clear DiscoveredPathManager's path info cache - DiscoveredInfoHolder holder = getHolder(project, false); - InfoContext context = new InfoContext(project); - IDiscoveredPathInfo oldInfo = holder.getInfo(context); - - // 2. switch the containers - try { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#changeDiscoveredContainer(org.eclipse.core.resources.IProject, java.lang.String) + */ + @Override + public void changeDiscoveredContainer(final IProject project, final ScannerConfigScope profileScope, + final List changedResources) { + // order here is of essence + // 1. clear DiscoveredPathManager's path info cache + DiscoveredInfoHolder holder = getHolder(project, false); + InfoContext context = new InfoContext(project); + IDiscoveredPathInfo oldInfo = holder.getInfo(context); + + // 2. switch the containers + try { + IWorkspaceRunnable runnable = new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { - ICProject cProject = CoreModel.getDefault().create(project); - if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) { - CoreModel.setPathEntryContainer(new ICProject[]{cProject}, - new DiscoveredPathContainer(project), null); - } - else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) { - PerFileDiscoveredPathContainer container = new PerFileDiscoveredPathContainer(project); - CoreModel.setPathEntryContainer(new ICProject[]{cProject}, - container, null); - if (changedResources != null) { - List changeDelta = new ArrayList(changedResources.size()); - for (IResource resource : changedResources) { - IPath path = resource.getFullPath(); - changeDelta.add(new PathEntryContainerChanged(path, - PathEntryContainerChanged.INCLUDE_CHANGED | - PathEntryContainerChanged.MACRO_CHANGED)); // both include paths and symbols changed - } - CoreModel.pathEntryContainerUpdates(container, - changeDelta.toArray(new PathEntryContainerChanged[changeDelta.size()]), - null); - } - } - else { - MakeCorePlugin.log(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), 1, - MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$ - } - - } - }; - CoreModel.run(runnable, null); - } - catch (CoreException e) { - MakeCorePlugin.log(e); - } - - // 3. clear the container's path entry cache - if (oldInfo != null) { - fireUpdate(INFO_REMOVED, oldInfo); - } - } + ICProject cProject = CoreModel.getDefault().create(project); + if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) { + CoreModel.setPathEntryContainer(new ICProject[] { cProject }, + new DiscoveredPathContainer(project), null); + } else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) { + PerFileDiscoveredPathContainer container = new PerFileDiscoveredPathContainer(project); + CoreModel.setPathEntryContainer(new ICProject[] { cProject }, container, null); + if (changedResources != null) { + List changeDelta = new ArrayList( + changedResources.size()); + for (IResource resource : changedResources) { + IPath path = resource.getFullPath(); + changeDelta.add( + new PathEntryContainerChanged(path, PathEntryContainerChanged.INCLUDE_CHANGED + | PathEntryContainerChanged.MACRO_CHANGED)); // both include paths and symbols changed + } + CoreModel.pathEntryContainerUpdates(container, + changeDelta.toArray(new PathEntryContainerChanged[changeDelta.size()]), null); + } + } else { + MakeCorePlugin.log(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), 1, + MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$ + } + + } + }; + CoreModel.run(runnable, null); + } catch (CoreException e) { + MakeCorePlugin.log(e); + } + + // 3. clear the container's path entry cache + if (oldInfo != null) { + fireUpdate(INFO_REMOVED, oldInfo); + } + } private void fireUpdate(final int type, final IDiscoveredPathInfo info) { Object[] list = listeners.toArray(); for (int i = 0; i < list.length; i++) { - final IDiscoveredInfoListener listener = (IDiscoveredInfoListener)list[i]; + final IDiscoveredInfoListener listener = (IDiscoveredInfoListener) list[i]; if (listener != null) { SafeRunner.run(new ISafeRunnable() { @@ -386,12 +385,12 @@ public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceC @Override public void run() throws Exception { switch (type) { - case INFO_CHANGED : - listener.infoChanged(info); - break; - case INFO_REMOVED : - listener.infoRemoved(info); - break; + case INFO_CHANGED: + listener.infoChanged(info); + break; + case INFO_REMOVED: + listener.infoRemoved(info); + break; } } }); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java index 6ee238732d7..f8a2707ccce 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java @@ -61,15 +61,15 @@ import org.xml.sax.SAXException; * @author vhirsl */ public final class DiscoveredScannerInfoStore { - private static final QualifiedName dscFileNameProperty = new - QualifiedName(MakeCorePlugin.getUniqueIdentifier(), "discoveredScannerConfigFileName"); //$NON-NLS-1$ + private static final QualifiedName dscFileNameProperty = new QualifiedName(MakeCorePlugin.getUniqueIdentifier(), + "discoveredScannerConfigFileName"); //$NON-NLS-1$ private static final String CDESCRIPTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".discoveredScannerInfo"; //$NON-NLS-1$ - public static final String SCD_STORE_VERSION = "scdStore"; //$NON-NLS-1$ + public static final String SCD_STORE_VERSION = "scdStore"; //$NON-NLS-1$ public static final String SI_ELEM = "scannerInfo"; //$NON-NLS-1$ public static final String COLLECTOR_ELEM = "collector"; //$NON-NLS-1$ public static final String ID_ATTR = "id"; //$NON-NLS-1$ - private static final String INSTANCE_ELEM = "instance"; //$NON-NLS-1$ + private static final String INSTANCE_ELEM = "instance"; //$NON-NLS-1$ private static DiscoveredScannerInfoStore instance; @@ -84,6 +84,7 @@ public final class DiscoveredScannerInfoStore { } return instance; } + /** * */ @@ -95,31 +96,31 @@ public final class DiscoveredScannerInfoStore { loadDiscoveredScannerInfoFromState(project, new InfoContext(project), serializable); } - public void loadDiscoveredScannerInfoFromState(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable) - throws CoreException { + public void loadDiscoveredScannerInfoFromState(IProject project, InfoContext context, + IDiscoveredScannerInfoSerializable serializable) throws CoreException { // Get the document Element rootElem = getRootElement(project, context, serializable); - if(rootElem != null){ - // get the collector element - NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM); - if (collectorList.getLength() > 0) { - // find the collector element - for (int i = 0; i < collectorList.getLength(); ++i) { - Element collectorElem = (Element) collectorList.item(i); - String collectorId = collectorElem.getAttribute(ID_ATTR); - if (serializable.getCollectorId().equals(collectorId)) { - serializable.deserialize(collectorElem); - break; - } - } - } + if (rootElem != null) { + // get the collector element + NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM); + if (collectorList.getLength() > 0) { + // find the collector element + for (int i = 0; i < collectorList.getLength(); ++i) { + Element collectorElem = (Element) collectorList.item(i); + String collectorId = collectorElem.getAttribute(ID_ATTR); + if (serializable.getCollectorId().equals(collectorId)) { + serializable.deserialize(collectorElem); + break; + } + } + } } } - public boolean hasInfo(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable){ + public boolean hasInfo(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable) { try { - if(getRootElement(project, context, serializable) != null) + if (getRootElement(project, context, serializable) != null) return true; } catch (CoreException e) { MakeCorePlugin.log(e); @@ -127,8 +128,9 @@ public final class DiscoveredScannerInfoStore { return false; } - private Element getRootElement(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable) throws CoreException{ - if(serializable == null) + private Element getRootElement(IProject project, InfoContext context, + IDiscoveredScannerInfoSerializable serializable) throws CoreException { + if (serializable == null) return null; Document document = getDocument(project); @@ -138,12 +140,12 @@ public final class DiscoveredScannerInfoStore { if (rootList.getLength() > 0) { rootElem = (Element) rootList.item(0); - if(!context.isDefaultContext()){ + if (!context.isDefaultContext()) { String instanceId = context.getInstanceId(); - Element instanceElem = findChild(rootElem, INSTANCE_ELEM, ID_ATTR, instanceId); + Element instanceElem = findChild(rootElem, INSTANCE_ELEM, ID_ATTR, instanceId); - rootElem = instanceElem; + rootElem = instanceElem; } } } @@ -153,48 +155,44 @@ public final class DiscoveredScannerInfoStore { private Document getDocument(IProject project) throws CoreException { // Get the document - Reference ref= fDocumentCache.get(project); + Reference ref = fDocumentCache.get(project); Document document = ref != null ? ref.get() : null; if (document == null) { - try { - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - IPath path = getDiscoveredScannerConfigStore(project); - if (path.toFile().exists()) { - // read form file - FileInputStream file = new FileInputStream(path.toFile()); - document = builder.parse(file); - Node rootElem = document.getFirstChild(); - if (rootElem.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) { - // no version info; upgrade - upgradeDocument(document, project); - } - } - else { - // create new document - document = builder.newDocument(); - ProcessingInstruction pi = document.createProcessingInstruction(SCD_STORE_VERSION, "version=\"2\""); //$NON-NLS-1$ - document.appendChild(pi); - Element rootElement = document.createElement(SI_ELEM); - rootElement.setAttribute(ID_ATTR, CDESCRIPTOR_ID); - document.appendChild(rootElement); - } - fDocumentCache.put(project, new SoftReference(document)); - } - catch (IOException e) { - MakeCorePlugin.log(e); - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, - MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$ - } - catch (ParserConfigurationException e) { - MakeCorePlugin.log(e); - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, - MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$ - } - catch (SAXException e) { - MakeCorePlugin.log(e); - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, - MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$ - } + try { + DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + IPath path = getDiscoveredScannerConfigStore(project); + if (path.toFile().exists()) { + // read form file + FileInputStream file = new FileInputStream(path.toFile()); + document = builder.parse(file); + Node rootElem = document.getFirstChild(); + if (rootElem.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) { + // no version info; upgrade + upgradeDocument(document, project); + } + } else { + // create new document + document = builder.newDocument(); + ProcessingInstruction pi = document.createProcessingInstruction(SCD_STORE_VERSION, "version=\"2\""); //$NON-NLS-1$ + document.appendChild(pi); + Element rootElement = document.createElement(SI_ELEM); + rootElement.setAttribute(ID_ATTR, CDESCRIPTOR_ID); + document.appendChild(rootElement); + } + fDocumentCache.put(project, new SoftReference(document)); + } catch (IOException e) { + MakeCorePlugin.log(e); + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, + MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$ + } catch (ParserConfigurationException e) { + MakeCorePlugin.log(e); + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, + MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$ + } catch (SAXException e) { + MakeCorePlugin.log(e); + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, + MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$ + } } return document; } @@ -212,78 +210,81 @@ public final class DiscoveredScannerInfoStore { rootElem.appendChild(collectorElem); } - private Element findChild(Element parentElem, String name, String attr, String attrValue){ - Element cfgElem = null; - NodeList cfgList = parentElem.getElementsByTagName(name); - if (cfgList.getLength() > 0) { - // find per file collector element and remove children - for (int i = 0; i < cfgList.getLength(); ++i) { - Element cElem = (Element) cfgList.item(i); - String value = cElem.getAttribute(attr); - if (value.equals(attrValue)) { - cfgElem = cElem; - break; - } - } - } - - return cfgElem; + private Element findChild(Element parentElem, String name, String attr, String attrValue) { + Element cfgElem = null; + NodeList cfgList = parentElem.getElementsByTagName(name); + if (cfgList.getLength() > 0) { + // find per file collector element and remove children + for (int i = 0; i < cfgList.getLength(); ++i) { + Element cElem = (Element) cfgList.item(i); + String value = cElem.getAttribute(attr); + if (value.equals(attrValue)) { + cfgElem = cElem; + break; + } + } + } + + return cfgElem; } - private void saveDiscoveredScannerInfo(InfoContext context, IDiscoveredScannerInfoSerializable serializable, Document doc) { + private void saveDiscoveredScannerInfo(InfoContext context, IDiscoveredScannerInfoSerializable serializable, + Document doc) { NodeList rootList = doc.getElementsByTagName(SI_ELEM); if (rootList.getLength() > 0) { Element rootElem = (Element) rootList.item(0); // get the collector element - if(!context.isDefaultContext()){ + if (!context.isDefaultContext()) { String instanceId = context.getInstanceId(); Element instanceElem = findChild(rootElem, INSTANCE_ELEM, ID_ATTR, instanceId); - if(instanceElem == null){ - instanceElem = doc.createElement(INSTANCE_ELEM); - instanceElem.setAttribute(ID_ATTR, instanceId); - rootElem.appendChild(instanceElem); - } + if (instanceElem == null) { + instanceElem = doc.createElement(INSTANCE_ELEM); + instanceElem.setAttribute(ID_ATTR, instanceId); + rootElem.appendChild(instanceElem); + } - rootElem = instanceElem; + rootElem = instanceElem; } // get the collector element - Element collectorElem = null; - NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM); - if (collectorList.getLength() > 0) { - // find per file collector element and remove children - for (int i = 0; i < collectorList.getLength(); ++i) { - Element cElem = (Element) collectorList.item(i); - String collectorId = cElem.getAttribute(ID_ATTR); - if (serializable.getCollectorId().equals(collectorId)) { - for (Node child = cElem.getFirstChild(); child != null; - child = cElem.getFirstChild()) { - cElem.removeChild(child); - } - collectorElem = cElem; - break; - } - } - } - if (collectorElem == null) { - // create per profile element - collectorElem = doc.createElement(COLLECTOR_ELEM); - collectorElem.setAttribute(ID_ATTR, serializable.getCollectorId()); - rootElem.appendChild(collectorElem); - } + Element collectorElem = null; + NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM); + if (collectorList.getLength() > 0) { + // find per file collector element and remove children + for (int i = 0; i < collectorList.getLength(); ++i) { + Element cElem = (Element) collectorList.item(i); + String collectorId = cElem.getAttribute(ID_ATTR); + if (serializable.getCollectorId().equals(collectorId)) { + for (Node child = cElem.getFirstChild(); child != null; child = cElem.getFirstChild()) { + cElem.removeChild(child); + } + collectorElem = cElem; + break; + } + } + } + if (collectorElem == null) { + // create per profile element + collectorElem = doc.createElement(COLLECTOR_ELEM); + collectorElem.setAttribute(ID_ATTR, serializable.getCollectorId()); + rootElem.appendChild(collectorElem); + } // Save the discovered scanner info serializable.serialize(collectorElem); } } - public void saveDiscoveredScannerInfoToState(IProject project, IDiscoveredScannerInfoSerializable serializable) throws CoreException { + + public void saveDiscoveredScannerInfoToState(IProject project, IDiscoveredScannerInfoSerializable serializable) + throws CoreException { saveDiscoveredScannerInfoToState(project, new InfoContext(project), serializable); } - public void saveDiscoveredScannerInfoToState(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable) throws CoreException { + public void saveDiscoveredScannerInfoToState(IProject project, InfoContext context, + IDiscoveredScannerInfoSerializable serializable) throws CoreException { Document document = getDocument(project); // Create document try { @@ -323,98 +324,95 @@ public final class DiscoveredScannerInfoStore { } } - public IPath getDiscoveredScannerConfigStore(IProject project) { - String fileName = project.getName() + ".sc"; //$NON-NLS-1$ - String storedFileName = null; - try { - storedFileName = project.getPersistentProperty(dscFileNameProperty); - } catch (CoreException e) { - MakeCorePlugin.log(e.getStatus()); - } - if (storedFileName != null && !storedFileName.equals(fileName)) { - // try to move 2.x file name format to 3.x file name format - movePluginStateFile(storedFileName, fileName); - } - try { - project.setPersistentProperty(dscFileNameProperty, fileName); - } catch (CoreException e) { - MakeCorePlugin.log(e.getStatus()); - } - - return MakeCorePlugin.getWorkingDirectory().append(fileName); - } - - public void updateScannerConfigStore(IResourceDelta delta) { - try { - delta.accept(new IResourceDeltaVisitor() { - - @Override + public IPath getDiscoveredScannerConfigStore(IProject project) { + String fileName = project.getName() + ".sc"; //$NON-NLS-1$ + String storedFileName = null; + try { + storedFileName = project.getPersistentProperty(dscFileNameProperty); + } catch (CoreException e) { + MakeCorePlugin.log(e.getStatus()); + } + if (storedFileName != null && !storedFileName.equals(fileName)) { + // try to move 2.x file name format to 3.x file name format + movePluginStateFile(storedFileName, fileName); + } + try { + project.setPersistentProperty(dscFileNameProperty, fileName); + } catch (CoreException e) { + MakeCorePlugin.log(e.getStatus()); + } + + return MakeCorePlugin.getWorkingDirectory().append(fileName); + } + + public void updateScannerConfigStore(IResourceDelta delta) { + try { + delta.accept(new IResourceDeltaVisitor() { + + @Override public boolean visit(IResourceDelta delta) throws CoreException { - IResource resource = delta.getResource(); - if (resource instanceof IProject) { - IProject project = (IProject) resource; - int kind = delta.getKind(); - switch (kind) { - case IResourceDelta.REMOVED: - if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) { - // project renamed - IPath newPath = delta.getMovedToPath(); - IProject newProject = delta.getResource().getWorkspace(). - getRoot().getProject(newPath.toString()); - scProjectRenamed(project, newProject); - } - else { - // project deleted - scProjectDeleted(project); - } - // remove from cache - fDocumentCache.remove(project); - } - return false; - } - return true; - } - - }); - } - catch (CoreException e) { - MakeCorePlugin.log(e); - } - } - - private void scProjectDeleted(IProject project) { - String scFileName = project.getName() + ".sc"; //$NON-NLS-1$ - deletePluginStateFile(scFileName); - } - - private void deletePluginStateFile(String scFileName) { - IPath path = MakeCorePlugin.getWorkingDirectory().append(scFileName); - File file = path.toFile(); - if (file.exists()) { - file.delete(); - } - } - - private void scProjectRenamed(IProject project, IProject newProject) { - String scOldFileName = project.getName() + ".sc"; //$NON-NLS-1$ - String scNewFileName = newProject.getName() + ".sc"; //$NON-NLS-1$ - movePluginStateFile(scOldFileName, scNewFileName); - try { - newProject.setPersistentProperty(dscFileNameProperty, scNewFileName); - } - catch (CoreException e) { - MakeCorePlugin.log(e); - } - } - - private void movePluginStateFile(String oldFileName, String newFileName) { - IPath oldPath = MakeCorePlugin.getWorkingDirectory().append(oldFileName); - IPath newPath = MakeCorePlugin.getWorkingDirectory().append(newFileName); - File oldFile = oldPath.toFile(); - File newFile = newPath.toFile(); - if (oldFile.exists()) { - oldFile.renameTo(newFile); - } - } + IResource resource = delta.getResource(); + if (resource instanceof IProject) { + IProject project = (IProject) resource; + int kind = delta.getKind(); + switch (kind) { + case IResourceDelta.REMOVED: + if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) { + // project renamed + IPath newPath = delta.getMovedToPath(); + IProject newProject = delta.getResource().getWorkspace().getRoot() + .getProject(newPath.toString()); + scProjectRenamed(project, newProject); + } else { + // project deleted + scProjectDeleted(project); + } + // remove from cache + fDocumentCache.remove(project); + } + return false; + } + return true; + } + + }); + } catch (CoreException e) { + MakeCorePlugin.log(e); + } + } + + private void scProjectDeleted(IProject project) { + String scFileName = project.getName() + ".sc"; //$NON-NLS-1$ + deletePluginStateFile(scFileName); + } + + private void deletePluginStateFile(String scFileName) { + IPath path = MakeCorePlugin.getWorkingDirectory().append(scFileName); + File file = path.toFile(); + if (file.exists()) { + file.delete(); + } + } + + private void scProjectRenamed(IProject project, IProject newProject) { + String scOldFileName = project.getName() + ".sc"; //$NON-NLS-1$ + String scNewFileName = newProject.getName() + ".sc"; //$NON-NLS-1$ + movePluginStateFile(scOldFileName, scNewFileName); + try { + newProject.setPersistentProperty(dscFileNameProperty, scNewFileName); + } catch (CoreException e) { + MakeCorePlugin.log(e); + } + } + + private void movePluginStateFile(String oldFileName, String newFileName) { + IPath oldPath = MakeCorePlugin.getWorkingDirectory().append(oldFileName); + IPath newPath = MakeCorePlugin.getWorkingDirectory().append(newFileName); + File oldFile = oldPath.toFile(); + File newFile = newPath.toFile(); + if (oldFile.exists()) { + oldFile.renameTo(newFile); + } + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java index e4b0f54cf87..94f53c116e2 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java @@ -89,8 +89,7 @@ public class PerFileDiscoveredPathContainer extends DiscoveredPathContainer impl } } } - } - catch (CoreException e) { + } catch (CoreException e) { // } return entries.toArray(new IPathEntry[entries.size()]); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java index e6efd5b51d9..08930b92ee0 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java @@ -81,8 +81,8 @@ public class ScannerConfigInfoFactory { */ @Override public boolean isMakeBuilderConsoleParserEnabled() { - if (getString(MAKE_BUILDER_PARSER_ENABLED) == null || - getString(MAKE_BUILDER_PARSER_ENABLED).length() == 0) { // if no property then default to true + if (getString(MAKE_BUILDER_PARSER_ENABLED) == null + || getString(MAKE_BUILDER_PARSER_ENABLED).length() == 0) { // if no property then default to true return true; } return getBoolean(MAKE_BUILDER_PARSER_ENABLED); @@ -103,13 +103,13 @@ public class ScannerConfigInfoFactory { public String getMakeBuilderConsoleParserId() { String parserId = getString(MAKE_BUILDER_PARSER_ID); if (parserId == null || parserId.length() == 0) { - String[] parserIds = MakeCorePlugin.getDefault(). - getScannerInfoConsoleParserIds("makeBuilder"); //$NON-NLS-1$ + String[] parserIds = MakeCorePlugin.getDefault().getScannerInfoConsoleParserIds("makeBuilder"); //$NON-NLS-1$ // the default is the first one in the registry parserId = parserIds[0]; } return parserId; } + /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setMakeBuilderConsoleParserId(java.lang.String) */ @@ -123,8 +123,8 @@ public class ScannerConfigInfoFactory { */ @Override public boolean isESIProviderCommandEnabled() { - if (getString(ESI_PROVIDER_COMMAND_ENABLED) == null || - getString(ESI_PROVIDER_COMMAND_ENABLED).length() == 0) { // if no property then default to true + if (getString(ESI_PROVIDER_COMMAND_ENABLED) == null + || getString(ESI_PROVIDER_COMMAND_ENABLED).length() == 0) { // if no property then default to true return true; } return getBoolean(ESI_PROVIDER_COMMAND_ENABLED); @@ -143,8 +143,8 @@ public class ScannerConfigInfoFactory { */ @Override public boolean isDefaultESIProviderCmd() { - if (getString(USE_DEFAULT_ESI_PROVIDER_CMD) == null || - getString(USE_DEFAULT_ESI_PROVIDER_CMD).length() == 0) { // if no property then default to true + if (getString(USE_DEFAULT_ESI_PROVIDER_CMD) == null + || getString(USE_DEFAULT_ESI_PROVIDER_CMD).length() == 0) { // if no property then default to true return true; } return getBoolean(USE_DEFAULT_ESI_PROVIDER_CMD); @@ -211,8 +211,8 @@ public class ScannerConfigInfoFactory { public String getESIProviderConsoleParserId() { String parserId = getString(ESI_PROVIDER_PARSER_ID); if (parserId == null || parserId.length() == 0) { - String[] parserIds = MakeCorePlugin.getDefault(). - getScannerInfoConsoleParserIds("externalScannerInfoProvider"); //$NON-NLS-1$ + String[] parserIds = MakeCorePlugin.getDefault() + .getScannerInfoConsoleParserIds("externalScannerInfoProvider"); //$NON-NLS-1$ // the default is the first one in the registry parserId = parserIds[0]; } @@ -232,9 +232,9 @@ public class ScannerConfigInfoFactory { */ @Override public boolean isSIProblemGenerationEnabled() { - if (getString(SI_PROBLEM_GENERATION_ENABLED) == null || - getString(SI_PROBLEM_GENERATION_ENABLED).length() == 0) { // if no property then default to true - return true; + if (getString(SI_PROBLEM_GENERATION_ENABLED) == null + || getString(SI_PROBLEM_GENERATION_ENABLED).length() == 0) { // if no property then default to true + return true; } return getBoolean(SI_PROBLEM_GENERATION_ENABLED); } @@ -252,16 +252,16 @@ public class ScannerConfigInfoFactory { } protected abstract String getBuilderID(); + protected abstract String getString(String property); + protected abstract void putString(String name, String value) throws CoreException; protected String getESIProviderParameter(String name) { - IExtension extension = - Platform.getExtensionRegistry().getExtension( - MakeCorePlugin.getUniqueIdentifier(), - MakeCorePlugin.EXTERNAL_SI_PROVIDER_SIMPLE_ID, - // TODO VMIR make this configurable - MakeCorePlugin.DEFAULT_EXTERNAL_SI_PROVIDER_ID); + IExtension extension = Platform.getExtensionRegistry().getExtension(MakeCorePlugin.getUniqueIdentifier(), + MakeCorePlugin.EXTERNAL_SI_PROVIDER_SIMPLE_ID, + // TODO VMIR make this configurable + MakeCorePlugin.DEFAULT_EXTERNAL_SI_PROVIDER_ID); if (extension == null) return null; IConfigurationElement[] configs = extension.getConfigurationElements(); @@ -322,12 +322,12 @@ public class ScannerConfigInfoFactory { this.builderID = builderID; ICommand builder = ScannerConfigNature.getBuildSpec(project.getDescription(), builderID); if (builder == null) { - throw new CoreException(new Status(IStatus.ERROR, - MakeCorePlugin.getUniqueIdentifier(), -1, + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeMessages.getString("ScannerConfigInfoFactory.Missing_Builder")//$NON-NLS-1$ - + builderID, null)); + + builderID, + null)); } - Map bArgs = builder.getArguments(); + Map bArgs = builder.getArguments(); args = bArgs; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java index 371de2d3e9a..a03c3b98cce 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java @@ -26,16 +26,17 @@ import org.eclipse.core.runtime.IPath; /** * Utility class that handles some Scanner Config specifig collection conversions - * + * * @author vhirsl */ public final class ScannerConfigUtil { - /** + /** * Adds all new discovered symbols/values to the existing ones. - * + * * @param sumSymbols - a map of [String, Map] where Map is a SymbolEntry */ - public static boolean scAddSymbolsList2SymbolEntryMap(Map sumSymbols, List symbols, boolean active) { + public static boolean scAddSymbolsList2SymbolEntryMap(Map sumSymbols, List symbols, + boolean active) { boolean rc = false; for (String symbol : symbols) { String key; @@ -52,8 +53,7 @@ public final class ScannerConfigUtil { // make only the first one to be active sEntry = new SymbolEntry(key, value, true); rc = true; - } - else { + } else { rc |= sEntry.add(value, active); } sumSymbols.put(key, sEntry); @@ -71,17 +71,16 @@ public final class ScannerConfigUtil { SymbolEntry sEntry = symbol.getValue(); if (active) { rv.addAll(sEntry.getActiveRaw()); - } - else { + } else { rv.addAll(sEntry.getRemovedRaw()); } } return rv; } - + /** * MapsSymbolEntryMap to a plain Map - * + * * @param sumSymbols (in) - discovered symbols in SymbolEntryMap * @return - active symbols as a plain Map */ @@ -101,7 +100,8 @@ public final class ScannerConfigUtil { /** * Adds a single symbol definition string ("DEBUG_LEVEL=4") to the SymbolEntryMap */ - public static boolean scAddSymbolString2SymbolEntryMap(Map symbols, String symbol, boolean active) { + public static boolean scAddSymbolString2SymbolEntryMap(Map symbols, String symbol, + boolean active) { boolean rc = false; String key; String value = null; @@ -117,8 +117,7 @@ public final class ScannerConfigUtil { // make only the first one to be active sEntry = new SymbolEntry(key, value, active); rc = true; - } - else { + } else { rc |= sEntry.add(value, active); } symbols.put(key, sEntry); @@ -129,7 +128,8 @@ public final class ScannerConfigUtil { * @param result (out) * @param addend (in) */ - public static boolean scAddSymbolEntryMap2SymbolEntryMap(Map result, Map addend) { + public static boolean scAddSymbolEntryMap2SymbolEntryMap(Map result, + Map addend) { boolean rc = false; Set keySet = addend.keySet(); for (String key : keySet) { @@ -152,8 +152,7 @@ public final class ScannerConfigUtil { rc |= true; } } - } - else { + } else { // result does not contain the symbol; add it // shallow copy SymbolEntry aSymbolEntry = addend.get(key); @@ -174,14 +173,14 @@ public final class ScannerConfigUtil { } return symbol; } - + /** * Returns a symbol value (i.e. for DEF=1 returns 1), may be null */ public static String getSymbolValue(String symbol) { int index = symbol.indexOf('='); if (index != -1) { - return symbol.substring(index+1).trim(); + return symbol.substring(index + 1).trim(); } return null; } @@ -189,7 +188,7 @@ public final class ScannerConfigUtil { /** * Removes a symbol value from the symbol entry. If it was an only value than * it symbol entry will be removed alltogether. - * + * * @param symbolEntryMap map of [symbol's key, symbolEntry] */ public static void removeSymbolEntryValue(String symbol, Map symbolEntryMap) { @@ -204,18 +203,17 @@ public final class ScannerConfigUtil { } } } - + /** * Swaps two include paths in the include paths Map. * Used by Up/Down discovered paths - * + * * @return new map of include paths */ - public static LinkedHashMap swapIncludePaths(LinkedHashMap sumPaths, int index1, int index2) { + public static LinkedHashMap swapIncludePaths(LinkedHashMap sumPaths, + int index1, int index2) { int size = sumPaths.size(); - if (index1 == index2 || - !(index1 >= 0 && index1 < size && - index2 >= 0 && index2 < size)) { + if (index1 == index2 || !(index1 >= 0 && index1 < size && index2 >= 0 && index2 < size)) { return sumPaths; } ArrayList pathKeyList = new ArrayList(sumPaths.keySet()); @@ -223,14 +221,14 @@ public final class ScannerConfigUtil { String temp2 = pathKeyList.get(index2); pathKeyList.set(index1, temp2); pathKeyList.set(index2, temp1); - + LinkedHashMap newSumPaths = new LinkedHashMap(sumPaths.size()); for (String key : pathKeyList) { newSumPaths.put(key, sumPaths.get(key)); } return newSumPaths; } - + /** * Tokenizes string with quotes */ @@ -240,9 +238,9 @@ public final class ScannerConfigUtil { for (int i = 0; i < tokens.length; ++i) { if (i % 2 == 0) { // even tokens need further tokenization String[] sTokens = tokens[i].split("\\s+"); //$NON-NLS-1$ - for (int j = 0; j < sTokens.length; allTokens.add(sTokens[j++])) {} - } - else { + for (int j = 0; j < sTokens.length; allTokens.add(sTokens[j++])) { + } + } else { allTokens.add(tokens[i]); } } @@ -255,9 +253,9 @@ public final class ScannerConfigUtil { public static String[] iPathArray2StringArray(IPath[] paths) { String[] rv = new String[paths.length]; for (int i = 0; i < paths.length; ++i) { - rv[i] = paths[i].toString(); + rv[i] = paths[i].toString(); } return rv; } - + } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java index 80686a04a46..f26653ffc3f 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java @@ -47,31 +47,24 @@ public class ScannerInfoConsoleParserFactory { * Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser * and a utility. */ - public static ConsoleOutputSniffer getESIProviderOutputSniffer(OutputStream outputStream, - OutputStream errorStream, - IProject project, - String id, - IScannerConfigBuilderInfo2 info2, - IScannerInfoCollector collector, + public static ConsoleOutputSniffer getESIProviderOutputSniffer(OutputStream outputStream, OutputStream errorStream, + IProject project, String id, IScannerConfigBuilderInfo2 info2, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { - return getESIProviderOutputSniffer(outputStream, errorStream, project, new InfoContext(project), id, info2, collector, markerGenerator); + return getESIProviderOutputSniffer(outputStream, errorStream, project, new InfoContext(project), id, info2, + collector, markerGenerator); } /** * Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser * and a utility. */ - public static ConsoleOutputSniffer getESIProviderOutputSniffer(OutputStream outputStream, - OutputStream errorStream, - IProject project, - InfoContext infoContext, - String id, - IScannerConfigBuilderInfo2 info2, - IScannerInfoCollector collector, - IMarkerGenerator markerGenerator) { + public static ConsoleOutputSniffer getESIProviderOutputSniffer(OutputStream outputStream, OutputStream errorStream, + IProject project, InfoContext infoContext, String id, IScannerConfigBuilderInfo2 info2, + IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { - IScannerInfoConsoleParser parser = getESIConsoleParser(project, infoContext, id, info2, collector, markerGenerator); + IScannerInfoConsoleParser parser = getESIConsoleParser(project, infoContext, id, info2, collector, + markerGenerator); if (parser != null) { return new ConsoleOutputSniffer(outputStream, errorStream, new IScannerInfoConsoleParser[] { parser }); } @@ -81,16 +74,12 @@ public class ScannerInfoConsoleParserFactory { /** /* Get the ESIProvider console parser. */ - public static IScannerInfoConsoleParser getESIConsoleParser(IProject project, - InfoContext infoContext, - String id, - IScannerConfigBuilderInfo2 info2, - IScannerInfoCollector collector, - IMarkerGenerator markerGenerator) { + public static IScannerInfoConsoleParser getESIConsoleParser(IProject project, InfoContext infoContext, String id, + IScannerConfigBuilderInfo2 info2, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { if (info2.isProviderOutputParserEnabled(id)) { - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(project, infoContext, info2.getSelectedProfileId()); + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, + infoContext, info2.getSelectedProfileId()); IScannerInfoConsoleParser parser = profileInstance.createExternalScannerInfoParser(id); IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(project, MakeBuilder.BUILDER_ID); @@ -105,112 +94,104 @@ public class ScannerInfoConsoleParserFactory { * Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser * and a utility. */ - public static ConsoleOutputSniffer getMakeBuilderOutputSniffer( - OutputStream outputStream, - OutputStream errorStream, - IProject project, - IPath workingDirectory, - IScannerConfigBuilderInfo2 info2, - IMarkerGenerator markerGenerator, - IScannerInfoCollector collector) { - - return getMakeBuilderOutputSniffer(outputStream, errorStream, project, new InfoContext(project), workingDirectory, info2, markerGenerator, collector); + public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(OutputStream outputStream, OutputStream errorStream, + IProject project, IPath workingDirectory, IScannerConfigBuilderInfo2 info2, + IMarkerGenerator markerGenerator, IScannerInfoCollector collector) { + + return getMakeBuilderOutputSniffer(outputStream, errorStream, project, new InfoContext(project), + workingDirectory, info2, markerGenerator, collector); } /** * Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser * and a utility. */ - public static ConsoleOutputSniffer getMakeBuilderOutputSniffer( - OutputStream outputStream, - OutputStream errorStream, - IProject project, - InfoContext infoContext, - IPath workingDirectory, - IScannerConfigBuilderInfo2 info2, - IMarkerGenerator markerGenerator, - IScannerInfoCollector collector) { + public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(OutputStream outputStream, OutputStream errorStream, + IProject project, InfoContext infoContext, IPath workingDirectory, IScannerConfigBuilderInfo2 info2, + IMarkerGenerator markerGenerator, IScannerInfoCollector collector) { - IScannerInfoConsoleParser parser = getScannerInfoConsoleParserInternal(project, infoContext, workingDirectory, info2, markerGenerator, collector); + IScannerInfoConsoleParser parser = getScannerInfoConsoleParserInternal(project, infoContext, workingDirectory, + info2, markerGenerator, collector); if (parser != null) { // create an output stream sniffer - return new ConsoleOutputSniffer(outputStream, errorStream, new IScannerInfoConsoleParser[] {parser}); + return new ConsoleOutputSniffer(outputStream, errorStream, new IScannerInfoConsoleParser[] { parser }); } return null; } private static IScannerInfoConsoleParser getScannerInfoConsoleParserInternal(IProject project, - InfoContext infoContext, - IPath workingDirectory, - IScannerConfigBuilderInfo2 info2, - IMarkerGenerator markerGenerator, - IScannerInfoCollector collector) { + InfoContext infoContext, IPath workingDirectory, IScannerConfigBuilderInfo2 info2, + IMarkerGenerator markerGenerator, IScannerInfoCollector collector) { IScannerInfoConsoleParser parser = null; -// try { - // get the SC builder settings - /*if (currentProject.hasNature(ScannerConfigNature.NATURE_ID))*/ { - if (info2 == null) { - try { - IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(project); - info2 = container.getInfo(infoContext); - } catch (CoreException e) { - // builder not installed or disabled - } + // try { + // get the SC builder settings + /*if (currentProject.hasNature(ScannerConfigNature.NATURE_ID))*/ { + if (info2 == null) { + try { + IScannerConfigBuilderInfo2Set container = ScannerConfigProfileManager + .createScannerConfigBuildInfo2Set(project); + info2 = container.getInfo(infoContext); + } catch (CoreException e) { + // builder not installed or disabled } - if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) { - String id = info2.getSelectedProfileId(); - - // get the make builder console parser - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, infoContext, id); - parser = profileInstance.createBuildOutputParser(); - if (parser != null){ - if (collector == null) { - collector = profileInstance.getScannerInfoCollector(); - } - parser.startup(project, workingDirectory, collector, info2.isProblemReportingEnabled() ? markerGenerator : null); + } + if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) { + String id = info2.getSelectedProfileId(); + + // get the make builder console parser + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance() + .getSCProfileInstance(project, infoContext, id); + parser = profileInstance.createBuildOutputParser(); + if (parser != null) { + if (collector == null) { + collector = profileInstance.getScannerInfoCollector(); } + parser.startup(project, workingDirectory, collector, + info2.isProblemReportingEnabled() ? markerGenerator : null); } } -// } -// catch (CoreException e) { -// MakeCorePlugin.log(e.getStatus()); -// } + } + // } + // catch (CoreException e) { + // MakeCorePlugin.log(e.getStatus()); + // } return parser; } - public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, URI workingDirectoryURI, IMarkerGenerator markerGenerator) { + public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, URI workingDirectoryURI, + IMarkerGenerator markerGenerator) { String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI); - if(pathFromURI == null) { + if (pathFromURI == null) { // fallback to CWD pathFromURI = System.getProperty("user.dir"); //$NON-NLS-1$ } - return getScannerInfoConsoleParserInternal(project, new InfoContext(project), new Path(pathFromURI), null, markerGenerator, null); + return getScannerInfoConsoleParserInternal(project, new InfoContext(project), new Path(pathFromURI), null, + markerGenerator, null); } // TODO - perhaps this be unified with the other one? - public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, - InfoContext infoContext, - IPath workingDirectory, - IScannerConfigBuilderInfo2 info2, - IMarkerGenerator markerGenerator, + public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, InfoContext infoContext, + IPath workingDirectory, IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) { IScannerInfoConsoleParser parser = null; if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) { String id = info2.getSelectedProfileId(); ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(id); - if(profile.getBuildOutputProviderElement() != null){ + if (profile.getBuildOutputProviderElement() != null) { // get the make builder console parser - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, infoContext, id); + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance() + .getSCProfileInstance(project, infoContext, id); parser = profileInstance.createBuildOutputParser(); - if(parser != null){ + if (parser != null) { if (collector == null) { collector = profileInstance.getScannerInfoCollector(); } - parser.startup(project, workingDirectory, collector, info2.isProblemReportingEnabled() ? markerGenerator : null); + parser.startup(project, workingDirectory, collector, + info2.isProblemReportingEnabled() ? markerGenerator : null); } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java index 49d951a47af..e869b3a7985 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java @@ -32,147 +32,147 @@ import org.eclipse.core.resources.IProject; * @author vhirsl */ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsoleParser { - protected static final String[] COMPILER_INVOCATION = { - "gcc", "g++", "cc", "c++" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - }; - protected static final String DASHIDASH= "-I-"; //$NON-NLS-1$ - protected static final String DASHI= "-I"; //$NON-NLS-1$ - protected static final String DASHD= "-D"; //$NON-NLS-1$ + protected static final String[] COMPILER_INVOCATION = { "gcc", "g++", "cc", "c++" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + }; + protected static final String DASHIDASH = "-I-"; //$NON-NLS-1$ + protected static final String DASHI = "-I"; //$NON-NLS-1$ + protected static final String DASHD = "-D"; //$NON-NLS-1$ - private IProject project; - protected IScannerInfoCollector collector; + private IProject project; + protected IScannerInfoCollector collector; - private boolean bMultiline = false; - private String sMultiline = ""; //$NON-NLS-1$ + private boolean bMultiline = false; + private String sMultiline = ""; //$NON-NLS-1$ protected String[] fCompilerCommands; - /** - * @return Returns the project. - */ - protected IProject getProject() { - return project; - } - /** - * @return Returns the collector. - */ - protected IScannerInfoCollector getCollector() { - return collector; - } + /** + * @return Returns the project. + */ + protected IProject getProject() { + return project; + } - public void startup(IProject project, IScannerInfoCollector collector) { - this.project = project; - this.collector = collector; - fCompilerCommands= computeCompilerCommands(); - } + /** + * @return Returns the collector. + */ + protected IScannerInfoCollector getCollector() { + return collector; + } - /** - * Returns array of additional compiler commands to look for - * - * @return String[] - */ - private String[] computeCompilerCommands() { - if (project != null) { - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID); - BuildOutputProvider boProvider = profileInstance.getProfile().getBuildOutputProviderElement(); - if (boProvider != null) { - String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands(); - if (compilerCommandsString != null && compilerCommandsString.length() > 0) { - String[] compilerCommands = compilerCommandsString.split(",\\s*"); //$NON-NLS-1$ - if (compilerCommands.length > 0) { - String[] compilerInvocation = new String[COMPILER_INVOCATION.length + compilerCommands.length]; - System.arraycopy(COMPILER_INVOCATION, 0, compilerInvocation, 0, COMPILER_INVOCATION.length); - System.arraycopy(compilerCommands, 0, compilerInvocation, COMPILER_INVOCATION.length, compilerCommands.length); - return compilerInvocation; - } - } - } - } - return COMPILER_INVOCATION; - } + public void startup(IProject project, IScannerInfoCollector collector) { + this.project = project; + this.collector = collector; + fCompilerCommands = computeCompilerCommands(); + } + + /** + * Returns array of additional compiler commands to look for + * + * @return String[] + */ + private String[] computeCompilerCommands() { + if (project != null) { + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, + ScannerConfigProfileManager.NULL_PROFILE_ID); + BuildOutputProvider boProvider = profileInstance.getProfile().getBuildOutputProviderElement(); + if (boProvider != null) { + String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands(); + if (compilerCommandsString != null && compilerCommandsString.length() > 0) { + String[] compilerCommands = compilerCommandsString.split(",\\s*"); //$NON-NLS-1$ + if (compilerCommands.length > 0) { + String[] compilerInvocation = new String[COMPILER_INVOCATION.length + compilerCommands.length]; + System.arraycopy(COMPILER_INVOCATION, 0, compilerInvocation, 0, COMPILER_INVOCATION.length); + System.arraycopy(compilerCommands, 0, compilerInvocation, COMPILER_INVOCATION.length, + compilerCommands.length); + return compilerInvocation; + } + } + } + } + return COMPILER_INVOCATION; + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String) + */ + @Override public boolean processLine(String line) { if (line.trim().length() == 0) { return false; } - boolean rc = false; - int lineBreakPos = line.length()-1; - char[] lineChars = line.toCharArray(); - while (lineBreakPos >= 0 && Character.isWhitespace(lineChars[lineBreakPos])) { - lineBreakPos--; - } - if (lineBreakPos >= 0) { - if (lineChars[lineBreakPos] != '\\' - || (lineBreakPos > 0 && lineChars[lineBreakPos-1] == '\\')) { - lineBreakPos = -1; - } - } - // check for multiline commands (ends with '\') - if (lineBreakPos >= 0) { - sMultiline += line.substring(0, lineBreakPos); - bMultiline = true; - return rc; - } - if (bMultiline) { - line = sMultiline + line; - bMultiline = false; - sMultiline = ""; //$NON-NLS-1$ - } - line= line.trim(); - TraceUtil.outputTrace("AbstractGCCBOPConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$ - // make\[[0-9]*\]: error_desc - int firstColon= line.indexOf(':'); - String make = line.substring(0, firstColon + 1); - if (firstColon != -1 && make.indexOf("make") != -1) { //$NON-NLS-1$ - boolean enter = false; - String msg = line.substring(firstColon + 1).trim(); - if ((enter = msg.startsWith(MakeMessages.getString("AbstractGCCBOPConsoleParser_EnteringDirectory"))) || //$NON-NLS-1$ - (msg.startsWith(MakeMessages.getString("AbstractGCCBOPConsoleParser_LeavingDirectory")))) { //$NON-NLS-1$ - int s = msg.indexOf('`'); - int e = msg.indexOf('\''); - if (s != -1 && e != -1) { - String dir = msg.substring(s+1, e); - if (getUtility() != null) { - getUtility().changeMakeDirectory(dir, getDirectoryLevel(line), enter); - } - return rc; - } - } - } - // call sublclass to process a single line - return processSingleLine(line.trim()); - } + boolean rc = false; + int lineBreakPos = line.length() - 1; + char[] lineChars = line.toCharArray(); + while (lineBreakPos >= 0 && Character.isWhitespace(lineChars[lineBreakPos])) { + lineBreakPos--; + } + if (lineBreakPos >= 0) { + if (lineChars[lineBreakPos] != '\\' || (lineBreakPos > 0 && lineChars[lineBreakPos - 1] == '\\')) { + lineBreakPos = -1; + } + } + // check for multiline commands (ends with '\') + if (lineBreakPos >= 0) { + sMultiline += line.substring(0, lineBreakPos); + bMultiline = true; + return rc; + } + if (bMultiline) { + line = sMultiline + line; + bMultiline = false; + sMultiline = ""; //$NON-NLS-1$ + } + line = line.trim(); + TraceUtil.outputTrace("AbstractGCCBOPConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$ + // make\[[0-9]*\]: error_desc + int firstColon = line.indexOf(':'); + String make = line.substring(0, firstColon + 1); + if (firstColon != -1 && make.indexOf("make") != -1) { //$NON-NLS-1$ + boolean enter = false; + String msg = line.substring(firstColon + 1).trim(); + if ((enter = msg.startsWith(MakeMessages.getString("AbstractGCCBOPConsoleParser_EnteringDirectory"))) || //$NON-NLS-1$ + (msg.startsWith(MakeMessages.getString("AbstractGCCBOPConsoleParser_LeavingDirectory")))) { //$NON-NLS-1$ + int s = msg.indexOf('`'); + int e = msg.indexOf('\''); + if (s != -1 && e != -1) { + String dir = msg.substring(s + 1, e); + if (getUtility() != null) { + getUtility().changeMakeDirectory(dir, getDirectoryLevel(line), enter); + } + return rc; + } + } + } + // call sublclass to process a single line + return processSingleLine(line.trim()); + } - private int getDirectoryLevel(String line) { - int s = line.indexOf('['); - int num = 0; - if (s != -1) { - int e = line.indexOf(']'); - String number = line.substring(s + 1, e).trim(); - try { - num = Integer.parseInt(number); - } catch (NumberFormatException exc) { - } - } - return num; - } + private int getDirectoryLevel(String line) { + int s = line.indexOf('['); + int num = 0; + if (s != -1) { + int e = line.indexOf(']'); + String number = line.substring(s + 1, e).trim(); + try { + num = Integer.parseInt(number); + } catch (NumberFormatException exc) { + } + } + return num; + } - protected abstract AbstractGCCBOPConsoleParserUtility getUtility(); + protected abstract AbstractGCCBOPConsoleParserUtility getUtility(); - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#shutdown() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#shutdown() + */ + @Override public void shutdown() { - if (getUtility() != null) { - getUtility().reportProblems(); - } - } + if (getUtility() != null) { + getUtility().reportProblems(); + } + } /** * Tokenizes a line into an array of commands. Commands are separated by @@ -187,78 +187,74 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole * @return array of commands */ protected String[][] tokenize(String line, boolean escapeInsideDoubleQuotes) { - ArrayList commands= new ArrayList(); - ArrayList tokens= new ArrayList(); - StringBuilder token= new StringBuilder(); + ArrayList commands = new ArrayList(); + ArrayList tokens = new ArrayList(); + StringBuilder token = new StringBuilder(); - final char[] input= line.toCharArray(); - boolean nextEscaped= false; - char currentQuote= 0; + final char[] input = line.toCharArray(); + boolean nextEscaped = false; + char currentQuote = 0; for (int i = 0; i < input.length; i++) { final char c = input[i]; - final boolean escaped= nextEscaped; nextEscaped= false; + final boolean escaped = nextEscaped; + nextEscaped = false; if (currentQuote != 0) { if (c == currentQuote) { if (escaped) { token.append(c); - } - else { - if (c=='`') { - token.append(c); // preserve back-quotes + } else { + if (c == '`') { + token.append(c); // preserve back-quotes } - currentQuote= 0; + currentQuote = 0; } - } - else { + } else { if (escapeInsideDoubleQuotes && currentQuote == '"' && c == '\\') { - nextEscaped= !escaped; + nextEscaped = !escaped; if (escaped) { token.append(c); } - } - else { + } else { if (escaped) { token.append('\\'); } token.append(c); } } - } - else { - switch(c) { + } else { + switch (c) { case '\\': if (escaped) { token.append(c); - } - else { - nextEscaped= true; + } else { + nextEscaped = true; } break; - case '\'': case '"': case '`': + case '\'': + case '"': + case '`': if (escaped) { token.append(c); - } - else { + } else { if (c == '`') { token.append(c); } - currentQuote= c; + currentQuote = c; } break; case ';': if (escaped) { token.append(c); - } - else { + } else { endCommand(token, tokens, commands); } break; - case '&': case '|': - if (escaped || i+1 >= input.length || input[i+1] != c) { + case '&': + case '|': + if (escaped || i + 1 >= input.length || input[i + 1] != c) { token.append(c); - } - else { + } else { i++; endCommand(token, tokens, commands); } @@ -268,14 +264,12 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole if (Character.isWhitespace(c)) { if (escaped) { token.append(c); - } - else { + } else { endToken(token, tokens); } - } - else { + } else { if (escaped) { - token.append('\\'); // for windows put backslash back onto the token. + token.append('\\'); // for windows put backslash back onto the token. } token.append(c); } @@ -293,6 +287,7 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole tokens.clear(); } } + private void endToken(StringBuilder token, ArrayList tokens) { if (token.length() > 0) { tokens.add(token.toString()); @@ -300,22 +295,21 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole } } - protected boolean processSingleLine(String line) { - boolean rc= false; - String[][] tokens= tokenize(line, true); + protected boolean processSingleLine(String line) { + boolean rc = false; + String[][] tokens = tokenize(line, true); for (int i = 0; i < tokens.length; i++) { String[] command = tokens[i]; if (processCommand(command)) { - rc= true; - } - else { // go inside quotes, if the compiler is called per wrapper or shell script + rc = true; + } else { // go inside quotes, if the compiler is called per wrapper or shell script for (int j = 0; j < command.length; j++) { - String[][] subtokens= tokenize(command[j], true); + String[][] subtokens = tokenize(command[j], true); for (int k = 0; k < subtokens.length; k++) { String[] subcommand = subtokens[k]; - if (subcommand.length > 1) { // only proceed if there is any additional info + if (subcommand.length > 1) { // only proceed if there is any additional info if (processCommand(subcommand)) { - rc= true; + rc = true; } } } @@ -323,20 +317,20 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole } } return rc; - } + } - protected int findCompilerInvocation(String[] tokens) { - for (int i = 0; i < tokens.length; i++) { + protected int findCompilerInvocation(String[] tokens) { + for (int i = 0; i < tokens.length; i++) { final String token = tokens[i].toLowerCase(); - final int searchFromOffset= Math.max(token.lastIndexOf('/'), token.lastIndexOf('\\')) + 1; - for (int j=0; j < fCompilerCommands.length; j++) { - if (token.indexOf(fCompilerCommands[j], searchFromOffset) != -1) { - return i; - } - } - } - return -1; - } + final int searchFromOffset = Math.max(token.lastIndexOf('/'), token.lastIndexOf('\\')) + 1; + for (int j = 0; j < fCompilerCommands.length; j++) { + if (token.indexOf(fCompilerCommands[j], searchFromOffset) != -1) { + return i; + } + } + } + return -1; + } - abstract protected boolean processCommand(String[] command); + abstract protected boolean processCommand(String[] command); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java index 46bb7932107..f6abd11f199 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java @@ -26,177 +26,173 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; /** - * Common utilities for GCC build output console parsers - * + * Common utilities for GCC build output console parsers + * * @author vhirsl */ public abstract class AbstractGCCBOPConsoleParserUtility { - private IProject project; - private IPath fBaseDirectory; - private Vector fDirectoryStack; - private IMarkerGenerator fMarkerGenerator; - private ArrayList fErrors; - - /** - * - */ - public AbstractGCCBOPConsoleParserUtility(IProject project, IPath workingDirectory, - IMarkerGenerator markerGenerator) { - fDirectoryStack = new Vector(); - fErrors = new ArrayList(); - this.project = project; - fBaseDirectory = new Path(EFSExtensionManager.getDefault().getPathFromURI(project.getLocationURI())); - if (workingDirectory != null) { - pushDirectory(workingDirectory); - } - } - - /** - * @return Returns the fBaseDirectory. - */ - public IPath getBaseDirectory() { - return fBaseDirectory; - } - /** - * @return Returns the fDirectoryStack. - */ - protected Vector getDirectoryStack() { - return fDirectoryStack; - } - /** - * @return Returns the fErrors. - */ - protected ArrayList getErrors() { - return fErrors; - } - /** - * @return Returns the fMarkerGenerator. - */ - protected IMarkerGenerator getMarkerGenerator() { - return fMarkerGenerator; - } - /** - * @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 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 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 IProject project; + private IPath fBaseDirectory; + private Vector fDirectoryStack; + private IMarkerGenerator fMarkerGenerator; + private ArrayList fErrors; + + /** + * + */ + public AbstractGCCBOPConsoleParserUtility(IProject project, IPath workingDirectory, + IMarkerGenerator markerGenerator) { + fDirectoryStack = new Vector(); + fErrors = new ArrayList(); + this.project = project; + fBaseDirectory = new Path(EFSExtensionManager.getDefault().getPathFromURI(project.getLocationURI())); + if (workingDirectory != null) { + pushDirectory(workingDirectory); + } + } + + /** + * @return Returns the fBaseDirectory. + */ + public IPath getBaseDirectory() { + return fBaseDirectory; + } + + /** + * @return Returns the fDirectoryStack. + */ + protected Vector getDirectoryStack() { + return fDirectoryStack; + } + + /** + * @return Returns the fErrors. + */ + protected ArrayList getErrors() { + return fErrors; + } + + /** + * @return Returns the fMarkerGenerator. + */ + protected IMarkerGenerator getMarkerGenerator() { + return fMarkerGenerator; + } + + /** + * @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 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 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; } 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 int getDirectoryLevel() { - return fDirectoryStack.size(); - } - - 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 */ - } - } - - public boolean reportProblems() { - boolean reset = false; - for (Iterator 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; - } - - protected class Problem { - protected IResource file; - protected int lineNumber; - protected String description; - 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; - } - } - - /** - * 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); - } - } + int i = getDirectoryLevel(); + if (i != 0) { + IPath dir = fDirectoryStack.lastElement(); + fDirectoryStack.removeElementAt(i - 1); + return dir; + } + return new Path(""); //$NON-NLS-1$ + } + + protected int getDirectoryLevel() { + return fDirectoryStack.size(); + } + + 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 */ + } + } + + public boolean reportProblems() { + boolean reset = false; + for (Iterator 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; + } + + protected class Problem { + protected IResource file; + protected int lineNumber; + protected String description; + 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; + } + } + + /** + * 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); + } + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java index be42b3bedde..354248e07ef 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java @@ -33,99 +33,96 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; - /** * GCC per file build output parser * * @author vhirsl */ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser { - private final static String[] FILE_EXTENSIONS = { - ".c", ".cc", ".cpp", ".cxx", ".C", ".CC", ".CPP", ".CXX" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ - }; - private final static List FILE_EXTENSIONS_LIST = Arrays.asList(FILE_EXTENSIONS); + private final static String[] FILE_EXTENSIONS = { ".c", ".cc", ".cpp", ".cxx", ".C", ".CC", ".CPP", ".CXX" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ + }; + private final static List FILE_EXTENSIONS_LIST = Arrays.asList(FILE_EXTENSIONS); - private GCCPerFileBOPConsoleParserUtility fUtil; + private GCCPerFileBOPConsoleParserUtility fUtil; - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator) - */ - @Override - public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { - fUtil = (project != null && workingDirectory != null && markerGenerator != null) ? - new GCCPerFileBOPConsoleParserUtility(project, workingDirectory, markerGenerator) : null; - super.startup(project, collector); - } + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator) + */ + @Override + public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, + IMarkerGenerator markerGenerator) { + fUtil = (project != null && workingDirectory != null && markerGenerator != null) + ? new GCCPerFileBOPConsoleParserUtility(project, workingDirectory, markerGenerator) + : null; + super.startup(project, collector); + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#getUtility() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#getUtility() + */ + @Override protected AbstractGCCBOPConsoleParserUtility getUtility() { - return fUtil; - } + return fUtil; + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#processSingleLine(java.lang.String) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#processSingleLine(java.lang.String) + */ + @Override protected boolean processCommand(String[] tokens) { - // GCC C/C++ compiler invocation - int compilerInvocationIndex= findCompilerInvocation(tokens); - if (compilerInvocationIndex < 0) { - return false; - } + // 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; - 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 = FILE_EXTENSIONS_LIST.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==null || filePath.indexOf(FILE_EXTENSIONS[extensionsIndex]) == -1) { - TraceUtil.outputTrace("Error identifying file name :2", tokens, TraceUtil.EOL); //$NON-NLS-1$ - return false; - } - if (fUtil != null) { - IPath pFilePath = fUtil.getAbsolutePath(filePath); - String shortFileName = pFilePath.removeFileExtension().lastSegment(); + // find a file name + int extensionsIndex = -1; + boolean found = false; + String filePath = null; + 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 = FILE_EXTENSIONS_LIST.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 == null || filePath.indexOf(FILE_EXTENSIONS[extensionsIndex]) == -1) { + TraceUtil.outputTrace("Error identifying file name :2", tokens, TraceUtil.EOL); //$NON-NLS-1$ + return false; + } + if (fUtil != null) { + IPath pFilePath = fUtil.getAbsolutePath(filePath); + String shortFileName = pFilePath.removeFileExtension().lastSegment(); - // generalize occurrences of the file name - for (int i = compilerInvocationIndex+1; i < tokens.length; i++) { + // 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$ + } 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]= "SHORT_NAME" + token.substring(shortFileName.length()); //$NON-NLS-1$ + } else if (token.equals(filePath)) { + tokens[i] = "LONG_NAME"; //$NON-NLS-1$ + } else if (token.startsWith(shortFileName)) { + tokens[i] = "SHORT_NAME" + token.substring(shortFileName.length()); //$NON-NLS-1$ } } - IFile file= null; - IPath baseDirectory= fUtil.getBaseDirectory(); - if (baseDirectory.isPrefixOf(pFilePath) || baseDirectory.setDevice(null).isPrefixOf(pFilePath)) { + IFile file = null; + IPath baseDirectory = fUtil.getBaseDirectory(); + if (baseDirectory.isPrefixOf(pFilePath) || baseDirectory.setDevice(null).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 @@ -133,22 +130,22 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser { //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 { - // search linked resources - final IProject prj= fUtil.getProject(); - file= ResourceLookup.selectFileForLocation(pFilePath, prj); - } - if (file != null) { - CCommandDSC cmd = fUtil.getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0); - List cmdList = new CopyOnWriteArrayList(); - cmdList.add(cmd); - Map> sc = new HashMap>(1); - sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList); - getCollector().contributeToScannerConfig(file, sc); - } else - TraceUtil.outputError("Build command for file outside project: "+pFilePath.toString(), tokens); //$NON-NLS-1$ - } - return true; - } + file = getProject().getFile(relPath); + } else { + // search linked resources + final IProject prj = fUtil.getProject(); + file = ResourceLookup.selectFileForLocation(pFilePath, prj); + } + if (file != null) { + CCommandDSC cmd = fUtil.getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0); + List cmdList = new CopyOnWriteArrayList(); + cmdList.add(cmd); + Map> sc = new HashMap>(1); + sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList); + getCollector().contributeToScannerConfig(file, sc); + } else + TraceUtil.outputError("Build command for file outside project: " + pFilePath.toString(), tokens); //$NON-NLS-1$ + } + return true; + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java index a0a1031a29e..51774fab885 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java @@ -33,262 +33,253 @@ import org.eclipse.core.runtime.Path; /** * TODO Provide description - * + * * @author vhirsl */ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsoleParserUtility { - private Map>>> directoryCommandListMap; - private List compiledFileList; - - private List commandsList2; - - private int workingDirsN = 0; - private int commandsN = 0; - private int filesN = 0; - private String fDefaultMacroDefinitionValue= "1"; //$NON-NLS-1$ + private Map>>> directoryCommandListMap; + private List compiledFileList; + private List commandsList2; - public GCCPerFileBOPConsoleParserUtility(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) { - super(project, workingDirectory, markerGenerator); - } + private int workingDirsN = 0; + private int commandsN = 0; + private int filesN = 0; + private String fDefaultMacroDefinitionValue = "1"; //$NON-NLS-1$ - 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 = directoryCommandListMap.get(workingDir); - if (directoryCommandList == null) { - directoryCommandList = new CopyOnWriteArrayList>>(); - directoryCommandListMap.put(workingDir, directoryCommandList); - ++workingDirsN; - } - Map> command21FileListMap = null; - for (Map> map : directoryCommandList) { - command21FileListMap = map; - List fileList = 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 CopyOnWriteArrayList(); - command21FileListMap.put(genericCommand, fileList); - fileList.add(longFileName); - ++filesN; - } + public GCCPerFileBOPConsoleParserUtility(IProject project, IPath workingDirectory, + IMarkerGenerator markerGenerator) { + super(project, workingDirectory, markerGenerator); + } - /** - * - */ - 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$ - } + void addGenericCommandForFile(String longFileName, String genericCommand) { + // if a file name has already been added once, return + if (compiledFileList.contains(longFileName)) + return; + compiledFileList.add(longFileName); - /** - * Adds a mapping command line -> file, this time without a dir - */ - 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 workingDir = getWorkingDirectory().toString(); + List>> directoryCommandList = directoryCommandListMap.get(workingDir); + if (directoryCommandList == null) { + directoryCommandList = new CopyOnWriteArrayList>>(); + directoryCommandListMap.put(workingDir, directoryCommandList); + ++workingDirsN; + } + Map> command21FileListMap = null; + for (Map> map : directoryCommandList) { + command21FileListMap = map; + List fileList = 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 CopyOnWriteArrayList(); + command21FileListMap.put(genericCommand, fileList); + fileList.add(longFileName); + ++filesN; + } - 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 = commandsList2.get(index); - } -// // add a file -// command.addFile(longFileName); -// ++filesN; - } + /** + * + */ + 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$ + } + + /** + * Adds a mapping command line -> file, this time without a dir + */ + 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 = commandsList2.get(index); + } + // // add a file + // command.addFile(longFileName); + // ++filesN; + } - /** - * @return CCommandDSC compile command description - */ - public CCommandDSC getNewCCommandDSC(String[] tokens, final int idxOfCompilerCommand, boolean cppFileType) { + /** + * @return CCommandDSC compile command description + */ + public CCommandDSC getNewCCommandDSC(String[] tokens, final int idxOfCompilerCommand, boolean cppFileType) { CopyOnWriteArrayList dirafter = new CopyOnWriteArrayList(); CopyOnWriteArrayList includes = new CopyOnWriteArrayList(); - CCommandDSC command = new CCommandDSC(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.startsWith("--sysroot") || //$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)); + CCommandDSC command = new CCommandDSC(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.startsWith("--sysroot") || //$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)); 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 (String inc : includes) { - option = inc; - KVStringPair pair = new KVStringPair(SCDOptionsEnum.IQUOTE.toString(), option); - command.addSCOption(pair); - } - includes = new CopyOnWriteArrayList(); - // -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; - } - } - } - for (String option : includes) { - KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option); - command.addSCOption(pair); - } - for (KVStringPair kvStringPair : dirafter) { - command.addSCOption(kvStringPair); - } - return command; - } + String option = token.substring(optionKind.toString().length()).trim(); + if (option.length() > 0) { + // ex. -I/dir + } else if (optionKind.equals(SCDOptionsEnum.IDASH)) { + for (String inc : includes) { + option = inc; + KVStringPair pair = new KVStringPair(SCDOptionsEnum.IQUOTE.toString(), option); + command.addSCOption(pair); + } + includes = new CopyOnWriteArrayList(); + // -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(); + } - public void setDefaultMacroDefinitionValue(String val) { - if (val != null) { - fDefaultMacroDefinitionValue= val; - } + 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; + } + } + } + for (String option : includes) { + KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option); + command.addSCOption(pair); + } + for (KVStringPair kvStringPair : dirafter) { + command.addSCOption(kvStringPair); + } + return command; + } + + public void setDefaultMacroDefinitionValue(String val) { + if (val != null) { + fDefaultMacroDefinitionValue = val; + } } /** - * @param filePath : String - * @return filePath : IPath - not null - */ - public IPath getAbsolutePath(String filePath) { - IPath pFilePath; - if (filePath.startsWith("/")) { //$NON-NLS-1$ - pFilePath = 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); - } - - if (pFilePath.getDevice()==null) { - pFilePath = pFilePath.setDevice(getWorkingDirectory().getDevice()); - } - return pFilePath; - } + * @param filePath : String + * @return filePath : IPath - not null + */ + public IPath getAbsolutePath(String filePath) { + IPath pFilePath; + if (filePath.startsWith("/")) { //$NON-NLS-1$ + pFilePath = 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); + } - /** - * - */ -// void generateReport2() { -// StringWriter buffer = new StringWriter(); -// PrintWriter writer = new PrintWriter(buffer); -// for (Iterator i = commandsList2.iterator(); i.hasNext(); ) { -// CCommandDSC cmd = (CCommandDSC)i.next(); -// writer.println("Stats for generic command: '" + cmd.getCommandAsString() + "' applicable for " + -// Integer.toString(cmd.getNumberOfFiles()) + " files: "); -// List filesList = cmd.getFilesList(); -// if (filesList != null) { -// for (Iterator j = filesList.iterator(); j.hasNext(); ) { -// writer.println(" " + (String)j.next()); -// } -// } -// } -// writer.close(); -// -// TraceUtil.metricsTrace(buffer.toString()); -// TraceUtil.summaryTrace("Discovery summary", workingDirsN, commandsN, filesN); -// } + if (pFilePath.getDevice() == null) { + pFilePath = pFilePath.setDevice(getWorkingDirectory().getDevice()); + } + return pFilePath; + } - /** - * 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 CopyOnWriteArrayList(commandsList2); - } + /** + * + */ + // void generateReport2() { + // StringWriter buffer = new StringWriter(); + // PrintWriter writer = new PrintWriter(buffer); + // for (Iterator i = commandsList2.iterator(); i.hasNext(); ) { + // CCommandDSC cmd = (CCommandDSC)i.next(); + // writer.println("Stats for generic command: '" + cmd.getCommandAsString() + "' applicable for " + + // Integer.toString(cmd.getNumberOfFiles()) + " files: "); + // List filesList = cmd.getFilesList(); + // if (filesList != null) { + // for (Iterator j = filesList.iterator(); j.hasNext(); ) { + // writer.println(" " + (String)j.next()); + // } + // } + // } + // writer.close(); + // + // TraceUtil.metricsTrace(buffer.toString()); + // TraceUtil.summaryTrace("Discovery summary", workingDirsN, commandsN, filesN); + // } + + /** + * 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 CopyOnWriteArrayList(commandsList2); + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java index a81b5cf780a..32d2ed6f4b8 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java @@ -33,107 +33,103 @@ import org.eclipse.core.runtime.IPath; * @author vhirsl */ public class GCCPerFileSIPConsoleParser implements IScannerInfoConsoleParser { - private final static String INCLUDE_PREAMBLE = "#include <...>"; //$NON-NLS-1$ - private final static String QUOTE_INCLUDE_PREAMBLE = "#include \"...\""; //$NON-NLS-1$ - private final static String DEFINE_PREAMBLE = "#define"; //$NON-NLS-1$ - private final static String COMMAND_ID_BEGIN = "begin generating scanner info for scd_cmd_"; //$NON-NLS-1$ - private final static String COMMAND_ID_END = "end generating scanner info for scd_cmd_"; //$NON-NLS-1$ + private final static String INCLUDE_PREAMBLE = "#include <...>"; //$NON-NLS-1$ + private final static String QUOTE_INCLUDE_PREAMBLE = "#include \"...\""; //$NON-NLS-1$ + private final static String DEFINE_PREAMBLE = "#define"; //$NON-NLS-1$ + private final static String COMMAND_ID_BEGIN = "begin generating scanner info for scd_cmd_"; //$NON-NLS-1$ + private final static String COMMAND_ID_END = "end generating scanner info for scd_cmd_"; //$NON-NLS-1$ - private final static int NO_INCLUDES = 0; - private final static int QUOTE_INCLUDES = 1; - private final static int INCLUDES = 2; + private final static int NO_INCLUDES = 0; + private final static int QUOTE_INCLUDES = 1; + private final static int INCLUDES = 2; - private IScannerInfoCollector fCollector = null; + private IScannerInfoCollector fCollector = null; - private int expectingIncludes = NO_INCLUDES; - private List symbols; - private List includes; - private List quoteIncludes; - private int commandId = -1; + private int expectingIncludes = NO_INCLUDES; + private List symbols; + private List includes; + private List quoteIncludes; + private int commandId = -1; - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator) - */ - @Override - public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { - this.fCollector = collector; - } + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator) + */ + @Override + public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, + IMarkerGenerator markerGenerator) { + this.fCollector = collector; + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String) + */ + @Override public boolean processLine(String line) { - boolean rc = false; - line= line.trim(); - TraceUtil.outputTrace("GCCPerFileSIPConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$//$NON-NLS-2$ + boolean rc = false; + line = line.trim(); + TraceUtil.outputTrace("GCCPerFileSIPConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$//$NON-NLS-2$ - if (line.startsWith(COMMAND_ID_BEGIN)) { - commandId = Integer.parseInt(line.substring(COMMAND_ID_BEGIN.length())); - symbols = new ArrayList(); - includes = new ArrayList(); - quoteIncludes = new ArrayList(); - } - else if (line.startsWith(COMMAND_ID_END)) { - Map> scannerInfo = new HashMap>(); - scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes); - scannerInfo.put(ScannerInfoTypes.QUOTE_INCLUDE_PATHS, quoteIncludes); - scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols); - fCollector.contributeToScannerConfig(Integer.valueOf(commandId), scannerInfo); - commandId = -1; - rc = true; - } - // contribution of -dD option - else if (line.startsWith(DEFINE_PREAMBLE)) { - String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$ - if (defineParts[0].equals(DEFINE_PREAMBLE)) { - String symbol = null; - switch (defineParts.length) { - case 2: - symbol = defineParts[1]; - break; - case 3: - symbol = defineParts[1] + "=" + defineParts[2]; //$NON-NLS-1$ - break; - } - if (symbol != null && !symbols.contains(symbol)) { - symbols.add(symbol); - } - } - } - // now get all the includes - else if (line.startsWith(QUOTE_INCLUDE_PREAMBLE) && line.endsWith("search starts here:")) { //$NON-NLS-1$ - expectingIncludes = QUOTE_INCLUDES; - } - else if (line.startsWith(INCLUDE_PREAMBLE) && line.endsWith("search starts here:")) { //$NON-NLS-1$ - expectingIncludes = INCLUDES; - } - else if (line.startsWith("End of search list.")) { //$NON-NLS-1$ - expectingIncludes = NO_INCLUDES; - } - else if (expectingIncludes == QUOTE_INCLUDES) { - if (!quoteIncludes.contains(line)) - quoteIncludes.add(line); - } - else if (expectingIncludes == INCLUDES) { - if (!includes.contains(line)) - includes.add(line); - } + if (line.startsWith(COMMAND_ID_BEGIN)) { + commandId = Integer.parseInt(line.substring(COMMAND_ID_BEGIN.length())); + symbols = new ArrayList(); + includes = new ArrayList(); + quoteIncludes = new ArrayList(); + } else if (line.startsWith(COMMAND_ID_END)) { + Map> scannerInfo = new HashMap>(); + scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes); + scannerInfo.put(ScannerInfoTypes.QUOTE_INCLUDE_PATHS, quoteIncludes); + scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols); + fCollector.contributeToScannerConfig(Integer.valueOf(commandId), scannerInfo); + commandId = -1; + rc = true; + } + // contribution of -dD option + else if (line.startsWith(DEFINE_PREAMBLE)) { + String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$ + if (defineParts[0].equals(DEFINE_PREAMBLE)) { + String symbol = null; + switch (defineParts.length) { + case 2: + symbol = defineParts[1]; + break; + case 3: + symbol = defineParts[1] + "=" + defineParts[2]; //$NON-NLS-1$ + break; + } + if (symbol != null && !symbols.contains(symbol)) { + symbols.add(symbol); + } + } + } + // now get all the includes + else if (line.startsWith(QUOTE_INCLUDE_PREAMBLE) && line.endsWith("search starts here:")) { //$NON-NLS-1$ + expectingIncludes = QUOTE_INCLUDES; + } else if (line.startsWith(INCLUDE_PREAMBLE) && line.endsWith("search starts here:")) { //$NON-NLS-1$ + expectingIncludes = INCLUDES; + } else if (line.startsWith("End of search list.")) { //$NON-NLS-1$ + expectingIncludes = NO_INCLUDES; + } else if (expectingIncludes == QUOTE_INCLUDES) { + if (!quoteIncludes.contains(line)) + quoteIncludes.add(line); + } else if (expectingIncludes == INCLUDES) { + if (!includes.contains(line)) + includes.add(line); + } - return rc; - } + return rc; + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown() + */ + @Override public void shutdown() { -// Map scannerInfo = new HashMap(); -// scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes); -// scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols); -// fCollector.contributeToScannerConfig(fProject, scannerInfo); -// TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$ -// "Include paths", includes, new ArrayList(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$); - } + // Map scannerInfo = new HashMap(); + // scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes); + // scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols); + // fCollector.contributeToScannerConfig(fProject, scannerInfo); + // TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$ + // "Include paths", includes, new ArrayList(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$); + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java index 92b19e78584..4edcdf4815c 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java @@ -26,12 +26,12 @@ import org.eclipse.core.runtime.Status; /** * GCC related utility class - * + * * @author vhirsl */ public class GCCScannerConfigUtil { - public static final String CPP_SPECS_FILE = "specs.cpp"; //$NON-NLS-1$ - public static final String C_SPECS_FILE = "specs.c"; //$NON-NLS-1$ + public static final String CPP_SPECS_FILE = "specs.cpp"; //$NON-NLS-1$ + public static final String C_SPECS_FILE = "specs.c"; //$NON-NLS-1$ public static void createSpecs() { IPath path = MakeCorePlugin.getWorkingDirectory(); @@ -52,9 +52,8 @@ public class GCCScannerConfigUtil { file.write('\n'); file.close(); } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, - MakeCorePlugin.getUniqueIdentifier(), -1, - MakeMessages.getString("GCCScannerConfigUtil.Error_Message"), e)); //$NON-NLS-1$ + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, + MakeMessages.getString("GCCScannerConfigUtil.Error_Message"), e)); //$NON-NLS-1$ } } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java index 37e93a27391..e834b093a0f 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java @@ -40,179 +40,173 @@ import org.eclipse.core.runtime.Path; public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser { protected ScannerInfoConsoleParserUtility fUtil = null; - private String fDefaultMacroDefinitionValue= "1"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator) - */ - @Override - public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) { - fUtil = (project != null && workingDirectory != null && markerGenerator != null) ? - new ScannerInfoConsoleParserUtility(project, workingDirectory, markerGenerator) : null; - super.startup(project, collector); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#getUtility() - */ - @Override - protected AbstractGCCBOPConsoleParserUtility getUtility() { - return fUtil; - } - - @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 includes = new CopyOnWriteArrayList(); - List symbols = new CopyOnWriteArrayList(); - List targetSpecificOptions = new CopyOnWriteArrayList(); - - String fileName = null; - for (int j= compilerInvocationIdx+1; j < tokens.length; j++) { + private String fDefaultMacroDefinitionValue = "1"; //$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator) + */ + @Override + public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, + IMarkerGenerator markerGenerator) { + fUtil = (project != null && workingDirectory != null && markerGenerator != null) + ? new ScannerInfoConsoleParserUtility(project, workingDirectory, markerGenerator) + : null; + super.startup(project, collector); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#getUtility() + */ + @Override + protected AbstractGCCBOPConsoleParserUtility getUtility() { + return fUtil; + } + + @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 includes = new CopyOnWriteArrayList(); + List symbols = new CopyOnWriteArrayList(); + List targetSpecificOptions = new CopyOnWriteArrayList(); + + 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 (fUtil != null) { - candidate= fUtil.normalizePath(candidate); + candidate = fUtil.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+= '='+ fDefaultMacroDefinitionValue; - } - if (!symbols.contains(candidate)) { - symbols.add(candidate); - } - } - } - else if (token.startsWith("-m") || //$NON-NLS-1$ + if (candidate != null && candidate.length() > 0) { + if (candidate.indexOf('=') == -1) { + candidate += '=' + fDefaultMacroDefinitionValue; + } + if (!symbols.contains(candidate)) { + symbols.add(candidate); + } + } + } else if (token.startsWith("-m") || //$NON-NLS-1$ token.startsWith("--sysroot") || //$NON-NLS-1$ - token.equals("-ansi") || //$NON-NLS-1$ - token.equals("-nostdinc") || //$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$ - if (!targetSpecificOptions.contains(token)) - targetSpecificOptions.add(token); - } - else if (fileName == null) { - String possibleFileName = token.toLowerCase(); - if (possibleFileName.endsWith(".c") || //$NON-NLS-1$ - possibleFileName.endsWith(".cpp") || //$NON-NLS-1$ - possibleFileName.endsWith(".cc") || //$NON-NLS-1$ - possibleFileName.endsWith(".cxx") || //$NON-NLS-1$ - possibleFileName.endsWith(".C") || //$NON-NLS-1$ - possibleFileName.endsWith(".CPP") || //$NON-NLS-1$ - possibleFileName.endsWith(".CC") || //$NON-NLS-1$ - possibleFileName.endsWith(".CXX") || //$NON-NLS-1$ - possibleFileName.endsWith(".c++")) { //$NON-NLS-1$ - fileName = token; - } - } - } - - if (fileName != null && fileName.startsWith("/cygdrive/")) { //$NON-NLS-1$ - fileName= AbstractGCCBOPConsoleParserUtility.convertCygpath(new Path(fileName)).toOSString(); - } - if (fileName == null || fileName.trim().length()==0) { - return false; // return when no file was given (analogous to GCCPerFileBOPConsoleParser) - } - - IProject project = getProject(); - IFile file = null; - List translatedIncludes = new LinkedList(); - translatedIncludes.addAll(includes); - if (includes.size() > 0) { - if (fUtil != null) { - file = fUtil.findFile(fileName); - if (file != null) { - project = file.getProject(); - translatedIncludes = fUtil.translateRelativePaths(file, fileName, includes); - } - } - if (file == null && fUtil != null) { // real world case - // remove non-absolute include paths since there was no chance to translate them - Iterator iterator = translatedIncludes.iterator(); - while (iterator.hasNext()) { - String include = iterator.next(); - IPath includePath = new Path(include); - if (!includePath.isAbsolute() && !includePath.isUNC()) { // do not translate UNC paths - iterator.remove(); - } - } - } - } - - CopyOnWriteArrayList translatedIncludesToPut = new CopyOnWriteArrayList(translatedIncludes); - - // Contribute discovered includes and symbols to the ScannerInfoCollector - if (translatedIncludesToPut.size() > 0 || symbols.size() > 0) { - Map> scannerInfo = new HashMap>(); - scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, translatedIncludesToPut); - scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols); - scannerInfo.put(ScannerInfoTypes.TARGET_SPECIFIC_OPTION, targetSpecificOptions); - getCollector().contributeToScannerConfig(project, scannerInfo); - - TraceUtil.outputTrace("Discovered scanner info for file \'" + fileName + '\'', //$NON-NLS-1$ - "Include paths", includes, translatedIncludesToPut, "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$ - } + token.equals("-ansi") || //$NON-NLS-1$ + token.equals("-nostdinc") || //$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$ + if (!targetSpecificOptions.contains(token)) + targetSpecificOptions.add(token); + } else if (fileName == null) { + String possibleFileName = token.toLowerCase(); + if (possibleFileName.endsWith(".c") || //$NON-NLS-1$ + possibleFileName.endsWith(".cpp") || //$NON-NLS-1$ + possibleFileName.endsWith(".cc") || //$NON-NLS-1$ + possibleFileName.endsWith(".cxx") || //$NON-NLS-1$ + possibleFileName.endsWith(".C") || //$NON-NLS-1$ + possibleFileName.endsWith(".CPP") || //$NON-NLS-1$ + possibleFileName.endsWith(".CC") || //$NON-NLS-1$ + possibleFileName.endsWith(".CXX") || //$NON-NLS-1$ + possibleFileName.endsWith(".c++")) { //$NON-NLS-1$ + fileName = token; + } + } + } + + if (fileName != null && fileName.startsWith("/cygdrive/")) { //$NON-NLS-1$ + fileName = AbstractGCCBOPConsoleParserUtility.convertCygpath(new Path(fileName)).toOSString(); + } + if (fileName == null || fileName.trim().length() == 0) { + return false; // return when no file was given (analogous to GCCPerFileBOPConsoleParser) + } + + IProject project = getProject(); + IFile file = null; + List translatedIncludes = new LinkedList(); + translatedIncludes.addAll(includes); + if (includes.size() > 0) { + if (fUtil != null) { + file = fUtil.findFile(fileName); + if (file != null) { + project = file.getProject(); + translatedIncludes = fUtil.translateRelativePaths(file, fileName, includes); + } + } + if (file == null && fUtil != null) { // real world case + // remove non-absolute include paths since there was no chance to translate them + Iterator iterator = translatedIncludes.iterator(); + while (iterator.hasNext()) { + String include = iterator.next(); + IPath includePath = new Path(include); + if (!includePath.isAbsolute() && !includePath.isUNC()) { // do not translate UNC paths + iterator.remove(); + } + } + } + } + + CopyOnWriteArrayList translatedIncludesToPut = new CopyOnWriteArrayList(translatedIncludes); + + // Contribute discovered includes and symbols to the ScannerInfoCollector + if (translatedIncludesToPut.size() > 0 || symbols.size() > 0) { + Map> scannerInfo = new HashMap>(); + scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, translatedIncludesToPut); + scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols); + scannerInfo.put(ScannerInfoTypes.TARGET_SPECIFIC_OPTION, targetSpecificOptions); + getCollector().contributeToScannerConfig(project, scannerInfo); + + TraceUtil.outputTrace("Discovered scanner info for file \'" + fileName + '\'', //$NON-NLS-1$ + "Include paths", includes, translatedIncludesToPut, "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$ + } return true; } - public void setDefaultMacroDefinitionValue(String val) { - if (val != null) { - fDefaultMacroDefinitionValue= val; - } + public void setDefaultMacroDefinitionValue(String val) { + if (val != null) { + fDefaultMacroDefinitionValue = val; + } } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java index 593809b4d1e..48c69b69534 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java @@ -48,7 +48,8 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { protected List includes = new ArrayList(); @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; } @@ -58,9 +59,9 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { */ @Override public boolean processLine(String line) { - TraceUtil.outputTrace("GCCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$ + TraceUtil.outputTrace("GCCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$ - line= line.trim(); + line = line.trim(); if (line.length() == 0) { return false; } @@ -83,7 +84,8 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { defineParts[2] = line.substring(i + 1).trim(); } } else { - MakeCorePlugin.log(new Exception("GCCSpecsConsoleParser ERROR: Unmatched brackets: ["+ line+ "]")); //$NON-NLS-1$ //$NON-NLS-2$ + MakeCorePlugin + .log(new Exception("GCCSpecsConsoleParser ERROR: Unmatched brackets: [" + line + "]")); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -103,11 +105,9 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { // now get all the includes else if (line.startsWith(INCLUDE) && line.endsWith("search starts here:")) { //$NON-NLS-1$ expectingIncludes = true; - } - else if (line.startsWith("End of search list.")) { //$NON-NLS-1$ + } else if (line.startsWith("End of search list.")) { //$NON-NLS-1$ expectingIncludes = false; - } - else if (expectingIncludes) { + } else if (expectingIncludes) { if (!includes.contains(line)) includes.add(line); } @@ -130,8 +130,8 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser { fCollector.contributeToScannerConfig(fProject, scannerInfo); } } - TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$ - "Include paths", includes, new ArrayList(0), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$); + TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$ + "Include paths", includes, new ArrayList(0), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$); } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java index 5307c788a37..0e270d2c62f 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java @@ -39,7 +39,7 @@ import org.eclipse.core.runtime.Path; /** * Implements error reporting mechanism and file/path translation mechanism * Taken from ErrorParserManager and modified. - * + * * @author vhirsl */ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParserUtility { @@ -49,10 +49,10 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser private Map fFilesInProject; private List fCollectedFiles; private List fNameConflicts; - + public ScannerInfoConsoleParserUtility(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) { - super(project, workingDirectory, markerGenerator); - + super(project, workingDirectory, markerGenerator); + fFilesInProject = new HashMap(); fCollectedFiles = new ArrayList(); fNameConflicts = new ArrayList(); @@ -67,7 +67,7 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser } } } - + /** * Called by the console line parsers to find a file with a given name. * @return IFile or null @@ -81,21 +81,21 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser // If there is a conflict then try all files in the project. if (isConflictingName(fileName)) { file = null; - + // 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); } } } - - if (file!=null) { + + if (file != null) { IPath filePath = new Path(fileName); - if(filePath.segment(0).compareTo("..") == 0) { //$NON-NLS-1$ + if (filePath.segment(0).compareTo("..") == 0) { //$NON-NLS-1$ filePath = filePath.removeFirstSegments(1); } - + String foundLocation = file.getLocationURI().toString(); if (!foundLocation.endsWith(filePath.toString())) { file = null; @@ -103,7 +103,7 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser } return file; } - + /** * @return file in workspace as {@link IFile} or {@code null} if not found */ @@ -155,10 +155,10 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser IFile file = null; if (path.isAbsolute()) { IWorkspaceRoot root = getProject().getWorkspace().getRoot(); - file = root.getFileForLocation(path); + file = root.getFileForLocation(path); // It may be a link resource so we must check it also. if (file == null) { - file= ResourceLookup.selectFileForLocation(path, getProject()); + file = ResourceLookup.selectFileForLocation(path, getProject()); } } else { file = getProject().getFile(path); @@ -194,16 +194,17 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser if (includePath.isUNC()) { // do not translate UNC paths } else if (includePath.isAbsolute()) { - if (includePath.getDevice()==null) { + if (includePath.getDevice() == null) { String device = getWorkingDirectory().getDevice(); IPath candidatePath = includePath.setDevice(device); File dir = candidatePath.toFile(); if (dir.exists()) { include = candidatePath.toString(); } else { - final String error = MakeMessages.getString("ConsoleParser.Nonexistent_Include_Path_Error_Message"); //$NON-NLS-1$ + 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); } } } else { @@ -212,10 +213,10 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser if (!cwd.isAbsolute()) { cwd = getBaseDirectory().append(cwd); } - + IPath filePath = new Path(fileName); if (filePath.isAbsolute()) { - if (filePath.getDevice()==null) { + if (filePath.getDevice() == null) { String device = getWorkingDirectory().getDevice(); filePath = filePath.setDevice(device); } @@ -228,35 +229,35 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser if (!filePath.toString().equalsIgnoreCase(fileLocation.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 { - // remove common segments at the end + } 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 = fileLocation; - 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()); } } } - + IPath candidatePath = cwd.append(includePath); File dir = candidatePath.toFile(); include = candidatePath.toString(); 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 @@ -272,25 +273,25 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser 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) { @@ -305,26 +306,23 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser 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; } } newBuf.append(buf.substring(scp, len)); - + IPath orgPath = new Path(newBuf.toString()); return orgPath.toString(); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java index 7e0f969f881..222144cf6fd 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java @@ -26,46 +26,47 @@ import org.eclipse.core.runtime.jobs.Job; /** * Build output reader job - * + * * @author vhirsl */ public class BuildOutputReaderJob extends Job { private static final String JOB_NAME = "Build Output Reader"; //$NON-NLS-1$ - - private IResource resource; - private InfoContext context; - private IScannerConfigBuilderInfo2 buildInfo; - public BuildOutputReaderJob(IProject project, IScannerConfigBuilderInfo2 buildInfo) { - this(project, buildInfo.getContext(), buildInfo); - } + private IResource resource; + private InfoContext context; + private IScannerConfigBuilderInfo2 buildInfo; - public BuildOutputReaderJob(IProject project, InfoContext context, IScannerConfigBuilderInfo2 buildInfo) { - super(JOB_NAME); - this.resource = project; - this.context = context; - this.buildInfo = buildInfo; - setUser(true); - } + public BuildOutputReaderJob(IProject project, IScannerConfigBuilderInfo2 buildInfo) { + this(project, buildInfo.getContext(), buildInfo); + } - /* (non-Javadoc) + public BuildOutputReaderJob(IProject project, InfoContext context, IScannerConfigBuilderInfo2 buildInfo) { + super(JOB_NAME); + this.resource = project; + this.context = context; + this.buildInfo = buildInfo; + setUser(true); + } + + /* (non-Javadoc) * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) */ @Override protected IStatus run(IProgressMonitor monitor) { - IProject project = resource.getProject(); - monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$ - monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$ - project.getName()); + IProject project = resource.getProject(); + monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$ + monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$ + project.getName()); + + boolean rc = SCJobsUtil.readBuildOutputFile(project, context, buildInfo, new SubProgressMonitor(monitor, 70)); + rc |= SCJobsUtil.getProviderScannerInfo(project, context, buildInfo, new SubProgressMonitor(monitor, 20)); + if (rc) { + rc = SCJobsUtil.updateScannerConfiguration(project, context, buildInfo, + new SubProgressMonitor(monitor, 10)); + } - boolean rc = SCJobsUtil.readBuildOutputFile(project, context, buildInfo, new SubProgressMonitor(monitor, 70)); - rc |= SCJobsUtil.getProviderScannerInfo(project, context, buildInfo, new SubProgressMonitor(monitor, 20)); - if (rc) { - rc = SCJobsUtil.updateScannerConfiguration(project, context, buildInfo, new SubProgressMonitor(monitor, 10)); - } - - monitor.done(); - return (rc == true) ? Status.OK_STATUS : Status.CANCEL_STATUS; + monitor.done(); + return (rc == true) ? Status.OK_STATUS : Status.CANCEL_STATUS; } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java index 3a15bf6211d..ea4126a38f8 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java @@ -41,170 +41,166 @@ import org.eclipse.core.runtime.SafeRunner; * @author vhirsl */ public class SCJobsUtil { - private static class RC { - public RC(boolean init) { - rc = init; - } - /** - * @return Returns the rc. - */ - public boolean get() { - return rc; - } - /** - * @param rc The rc to set. - */ - public void set(boolean rc) { - this.rc = rc; - } - - @Override + private static class RC { + public RC(boolean init) { + rc = init; + } + + /** + * @return Returns the rc. + */ + public boolean get() { + return rc; + } + + /** + * @param rc The rc to set. + */ + public void set(boolean rc) { + this.rc = rc; + } + + @Override public String toString() { - return rc ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$ - } - private boolean rc; - } - /** - * Call ESI providers to get scanner info - */ - public static boolean getProviderScannerInfo(final IProject project, - final IScannerConfigBuilderInfo2 buildInfo, - final IProgressMonitor monitor) { - return getProviderScannerInfo(project, buildInfo.getContext(), buildInfo, monitor); - } - - public static boolean getProviderScannerInfo(final IProject project, - final InfoContext context, - final IScannerConfigBuilderInfo2 buildInfo, - final IProgressMonitor monitor) { - - final RC rc = new RC(false); - // get the collector - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(project, context, buildInfo.getSelectedProfileId()); - final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); - - List providerIds = buildInfo.getProviderIdList(); - for (int i = 0; i < providerIds.size(); ++i) { - final String providerId = providerIds.get(i); - if (buildInfo.isProviderOutputParserEnabled(providerId)) { - final IExternalScannerInfoProvider esiProvider = profileInstance. - createExternalScannerInfoProvider(providerId); - if (esiProvider != null) { - ISafeRunnable runnable = new ISafeRunnable() { - - @Override + return rc ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + private boolean rc; + } + + /** + * Call ESI providers to get scanner info + */ + public static boolean getProviderScannerInfo(final IProject project, final IScannerConfigBuilderInfo2 buildInfo, + final IProgressMonitor monitor) { + return getProviderScannerInfo(project, buildInfo.getContext(), buildInfo, monitor); + } + + public static boolean getProviderScannerInfo(final IProject project, final InfoContext context, + final IScannerConfigBuilderInfo2 buildInfo, final IProgressMonitor monitor) { + + final RC rc = new RC(false); + // get the collector + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, + context, buildInfo.getSelectedProfileId()); + final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); + + List providerIds = buildInfo.getProviderIdList(); + for (int i = 0; i < providerIds.size(); ++i) { + final String providerId = providerIds.get(i); + if (buildInfo.isProviderOutputParserEnabled(providerId)) { + final IExternalScannerInfoProvider esiProvider = profileInstance + .createExternalScannerInfoProvider(providerId); + if (esiProvider != null) { + ISafeRunnable runnable = new ISafeRunnable() { + + @Override public void run() { - // TODO we need the environment for the project here... - ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project); - ICConfigurationDescription configDesc = projDesc.getActiveConfiguration(); - IEnvironmentVariableManager envVarManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); - IEnvironmentVariable[] envVars = envVarManager.getVariables(configDesc, true); - Properties env = new Properties(); - for (int i = 0; i < envVars.length; ++i) { - IEnvironmentVariable envVar = envVars[i]; - env.put(envVar.getName(), envVar.getValue()); - } - esiProvider.invokeProvider(monitor, project, context, providerId, buildInfo, collector, env); - rc.set(true); - } - - @Override + // TODO we need the environment for the project here... + ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project); + ICConfigurationDescription configDesc = projDesc.getActiveConfiguration(); + IEnvironmentVariableManager envVarManager = CCorePlugin.getDefault() + .getBuildEnvironmentManager(); + IEnvironmentVariable[] envVars = envVarManager.getVariables(configDesc, true); + Properties env = new Properties(); + for (int i = 0; i < envVars.length; ++i) { + IEnvironmentVariable envVar = envVars[i]; + env.put(envVar.getName(), envVar.getValue()); + } + esiProvider.invokeProvider(monitor, project, context, providerId, buildInfo, collector, + env); + rc.set(true); + } + + @Override public void handleException(Throwable exception) { - rc.set(false); - MakeCorePlugin.log(exception); - } - - }; - SafeRunner.run(runnable); - } - } - } - return rc.get(); - } - - /** - * Update and persist scanner configuration - */ - public static boolean updateScannerConfiguration(IProject project, - IScannerConfigBuilderInfo2 buildInfo, - final IProgressMonitor monitor) { - return updateScannerConfiguration(project, buildInfo.getContext(), buildInfo, monitor); - } - - /** - * Update and persist scanner configuration - */ - public static boolean updateScannerConfiguration(IProject project, - InfoContext context, - IScannerConfigBuilderInfo2 buildInfo, - final IProgressMonitor monitor) { - final RC rc = new RC(false); - // get the collector - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(project, context, buildInfo.getSelectedProfileId()); - IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); - if (collector instanceof IScannerInfoCollector2) { - final IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; - ISafeRunnable runnable = new ISafeRunnable() { - - @Override + rc.set(false); + MakeCorePlugin.log(exception); + } + + }; + SafeRunner.run(runnable); + } + } + } + return rc.get(); + } + + /** + * Update and persist scanner configuration + */ + public static boolean updateScannerConfiguration(IProject project, IScannerConfigBuilderInfo2 buildInfo, + final IProgressMonitor monitor) { + return updateScannerConfiguration(project, buildInfo.getContext(), buildInfo, monitor); + } + + /** + * Update and persist scanner configuration + */ + public static boolean updateScannerConfiguration(IProject project, InfoContext context, + IScannerConfigBuilderInfo2 buildInfo, final IProgressMonitor monitor) { + final RC rc = new RC(false); + // get the collector + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, + context, buildInfo.getSelectedProfileId()); + IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); + if (collector instanceof IScannerInfoCollector2) { + final IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; + ISafeRunnable runnable = new ISafeRunnable() { + + @Override public void run() throws Exception { - collector2.updateScannerConfiguration(monitor); - rc.set(true); - } + collector2.updateScannerConfiguration(monitor); + rc.set(true); + } - @Override + @Override public void handleException(Throwable exception) { - rc.set(false); - MakeCorePlugin.log(exception); - } - - }; - SafeRunner.run(runnable); - } - - return rc.get(); - } - - public static boolean readBuildOutputFile(final IProject project, - final IScannerConfigBuilderInfo2 buildInfo, - final IProgressMonitor monitor) { - return readBuildOutputFile(project, buildInfo.getContext(), buildInfo, monitor); - } - - public static boolean readBuildOutputFile(final IProject project, - final InfoContext context, - final IScannerConfigBuilderInfo2 buildInfo, - final IProgressMonitor monitor) { - final RC rc = new RC(false); - // get the collector - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(project, context, buildInfo.getSelectedProfileId()); - final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); - final IExternalScannerInfoProvider esiProvider = profileInstance. - createBuildOutputProvider(); - - if (buildInfo.isBuildOutputFileActionEnabled()) { - ISafeRunnable runnable = new ISafeRunnable() { - - @Override + rc.set(false); + MakeCorePlugin.log(exception); + } + + }; + SafeRunner.run(runnable); + } + + return rc.get(); + } + + public static boolean readBuildOutputFile(final IProject project, final IScannerConfigBuilderInfo2 buildInfo, + final IProgressMonitor monitor) { + return readBuildOutputFile(project, buildInfo.getContext(), buildInfo, monitor); + } + + public static boolean readBuildOutputFile(final IProject project, final InfoContext context, + final IScannerConfigBuilderInfo2 buildInfo, final IProgressMonitor monitor) { + final RC rc = new RC(false); + // get the collector + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, + context, buildInfo.getSelectedProfileId()); + final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); + final IExternalScannerInfoProvider esiProvider = profileInstance.createBuildOutputProvider(); + + if (buildInfo.isBuildOutputFileActionEnabled()) { + ISafeRunnable runnable = new ISafeRunnable() { + + @Override public void run() { - esiProvider.invokeProvider(monitor, project, context, null, buildInfo, collector, null); - rc.set(true); - } + esiProvider.invokeProvider(monitor, project, context, null, buildInfo, collector, null); + rc.set(true); + } - @Override + @Override public void handleException(Throwable exception) { - rc.set(false); - MakeCorePlugin.log(exception); - } + rc.set(false); + MakeCorePlugin.log(exception); + } - }; - SafeRunner.run(runnable); - } + }; + SafeRunner.run(runnable); + } - return rc.get(); - } + return rc.get(); + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java index a3df4120477..c8ec3492bfa 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java @@ -33,58 +33,56 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; /** - * Class that represents a compiler command and related scanner configuration - * + * Class that represents a compiler command and related scanner configuration + * * @author vhirsl */ public class CCommandDSC { - protected final static String SINGLE_SPACE = " "; //$NON-NLS-1$ - protected final static String CMD_DESCRIPTION_ELEM = "commandDescription"; //$NON-NLS-1$ - protected final static String CMD_SI_ELEM = "commandScannerInfo"; //$NON-NLS-1$ - protected final static String OPTION_ELEM = "option"; //$NON-NLS-1$ - protected final static String SI_ITEM_ELEM = "siItem"; //$NON-NLS-1$ - protected final static String KEY_ATTR = "key"; //$NON-NLS-1$ - protected final static String VALUE_ATTR = "value"; //$NON-NLS-1$ - protected final static String QUOTE_INCLUDE_ATTR = "quote"; //$NON-NLS-1$ - protected final static String KIND_ATTR = "kind"; //$NON-NLS-1$ - + protected final static String SINGLE_SPACE = " "; //$NON-NLS-1$ + protected final static String CMD_DESCRIPTION_ELEM = "commandDescription"; //$NON-NLS-1$ + protected final static String CMD_SI_ELEM = "commandScannerInfo"; //$NON-NLS-1$ + protected final static String OPTION_ELEM = "option"; //$NON-NLS-1$ + protected final static String SI_ITEM_ELEM = "siItem"; //$NON-NLS-1$ + protected final static String KEY_ATTR = "key"; //$NON-NLS-1$ + protected final static String VALUE_ATTR = "value"; //$NON-NLS-1$ + protected final static String QUOTE_INCLUDE_ATTR = "quote"; //$NON-NLS-1$ + protected final static String KIND_ATTR = "kind"; //$NON-NLS-1$ + protected int commandId; - protected List compilerCommand; // members are KVStringPair objects + protected List compilerCommand; // members are KVStringPair objects protected boolean discovered; - protected boolean cppFileType; // C or C++ file type + protected boolean cppFileType; // C or C++ file type protected IProject project; - protected List symbols; - protected List includes; - protected List quoteIncludes; + protected List symbols; + protected List includes; + protected List quoteIncludes; public CCommandDSC(boolean cppFileType) { this(cppFileType, null); } - + public CCommandDSC(boolean cppFileType, IProject project) { compilerCommand = new ArrayList(); discovered = false; this.cppFileType = cppFileType; - - symbols = new ArrayList(); - includes = new ArrayList(); - quoteIncludes = new ArrayList(); - this.project = project; + + symbols = new ArrayList(); + includes = new ArrayList(); + quoteIncludes = new ArrayList(); + this.project = project; + } + + public boolean appliesToCPPFileType() { + return cppFileType; } - public boolean appliesToCPPFileType() { - return cppFileType; - } - 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 = CygpathTranslator.translateIncludePaths(project, Collections.singletonList(value)).get(0); value = SafeStringInterner.safeIntern(makeRelative(project, new Path(value)).toOSString()); @@ -92,39 +90,40 @@ public class CCommandDSC { } compilerCommand.add(option); } - - public Integer getCommandIdAsInteger() { - return Integer.valueOf(getCommandId()); - } - /** - * @return Returns the commandId. - */ - public int getCommandId() { - return commandId; - } - /** - * @param commandId The commandId to set. - */ - public void setCommandId(int commandId) { - this.commandId = commandId; - } - + + public Integer getCommandIdAsInteger() { + return Integer.valueOf(getCommandId()); + } + + /** + * @return Returns the commandId. + */ + public int getCommandId() { + return commandId; + } + + /** + * @param commandId The commandId to set. + */ + public void setCommandId(int commandId) { + this.commandId = commandId; + } + @Override public String toString() { String commandAsString = ""; //$NON-NLS-1$ - for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); String value = optionPair.getValue(); - commandAsString += optionPair.getKey() + SINGLE_SPACE + - value + SINGLE_SPACE; + commandAsString += optionPair.getKey() + SINGLE_SPACE + value + SINGLE_SPACE; } return commandAsString.trim(); } - + public int getId() { return commandId; } - + /** * Returns a command where -imacros and -include options have been removed * @param quoteIncludePaths whether or not paths for includes must be put inside double quotes. @@ -132,99 +131,96 @@ public class CCommandDSC { */ public String getSCDRunnableCommand(boolean quoteIncludePaths, boolean quoteDefines) { String commandAsString = ""; //$NON-NLS-1$ - for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); - if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) { - commandAsString += optionPair.getValue() + SINGLE_SPACE; - } - else { - // skip -include and -imacros options - if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) || - optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) - continue; - String value = optionPair.getValue(); - if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) || - optionPair.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) || - optionPair.getKey().equals(SCDOptionsEnum.IQUOTE.toString())) { - value = makeAbsolute(project, value); - if (quoteIncludePaths) { - value= "\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - else if (quoteDefines && optionPair.getKey().equals(SCDOptionsEnum.DEFINE.toString())) { - if (value.indexOf('\'') == -1) { - value= "'" + value + "'"; //$NON-NLS-1$//$NON-NLS-2$ - } - else { - value= value.replaceAll("\"", "\\\\\""); //$NON-NLS-1$//$NON-NLS-2$ - value= "\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - commandAsString += optionPair.getKey() + SINGLE_SPACE + value + SINGLE_SPACE; - } + if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) { + commandAsString += optionPair.getValue() + SINGLE_SPACE; + } else { + // skip -include and -imacros options + if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) + || optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) + continue; + String value = optionPair.getValue(); + if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) + || optionPair.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) + || optionPair.getKey().equals(SCDOptionsEnum.IQUOTE.toString())) { + value = makeAbsolute(project, value); + if (quoteIncludePaths) { + value = "\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + } + } else if (quoteDefines && optionPair.getKey().equals(SCDOptionsEnum.DEFINE.toString())) { + if (value.indexOf('\'') == -1) { + value = "'" + value + "'"; //$NON-NLS-1$//$NON-NLS-2$ + } else { + value = value.replaceAll("\"", "\\\\\""); //$NON-NLS-1$//$NON-NLS-2$ + value = "\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + } + } + commandAsString += optionPair.getKey() + SINGLE_SPACE + value + SINGLE_SPACE; + } } return commandAsString.trim(); } - + /** * @return the compiler command */ public String getCompilerName() { String compiler = ""; //$NON-NLS-1$ - for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); - if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) { - compiler = optionPair.getValue(); - break; - } + if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) { + compiler = optionPair.getValue(); + break; + } } return compiler.trim(); } - + /** * @return list of strings */ public List getImacrosFile() { List imacrosFiles = new ArrayList(); - for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString())) { - imacrosFiles.add(makeAbsolute(project,optionPair.getValue())); + imacrosFiles.add(makeAbsolute(project, optionPair.getValue())); } } return imacrosFiles; } - + /** * @return list of strings */ public List getIncludeFile() { List includeFiles = new ArrayList(); - for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) { - includeFiles.add(makeAbsolute(project,optionPair.getValue())); + includeFiles.add(makeAbsolute(project, optionPair.getValue())); } } return includeFiles; } - -// public List getFilesList() { -// return files; -// } - + + // public List getFilesList() { + // return files; + // } + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object arg0) { if (arg0 != null && arg0.getClass().equals(this.getClass())) { - CCommandDSC other = (CCommandDSC)arg0; - return (compilerCommand.equals(other.compilerCommand) && - cppFileType == other.cppFileType); + CCommandDSC other = (CCommandDSC) arg0; + return (compilerCommand.equals(other.compilerCommand) && cppFileType == other.cppFileType); } return false; } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @@ -233,167 +229,170 @@ public class CCommandDSC { return compilerCommand.hashCode(); } - /** - * @return Returns the includes as strings. - */ - public List getIncludes() { - return makeAbsolute(project, includes); - } - /** - * @param includes The includes to set. - */ - public void setIncludes(List includes) { - this.includes = includes; - } - /** - * @return Returns the quote include paths as strings (for #include "...") - */ - public List getQuoteIncludes() { - return makeAbsolute(project, quoteIncludes); - } - /** - * @param includes - quote include paths (for #include "...") - */ - public void setQuoteIncludes(List includes) { - quoteIncludes = includes; - } - /** - * @return Returns the symbols. - */ - public List getSymbols() { - return symbols; - } - /** - * @param symbols The symbols to set. - */ - public void setSymbols(List symbols) { - this.symbols = symbols; - } - /** - * @return Returns the discovered. - */ - public boolean isDiscovered() { - return discovered; - } - /** - * @param discovered The discovered to set. - */ - public void setDiscovered(boolean discovered) { - this.discovered = discovered; - } - - public void serialize(Element cmdElem) { - Document doc = cmdElem.getOwnerDocument(); - // serialize the command - Element cmdDescElem = doc.createElement(CMD_DESCRIPTION_ELEM); - for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) { - Element optionElem = doc.createElement(OPTION_ELEM); - KVStringPair option = i.next(); - optionElem.setAttribute(KEY_ATTR, option.getKey()); - optionElem.setAttribute(VALUE_ATTR, option.getValue()); - cmdDescElem.appendChild(optionElem); - } - cmdElem.appendChild(cmdDescElem); - // serialize includes and symbols - Element siElem = doc.createElement(CMD_SI_ELEM); - for (Iterator j = quoteIncludes.iterator(); j.hasNext(); ) { - Element siItem = doc.createElement(SI_ITEM_ELEM); - siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ - siItem.setAttribute(VALUE_ATTR, j.next()); - siItem.setAttribute(QUOTE_INCLUDE_ATTR, "true"); //$NON-NLS-1$ - siElem.appendChild(siItem); - } - for (Iterator j = includes.iterator(); j.hasNext(); ) { - Element siItem = doc.createElement(SI_ITEM_ELEM); - siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ - siItem.setAttribute(VALUE_ATTR, j.next()); - siElem.appendChild(siItem); - } - for (Iterator j = symbols.iterator(); j.hasNext(); ) { - Element siItem = doc.createElement(SI_ITEM_ELEM); - siItem.setAttribute(KIND_ATTR, "SYMBOL_DEFINITION"); //$NON-NLS-1$ - siItem.setAttribute(VALUE_ATTR, j.next()); - siElem.appendChild(siItem); - } - cmdElem.appendChild(siElem); - } - - public void deserialize(Element cmdElem) { - // read command options - NodeList descList = cmdElem.getElementsByTagName(CMD_DESCRIPTION_ELEM); - if (descList.getLength() > 0) { - Element descElem = (Element) descList.item(0); - NodeList optionList = descElem.getElementsByTagName(OPTION_ELEM); - for (int i = 0; i < optionList.getLength(); ++i) { - Element optionElem = (Element) optionList.item(i); - String key = SafeStringInterner.safeIntern(optionElem.getAttribute(KEY_ATTR)); - String value = SafeStringInterner.safeIntern(optionElem.getAttribute(VALUE_ATTR)); - KVStringPair option = new KVStringPair(key, value); - addSCOption(option); - } - } - // read associated scanner info - NodeList siList = cmdElem.getElementsByTagName(CMD_SI_ELEM); - if (siList.getLength() > 0) { - Element siElem = (Element) siList.item(0); - NodeList siItemList = siElem.getElementsByTagName(SI_ITEM_ELEM); - for (int i = 0; i < siItemList.getLength(); ++i) { - Element siItemElem = (Element) siItemList.item(i); - String kind = siItemElem.getAttribute(KIND_ATTR); - String value = siItemElem.getAttribute(VALUE_ATTR); - String quote = siItemElem.getAttribute(QUOTE_INCLUDE_ATTR); - if (kind.equals("INCLUDE_PATH")) { //$NON-NLS-1$ - if (quote.equals("true")) { //$NON-NLS-1$ - quoteIncludes.add(SafeStringInterner.safeIntern(value)); - } - else { - includes.add(value); - } - } - else if (kind.equals("SYMBOL_DEFINITION")) { //$NON-NLS-1$ - symbols.add(SafeStringInterner.safeIntern(value)); - } - } - setDiscovered(true); - } - } - - public void resolveOptions(IProject project) { - if (!isDiscovered()) { - // that's wrong for sure, options cannot be resolved fron the optionPairs?? - ArrayList symbols = new ArrayList(); - ArrayList includes = new ArrayList(); - ArrayList quoteincludes = new ArrayList(); - for (Iterator options = compilerCommand.iterator(); options.hasNext(); ) { - KVStringPair optionPair = options.next(); - String key = optionPair.getKey(); - String value = optionPair.getValue(); - if (key.equals(SCDOptionsEnum.INCLUDE.toString()) || key.equals(SCDOptionsEnum.ISYSTEM.toString())) { - includes.add(SafeStringInterner.safeIntern(value)); - } - else if (key.equals(SCDOptionsEnum.IQUOTE.toString())) { - quoteincludes.add(SafeStringInterner.safeIntern(value)); - } - else if (key.equals(SCDOptionsEnum.DEFINE.toString())) { - symbols.add(SafeStringInterner.safeIntern(value)); - } - } - setIncludes(includes); - setQuoteIncludes(quoteincludes); - setSymbols(symbols); - } - setDiscovered(true); - } - + /** + * @return Returns the includes as strings. + */ + public List getIncludes() { + return makeAbsolute(project, includes); + } + + /** + * @param includes The includes to set. + */ + public void setIncludes(List includes) { + this.includes = includes; + } + + /** + * @return Returns the quote include paths as strings (for #include "...") + */ + public List getQuoteIncludes() { + return makeAbsolute(project, quoteIncludes); + } + + /** + * @param includes - quote include paths (for #include "...") + */ + public void setQuoteIncludes(List includes) { + quoteIncludes = includes; + } + + /** + * @return Returns the symbols. + */ + public List getSymbols() { + return symbols; + } + + /** + * @param symbols The symbols to set. + */ + public void setSymbols(List symbols) { + this.symbols = symbols; + } + + /** + * @return Returns the discovered. + */ + public boolean isDiscovered() { + return discovered; + } + + /** + * @param discovered The discovered to set. + */ + public void setDiscovered(boolean discovered) { + this.discovered = discovered; + } + + public void serialize(Element cmdElem) { + Document doc = cmdElem.getOwnerDocument(); + // serialize the command + Element cmdDescElem = doc.createElement(CMD_DESCRIPTION_ELEM); + for (Iterator i = compilerCommand.iterator(); i.hasNext();) { + Element optionElem = doc.createElement(OPTION_ELEM); + KVStringPair option = i.next(); + optionElem.setAttribute(KEY_ATTR, option.getKey()); + optionElem.setAttribute(VALUE_ATTR, option.getValue()); + cmdDescElem.appendChild(optionElem); + } + cmdElem.appendChild(cmdDescElem); + // serialize includes and symbols + Element siElem = doc.createElement(CMD_SI_ELEM); + for (Iterator j = quoteIncludes.iterator(); j.hasNext();) { + Element siItem = doc.createElement(SI_ITEM_ELEM); + siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ + siItem.setAttribute(VALUE_ATTR, j.next()); + siItem.setAttribute(QUOTE_INCLUDE_ATTR, "true"); //$NON-NLS-1$ + siElem.appendChild(siItem); + } + for (Iterator j = includes.iterator(); j.hasNext();) { + Element siItem = doc.createElement(SI_ITEM_ELEM); + siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ + siItem.setAttribute(VALUE_ATTR, j.next()); + siElem.appendChild(siItem); + } + for (Iterator j = symbols.iterator(); j.hasNext();) { + Element siItem = doc.createElement(SI_ITEM_ELEM); + siItem.setAttribute(KIND_ATTR, "SYMBOL_DEFINITION"); //$NON-NLS-1$ + siItem.setAttribute(VALUE_ATTR, j.next()); + siElem.appendChild(siItem); + } + cmdElem.appendChild(siElem); + } + + public void deserialize(Element cmdElem) { + // read command options + NodeList descList = cmdElem.getElementsByTagName(CMD_DESCRIPTION_ELEM); + if (descList.getLength() > 0) { + Element descElem = (Element) descList.item(0); + NodeList optionList = descElem.getElementsByTagName(OPTION_ELEM); + for (int i = 0; i < optionList.getLength(); ++i) { + Element optionElem = (Element) optionList.item(i); + String key = SafeStringInterner.safeIntern(optionElem.getAttribute(KEY_ATTR)); + String value = SafeStringInterner.safeIntern(optionElem.getAttribute(VALUE_ATTR)); + KVStringPair option = new KVStringPair(key, value); + addSCOption(option); + } + } + // read associated scanner info + NodeList siList = cmdElem.getElementsByTagName(CMD_SI_ELEM); + if (siList.getLength() > 0) { + Element siElem = (Element) siList.item(0); + NodeList siItemList = siElem.getElementsByTagName(SI_ITEM_ELEM); + for (int i = 0; i < siItemList.getLength(); ++i) { + Element siItemElem = (Element) siItemList.item(i); + String kind = siItemElem.getAttribute(KIND_ATTR); + String value = siItemElem.getAttribute(VALUE_ATTR); + String quote = siItemElem.getAttribute(QUOTE_INCLUDE_ATTR); + if (kind.equals("INCLUDE_PATH")) { //$NON-NLS-1$ + if (quote.equals("true")) { //$NON-NLS-1$ + quoteIncludes.add(SafeStringInterner.safeIntern(value)); + } else { + includes.add(value); + } + } else if (kind.equals("SYMBOL_DEFINITION")) { //$NON-NLS-1$ + symbols.add(SafeStringInterner.safeIntern(value)); + } + } + setDiscovered(true); + } + } + + public void resolveOptions(IProject project) { + if (!isDiscovered()) { + // that's wrong for sure, options cannot be resolved fron the optionPairs?? + ArrayList symbols = new ArrayList(); + ArrayList includes = new ArrayList(); + ArrayList quoteincludes = new ArrayList(); + for (Iterator options = compilerCommand.iterator(); options.hasNext();) { + KVStringPair optionPair = options.next(); + String key = optionPair.getKey(); + String value = optionPair.getValue(); + if (key.equals(SCDOptionsEnum.INCLUDE.toString()) || key.equals(SCDOptionsEnum.ISYSTEM.toString())) { + includes.add(SafeStringInterner.safeIntern(value)); + } else if (key.equals(SCDOptionsEnum.IQUOTE.toString())) { + quoteincludes.add(SafeStringInterner.safeIntern(value)); + } else if (key.equals(SCDOptionsEnum.DEFINE.toString())) { + symbols.add(SafeStringInterner.safeIntern(value)); + } + } + setIncludes(includes); + setQuoteIncludes(quoteincludes); + setSymbols(symbols); + } + setDiscovered(true); + } + public static IPath makeRelative(IProject project, IPath path) { IResource resource = findResource(project, path); if (resource != null) { if (resource.getProject() == project) { path = resource.getProjectRelativePath(); } -// else { -// path = resource.getFullPath(); -// } + // else { + // path = resource.getFullPath(); + // } } return path; } @@ -404,7 +403,7 @@ public class CCommandDSC { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); resource = root.findMember(path, false); if (resource == null) { - resource= ResourceLookup.selectFileForLocation(path, project); + resource = ResourceLookup.selectFileForLocation(path, project); } } return resource; @@ -412,7 +411,7 @@ public class CCommandDSC { public static List makeRelative(IProject project, List paths) { List list = new ArrayList(paths.size()); - for (Iterator iter=paths.iterator(); iter.hasNext(); ) { + for (Iterator iter = paths.iterator(); iter.hasNext();) { String path = iter.next(); path = makeRelative(project, new Path(path)).toOSString(); list.add(SafeStringInterner.safeIntern(path)); @@ -420,7 +419,6 @@ public class CCommandDSC { return list; } - public static final String makeAbsolute(IProject project, String path) { IPath ppath = new Path(path); if (project != null && !ppath.isAbsolute()) { @@ -435,14 +433,14 @@ public class CCommandDSC { path = ppath.toOSString(); } } -// path = new File(project.getLocation().toOSString(), path).getAbsolutePath(); + // path = new File(project.getLocation().toOSString(), path).getAbsolutePath(); } return SafeStringInterner.safeIntern(path); } public static List makeAbsolute(IProject project, List paths) { List list = new ArrayList(paths.size()); - for (Iterator iter=paths.iterator(); iter.hasNext(); ) { + for (Iterator iter = paths.iterator(); iter.hasNext();) { String path = iter.next(); path = makeAbsolute(project, path); list.add(SafeStringInterner.safeIntern(path)); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java index c19dfd95f6b..5ed1a7e566a 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java @@ -42,7 +42,7 @@ import org.eclipse.core.runtime.Platform; /** * Use binary parser's 'cygpath' command to translate cygpaths to absolute paths. * Note that this class does not support build configurations. - * + * * @author vhirsl */ public class CygpathTranslator { @@ -63,8 +63,7 @@ public class CygpathTranslator { } catch (ClassCastException e) { } } - } - catch (CoreException e) { + } catch (CoreException e) { } } @@ -72,7 +71,7 @@ public class CygpathTranslator { // first check if cygpath translation is needed at all boolean translationNeeded = false; if (Platform.getOS().equals(Platform.OS_WIN32)) { - for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) { + for (Iterator i = sumIncludes.iterator(); i.hasNext();) { String include = i.next(); if (include.startsWith("/")) { //$NON-NLS-1$ translationNeeded = true; @@ -113,22 +112,20 @@ public class CygpathTranslator { } List translatedIncludePaths = new ArrayList(); - for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) { + for (Iterator i = sumIncludes.iterator(); i.hasNext();) { String includePath = i.next(); IPath realPath = new Path(includePath); // only allow native pathes if they have a device prefix // to avoid matches on the current drive, e.g. /usr/bin = C:\\usr\\bin if (realPath.getDevice() != null && realPath.toFile().exists()) { translatedIncludePaths.add(includePath); - } - else { + } else { String translatedPath = includePath; if (useCygPathExtension) { try { translatedPath = cygpath.cygPath.getFileName(includePath); - } - catch (IOException e) { + } catch (IOException e) { TraceUtil.outputError("CygpathTranslator unable to translate path: ", includePath); //$NON-NLS-1$ } } else if (useCygwinFromPath) { @@ -141,9 +138,10 @@ public class CygpathTranslator { // try default conversions // /cygdrive/x/ --> X:\ if ("cygdrive".equals(realPath.segment(0))) { //$NON-NLS-1$ - String drive= realPath.segment(1); + String drive = realPath.segment(1); if (drive.length() == 1) { - translatedPath= realPath.removeFirstSegments(2).makeAbsolute().setDevice(drive.toUpperCase() + ':').toOSString(); + translatedPath = realPath.removeFirstSegments(2).makeAbsolute() + .setDevice(drive.toUpperCase() + ':').toOSString(); } } } @@ -151,16 +149,13 @@ public class CygpathTranslator { // Check if the translated path exists if (new File(translatedPath).exists()) { translatedIncludePaths.add(translatedPath); - } - else if (useCygPathExtension || useCygwinFromPath) { + } else if (useCygPathExtension || useCygwinFromPath) { // TODO VMIR for now add even if it does not exist translatedIncludePaths.add(translatedPath); - } - else { + } else { translatedIncludePaths.add(includePath); } - } - else { + } else { // TODO VMIR for now add even if it does not exist translatedIncludePaths.add(translatedPath); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java index d05ead6a63f..71fe959e9ee 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java @@ -15,28 +15,29 @@ package org.eclipse.cdt.make.internal.core.scannerconfig.util; /** * Key - Value String Pair - * + * * @author vhirsl */ public class KVStringPair { private String key; private String value; - + /** - * + * */ public KVStringPair(String key, String value) { this.key = key; this.value = value; } - + public String getKey() { return key; } - + public String getValue() { return value; } + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @@ -48,6 +49,7 @@ public class KVStringPair { } return false; } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @@ -55,6 +57,7 @@ public class KVStringPair { public int hashCode() { return 17 * key.hashCode() + value.hashCode(); } + /* (non-Javadoc) * @see java.lang.Object#toString() */ diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java index d30d1f434db..6a90e090447 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM - Initial API and implementation *******************************************************************************/ @@ -29,14 +29,14 @@ import org.eclipse.core.runtime.IStatus; /** * Log writer utility - * + * * @author vhirsl */ public class LogWriter { protected File logFile = null; protected Writer log = null; protected boolean newSession = true; - + protected static final String SESSION = "*** SESSION";//$NON-NLS-1$ protected static final String ENTRY = "ENTRY";//$NON-NLS-1$ protected static final String SUBENTRY = "SUBENTRY";//$NON-NLS-1$ @@ -52,16 +52,16 @@ public class LogWriter { } /** - * + * */ public LogWriter(File log) { this.logFile = log; - if(log.length() > MAXLOG_SIZE){ - log.delete(); + if (log.length() > MAXLOG_SIZE) { + log.delete(); } openLogFile(); } - + protected void closeLogFile() throws IOException { try { if (log != null) { @@ -72,10 +72,11 @@ public class LogWriter { log = null; } } - + protected void openLogFile() { try { - log = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(logFile.getAbsolutePath(), true), "UTF-8"));//$NON-NLS-1$ + log = new BufferedWriter( + new OutputStreamWriter(new FileOutputStream(logFile.getAbsolutePath(), true), "UTF-8"));//$NON-NLS-1$ if (newSession) { writeHeader(); newSession = false; @@ -85,6 +86,7 @@ public class LogWriter { //log = logForStream(System.err); } } + protected void writeHeader() throws IOException { writeln(); write(SESSION); @@ -92,12 +94,12 @@ public class LogWriter { String date = getDate(); write(date); writeSpace(); - for (int i=SESSION.length()+date.length(); i<78; i++) { + for (int i = SESSION.length() + date.length(); i < 78; i++) { write("-");//$NON-NLS-1$ } writeln(); } - + protected String getDate() { try { DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss.SS"); //$NON-NLS-1$ @@ -117,6 +119,7 @@ public class LogWriter { write(s); writeln(); } + /** * Shuts down the log. */ @@ -151,17 +154,18 @@ public class LogWriter { writeln("0");//$NON-NLS-1$ throwable.printStackTrace(new PrintWriter(log)); if (isCoreException) { - CoreException e = (CoreException) throwable; - write(e.getStatus(), 0); + CoreException e = (CoreException) throwable; + write(e.getStatus(), 0); } } - public synchronized void log(IStatus status){ + public synchronized void log(IStatus status) { try { this.write(status, 0); } catch (IOException e) { } } + protected void write(IStatus status, int depth) throws IOException { if (depth == 0) { write(ENTRY); @@ -190,7 +194,7 @@ public class LogWriter { if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { - write(children[i], depth+1); + write(children[i], depth + 1); } } } @@ -198,19 +202,21 @@ public class LogWriter { protected void writeln() throws IOException { write(LINE_SEPARATOR); } + protected void write(String message) throws IOException { if (message != null) log.write(message); } + protected void writeSpace() throws IOException { write(" ");//$NON-NLS-1$ } - - public synchronized void flushLog(){ + + public synchronized void flushLog() { try { log.flush(); - } catch (IOException e) {} + } catch (IOException e) { + } } - } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java index fd81f98cbfa..9067165d611 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java @@ -26,28 +26,25 @@ import org.eclipse.cdt.make.core.scannerconfig.PathInfo; import org.eclipse.core.runtime.IPath; public class PathInfoToLangSettingsConverter { - public static int getSupportedEntryKinds(IDiscoveredPathInfo info){ - if(info instanceof IPerFileDiscoveredPathInfo){ - return getSupportedEntryKinds((IPerFileDiscoveredPathInfo)info); + public static int getSupportedEntryKinds(IDiscoveredPathInfo info) { + if (info instanceof IPerFileDiscoveredPathInfo) { + return getSupportedEntryKinds((IPerFileDiscoveredPathInfo) info); } - return ICLanguageSettingEntry.INCLUDE_PATH - | ICLanguageSettingEntry.MACRO; + return ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.MACRO; } - public static int getSupportedEntryKinds(IPerFileDiscoveredPathInfo info){ - return ICLanguageSettingEntry.INCLUDE_FILE - | ICLanguageSettingEntry.INCLUDE_PATH - | ICLanguageSettingEntry.MACRO - | ICLanguageSettingEntry.MACRO_FILE; + public static int getSupportedEntryKinds(IPerFileDiscoveredPathInfo info) { + return ICLanguageSettingEntry.INCLUDE_FILE | ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.MACRO + | ICLanguageSettingEntry.MACRO_FILE; } - public static ICLanguageSettingEntry[] entriesForKind(int kind, int flags, PathInfo info){ + public static ICLanguageSettingEntry[] entriesForKind(int kind, int flags, PathInfo info) { switch (kind) { case ICLanguageSettingEntry.INCLUDE_PATH: ICLanguageSettingEntry[] incPaths = calculateEntries(kind, flags, info.getIncludePaths()); IPath[] quotedPaths = info.getQuoteIncludePaths(); - if(quotedPaths.length != 0){ - if(incPaths.length != 0){ + if (quotedPaths.length != 0) { + if (incPaths.length != 0) { ICLanguageSettingEntry quotedEntries[] = calculateEntries(kind, flags, quotedPaths); ICLanguageSettingEntry[] tmp = new ICLanguageSettingEntry[incPaths.length + quotedEntries.length]; System.arraycopy(incPaths, 0, tmp, 0, incPaths.length); @@ -68,15 +65,15 @@ public class PathInfoToLangSettingsConverter { return new ICLanguageSettingEntry[0]; } - private static ICLanguageSettingEntry[] calculateEntries(int kind, int flags, IPath[] values){ + private static ICLanguageSettingEntry[] calculateEntries(int kind, int flags, IPath[] values) { ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[values.length]; - for(int i = 0; i < values.length; i++){ - entries[i] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, values[i].toString(), null, null, flags); + for (int i = 0; i < values.length; i++) { + entries[i] = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, values[i].toString(), null, null, flags); } return entries; } - private static ICMacroEntry[] calculateEntries(int flags, Map map){ + private static ICMacroEntry[] calculateEntries(int flags, Map map) { ICMacroEntry entries[] = new ICMacroEntry[map.size()]; int num = 0; Set> entrySet = map.entrySet(); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java index 5efa17f273f..84bfbf56f67 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java @@ -16,53 +16,51 @@ package org.eclipse.cdt.make.internal.core.scannerconfig.util; /** * Enumeration class for scanner configuration affecting command line options - * + * * @author vhirsl */ public final class SCDOptionsEnum { - public static final SCDOptionsEnum COMMAND = new SCDOptionsEnum(0); // gcc or similar command + public static final SCDOptionsEnum COMMAND = new SCDOptionsEnum(0); // gcc or similar command public static final int MIN = 1; - public static final SCDOptionsEnum DEFINE = new SCDOptionsEnum(1); // -D name - public static final SCDOptionsEnum UNDEFINE = new SCDOptionsEnum(2); // -U name - public static final SCDOptionsEnum IDASH = new SCDOptionsEnum(3); // -I- - public static final SCDOptionsEnum INCLUDE = new SCDOptionsEnum(4); // -I dir - public static final SCDOptionsEnum NOSTDINC = new SCDOptionsEnum(5); // -nostdinc - public static final SCDOptionsEnum NOSTDINCPP = new SCDOptionsEnum(6); // -nostdinc++ - public static final SCDOptionsEnum INCLUDE_FILE = new SCDOptionsEnum(7); // -include file - public static final SCDOptionsEnum IMACROS_FILE = new SCDOptionsEnum(8); // -imacros file - public static final SCDOptionsEnum IDIRAFTER = new SCDOptionsEnum(9); // -idirafter dir - public static final SCDOptionsEnum ISYSTEM = new SCDOptionsEnum(10); // -isystem dir - public static final SCDOptionsEnum IPREFIX = new SCDOptionsEnum(11); // -iprefix prefix - public static final SCDOptionsEnum IWITHPREFIX = new SCDOptionsEnum(12); // -iwithprefix dir - public static final SCDOptionsEnum IWITHPREFIXBEFORE = new SCDOptionsEnum(13); // -iwithprefixbefore dir - public static final SCDOptionsEnum IQUOTE = new SCDOptionsEnum(14); // -iquote dir + public static final SCDOptionsEnum DEFINE = new SCDOptionsEnum(1); // -D name + public static final SCDOptionsEnum UNDEFINE = new SCDOptionsEnum(2); // -U name + public static final SCDOptionsEnum IDASH = new SCDOptionsEnum(3); // -I- + public static final SCDOptionsEnum INCLUDE = new SCDOptionsEnum(4); // -I dir + public static final SCDOptionsEnum NOSTDINC = new SCDOptionsEnum(5); // -nostdinc + public static final SCDOptionsEnum NOSTDINCPP = new SCDOptionsEnum(6); // -nostdinc++ + public static final SCDOptionsEnum INCLUDE_FILE = new SCDOptionsEnum(7); // -include file + public static final SCDOptionsEnum IMACROS_FILE = new SCDOptionsEnum(8); // -imacros file + public static final SCDOptionsEnum IDIRAFTER = new SCDOptionsEnum(9); // -idirafter dir + public static final SCDOptionsEnum ISYSTEM = new SCDOptionsEnum(10); // -isystem dir + public static final SCDOptionsEnum IPREFIX = new SCDOptionsEnum(11); // -iprefix prefix + public static final SCDOptionsEnum IWITHPREFIX = new SCDOptionsEnum(12); // -iwithprefix dir + public static final SCDOptionsEnum IWITHPREFIXBEFORE = new SCDOptionsEnum(13); // -iwithprefixbefore dir + public static final SCDOptionsEnum IQUOTE = new SCDOptionsEnum(14); // -iquote dir public static final int MAX = 14; - - private static final String[] SCDOPTION_STRING_VALS = { - "cc", //$NON-NLS-1$ - "-D", //$NON-NLS-1$ - "-U", //$NON-NLS-1$ - "-I-", //$NON-NLS-1$ - "-I", //$NON-NLS-1$ - "-nostdinc", //$NON-NLS-1$ - "-nostdinc++", //$NON-NLS-1$ - "-include", //$NON-NLS-1$ - "-imacros", //$NON-NLS-1$ - "-idirafter", //$NON-NLS-1$ - "-isystem", //$NON-NLS-1$ - "-iprefix", //$NON-NLS-1$ - "-iwithprefix", //$NON-NLS-1$ - "-iwithprefixbefore", //$NON-NLS-1$ - "-iquote" //$NON-NLS-1$ - }; - private static final SCDOptionsEnum SCDOPTIONS[] = { - COMMAND, DEFINE, UNDEFINE, IDASH, INCLUDE, NOSTDINC, NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE, - IDIRAFTER, ISYSTEM, IPREFIX, IWITHPREFIX, IWITHPREFIXBEFORE, IQUOTE + + private static final String[] SCDOPTION_STRING_VALS = { "cc", //$NON-NLS-1$ + "-D", //$NON-NLS-1$ + "-U", //$NON-NLS-1$ + "-I-", //$NON-NLS-1$ + "-I", //$NON-NLS-1$ + "-nostdinc", //$NON-NLS-1$ + "-nostdinc++", //$NON-NLS-1$ + "-include", //$NON-NLS-1$ + "-imacros", //$NON-NLS-1$ + "-idirafter", //$NON-NLS-1$ + "-isystem", //$NON-NLS-1$ + "-iprefix", //$NON-NLS-1$ + "-iwithprefix", //$NON-NLS-1$ + "-iwithprefixbefore", //$NON-NLS-1$ + "-iquote" //$NON-NLS-1$ }; - + private static final SCDOptionsEnum SCDOPTIONS[] = { COMMAND, DEFINE, UNDEFINE, IDASH, INCLUDE, NOSTDINC, + NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE, IDIRAFTER, ISYSTEM, IPREFIX, IWITHPREFIX, IWITHPREFIXBEFORE, + IQUOTE }; + /** - * + * */ private SCDOptionsEnum(int val) { this._enum = val; @@ -71,40 +69,45 @@ public final class SCDOptionsEnum { public int getEnumValue() { return _enum; } - + public static SCDOptionsEnum getSCDOptionsEnum(int val) { if (val >= 0 && val <= MAX) { return SCDOPTIONS[val]; } return null; } - - public static SCDOptionsEnum getSCDOptionsEnum(String desc) { - for (int i = 0; i <= MAX; ++i) { - if (desc.equals(SCDOPTION_STRING_VALS[i])) { - return SCDOPTIONS[i]; - } - } - return null; - } - + + public static SCDOptionsEnum getSCDOptionsEnum(String desc) { + for (int i = 0; i <= MAX; ++i) { + if (desc.equals(SCDOPTION_STRING_VALS[i])) { + return SCDOPTIONS[i]; + } + } + return null; + } + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object arg0) { - if (arg0 == null) return false; - if (arg0 == this) return true; - if (arg0 instanceof SCDOptionsEnum) return (_enum == ((SCDOptionsEnum)arg0)._enum); + if (arg0 == null) + return false; + if (arg0 == this) + return true; + if (arg0 instanceof SCDOptionsEnum) + return (_enum == ((SCDOptionsEnum) arg0)._enum); return false; } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { - return _enum*17 + 11; + return _enum * 17 + 11; } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -112,6 +115,6 @@ public final class SCDOptionsEnum { public String toString() { return SCDOPTION_STRING_VALS[_enum]; } - + private final int _enum; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java index 1d88ea545aa..9b01afc6710 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java @@ -21,7 +21,6 @@ import java.util.Map; import org.eclipse.cdt.internal.core.SafeStringInterner; - /** * Represents a symbol definition with possible multiple values * example: @@ -31,10 +30,10 @@ import org.eclipse.cdt.internal.core.SafeStringInterner; * @author vhirsl */ public class SymbolEntry { - private static final String UNSPECIFIED_VALUE = "1"; //$NON-NLS-1$ + private static final String UNSPECIFIED_VALUE = "1"; //$NON-NLS-1$ private String name; - private Map values; // Values can be either in the active (selected) group or in the removed group - + private Map values; // Values can be either in the active (selected) group or in the removed group + public SymbolEntry(String name, String value, boolean active) { this.name = SafeStringInterner.safeIntern(name); if (values == null) { @@ -44,42 +43,45 @@ public class SymbolEntry { } public boolean add(String value, boolean active) { - Boolean old= values.put(SafeStringInterner.safeIntern(value), Boolean.valueOf(active)); + Boolean old = values.put(SafeStringInterner.safeIntern(value), Boolean.valueOf(active)); return old == null || old.booleanValue() != active; } - + public void remove(String value) { values.remove(value); } - + public void removeAll() { values = null; } - + public List getActive() { return get(true, true, true); } + public List getActiveRaw() { return get(false, true, true); } - + public List getRemoved() { return get(true, true, false); } + public List getRemovedRaw() { return get(false, true, false); } - + public List getAll() { return get(true, false, true /*don't care*/); } + public List getAllRaw() { return get(false, false, true /*don't care*/); } /** * Utility function to retrieve values as a set. - * + * * @param format - false = raw * @param subset - false = all * @param active - false = removed @@ -92,13 +94,13 @@ public class SymbolEntry { continue; if (format) { rv.add(name + "=" + (val == null ? UNSPECIFIED_VALUE : val));//$NON-NLS-1$ - } - else { + } else { rv.add(name + (val == null ? "" : "=" + val));//$NON-NLS-1$ //$NON-NLS-2$ - } + } } return rv; } + /** * Returns only value part of all active entries * @return List @@ -113,11 +115,11 @@ public class SymbolEntry { } return rv; } - + public int numberOfValues() { return values.size(); } - + @Override public String toString() { StringBuilder buffer = new StringBuilder(name); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java index 427cc0b56d1..b7570a541fb 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM - Initial API and implementation * Markus Schorn (Wind River Systems) @@ -31,11 +31,12 @@ public class TraceUtil { public static final String EOL = System.getProperty("line.separator"); //$NON-NLS-1$ public static boolean SCANNER_CONFIG = false; private static LogWriter logger = null; - + static { - if (MakeCorePlugin.getDefault()!=null) // in case of running simple junit tests + if (MakeCorePlugin.getDefault() != null) // in case of running simple junit tests logger = new LogWriter(MakeCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$ } + /* (non-Javadoc) * @see java.lang.Object#finalize() */ @@ -44,17 +45,17 @@ public class TraceUtil { logger.shutdown(); super.finalize(); } - + public static boolean isTracing() { return SCANNER_CONFIG; } - + public static void outputTrace(String prefix, String[] tokens, String postfix) { if (isTracing()) { System.out.print(prefix + ' '); for (int i = 0; i < tokens.length; i++) { System.out.print(tokens[i] + ' '); - + } System.out.println(postfix); } @@ -65,7 +66,7 @@ public class TraceUtil { System.out.println(prefix + ' ' + msg + ' ' + postfix); } } - + /** * For traces of type: * Title: @@ -78,21 +79,23 @@ public class TraceUtil { * item2[1] * ... */ - public static void outputTrace(String title, String subtitle1, List item1, List item1new, String subtitle2, List item2) { + public static void outputTrace(String title, String subtitle1, List item1, List item1new, + String subtitle2, List item2) { if (isTracing()) { //System.out.println(); System.out.println(title); - final String prefix = " "; //$NON-NLS-1$ - final String doublePrefix = " "; //$NON-NLS-1$ - System.out.println(prefix + subtitle1 + " (" + item1.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ + final String prefix = " "; //$NON-NLS-1$ + final String doublePrefix = " "; //$NON-NLS-1$ + System.out.println(prefix + subtitle1 + " (" + item1.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ int count = 0; - for (Iterator i = item1.iterator(), j = item1new.iterator(); i.hasNext(); ) { - System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" +i.next() + (j.hasNext()?"\' -> \'" + j.next():"") + '\''); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + for (Iterator i = item1.iterator(), j = item1new.iterator(); i.hasNext();) { + System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" + i.next() //$NON-NLS-1$ + + (j.hasNext() ? "\' -> \'" + j.next() : "") + '\''); //$NON-NLS-1$ //$NON-NLS-2$ } - System.out.println(prefix + subtitle2 + " (" + item2.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ + System.out.println(prefix + subtitle2 + " (" + item2.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ count = 0; - for (Iterator i = item2.iterator(); i.hasNext(); ) { - System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" + i.next() + '\''); //$NON-NLS-1$ + for (Iterator i = item2.iterator(); i.hasNext();) { + System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" + i.next() + '\''); //$NON-NLS-1$ } } } @@ -139,8 +142,8 @@ public class TraceUtil { } } logger.flushLog(); + } catch (IOException e) { } - catch (IOException e) {} } public static void summaryTrace(String title, int workingDirsN, int commandsN, int filesN) { @@ -153,8 +156,8 @@ public class TraceUtil { logger.writeln(" Number of generic commands: " + Integer.toString(commandsN)); //$NON-NLS-1$ logger.writeln(" Number of compiled files: " + Integer.toString(filesN)); //$NON-NLS-1$ logger.flushLog(); + } catch (IOException e) { } - catch (IOException e) {} } /** @@ -167,8 +170,8 @@ public class TraceUtil { logger.writeln(); logger.writeln(trace); logger.flushLog(); + } catch (IOException e) { } - catch (IOException e) {} } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java index 687f7609f15..fb3e725896b 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java @@ -76,20 +76,15 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { private SCMarkerGenerator markerGenerator = new SCMarkerGenerator(); @Override - public boolean invokeProvider(IProgressMonitor monitor, IResource resource, - String providerId, IScannerConfigBuilderInfo2 buildInfo, - IScannerInfoCollector collector) { - return invokeProvider(monitor, resource, new InfoContext(resource.getProject()), providerId, buildInfo, collector, null); + public boolean invokeProvider(IProgressMonitor monitor, IResource resource, String providerId, + IScannerConfigBuilderInfo2 buildInfo, IScannerInfoCollector collector) { + return invokeProvider(monitor, resource, new InfoContext(resource.getProject()), providerId, buildInfo, + collector, null); } @Override - public boolean invokeProvider(IProgressMonitor monitor, - IResource resource, - InfoContext context, - String providerId, - IScannerConfigBuilderInfo2 buildInfo, - IScannerInfoCollector collector, - Properties env) { + public boolean invokeProvider(IProgressMonitor monitor, IResource resource, InfoContext context, String providerId, + IScannerConfigBuilderInfo2 buildInfo, IScannerInfoCollector collector, Properties env) { // initialize fields this.resource = resource; this.providerId = providerId; @@ -113,9 +108,10 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { ILanguage language = context.getLanguage(); IConsole console; - if (language!=null && isConsoleEnabled()) { + if (language != null && isConsoleEnabled()) { String consoleId = MakeCorePlugin.PLUGIN_ID + '.' + providerId + '.' + language.getId(); - String consoleName = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Console_Name", language.getName()); //$NON-NLS-1$ + String consoleName = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Console_Name", //$NON-NLS-1$ + language.getName()); console = CCorePlugin.getDefault().getBuildConsole(consoleId, consoleName, null); } else { // that looks in extension points registry and won't find the id @@ -127,24 +123,29 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { launcher.setProject(project); IPath program = getCommandToLaunch(); - if (! program.isEmpty()) { + if (!program.isEmpty()) { String[] comandLineOptions = getCommandLineOptions(); URI workingDirectoryURI = MakeBuilderUtil.getBuildDirectoryURI(project, MakeBuilder.BUILDER_ID); String[] envp = setEnvironment(launcher, env); - - ErrorParserManager epm = new ErrorParserManager(project, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID}); - + + ErrorParserManager epm = new ErrorParserManager(project, markerGenerator, + new String[] { GMAKE_ERROR_PARSER_ID }); + List parsers = new ArrayList(); - IConsoleParser parser = ScannerInfoConsoleParserFactory.getESIConsoleParser(project, context, providerId, buildInfo, collector, markerGenerator); + IConsoleParser parser = ScannerInfoConsoleParserFactory.getESIConsoleParser(project, context, + providerId, buildInfo, collector, markerGenerator); if (parser != null) { parsers.add(parser); } - - buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp ); - buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); - - buildRunnerHelper.greeting(MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$ - buildRunnerHelper.build(new SubProgressMonitor(monitor, TICKS_EXECUTE_PROGRAM, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); + + buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp); + buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, + TICKS_STREAM_PROGRESS_MONITOR, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); + + buildRunnerHelper.greeting( + MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$ + buildRunnerHelper.build(new SubProgressMonitor(monitor, TICKS_EXECUTE_PROGRAM, + SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); buildRunnerHelper.close(); buildRunnerHelper.goodbye(); } @@ -169,8 +170,7 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { protected String[] getCommandLineOptions() { // add additional arguments // subclass can change default behavior - return prepareArguments( - buildInfo.isUseDefaultProviderCommand(providerId)); + return prepareArguments(buildInfo.isUseDefaultProviderCommand(providerId)); } /** @@ -183,7 +183,7 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { //fWorkingDirectory = resource.getProject().getLocation(); URI workingDirURI = MakeBuilderUtil.getBuildDirectoryURI(currProject, MakeBuilder.BUILDER_ID); String pathString = EFSExtensionManager.getDefault().getPathFromURI(workingDirURI); - if(pathString != null) { + if (pathString != null) { fWorkingDirectory = new Path(pathString); } @@ -193,7 +193,8 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { } fCompileCommand = new Path(buildInfo.getProviderRunCommand(providerId)); - fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(buildInfo.getProviderRunArguments(providerId), "\"");//$NON-NLS-1$ + fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(buildInfo.getProviderRunArguments(providerId), + "\"");//$NON-NLS-1$ return (fCompileCommand != null); } @@ -220,7 +221,7 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { // of the language as long as the encoding is set to UTF-8. // English language is chosen because parser relies on English messages // in the output of the 'gcc -v' command. - props.put("LANGUAGE", "en"); // override for GNU gettext //$NON-NLS-1$ //$NON-NLS-2$ + props.put("LANGUAGE", "en"); // override for GNU gettext //$NON-NLS-1$ //$NON-NLS-2$ props.put("LC_ALL", "en_US.UTF-8"); // for other parts of the system libraries //$NON-NLS-1$ //$NON-NLS-2$ return props; } @@ -240,7 +241,6 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { return env; } - /** * Set preference to stream output of scanner discovery to a console. */ @@ -260,8 +260,8 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { * @return boolean preference value */ public static boolean isConsoleEnabled() { - boolean value = InstanceScope.INSTANCE.getNode(MakeCorePlugin.PLUGIN_ID) - .getBoolean(PREF_CONSOLE_ENABLED, false); + boolean value = InstanceScope.INSTANCE.getNode(MakeCorePlugin.PLUGIN_ID).getBoolean(PREF_CONSOLE_ENABLED, + false); return value; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java index 755a5678fe7..01440717b9a 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java @@ -47,51 +47,46 @@ import org.eclipse.core.runtime.IProgressMonitor; * @author vhirsl */ public class DefaultSIFileReader implements IExternalScannerInfoProvider { - private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = MakeCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$ + private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = MakeCorePlugin.getUniqueIdentifier() + + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$ - private long fileSize = 0; + private long fileSize = 0; - private SCMarkerGenerator markerGenerator = new SCMarkerGenerator(); + private SCMarkerGenerator markerGenerator = new SCMarkerGenerator(); - @Override - public boolean invokeProvider(IProgressMonitor monitor, IResource resource, - String providerId, IScannerConfigBuilderInfo2 buildInfo, - IScannerInfoCollector collector) { - return invokeProvider(monitor, resource, new InfoContext(resource.getProject()), providerId, buildInfo, collector, null); - } + @Override + public boolean invokeProvider(IProgressMonitor monitor, IResource resource, String providerId, + IScannerConfigBuilderInfo2 buildInfo, IScannerInfoCollector collector) { + return invokeProvider(monitor, resource, new InfoContext(resource.getProject()), providerId, buildInfo, + collector, null); + } - @Override - public boolean invokeProvider(IProgressMonitor monitor, - IResource resource, - InfoContext context, - String providerId, - IScannerConfigBuilderInfo2 buildInfo, - IScannerInfoCollector collector, - Properties env) { - boolean rc = false; - IProject project = resource.getProject(); - // input - BufferedReader reader = getStreamReader(buildInfo.getBuildOutputFilePath()); - if (reader == null) - return rc; + @Override + public boolean invokeProvider(IProgressMonitor monitor, IResource resource, InfoContext context, String providerId, + IScannerConfigBuilderInfo2 buildInfo, IScannerInfoCollector collector, Properties env) { + boolean rc = false; + IProject project = resource.getProject(); + // input + BufferedReader reader = getStreamReader(buildInfo.getBuildOutputFilePath()); + if (reader == null) + return rc; - try { - // output - IConsole console = CCorePlugin.getDefault().getConsole(EXTERNAL_SI_PROVIDER_CONSOLE_ID); - console.start(project); - OutputStream ostream; - try { - ostream = console.getOutputStream(); - } - catch (CoreException e) { - ostream = null; - } + try { + // output + IConsole console = CCorePlugin.getDefault().getConsole(EXTERNAL_SI_PROVIDER_CONSOLE_ID); + console.start(project); + OutputStream ostream; + try { + ostream = console.getOutputStream(); + } catch (CoreException e) { + ostream = null; + } - // get build location - IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(project, MakeBuilder.BUILDER_ID); + // get build location + IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(project, MakeBuilder.BUILDER_ID); - ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory. - getMakeBuilderOutputSniffer(ostream, null, project, context, buildDirectory, buildInfo, markerGenerator, collector); + ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getMakeBuilderOutputSniffer(ostream, null, + project, context, buildDirectory, buildInfo, markerGenerator, collector); if (sniffer != null) { ostream = sniffer.getOutputStream(); } @@ -99,62 +94,62 @@ public class DefaultSIFileReader implements IExternalScannerInfoProvider { if (ostream != null) { rc = readFileToOutputStream(monitor, reader, ostream); } - } finally { + } finally { try { reader.close(); } catch (IOException e) { - MakeCorePlugin.log(e); + MakeCorePlugin.log(e); } - } - return rc; + } + return rc; } - private BufferedReader getStreamReader(String inputFileName) { - BufferedReader reader = null; - try { - fileSize = new File(inputFileName).length(); - reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFileName))); - } catch (FileNotFoundException e) { - MakeCorePlugin.log(e); - } - return reader; - } + private BufferedReader getStreamReader(String inputFileName) { + BufferedReader reader = null; + try { + fileSize = new File(inputFileName).length(); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFileName))); + } catch (FileNotFoundException e) { + MakeCorePlugin.log(e); + } + return reader; + } - /** - * Precondition: Neither input nor output are null - */ - private boolean readFileToOutputStream(IProgressMonitor monitor, BufferedReader reader, OutputStream ostream) { - final String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$ - monitor.beginTask("Reading build output ...", (int)((fileSize == 0) ? 10000 : fileSize)); //$NON-NLS-1$ - // check if build output file exists - String line; - try { - while ((line = reader.readLine()) != null) { - if (monitor.isCanceled()) { - return false; - } + /** + * Precondition: Neither input nor output are null + */ + private boolean readFileToOutputStream(IProgressMonitor monitor, BufferedReader reader, OutputStream ostream) { + final String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$ + monitor.beginTask("Reading build output ...", (int) ((fileSize == 0) ? 10000 : fileSize)); //$NON-NLS-1$ + // check if build output file exists + String line; + try { + while ((line = reader.readLine()) != null) { + if (monitor.isCanceled()) { + return false; + } - line += lineSeparator; - byte[] bytes = line.getBytes(); - ostream.write(bytes); - monitor.worked(bytes.length); - } - } catch (IOException e) { - MakeCorePlugin.log(e); - } finally { - try { - ostream.flush(); - } catch (IOException e) { - MakeCorePlugin.log(e); - } - try { - ostream.close(); - } catch (IOException e) { - MakeCorePlugin.log(e); - } - } - monitor.done(); - return true; - } + line += lineSeparator; + byte[] bytes = line.getBytes(); + ostream.write(bytes); + monitor.worked(bytes.length); + } + } catch (IOException e) { + MakeCorePlugin.log(e); + } finally { + try { + ostream.flush(); + } catch (IOException e) { + MakeCorePlugin.log(e); + } + try { + ostream.close(); + } catch (IOException e) { + MakeCorePlugin.log(e); + } + } + monitor.done(); + return true; + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java index 51a3c84cc32..169465f360e 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java @@ -25,72 +25,71 @@ import org.eclipse.core.runtime.CoreException; /** * Runs a command to retrieve compiler intrinsic scanner info from 'specs' file. - * + * * @author vhirsl */ public class GCCSpecsRunSIProvider extends DefaultRunSIProvider { - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#initialize() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#initialize() + */ + @Override protected boolean initialize() { - boolean rc = super.initialize(); - - if (rc) { - String targetFile = "dummy"; //$NON-NLS-1$ - IProject project = resource.getProject(); - try { - if (project.hasNature(CCProjectNature.CC_NATURE_ID)) { - targetFile = GCCScannerConfigUtil.CPP_SPECS_FILE; - } - else if (project.hasNature(CProjectNature.C_NATURE_ID)) { - targetFile = GCCScannerConfigUtil.C_SPECS_FILE; - } - // replace string variables in compile arguments - // TODO Vmir - use string variable replacement - for (int i = 0; i < fCompileArguments.length; ++i) { - fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{plugin_state_location\\}", //$NON-NLS-1$ - MakeCorePlugin.getWorkingDirectory().toString()); - fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{specs_file\\}", targetFile); //$NON-NLS-1$ - } - } catch (CoreException e) { - //TODO VMIR better error handling - MakeCorePlugin.log(e.getStatus()); - rc = false; - } - } - return rc; - } + boolean rc = super.initialize(); + + if (rc) { + String targetFile = "dummy"; //$NON-NLS-1$ + IProject project = resource.getProject(); + try { + if (project.hasNature(CCProjectNature.CC_NATURE_ID)) { + targetFile = GCCScannerConfigUtil.CPP_SPECS_FILE; + } else if (project.hasNature(CProjectNature.C_NATURE_ID)) { + targetFile = GCCScannerConfigUtil.C_SPECS_FILE; + } + // replace string variables in compile arguments + // TODO Vmir - use string variable replacement + for (int i = 0; i < fCompileArguments.length; ++i) { + fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{plugin_state_location\\}", //$NON-NLS-1$ + MakeCorePlugin.getWorkingDirectory().toString()); + fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{specs_file\\}", targetFile); //$NON-NLS-1$ + } + } catch (CoreException e) { + //TODO VMIR better error handling + MakeCorePlugin.log(e.getStatus()); + rc = false; + } + } + return rc; + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#prepareArguments(boolean) - */ + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#prepareArguments(boolean) + */ @Override protected String[] prepareArguments(boolean isDefaultCommand) { - if (collector == null) - return fCompileArguments; - - @SuppressWarnings("unchecked") - List tso = collector.getCollectedScannerInfo(resource.getProject(), ScannerInfoTypes.TARGET_SPECIFIC_OPTION); - if (tso == null || tso.size() == 0) { - return fCompileArguments; - } - - String[] rv = null; - // commandArguments may have multiple arguments; tokenizing - int nTokens = 0; - if (fCompileArguments != null && fCompileArguments.length > 0) { - nTokens = fCompileArguments.length; - rv = new String[nTokens + tso.size()]; - System.arraycopy(fCompileArguments, 0, rv, 0, nTokens); - } - else { - rv = new String[tso.size()]; - } - for (int i = 0; i < tso.size(); ++i) { - rv[nTokens + i] = tso.get(i); - } - return rv; - } + if (collector == null) + return fCompileArguments; + + @SuppressWarnings("unchecked") + List tso = collector.getCollectedScannerInfo(resource.getProject(), + ScannerInfoTypes.TARGET_SPECIFIC_OPTION); + if (tso == null || tso.size() == 0) { + return fCompileArguments; + } + + String[] rv = null; + // commandArguments may have multiple arguments; tokenizing + int nTokens = 0; + if (fCompileArguments != null && fCompileArguments.length > 0) { + nTokens = fCompileArguments.length; + rv = new String[nTokens + tso.size()]; + System.arraycopy(fCompileArguments, 0, rv, 0, nTokens); + } else { + rv = new String[tso.size()]; + } + for (int i = 0; i < tso.size(); ++i) { + rv[nTokens + i] = tso.get(i); + } + return rv; + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/MakeConfigurationDataProviderMessages.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/MakeConfigurationDataProviderMessages.java index 758169db481..b72ef9aa242 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/MakeConfigurationDataProviderMessages.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/MakeConfigurationDataProviderMessages.java @@ -19,8 +19,7 @@ import java.util.ResourceBundle; public class MakeConfigurationDataProviderMessages { private static final String BUNDLE_NAME = "org.eclipse.cdt.make.internal.core.scannerconfig2.MakeConfigurationDataProvider"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private MakeConfigurationDataProviderMessages() { } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java index 76f357c753e..07793c72111 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java @@ -64,115 +64,113 @@ import org.w3c.dom.NodeList; * @author vhirsl */ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoCollectorCleaner { - protected static final int INCLUDE_PATH = 1; + protected static final int INCLUDE_PATH = 1; protected static final int QUOTE_INCLUDE_PATH = 2; - protected static final int INCLUDE_FILE = 3; - protected static final int MACROS_FILE = 4; - - protected class ScannerInfoData implements IDiscoveredScannerInfoSerializable { - protected final Map> commandIdToFilesMap; // command id and set of files it applies to - protected final Map fileToCommandIdMap; // maps each file to the corresponding command id - protected final Map commandIdCommandMap; // map of all commands - - public ScannerInfoData() { - commandIdCommandMap = new LinkedHashMap(); // [commandId, command] - fileToCommandIdMap = new HashMap(); // [file, commandId] - commandIdToFilesMap = new HashMap>(); // [commandId, set of files] - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element) - */ - @Override + protected static final int INCLUDE_FILE = 3; + protected static final int MACROS_FILE = 4; + + protected class ScannerInfoData implements IDiscoveredScannerInfoSerializable { + protected final Map> commandIdToFilesMap; // command id and set of files it applies to + protected final Map fileToCommandIdMap; // maps each file to the corresponding command id + protected final Map commandIdCommandMap; // map of all commands + + public ScannerInfoData() { + commandIdCommandMap = new LinkedHashMap(); // [commandId, command] + fileToCommandIdMap = new HashMap(); // [file, commandId] + commandIdToFilesMap = new HashMap>(); // [commandId, set of files] + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element) + */ + @Override public void serialize(Element collectorElem) { - synchronized (PerFileSICollector.this.fLock) { - Document doc = collectorElem.getOwnerDocument(); - - List commandIds = new ArrayList(commandIdCommandMap.keySet()); - Collections.sort(commandIds); - for (Integer commandId : commandIds) { - 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 files = commandIdToFilesMap.get(commandId); - if (files != null) { - for (IFile file : files) { - Element fileElem = doc.createElement(FILE_ELEM); - IPath path = file.getProjectRelativePath(); - fileElem.setAttribute(PATH_ATTR, path.toString()); - filesElem.appendChild(fileElem); - } - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element) - */ - @Override + synchronized (PerFileSICollector.this.fLock) { + Document doc = collectorElem.getOwnerDocument(); + + List commandIds = new ArrayList(commandIdCommandMap.keySet()); + Collections.sort(commandIds); + for (Integer commandId : commandIds) { + 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 files = commandIdToFilesMap.get(commandId); + if (files != null) { + for (IFile file : files) { + Element fileElem = doc.createElement(FILE_ELEM); + IPath path = file.getProjectRelativePath(); + fileElem.setAttribute(PATH_ATTR, path.toString()); + filesElem.appendChild(fileElem); + } + } + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element) + */ + @Override public void deserialize(Element collectorElem) { - synchronized (PerFileSICollector.this.fLock) { - for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) { - if (child.getNodeName().equals(CC_ELEM)) { - Element cmdElem = (Element) child; - boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++"); //$NON-NLS-1$ - CCommandDSC command = new CCommandDSC(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); - } + synchronized (PerFileSICollector.this.fLock) { + for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) { + if (child.getNodeName().equals(CC_ELEM)) { + Element cmdElem = (Element) child; + boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++"); //$NON-NLS-1$ + CCommandDSC command = new CCommandDSC(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; + } + + } - } + protected static class ProjectScannerInfo { + IPath[] includePaths; + IPath[] quoteIncludePaths; + IPath[] includeFiles; + IPath[] macrosFiles; + Map definedSymbols; - protected static class ProjectScannerInfo { - IPath[] includePaths; - IPath[] quoteIncludePaths; - IPath[] includeFiles; - IPath[] macrosFiles; - Map definedSymbols; 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 static final String COLLECTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".PerFileSICollector"; //$NON-NLS-1$ + public static final String COLLECTOR_ID = MakeCorePlugin.getUniqueIdentifier() + ".PerFileSICollector"; //$NON-NLS-1$ protected static final String CC_ELEM = "compilerCommand"; //$NON-NLS-1$ protected static final String ID_ATTR = "id"; //$NON-NLS-1$ protected static final String FILE_TYPE_ATTR = "fileType"; //$NON-NLS-1$ @@ -180,55 +178,54 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC protected static final String FILE_ELEM = "file"; //$NON-NLS-1$ protected static final String PATH_ATTR = "path"; //$NON-NLS-1$ - protected IProject project; - protected InfoContext context; + protected IProject project; + protected InfoContext context; - protected ScannerInfoData sid; // scanner info data - protected ProjectScannerInfo psi = null; // sum of all scanner info + protected ScannerInfoData sid; // scanner info data + protected ProjectScannerInfo psi = null; // sum of all scanner info -// protected List siChangedForFileList; // list of files for which scanner info has changed - protected final Map siChangedForFileMap; // (file, comandId) map for deltas - protected final List 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 siChangedForFileMap; // (file, comandId) map for deltas + protected final List siChangedForCommandIdList; // list of command ids for which scanner info has changed - protected final SortedSet freeCommandIdPool; // sorted set of free command ids - protected int commandIdCounter = 0; + protected final SortedSet freeCommandIdPool; // sorted set of free command ids + protected int commandIdCounter = 0; - /** monitor for data access */ - protected final Object fLock = new Object(); + /** monitor for data access */ + protected final Object fLock = new Object(); - /** - * - */ - public PerFileSICollector() { - sid = new ScannerInfoData(); + /** + * + */ + public PerFileSICollector() { + sid = new ScannerInfoData(); -// siChangedForFileList = new ArrayList(); + // siChangedForFileList = new ArrayList(); siChangedForFileMap = new HashMap(); siChangedForCommandIdList = new ArrayList(); - freeCommandIdPool = new TreeSet(); - } + freeCommandIdPool = new TreeSet(); + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#setProject(org.eclipse.core.resources.IProject) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#setProject(org.eclipse.core.resources.IProject) + */ + @Override public void setProject(IProject project) { - setInfoContext(new InfoContext(project)); - } + setInfoContext(new InfoContext(project)); + } - @Override + @Override public void setInfoContext(InfoContext context) { - this.project = context.getProject(); - this.context = context; - - try { - // deserialize from SI store - DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, sid); - } - catch (CoreException e) { - MakeCorePlugin.log(e); - } + this.project = context.getProject(); + this.context = context; + + try { + // deserialize from SI store + DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, sid); + } catch (CoreException e) { + MakeCorePlugin.log(e); + } } protected InfoContext getInfoContext() { @@ -236,110 +233,102 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC } /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map) - */ - @Override + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map) + */ + @Override public void contributeToScannerConfig(Object resource, @SuppressWarnings("rawtypes") 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) { - @SuppressWarnings("unchecked") - Map> scanInfo = scannerInfo; - addScannerInfo(((Integer)resource), scanInfo); - } - return; - } - else if (!(resource instanceof IFile)) { - errorMessage = "resource is not an IFile";//$NON-NLS-1$ - } - else if (((IFile) resource).getProject() == null) { - errorMessage = "project is null";//$NON-NLS-1$ - } - else if (!((IFile) resource).getProject().equals(project)) { - errorMessage = "wrong project";//$NON-NLS-1$ - } - if (errorMessage != null) { - TraceUtil.outputError("PerFileSICollector.contributeToScannerConfig : ", errorMessage); //$NON-NLS-1$ - return; - } - - IFile file = (IFile) resource; - - synchronized (fLock) { - @SuppressWarnings("unchecked") - Map> scanInfo = scannerInfo; - Set types = scanInfo.keySet(); - for (ScannerInfoTypes type : types) { - if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) { - List commands = scanInfo.get(type); - for (CCommandDSC cmd : commands) { - addCompilerCommand(file, cmd); - } - } - else { - addScannerInfo(type, scanInfo.get(type)); - } - } - } - } - - protected void addScannerInfo(Integer commandId, 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) { + @SuppressWarnings("unchecked") + Map> scanInfo = scannerInfo; + addScannerInfo(((Integer) resource), scanInfo); + } + return; + } else if (!(resource instanceof IFile)) { + errorMessage = "resource is not an IFile";//$NON-NLS-1$ + } else if (((IFile) resource).getProject() == null) { + errorMessage = "project is null";//$NON-NLS-1$ + } else if (!((IFile) resource).getProject().equals(project)) { + errorMessage = "wrong project";//$NON-NLS-1$ + } + if (errorMessage != null) { + TraceUtil.outputError("PerFileSICollector.contributeToScannerConfig : ", errorMessage); //$NON-NLS-1$ + return; + } + + IFile file = (IFile) resource; + + synchronized (fLock) { + @SuppressWarnings("unchecked") + Map> scanInfo = scannerInfo; + Set types = scanInfo.keySet(); + for (ScannerInfoTypes type : types) { + if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) { + List commands = scanInfo.get(type); + for (CCommandDSC cmd : commands) { + addCompilerCommand(file, cmd); + } + } else { + addScannerInfo(type, scanInfo.get(type)); + } + } + } + } + + protected void addScannerInfo(Integer commandId, Map> scannerInfo) { assert Thread.holdsLock(fLock); - CCommandDSC cmd = sid.commandIdCommandMap.get(commandId); - if (cmd != null) { - List siItem = scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS); - cmd.setSymbols(siItem); - siItem = scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS); - siItem = CygpathTranslator.translateIncludePaths(project, siItem); - siItem = CCommandDSC.makeRelative(project, siItem); - cmd.setIncludes(siItem); - siItem = scannerInfo.get(ScannerInfoTypes.QUOTE_INCLUDE_PATHS); - siItem = CygpathTranslator.translateIncludePaths(project, siItem); - siItem = CCommandDSC.makeRelative(project, siItem); - cmd.setQuoteIncludes(siItem); - - cmd.setDiscovered(true); - } - } - - protected void addCompilerCommand(IFile file, CCommandDSC cmd) { + CCommandDSC cmd = sid.commandIdCommandMap.get(commandId); + if (cmd != null) { + List siItem = scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS); + cmd.setSymbols(siItem); + siItem = scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS); + siItem = CygpathTranslator.translateIncludePaths(project, siItem); + siItem = CCommandDSC.makeRelative(project, siItem); + cmd.setIncludes(siItem); + siItem = scannerInfo.get(ScannerInfoTypes.QUOTE_INCLUDE_PATHS); + siItem = CygpathTranslator.translateIncludePaths(project, siItem); + siItem = CCommandDSC.makeRelative(project, siItem); + cmd.setQuoteIncludes(siItem); + + cmd.setDiscovered(true); + } + } + + protected void addCompilerCommand(IFile file, CCommandDSC cmd) { assert Thread.holdsLock(fLock); - List existingCommands = new ArrayList(sid.commandIdCommandMap.values()); - int index = existingCommands.indexOf(cmd); - if (index != -1) { - cmd = existingCommands.get(index); - } - else { - int commandId = -1; - if (!freeCommandIdPool.isEmpty()) { - Integer freeCommandId = freeCommandIdPool.first(); - freeCommandIdPool.remove(freeCommandId); - commandId = freeCommandId.intValue(); - } - else { - commandId = ++commandIdCounter; - } - cmd.setCommandId(commandId); - sid.commandIdCommandMap.put(cmd.getCommandIdAsInteger(), cmd); - } + List existingCommands = new ArrayList(sid.commandIdCommandMap.values()); + int index = existingCommands.indexOf(cmd); + if (index != -1) { + cmd = existingCommands.get(index); + } else { + int commandId = -1; + if (!freeCommandIdPool.isEmpty()) { + Integer freeCommandId = freeCommandIdPool.first(); + freeCommandIdPool.remove(freeCommandId); + commandId = freeCommandId.intValue(); + } else { + commandId = ++commandIdCounter; + } + cmd.setCommandId(commandId); + sid.commandIdCommandMap.put(cmd.getCommandIdAsInteger(), cmd); + } generateFileDelta(file, cmd); - } + } protected void generateFileDelta(IFile file, CCommandDSC cmd) { assert Thread.holdsLock(fLock); - Integer commandId = cmd.getCommandIdAsInteger(); + Integer commandId = cmd.getCommandIdAsInteger(); Integer oldCommandId = sid.fileToCommandIdMap.get(file); if (oldCommandId != null && oldCommandId.equals(commandId)) { // already exists; remove form delta siChangedForFileMap.remove(file); - } - else { + } else { // new (file, commandId) pair siChangedForFileMap.put(file, commandId); } @@ -352,40 +341,39 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC Integer commandId = siChangedForFileMap.get(file); if (commandId != null) { - // update sid.commandIdToFilesMap - Set fileSet = sid.commandIdToFilesMap.get(commandId); - if (fileSet == null) { - fileSet = new HashSet(); - sid.commandIdToFilesMap.put(commandId, fileSet); - CCommandDSC cmd = sid.commandIdCommandMap.get(commandId); - if (cmd != null) { - cmd.resolveOptions(project); - } - } - if (fileSet.add(file)) { - // update fileToCommandIdsMap - boolean change = true; - Integer oldCommandId = sid.fileToCommandIdMap.get(file); - if (oldCommandId != null) { - if (oldCommandId.equals(commandId)) { - change = false; - } - else { - Set oldFileSet = sid.commandIdToFilesMap.get(oldCommandId); - if (oldFileSet != null) { - oldFileSet.remove(file); - } - } - } - if (change) { - sid.fileToCommandIdMap.put(file, commandId); - // TODO generate change event for this resource -// IPath path = file.getFullPath(); -// if (!siChangedForFileList.contains(path)) { -// siChangedForFileList.add(path); -// } - } - } + // update sid.commandIdToFilesMap + Set fileSet = sid.commandIdToFilesMap.get(commandId); + if (fileSet == null) { + fileSet = new HashSet(); + sid.commandIdToFilesMap.put(commandId, fileSet); + CCommandDSC cmd = sid.commandIdCommandMap.get(commandId); + if (cmd != null) { + cmd.resolveOptions(project); + } + } + if (fileSet.add(file)) { + // update fileToCommandIdsMap + boolean change = true; + Integer oldCommandId = sid.fileToCommandIdMap.get(file); + if (oldCommandId != null) { + if (oldCommandId.equals(commandId)) { + change = false; + } else { + Set oldFileSet = sid.commandIdToFilesMap.get(oldCommandId); + if (oldFileSet != null) { + oldFileSet.remove(file); + } + } + } + if (change) { + sid.fileToCommandIdMap.put(file, commandId); + // TODO generate change event for this resource + // IPath path = file.getFullPath(); + // if (!siChangedForFileList.contains(path)) { + // siChangedForFileList.add(path); + // } + } + } } } generateProjectScannerInfo(); @@ -403,373 +391,371 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC protected void removeUnusedCommands() { assert Thread.holdsLock(fLock); - Set>> entrySet = sid.commandIdToFilesMap.entrySet(); - for (Entry> entry : entrySet) { - Integer cmdId = entry.getKey(); - Set fileSet = entry.getValue(); - if (fileSet.isEmpty()) { - // return cmdId to the free command id pool - freeCommandIdPool.add(cmdId); - } - } - for (Integer cmdId : freeCommandIdPool) { - // the command does not have any files associated; remove - sid.commandIdCommandMap.remove(cmdId); - sid.commandIdToFilesMap.remove(cmdId); - } - while (!freeCommandIdPool.isEmpty()) { - Integer last = freeCommandIdPool.last(); - if (last.intValue() == commandIdCounter) { - freeCommandIdPool.remove(last); - --commandIdCounter; - } - else break; - } - } - - protected void addScannerInfo(ScannerInfoTypes type, List delta) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#updateScannerConfiguration(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override + Set>> entrySet = sid.commandIdToFilesMap.entrySet(); + for (Entry> entry : entrySet) { + Integer cmdId = entry.getKey(); + Set fileSet = entry.getValue(); + if (fileSet.isEmpty()) { + // return cmdId to the free command id pool + freeCommandIdPool.add(cmdId); + } + } + for (Integer cmdId : freeCommandIdPool) { + // the command does not have any files associated; remove + sid.commandIdCommandMap.remove(cmdId); + sid.commandIdToFilesMap.remove(cmdId); + } + while (!freeCommandIdPool.isEmpty()) { + Integer last = freeCommandIdPool.last(); + if (last.intValue() == commandIdCounter) { + freeCommandIdPool.remove(last); + --commandIdCounter; + } else + break; + } + } + + protected void addScannerInfo(ScannerInfoTypes type, List delta) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#updateScannerConfiguration(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override public void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException { - if (monitor == null) { - monitor = new NullProgressMonitor(); - } - monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$ - monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$ - ArrayList changedResources = null; - synchronized (fLock) { - if (scannerInfoChanged()) { - applyFileDeltas(); - removeUnusedCommands(); - changedResources = new ArrayList(siChangedForFileMap.keySet()); - siChangedForFileMap.clear(); - } - siChangedForCommandIdList.clear(); - } - monitor.worked(50); - if (changedResources != null) { - // update outside monitor scope - try { - // update scanner configuration - monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$ - IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context); - if (!(pathInfo instanceof IPerFileDiscoveredPathInfo)) { - pathInfo = createPathInfoObject(); - } - MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(context, pathInfo, context.isDefaultContext(), changedResources); - } catch (CoreException e) { - MakeCorePlugin.log(e); - } - } - monitor.worked(50); + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$ + monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$ + ArrayList changedResources = null; + synchronized (fLock) { + if (scannerInfoChanged()) { + applyFileDeltas(); + removeUnusedCommands(); + changedResources = new ArrayList(siChangedForFileMap.keySet()); + siChangedForFileMap.clear(); + } + siChangedForCommandIdList.clear(); + } + monitor.worked(50); + if (changedResources != null) { + // update outside monitor scope + try { + // update scanner configuration + monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$ + IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager() + .getDiscoveredInfo(project, context); + if (!(pathInfo instanceof IPerFileDiscoveredPathInfo)) { + pathInfo = createPathInfoObject(); + } + MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(context, pathInfo, + context.isDefaultContext(), changedResources); + } catch (CoreException e) { + MakeCorePlugin.log(e); + } + } + monitor.worked(50); monitor.done(); - } + } - /* (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(); - } + return new PerFileDiscoveredPathInfo(); + } protected boolean scannerInfoChanged() { assert Thread.holdsLock(fLock); -// return !siChangedForFileList.isEmpty(); + // return !siChangedForFileList.isEmpty(); return !siChangedForFileMap.isEmpty(); } - /* (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 getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { - List rv = new ArrayList(); - // 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 (resource!=null && project.equals(((IResource)resource).getProject())) { - if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) { - synchronized (fLock) { - Set cmdIds = sid.commandIdCommandMap.keySet(); - for (Integer cmdId : cmdIds) { - Set 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()) { - Set files = siChangedForFileMap.keySet(); - for (IFile file : files) { - Integer cmdId = siChangedForFileMap.get(file); - if (cmdId != null) { - if (!siChangedForCommandIdList.contains(cmdId)) { - siChangedForCommandIdList.add(cmdId); - } - } - } - } - Collections.sort(siChangedForCommandIdList); - for (Integer cmdId : siChangedForCommandIdList) { - CCommandDSC command = sid.commandIdCommandMap.get(cmdId); - rv.add(command); - } - } - } - } - } - return rv; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllPaths(org.eclipse.core.resources.IResource) - */ - @Override + List rv = new ArrayList(); + // 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 (resource != null && project.equals(((IResource) resource).getProject())) { + if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) { + synchronized (fLock) { + Set cmdIds = sid.commandIdCommandMap.keySet(); + for (Integer cmdId : cmdIds) { + Set 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()) { + Set files = siChangedForFileMap.keySet(); + for (IFile file : files) { + Integer cmdId = siChangedForFileMap.get(file); + if (cmdId != null) { + if (!siChangedForCommandIdList.contains(cmdId)) { + siChangedForCommandIdList.add(cmdId); + } + } + } + } + Collections.sort(siChangedForCommandIdList); + for (Integer cmdId : siChangedForCommandIdList) { + CCommandDSC command = sid.commandIdCommandMap.get(cmdId); + rv.add(command); + } + } + } + } + } + return rv; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllPaths(org.eclipse.core.resources.IResource) + */ + @Override public void deleteAllPaths(IResource resource) { - // TODO Auto-generated method stub + // TODO Auto-generated method stub - } + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllSymbols(org.eclipse.core.resources.IResource) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllSymbols(org.eclipse.core.resources.IResource) + */ + @Override public void deleteAllSymbols(IResource resource) { - // TODO Auto-generated method stub + // TODO Auto-generated method stub - } + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deletePath(org.eclipse.core.resources.IResource, java.lang.String) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deletePath(org.eclipse.core.resources.IResource, java.lang.String) + */ + @Override public void deletePath(IResource resource, String path) { - // TODO Auto-generated method stub + // TODO Auto-generated method stub - } + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteSymbol(org.eclipse.core.resources.IResource, java.lang.String) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteSymbol(org.eclipse.core.resources.IResource, java.lang.String) + */ + @Override public void deleteSymbol(IResource resource, String symbol) { - // TODO Auto-generated method stub + // TODO Auto-generated method stub - } + } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource) + */ + @Override public void deleteAll(IResource resource) { - if (resource.equals(project)) { - synchronized (fLock) { -// siChangedForFileList = new ArrayList(); - siChangedForFileMap.clear(); - Set changedFiles = sid.fileToCommandIdMap.keySet(); - for (IFile file : changedFiles) { -// IPath path = file.getFullPath(); -// siChangedForFileList.add(path); - siChangedForFileMap.put(file, null); - } - - sid = new ScannerInfoData(); - psi = null; - - commandIdCounter = 0; + if (resource.equals(project)) { + synchronized (fLock) { + // siChangedForFileList = new ArrayList(); + siChangedForFileMap.clear(); + Set changedFiles = sid.fileToCommandIdMap.keySet(); + for (IFile file : changedFiles) { + // IPath path = file.getFullPath(); + // siChangedForFileList.add(path); + siChangedForFileMap.put(file, null); + } + + sid = new ScannerInfoData(); + psi = null; + + commandIdCounter = 0; freeCommandIdPool.clear(); - } - } - } - - /** - * Per file DPI object - * - * @author vhirsl - */ - protected class PerFileDiscoveredPathInfo implements IPerFileDiscoveredPathInfo2 { - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getProject() - */ - @Override + } + } + } + + /** + * Per file DPI object + * + * @author vhirsl + */ + protected class PerFileDiscoveredPathInfo implements IPerFileDiscoveredPathInfo2 { + /* (non-Javadoc) + * @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.IDiscoveredPathInfo#getIncludePaths() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths() + */ + @Override public IPath[] getIncludePaths() { - final IPath[] includepaths; - final IPath[] quotepaths; - synchronized (PerFileSICollector.this.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 result = new ArrayList(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#getSymbols() - */ - @Override + final IPath[] includepaths; + final IPath[] quotepaths; + synchronized (PerFileSICollector.this.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 result = new ArrayList(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#getSymbols() + */ + @Override public Map getSymbols() { -// return new HashMap(); - synchronized (PerFileSICollector.this.fLock) { - return getAllSymbols(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath) - */ - @Override + // return new HashMap(); + synchronized (PerFileSICollector.this.fLock) { + return getAllSymbols(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath) + */ + @Override public IPath[] getIncludePaths(IPath path) { - synchronized (PerFileSICollector.this.fLock) { - // get the command - CCommandDSC cmd = getCommand(path); - if (cmd != null && cmd.isDiscovered()) { - return stringListToPathArray(cmd.getIncludes()); - } - // use project scope scanner info - if (psi == null) { - generateProjectScannerInfo(); - } - return psi.includePaths; - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getQuoteIncludePaths(org.eclipse.core.runtime.IPath) - */ - @Override + synchronized (PerFileSICollector.this.fLock) { + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null && cmd.isDiscovered()) { + return stringListToPathArray(cmd.getIncludes()); + } + // use project scope scanner info + if (psi == null) { + generateProjectScannerInfo(); + } + return psi.includePaths; + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getQuoteIncludePaths(org.eclipse.core.runtime.IPath) + */ + @Override public IPath[] getQuoteIncludePaths(IPath path) { - synchronized (PerFileSICollector.this.fLock) { - // get the command - CCommandDSC cmd = getCommand(path); - if (cmd != null && cmd.isDiscovered()) { - return stringListToPathArray(cmd.getQuoteIncludes()); - } - // use project scope scanner info - if (psi == null) { - generateProjectScannerInfo(); - } - return psi.quoteIncludePaths; - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath) - */ - @Override + synchronized (PerFileSICollector.this.fLock) { + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null && cmd.isDiscovered()) { + return stringListToPathArray(cmd.getQuoteIncludes()); + } + // use project scope scanner info + if (psi == null) { + generateProjectScannerInfo(); + } + return psi.quoteIncludePaths; + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath) + */ + @Override public Map getSymbols(IPath path) { - synchronized (PerFileSICollector.this.fLock) { - // get the command - CCommandDSC cmd = getCommand(path); - if (cmd != null && cmd.isDiscovered()) { - List symbols = cmd.getSymbols(); - Map definedSymbols = new HashMap(symbols.size()); - for (String symbol : symbols) { - String key = SafeStringInterner.safeIntern(ScannerConfigUtil.getSymbolKey(symbol)); - String value = SafeStringInterner.safeIntern(ScannerConfigUtil.getSymbolValue(symbol)); - definedSymbols.put(key, value); - } - return definedSymbols; - } - // use project scope scanner info - if (psi == null) { - generateProjectScannerInfo(); - } - return psi.definedSymbols; - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludeFiles(org.eclipse.core.runtime.IPath) - */ - @Override + synchronized (PerFileSICollector.this.fLock) { + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null && cmd.isDiscovered()) { + List symbols = cmd.getSymbols(); + Map definedSymbols = new HashMap(symbols.size()); + for (String symbol : symbols) { + String key = SafeStringInterner.safeIntern(ScannerConfigUtil.getSymbolKey(symbol)); + String value = SafeStringInterner.safeIntern(ScannerConfigUtil.getSymbolValue(symbol)); + definedSymbols.put(key, value); + } + return definedSymbols; + } + // use project scope scanner info + if (psi == null) { + generateProjectScannerInfo(); + } + return psi.definedSymbols; + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludeFiles(org.eclipse.core.runtime.IPath) + */ + @Override public IPath[] getIncludeFiles(IPath path) { - synchronized (PerFileSICollector.this.fLock) { - // get the command - CCommandDSC cmd = getCommand(path); - if (cmd != null) { - return stringListToPathArray(cmd.getIncludeFile()); - } - // use project scope scanner info - if (psi == null) { - generateProjectScannerInfo(); - } - return psi.includeFiles; - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getMacroFiles(org.eclipse.core.runtime.IPath) - */ - @Override + synchronized (PerFileSICollector.this.fLock) { + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null) { + return stringListToPathArray(cmd.getIncludeFile()); + } + // use project scope scanner info + if (psi == null) { + generateProjectScannerInfo(); + } + return psi.includeFiles; + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getMacroFiles(org.eclipse.core.runtime.IPath) + */ + @Override public IPath[] getMacroFiles(IPath path) { - synchronized (PerFileSICollector.this.fLock) { - // get the command - CCommandDSC cmd = getCommand(path); - if (cmd != null) { - return stringListToPathArray(cmd.getImacrosFile()); - } - // use project scope scanner info - if (psi == null) { - generateProjectScannerInfo(); - } - return psi.macrosFiles; - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getSerializable() - */ - @Override + synchronized (PerFileSICollector.this.fLock) { + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null) { + return stringListToPathArray(cmd.getImacrosFile()); + } + // use project scope scanner info + if (psi == null) { + generateProjectScannerInfo(); + } + return psi.macrosFiles; + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getSerializable() + */ + @Override public IDiscoveredScannerInfoSerializable getSerializable() { - synchronized (PerFileSICollector.this.fLock) { - return sid; - } - } + synchronized (PerFileSICollector.this.fLock) { + return sid; + } + } /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#isEmpty(org.eclipse.core.runtime.IPath) @@ -780,12 +766,11 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC IResource resource = project.getWorkspace().getRoot().findMember(path); if (resource != null) { if (resource instanceof IFile) { - rc = (getCommand((IFile)resource) == null); - } - else if (resource instanceof IProject) { - synchronized (PerFileSICollector.this.fLock) { - rc = (psi == null || psi.isEmpty()); - } + rc = (getCommand((IFile) resource) == null); + } else if (resource instanceof IProject) { + synchronized (PerFileSICollector.this.fLock) { + rc = (psi == null || psi.isEmpty()); + } } } return rc; @@ -793,151 +778,151 @@ public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoC @Override public Map getPathInfoMap() { - synchronized (PerFileSICollector.this.fLock) { + synchronized (PerFileSICollector.this.fLock) { //TODO: do we need to cache this? return calculatePathInfoMap(); - } + } } - } + } - protected Map calculatePathInfoMap(){ + protected Map calculatePathInfoMap() { assert Thread.holdsLock(fLock); - Map map = new HashMap(sid.fileToCommandIdMap.size() + 1); - Set> entrySet = sid.fileToCommandIdMap.entrySet(); - for (Entry entry : entrySet) { - IFile file = entry.getKey(); - if(file != null){ - CCommandDSC cmd = sid.commandIdCommandMap.get(entry.getValue()); - if(cmd != null){ - PathInfo fpi = createFilePathInfo(cmd); - map.put(file, fpi); - } - } - } - - if(project != null){ - if(psi == null){ - generateProjectScannerInfo(); - } - - PathInfo fpi = new PathInfo(psi.includePaths, psi.quoteIncludePaths, psi.definedSymbols, psi.includeFiles, psi.macrosFiles); - map.put(project, fpi); - } - - return map; - } - - 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 definedSymbols = new HashMap(symbols.size()); - for (String symbol : symbols) { - String key = ScannerConfigUtil.getSymbolKey(symbol); - String value = ScannerConfigUtil.getSymbolValue(symbol); - definedSymbols.put(key, value); - } - - return new PathInfo(includes, quotedIncludes, definedSymbols, incFiles, macroFiles); - } - - protected CCommandDSC getCommand(IPath path) { - try { - IFile file = project.getWorkspace().getRoot().getFile(path); - return getCommand(file); - } - catch (Exception e) { - return null; - } - } - - protected CCommandDSC getCommand(IFile file) { - CCommandDSC cmd = null; - if (file != null) { - Integer cmdId = sid.fileToCommandIdMap.get(file); - if (cmdId != null) { - // get the command - cmd = sid.commandIdCommandMap.get(cmdId); - } - } - return cmd; - } - - /** - * @param type can be one of the following: - *
  • INCLUDE_PATH - *
  • QUOTE_INCLUDE_PATH - *
  • INCLUDE_FILE - *
  • MACROS_FILE - * - * @return list of IPath(s). - */ - protected IPath[] getAllIncludePaths(int type) { - List allIncludes = new ArrayList(); - Set cmdIds = sid.commandIdCommandMap.keySet(); - for (Integer cmdId : cmdIds) { - CCommandDSC cmd = sid.commandIdCommandMap.get(cmdId); - if (cmd.isDiscovered()) { - List discovered = null; - switch (type) { - case INCLUDE_PATH: - discovered = cmd.getIncludes(); - break; - case QUOTE_INCLUDE_PATH: - discovered = cmd.getQuoteIncludes(); - break; - case INCLUDE_FILE: - discovered = cmd.getIncludeFile(); - break; - case MACROS_FILE: - discovered = cmd.getImacrosFile(); - break; - default: - discovered = new ArrayList(0); - } - for (String include : discovered) { - // the following line degrades perfomance - // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=189127 - // it is not necessary for renaming projects anyway - // include = CCommandDSC.makeRelative(project, new Path(include)).toPortableString(); - if (!allIncludes.contains(include)) { - allIncludes.add(include); - } - } - } - } - return stringListToPathArray(allIncludes); - } + Map map = new HashMap(sid.fileToCommandIdMap.size() + 1); + Set> entrySet = sid.fileToCommandIdMap.entrySet(); + for (Entry entry : entrySet) { + IFile file = entry.getKey(); + if (file != null) { + CCommandDSC cmd = sid.commandIdCommandMap.get(entry.getValue()); + if (cmd != null) { + PathInfo fpi = createFilePathInfo(cmd); + map.put(file, fpi); + } + } + } + + if (project != null) { + if (psi == null) { + generateProjectScannerInfo(); + } + + PathInfo fpi = new PathInfo(psi.includePaths, psi.quoteIncludePaths, psi.definedSymbols, psi.includeFiles, + psi.macrosFiles); + map.put(project, fpi); + } + + return map; + } + + 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 definedSymbols = new HashMap(symbols.size()); + for (String symbol : symbols) { + String key = ScannerConfigUtil.getSymbolKey(symbol); + String value = ScannerConfigUtil.getSymbolValue(symbol); + definedSymbols.put(key, value); + } + + return new PathInfo(includes, quotedIncludes, definedSymbols, incFiles, macroFiles); + } + + protected CCommandDSC getCommand(IPath path) { + try { + IFile file = project.getWorkspace().getRoot().getFile(path); + return getCommand(file); + } catch (Exception e) { + return null; + } + } + + protected CCommandDSC getCommand(IFile file) { + CCommandDSC cmd = null; + if (file != null) { + Integer cmdId = sid.fileToCommandIdMap.get(file); + if (cmdId != null) { + // get the command + cmd = sid.commandIdCommandMap.get(cmdId); + } + } + return cmd; + } + + /** + * @param type can be one of the following: + *
  • INCLUDE_PATH + *
  • QUOTE_INCLUDE_PATH + *
  • INCLUDE_FILE + *
  • MACROS_FILE + * + * @return list of IPath(s). + */ + protected IPath[] getAllIncludePaths(int type) { + List allIncludes = new ArrayList(); + Set cmdIds = sid.commandIdCommandMap.keySet(); + for (Integer cmdId : cmdIds) { + CCommandDSC cmd = sid.commandIdCommandMap.get(cmdId); + if (cmd.isDiscovered()) { + List discovered = null; + switch (type) { + case INCLUDE_PATH: + discovered = cmd.getIncludes(); + break; + case QUOTE_INCLUDE_PATH: + discovered = cmd.getQuoteIncludes(); + break; + case INCLUDE_FILE: + discovered = cmd.getIncludeFile(); + break; + case MACROS_FILE: + discovered = cmd.getImacrosFile(); + break; + default: + discovered = new ArrayList(0); + } + for (String include : discovered) { + // the following line degrades perfomance + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=189127 + // it is not necessary for renaming projects anyway + // include = CCommandDSC.makeRelative(project, new Path(include)).toPortableString(); + if (!allIncludes.contains(include)) { + allIncludes.add(include); + } + } + } + } + return stringListToPathArray(allIncludes); + } protected static IPath[] stringListToPathArray(List discovered) { List allIncludes = new ArrayList(discovered.size()); for (String include : discovered) { - if (!allIncludes.contains(include)) { - allIncludes.add(new Path(include)); - } + if (!allIncludes.contains(include)) { + allIncludes.add(new Path(include)); + } } return allIncludes.toArray(new IPath[allIncludes.size()]); } - protected Map getAllSymbols() { + protected Map getAllSymbols() { assert Thread.holdsLock(fLock); - Map symbols = new HashMap(); - Set cmdIds = sid.commandIdCommandMap.keySet(); - for (Integer cmdId : cmdIds) { - CCommandDSC cmd = sid.commandIdCommandMap.get(cmdId); - if (cmd.isDiscovered()) { - List discovered = cmd.getSymbols(); - for (String symbol : discovered) { - String key = SafeStringInterner.safeIntern(ScannerConfigUtil.getSymbolKey(symbol)); - String value = SafeStringInterner.safeIntern(ScannerConfigUtil.getSymbolValue(symbol)); - symbols.put(key, value); - } - } - } - return symbols; - } + Map symbols = new HashMap(); + Set cmdIds = sid.commandIdCommandMap.keySet(); + for (Integer cmdId : cmdIds) { + CCommandDSC cmd = sid.commandIdCommandMap.get(cmdId); + if (cmd.isDiscovered()) { + List discovered = cmd.getSymbols(); + for (String symbol : discovered) { + String key = SafeStringInterner.safeIntern(ScannerConfigUtil.getSymbolKey(symbol)); + String value = SafeStringInterner.safeIntern(ScannerConfigUtil.getSymbolValue(symbol)); + symbols.put(key, value); + } + } + } + return symbols; + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java index 016ab7dea63..63acee31c14 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java @@ -73,23 +73,23 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn protected IProject project; protected InfoContext context; - private boolean isBuiltinConfig= false; + private boolean isBuiltinConfig = false; protected Map> discoveredSI; -// private List discoveredIncludes; -// private List discoveredSymbols; -// private List discoveredTSO; // target specific options + // private List discoveredIncludes; + // private List discoveredSymbols; + // private List discoveredTSO; // target specific options // cumulative values protected List sumDiscoveredIncludes; private Map sumDiscoveredSymbols; - protected boolean scPersisted = false; + protected boolean scPersisted = false; public PerProjectSICollector() { - discoveredSI = new HashMap>(); -// discoveredIncludes = new ArrayList(); -// discoveredSymbols = new ArrayList(); -// discoveredTSO = new ArrayList(); -// + discoveredSI = new HashMap>(); + // discoveredIncludes = new ArrayList(); + // discoveredSymbols = new ArrayList(); + // discoveredTSO = new ArrayList(); + // sumDiscoveredIncludes = new ArrayList(); sumDiscoveredSymbols = new LinkedHashMap(); } @@ -103,13 +103,13 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn this.context = new InfoContext(project); } - public synchronized void contributeToScannerConfig(Object resource, @SuppressWarnings("rawtypes") Map scannerInfo, boolean isBuiltinConfig) { - this.isBuiltinConfig= isBuiltinConfig; + public synchronized void contributeToScannerConfig(Object resource, @SuppressWarnings("rawtypes") Map scannerInfo, + boolean isBuiltinConfig) { + this.isBuiltinConfig = isBuiltinConfig; try { contributeToScannerConfig(resource, scannerInfo); - } - finally { - this.isBuiltinConfig= false; + } finally { + this.isBuiltinConfig = false; } } @@ -122,14 +122,11 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn String errorMessage = null; if (resource == null) { errorMessage = "resource is null";//$NON-NLS-1$ - } - else if (!(resource instanceof IResource)) { + } else if (!(resource instanceof IResource)) { errorMessage = "resource is not an IResource";//$NON-NLS-1$ - } - else if (((IResource) resource).getProject() == null) { + } else if (((IResource) resource).getProject() == null) { errorMessage = "project is null";//$NON-NLS-1$ - } - else if (!((IResource) resource).getProject().equals(project)) { + } else if (!((IResource) resource).getProject().equals(project)) { errorMessage = "wrong project";//$NON-NLS-1$ } if (errorMessage != null) { @@ -137,35 +134,32 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn return; } - if (scPersisted) { - // delete discovered scanner config - discoveredSI.clear(); - // new collection cycle - scPersisted = false; - } + if (scPersisted) { + // delete discovered scanner config + discoveredSI.clear(); + // new collection cycle + scPersisted = false; + } try { if (/*project.hasNature(MakeProjectNature.NATURE_ID) && */// limits to StandardMake projects - (project.hasNature(CProjectNature.C_NATURE_ID) || - project.hasNature(CCProjectNature.CC_NATURE_ID))) { - - for (Object name : scannerInfo.keySet()) { - ScannerInfoTypes siType = (ScannerInfoTypes) name; - @SuppressWarnings("unchecked") - List delta = (List) scannerInfo.get(siType); - - List discovered = discoveredSI.get(siType); - if (discovered == null) { - discovered = new ArrayList(delta); - discoveredSI.put(siType, discovered); - } - else { - final boolean addSorted= !isBuiltinConfig && siType.equals(ScannerInfoTypes.INCLUDE_PATHS); - contribute(discovered, delta, addSorted); - } - } + (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID))) { + + for (Object name : scannerInfo.keySet()) { + ScannerInfoTypes siType = (ScannerInfoTypes) name; + @SuppressWarnings("unchecked") + List delta = (List) scannerInfo.get(siType); + + List discovered = discoveredSI.get(siType); + if (discovered == null) { + discovered = new ArrayList(delta); + discoveredSI.put(siType, discovered); + } else { + final boolean addSorted = !isBuiltinConfig && siType.equals(ScannerInfoTypes.INCLUDE_PATHS); + contribute(discovered, delta, addSorted); + } + } } - } - catch (CoreException e) { + } catch (CoreException e) { MakeCorePlugin.log(e); } } @@ -185,7 +179,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn /** * Adds new items to the already accumulated ones preserving order * - * @param sumIncludes - previously accumulated items + * @param sumIncludes - previously accumulated items * @param includes - items to be added * @param ordered - to preserve order or append at the end * @return boolean - true if added @@ -195,12 +189,12 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn return false; boolean addedIncludes = false; - int insertionPoint= ordered ? 0 : sumIncludes.size(); + int insertionPoint = ordered ? 0 : sumIncludes.size(); for (String item : includes) { - int pos= sumIncludes.indexOf(item); + int pos = sumIncludes.indexOf(item); if (pos >= 0) { if (ordered) { - insertionPoint= pos+1; + insertionPoint = pos + 1; } } else { sumIncludes.add(insertionPoint++, item); @@ -218,28 +212,30 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn if (monitor == null) { monitor = new NullProgressMonitor(); } - IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context); - if (pathInfo instanceof IPerProjectDiscoveredPathInfo) { - IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) pathInfo; - - monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$ - monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$ - if (scannerConfigNeedsUpdate(projectPathInfo)) { - monitor.worked(50); - monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$ - try { - // update scanner configuration + IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, + context); + if (pathInfo instanceof IPerProjectDiscoveredPathInfo) { + IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) pathInfo; + + monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$ + monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$ + if (scannerConfigNeedsUpdate(projectPathInfo)) { + monitor.worked(50); + monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$ + try { + // update scanner configuration List resourceDelta = new ArrayList(1); resourceDelta.add(project); - MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(context, pathInfo, context.isDefaultContext(), resourceDelta); - monitor.worked(50); - } catch (CoreException e) { - MakeCorePlugin.log(e); - } - } - monitor.done(); - scPersisted = true; - } + MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(context, pathInfo, + context.isDefaultContext(), resourceDelta); + monitor.worked(50); + } catch (CoreException e) { + MakeCorePlugin.log(e); + } + } + monitor.done(); + scPersisted = true; + } } /** @@ -257,21 +253,21 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn */ private boolean includePathsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) { boolean addedIncludes = false; - List discoveredIncludes = discoveredSI.get(ScannerInfoTypes.INCLUDE_PATHS); + List discoveredIncludes = discoveredSI.get(ScannerInfoTypes.INCLUDE_PATHS); if (discoveredIncludes != null) { // Step 1. Add discovered scanner config to the existing discovered scanner config // add the includes from the latest discovery -// if (sumDiscoveredIncludes == null) { -// sumDiscoveredIncludes = new ArrayList(discoveredIncludes); -// addedIncludes = true; -// } -// else { -// addedIncludes = addItemsWithOrder(sumDiscoveredIncludes, discoveredIncludes, true); -// } -// instead - addedIncludes = addItemsWithOrder(sumDiscoveredIncludes, discoveredIncludes, true); - - // try to translate cygpaths to absolute paths + // if (sumDiscoveredIncludes == null) { + // sumDiscoveredIncludes = new ArrayList(discoveredIncludes); + // addedIncludes = true; + // } + // else { + // addedIncludes = addItemsWithOrder(sumDiscoveredIncludes, discoveredIncludes, true); + // } + // instead + addedIncludes = addItemsWithOrder(sumDiscoveredIncludes, discoveredIncludes, true); + + // try to translate cygpaths to absolute paths List finalSumIncludes = CygpathTranslator.translateIncludePaths(project, sumDiscoveredIncludes); // Step 2. Get project's scanner config @@ -288,20 +284,20 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn for (String include : persistedKeyList) { if (persistedIncludes.containsKey(include)) { newPersistedIncludes.put(include, persistedIncludes.get(include)); - } - else { + } else { // the paths may be on EFS resources, not local Boolean includePathExists = true; URI projectLocationURI = discPathInfo.getProject().getLocationURI(); // use the project's location... create a URI that uses the same provider but that points to the include path - URI includeURI = EFSExtensionManager.getDefault().createNewURIFromPath(projectLocationURI, include); + URI includeURI = EFSExtensionManager.getDefault().createNewURIFromPath(projectLocationURI, + include); // ask EFS if the path exists try { IFileStore fileStore = EFS.getStore(includeURI); IFileInfo info = fileStore.fetchInfo(); - if(!info.exists()) { + if (!info.exists()) { includePathExists = false; } } catch (CoreException e) { @@ -313,8 +309,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn newPersistedIncludes.put(include, !includePathExists); } } - } - else { + } else { newPersistedIncludes = persistedIncludes; } @@ -329,21 +324,24 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn */ protected boolean definedSymbolsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) { boolean addedSymbols = false; - List discoveredSymbols = discoveredSI.get(ScannerInfoTypes.SYMBOL_DEFINITIONS); + List discoveredSymbols = discoveredSI.get(ScannerInfoTypes.SYMBOL_DEFINITIONS); if (discoveredSymbols != null) { // Step 1. Add discovered scanner config to the existing discovered scanner config // add the symbols from the latest discovery -// if (sumDiscoveredSymbols == null) { -// sumDiscoveredSymbols = new LinkedHashMap(); -// } - addedSymbols = ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(sumDiscoveredSymbols, discoveredSymbols, true); + // if (sumDiscoveredSymbols == null) { + // sumDiscoveredSymbols = new LinkedHashMap(); + // } + addedSymbols = ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(sumDiscoveredSymbols, discoveredSymbols, + true); // Step 2. Get project's scanner config LinkedHashMap persistedSymbols = discPathInfo.getSymbolMap(); // Step 3. Merge scanner config from steps 1 and 2 - LinkedHashMap candidateSymbols = new LinkedHashMap(persistedSymbols); - addedSymbols |= ScannerConfigUtil.scAddSymbolEntryMap2SymbolEntryMap(candidateSymbols, sumDiscoveredSymbols); + LinkedHashMap candidateSymbols = new LinkedHashMap( + persistedSymbols); + addedSymbols |= ScannerConfigUtil.scAddSymbolEntryMap2SymbolEntryMap(candidateSymbols, + sumDiscoveredSymbols); // Step 4. Set resulting scanner config discPathInfo.setSymbolMap(candidateSymbols); @@ -351,133 +349,128 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn return addedSymbols; } - /* (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 getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { - List rv = null; - // 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$ - } - else if (resource!=null && project.equals(((IResource)resource).getProject())) { - rv = discoveredSI.get(type); - } - return rv; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#getDefinedSymbols() - */ - public Map getDefinedSymbols() { - Map definedSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(sumDiscoveredSymbols); - return definedSymbols; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#getIncludePaths() - */ - public List getIncludePaths() { - return sumDiscoveredIncludes; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#serialize(org.w3c.dom.Element) - */ - public void serialize(Element root) { - // not supported in PerProject collector - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deserialize(org.w3c.dom.Element) - */ - public void deserialize(Element root) { - // not supported in PerProject collector - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllPaths(org.eclipse.core.resources.IResource) - */ - @Override + List rv = null; + // 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$ + } else if (resource != null && project.equals(((IResource) resource).getProject())) { + rv = discoveredSI.get(type); + } + return rv; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#getDefinedSymbols() + */ + public Map getDefinedSymbols() { + Map definedSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(sumDiscoveredSymbols); + return definedSymbols; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#getIncludePaths() + */ + public List getIncludePaths() { + return sumDiscoveredIncludes; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#serialize(org.w3c.dom.Element) + */ + public void serialize(Element root) { + // not supported in PerProject collector + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deserialize(org.w3c.dom.Element) + */ + public void deserialize(Element root) { + // not supported in PerProject collector + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllPaths(org.eclipse.core.resources.IResource) + */ + @Override public void deleteAllPaths(IResource resource) { - IProject project = resource.getProject(); - if (project != null && project.equals(this.project)) { - sumDiscoveredIncludes.clear(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllSymbols(org.eclipse.core.resources.IResource) - */ - @Override + IProject project = resource.getProject(); + if (project != null && project.equals(this.project)) { + sumDiscoveredIncludes.clear(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllSymbols(org.eclipse.core.resources.IResource) + */ + @Override public void deleteAllSymbols(IResource resource) { - IProject project = resource.getProject(); - if (project != null && project.equals(this.project)) { - sumDiscoveredSymbols.clear(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deletePath(org.eclipse.core.resources.IResource, java.lang.String) - */ - @Override + IProject project = resource.getProject(); + if (project != null && project.equals(this.project)) { + sumDiscoveredSymbols.clear(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deletePath(org.eclipse.core.resources.IResource, java.lang.String) + */ + @Override public void deletePath(IResource resource, String path) { - IProject project = resource.getProject(); - if (project != null && project.equals(this.project)) { - sumDiscoveredIncludes.remove(path); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteSymbol(org.eclipse.core.resources.IResource, java.lang.String) - */ - @Override + IProject project = resource.getProject(); + if (project != null && project.equals(this.project)) { + sumDiscoveredIncludes.remove(path); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteSymbol(org.eclipse.core.resources.IResource, java.lang.String) + */ + @Override public void deleteSymbol(IResource resource, String symbol) { - IProject project = resource.getProject(); - if (project != null && project.equals(this.project)) { - // remove it from the Map of SymbolEntries - ScannerConfigUtil.removeSymbolEntryValue(symbol, sumDiscoveredSymbols); - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource) - */ - @Override + IProject project = resource.getProject(); + if (project != null && project.equals(this.project)) { + // remove it from the Map of SymbolEntries + ScannerConfigUtil.removeSymbolEntryValue(symbol, sumDiscoveredSymbols); + } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource) + */ + @Override public void deleteAll(IResource resource) { - deleteAllPaths(resource); - deleteAllSymbols(resource); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject() - */ - @Override + deleteAllPaths(resource); + deleteAllSymbols(resource); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject() + */ + @Override public IDiscoveredPathInfo createPathInfoObject() { - DiscoveredPathInfo pathInfo = new DiscoveredPathInfo(project); - try { - DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, pathInfo); - } - catch (CoreException e) { - MakeCorePlugin.log(e); - } - return pathInfo; - } + DiscoveredPathInfo pathInfo = new DiscoveredPathInfo(project); + try { + DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, pathInfo); + } catch (CoreException e) { + MakeCorePlugin.log(e); + } + return pathInfo; + } /** * Static method to return compiler built-in scanner info. @@ -487,11 +480,10 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn public static void calculateCompilerBuiltins(final IProject project) throws CModelException { createDiscoveredPathContainer(project, new NullProgressMonitor()); String scdProfileId = ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID; - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(project, scdProfileId); - final IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager. - createScannerConfigBuildInfo2(MakeCorePlugin.getDefault().getPluginPreferences(), - scdProfileId, true); + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().getSCProfileInstance(project, + scdProfileId); + final IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager + .createScannerConfigBuildInfo2(MakeCorePlugin.getDefault().getPluginPreferences(), scdProfileId, true); final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector(); if (collector instanceof IScannerInfoCollectorCleaner) { ((IScannerInfoCollectorCleaner) collector).deleteAll(project); @@ -521,20 +513,21 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn SafeRunner.run(runnable); } - private static void createDiscoveredPathContainer(IProject project, IProgressMonitor monitor) throws CModelException { - IPathEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID); - ICProject cProject = CoreModel.getDefault().create(project); - if (cProject != null) { - IPathEntry[] entries = cProject.getRawPathEntries(); - List newEntries = new ArrayList(Arrays.asList(entries)); - if (!newEntries.contains(container)) { - newEntries.add(container); - cProject.setRawPathEntries(newEntries.toArray(new IPathEntry[newEntries.size()]), monitor); - } - } - // create a new discovered scanner config store - MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project); - } + private static void createDiscoveredPathContainer(IProject project, IProgressMonitor monitor) + throws CModelException { + IPathEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID); + ICProject cProject = CoreModel.getDefault().create(project); + if (cProject != null) { + IPathEntry[] entries = cProject.getRawPathEntries(); + List newEntries = new ArrayList(Arrays.asList(entries)); + if (!newEntries.contains(container)) { + newEntries.add(container); + cProject.setRawPathEntries(newEntries.toArray(new IPathEntry[newEntries.size()]), monitor); + } + } + // create a new discovered scanner config store + MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project); + } @Override public void setInfoContext(InfoContext context) { @@ -542,7 +535,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn this.project = context.getProject(); } - public InfoContext getContext(){ + public InfoContext getContext() { return this.context; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java index b5ac55cbd33..642108dc019 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM - Initial API and implementation * Markus Schorn (Wind River Systems) @@ -29,134 +29,131 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; - /** * A 'provider' that will generate a special makefile to generate scanner config - * + * * @author vhirsl */ public class SCDMakefileGenerator extends DefaultRunSIProvider { - private static final String ENDL = System.getProperty("line.separator"); //$NON-NLS-1$ - private static final String DENDL = ENDL+ENDL; - private String fMakeCommand = "-f ${project_name}_scd.mk "; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#initialize() - */ - @Override + private static final String ENDL = System.getProperty("line.separator"); //$NON-NLS-1$ + private static final String DENDL = ENDL + ENDL; + private String fMakeCommand = "-f ${project_name}_scd.mk "; //$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#initialize() + */ + @Override protected boolean initialize() { - String args = buildInfo.getProviderRunArguments(providerId); - if (null == args) - args = " -E -P -v -dD "; //$NON-NLS-1$ - else { - int nPos = args.indexOf('|'); - if(nPos > 0) { - fMakeCommand = args.substring(0, nPos); - args = args.substring(nPos + 1); - } - } - fCompileCommand = new Path(buildInfo.getProviderRunCommand(providerId)); - args = substituteDynamicVariables(args); - fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(args, "\"");//$NON-NLS-1$ - fWorkingDirectory = MakeCorePlugin.getWorkingDirectory(); - fMakeCommand = substituteDynamicVariables(fMakeCommand); - - return generateMakefile(resource.getProject().getName()); - } + String args = buildInfo.getProviderRunArguments(providerId); + if (null == args) + args = " -E -P -v -dD "; //$NON-NLS-1$ + else { + int nPos = args.indexOf('|'); + if (nPos > 0) { + fMakeCommand = args.substring(0, nPos); + args = args.substring(nPos + 1); + } + } + fCompileCommand = new Path(buildInfo.getProviderRunCommand(providerId)); + args = substituteDynamicVariables(args); + fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(args, "\"");//$NON-NLS-1$ + fWorkingDirectory = MakeCorePlugin.getWorkingDirectory(); + fMakeCommand = substituteDynamicVariables(fMakeCommand); + + return generateMakefile(resource.getProject().getName()); + } private boolean generateMakefile(String projectName) { - boolean rc = false; - if (collector instanceof IScannerInfoCollector2) { - IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; - @SuppressWarnings("unchecked") - List commands = collector2.getCollectedScannerInfo( - resource.getProject(), ScannerInfoTypes.UNDISCOVERED_COMPILER_COMMAND); - if (commands != null && commands.size() > 0) { - - StringBuilder buffer = new StringBuilder(); - buffer.append("# This is a generated file. Please do not edit."); //$NON-NLS-1$ - buffer.append(DENDL); - buffer.append(".PHONY: all"); //$NON-NLS-1$ - buffer.append(DENDL); - buffer.append("COMMANDS := "); //$NON-NLS-1$ - for (CCommandDSC cmd : commands) { - buffer.append("\t\\"); //$NON-NLS-1$ - buffer.append(ENDL); - buffer.append("\t scd_cmd_"); //$NON-NLS-1$ - buffer.append(cmd.getCommandId()); - } - buffer.append(DENDL); - buffer.append("all: $(COMMANDS)"); //$NON-NLS-1$ - buffer.append(DENDL); - for (CCommandDSC cmd : commands) { - buffer.append("scd_cmd_"); //$NON-NLS-1$ - buffer.append(cmd.getCommandId()); - buffer.append(':'); - buffer.append(ENDL); - buffer.append("\t@echo begin generating scanner info for $@"); //$NON-NLS-1$ - buffer.append(ENDL); - buffer.append('\t'); - buffer.append(cmd.getSCDRunnableCommand(true, true)); // quote includes and defines - for (String arg : prepareArguments(buildInfo.isUseDefaultProviderCommand(providerId))) { - buffer.append(' '); - buffer.append(arg); - } - buffer.append(' '); - buffer.append(cmd.appliesToCPPFileType() ? "specs.cpp" : "specs.c"); //$NON-NLS-1$ //$NON-NLS-2$ - buffer.append(ENDL); - buffer.append("\t@echo end generating scanner info for $@"); //$NON-NLS-1$ - buffer.append(DENDL); - } - - File makefile = new File(fWorkingDirectory.toFile(), getMakeFileName(projectName)); - try { - PrintStream ps = new PrintStream(new FileOutputStream(makefile)); - ps.println(buffer.toString()); - ps.close(); - rc = true; - } - catch (FileNotFoundException e) { - MakeCorePlugin.log(e); - } - } - } - - return rc; - } - - private String getMakeFileName(String projectName) { - String[] makeArgs = ScannerConfigUtil.tokenizeStringWithQuotes(fMakeCommand, "\"");//$NON-NLS-1$ - boolean found = false; - for(String arg : makeArgs) { - if(found) - return arg; - if(arg.equals("-f")) //$NON-NLS-1$ - found = true; - } - return projectName+"_scd.mk"; //$NON-NLS-1$ - } - + boolean rc = false; + if (collector instanceof IScannerInfoCollector2) { + IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; + @SuppressWarnings("unchecked") + List commands = collector2.getCollectedScannerInfo(resource.getProject(), + ScannerInfoTypes.UNDISCOVERED_COMPILER_COMMAND); + if (commands != null && commands.size() > 0) { - protected String substituteDynamicVariables(String in) { - String string = in; -// TODO: replace it with Eclipse Dynamic Variable Resolver -// string = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(string, false); - string = string.replaceAll("\\$\\{project_name\\}", //$NON-NLS-1$ - resource.getProject().getName()); - string = string.replaceAll("\\$\\{plugin_state_location\\}", //$NON-NLS-1$ - MakeCorePlugin.getWorkingDirectory().toString()); - string = string.replaceAll("\\$\\{specs_file\\}", //$NON-NLS-1$ - GCCScannerConfigUtil.C_SPECS_FILE ); - return string; - } + StringBuilder buffer = new StringBuilder(); + buffer.append("# This is a generated file. Please do not edit."); //$NON-NLS-1$ + buffer.append(DENDL); + buffer.append(".PHONY: all"); //$NON-NLS-1$ + buffer.append(DENDL); + buffer.append("COMMANDS := "); //$NON-NLS-1$ + for (CCommandDSC cmd : commands) { + buffer.append("\t\\"); //$NON-NLS-1$ + buffer.append(ENDL); + buffer.append("\t scd_cmd_"); //$NON-NLS-1$ + buffer.append(cmd.getCommandId()); + } + buffer.append(DENDL); + buffer.append("all: $(COMMANDS)"); //$NON-NLS-1$ + buffer.append(DENDL); + for (CCommandDSC cmd : commands) { + buffer.append("scd_cmd_"); //$NON-NLS-1$ + buffer.append(cmd.getCommandId()); + buffer.append(':'); + buffer.append(ENDL); + buffer.append("\t@echo begin generating scanner info for $@"); //$NON-NLS-1$ + buffer.append(ENDL); + buffer.append('\t'); + buffer.append(cmd.getSCDRunnableCommand(true, true)); // quote includes and defines + for (String arg : prepareArguments(buildInfo.isUseDefaultProviderCommand(providerId))) { + buffer.append(' '); + buffer.append(arg); + } + buffer.append(' '); + buffer.append(cmd.appliesToCPPFileType() ? "specs.cpp" : "specs.c"); //$NON-NLS-1$ //$NON-NLS-2$ + buffer.append(ENDL); + buffer.append("\t@echo end generating scanner info for $@"); //$NON-NLS-1$ + buffer.append(DENDL); + } + + File makefile = new File(fWorkingDirectory.toFile(), getMakeFileName(projectName)); + try { + PrintStream ps = new PrintStream(new FileOutputStream(makefile)); + ps.println(buffer.toString()); + ps.close(); + rc = true; + } catch (FileNotFoundException e) { + MakeCorePlugin.log(e); + } + } + } + + return rc; + } + + private String getMakeFileName(String projectName) { + String[] makeArgs = ScannerConfigUtil.tokenizeStringWithQuotes(fMakeCommand, "\"");//$NON-NLS-1$ + boolean found = false; + for (String arg : makeArgs) { + if (found) + return arg; + if (arg.equals("-f")) //$NON-NLS-1$ + found = true; + } + return projectName + "_scd.mk"; //$NON-NLS-1$ + } + + protected String substituteDynamicVariables(String in) { + String string = in; + // TODO: replace it with Eclipse Dynamic Variable Resolver + // string = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(string, false); + string = string.replaceAll("\\$\\{project_name\\}", //$NON-NLS-1$ + resource.getProject().getName()); + string = string.replaceAll("\\$\\{plugin_state_location\\}", //$NON-NLS-1$ + MakeCorePlugin.getWorkingDirectory().toString()); + string = string.replaceAll("\\$\\{specs_file\\}", //$NON-NLS-1$ + GCCScannerConfigUtil.C_SPECS_FILE); + return string; + } @Override protected String[] getCommandLineOptions() { - return ScannerConfigUtil.tokenizeStringWithQuotes(fMakeCommand, "\""); //$NON-NLS-1$ + return ScannerConfigUtil.tokenizeStringWithQuotes(fMakeCommand, "\""); //$NON-NLS-1$ } @Override protected IPath getCommandToLaunch() { - return new Path("make"); //$NON-NLS-1$ + return new Path("make"); //$NON-NLS-1$ } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java index 39403b4170f..a062dcd0cb7 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java @@ -68,7 +68,8 @@ public class SCMarkerGenerator implements IMarkerGenerator { protected IStatus run(IProgressMonitor monitor) { IMarker marker; try { - IMarker[] cur = problemMarkerInfo.file.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ONE); + IMarker[] cur = problemMarkerInfo.file.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, + IResource.DEPTH_ONE); /* * Try to find matching markers and don't put in duplicates */ @@ -77,13 +78,16 @@ public class SCMarkerGenerator implements IMarkerGenerator { int line = ((Integer) cur[i].getAttribute(IMarker.LINE_NUMBER)).intValue(); int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue(); String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE); - if (line == problemMarkerInfo.lineNumber && sev == mapMarkerSeverity(problemMarkerInfo.severity) && mesg.equals(problemMarkerInfo.description)) { + if (line == problemMarkerInfo.lineNumber + && sev == mapMarkerSeverity(problemMarkerInfo.severity) + && mesg.equals(problemMarkerInfo.description)) { return Status.OK_STATUS; } } } } catch (CoreException e) { - return new Status(Status.ERROR, MakeCorePlugin.getUniqueIdentifier(), Messages.SCMarkerGenerator_Error_Adding_Markers, e); + return new Status(Status.ERROR, MakeCorePlugin.getUniqueIdentifier(), + Messages.SCMarkerGenerator_Error_Adding_Markers, e); } try { @@ -99,7 +103,8 @@ public class SCMarkerGenerator implements IMarkerGenerator { } marker.setAttribute(IMarker.LOCATION, Messages.SCMarkerGenerator_Discovery_Options_Page); } catch (CoreException e) { - return new Status(Status.ERROR, MakeCorePlugin.getUniqueIdentifier(), Messages.SCMarkerGenerator_Error_Adding_Markers, e); + return new Status(Status.ERROR, MakeCorePlugin.getUniqueIdentifier(), + Messages.SCMarkerGenerator_Error_Adding_Markers, e); } return Status.OK_STATUS; @@ -123,9 +128,7 @@ public class SCMarkerGenerator implements IMarkerGenerator { int location = ((Integer) marker.getAttribute(IMarker.LINE_NUMBER)).intValue(); String error = (String) marker.getAttribute(IMarker.MESSAGE); int sev = ((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue(); - if (location == lineNumber && - errorDesc.equals(error) && - sev == severity) { + if (location == lineNumber && errorDesc.equals(error) && sev == severity) { exactMarkers.add(marker); } } @@ -134,21 +137,20 @@ public class SCMarkerGenerator implements IMarkerGenerator { FixitManager.getInstance().deleteMarkers(exactMarkers.toArray(new IMarker[0])); } } - } - catch (CoreException e) { + } catch (CoreException e) { MakeCorePlugin.log(e.getStatus()); } } int mapMarkerSeverity(int severity) { switch (severity) { - case SEVERITY_ERROR_BUILD : - case SEVERITY_ERROR_RESOURCE : - return IMarker.SEVERITY_ERROR; - case SEVERITY_INFO : - return IMarker.SEVERITY_INFO; - case SEVERITY_WARNING : - return IMarker.SEVERITY_WARNING; + case SEVERITY_ERROR_BUILD: + case SEVERITY_ERROR_RESOURCE: + return IMarker.SEVERITY_ERROR; + case SEVERITY_INFO: + return IMarker.SEVERITY_INFO; + case SEVERITY_WARNING: + return IMarker.SEVERITY_WARNING; } return IMarker.SEVERITY_ERROR; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java index 1613d43f030..841e623dab3 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java @@ -30,7 +30,7 @@ import org.eclipse.core.resources.IProject; /** * Instantiated scanner config profile - * + * * @author vhirsl */ public class SCProfileInstance { @@ -38,8 +38,9 @@ public class SCProfileInstance { private ScannerConfigProfile profile; private IScannerInfoCollector collector; private InfoContext context; + /** - * + * */ public SCProfileInstance(IProject project, ScannerConfigProfile profile) { this(project, new InfoContext(project), profile); @@ -52,46 +53,46 @@ public class SCProfileInstance { } /** - * + * */ private void instantiateCollector() { // create collector object collector = createScannerInfoCollector(); - if (collector != null) { - // call collector.setProject(project) if class supports it - Class clazz = collector.getClass(); - try { -// Method setProjectMethod = clazz.getMethod("setProject", new Class[] {IProject.class});//$NON-NLS-1$ -// setProjectMethod.invoke(collector, new Object[] {project}); - Object[] args = null; + if (collector != null) { + // call collector.setProject(project) if class supports it + Class clazz = collector.getClass(); + try { + // Method setProjectMethod = clazz.getMethod("setProject", new Class[] {IProject.class});//$NON-NLS-1$ + // setProjectMethod.invoke(collector, new Object[] {project}); + Object[] args = null; Method setMethod = null; - if(context != null){ + if (context != null) { try { - setMethod = clazz.getMethod("setInfoContext", new Class[] {InfoContext.class});//$NON-NLS-1$ - args = new Object[]{context}; - } catch(NoSuchMethodException e) { + setMethod = clazz.getMethod("setInfoContext", new Class[] { InfoContext.class });//$NON-NLS-1$ + args = new Object[] { context }; + } catch (NoSuchMethodException e) { } } - - if(setMethod == null){ + + if (setMethod == null) { try { - setMethod = clazz.getMethod("setProject", new Class[] {IProject.class});//$NON-NLS-1$ - args = new Object[]{project}; - } catch(NoSuchMethodException e) { + setMethod = clazz.getMethod("setProject", new Class[] { IProject.class });//$NON-NLS-1$ + args = new Object[] { project }; + } catch (NoSuchMethodException e) { } } - if(setMethod != null) + if (setMethod != null) setMethod.invoke(collector, args); } catch (SecurityException e) { MakeCorePlugin.log(e); -// } catch (NoSuchMethodException e) { + // } catch (NoSuchMethodException e) { } catch (IllegalArgumentException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { MakeCorePlugin.log(e.getCause()); } - } + } // all other objects are created on request } @@ -108,7 +109,7 @@ public class SCProfileInstance { } return collector; } - + public IScannerInfoCollector createScannerInfoCollector() { ScannerInfoCollector collector = profile.getScannerInfoCollectorElement(); if (collector != null) { @@ -116,33 +117,35 @@ public class SCProfileInstance { } return null; } - + /** * @return Creates new buildOutputProvider user object. */ public IExternalScannerInfoProvider createBuildOutputProvider() { - BuildOutputProvider bop = profile.getBuildOutputProviderElement(); - if (bop != null) { - Action action = bop.getAction(); - if (action != null) { - return (IExternalScannerInfoProvider) action.createExternalScannerInfoProvider(); - } - } - return null; + BuildOutputProvider bop = profile.getBuildOutputProviderElement(); + if (bop != null) { + Action action = bop.getAction(); + if (action != null) { + return (IExternalScannerInfoProvider) action.createExternalScannerInfoProvider(); + } + } + return null; } + /** * @return Creates new buildOutputParser user object. */ public IScannerInfoConsoleParser createBuildOutputParser() { - BuildOutputProvider bop = profile.getBuildOutputProviderElement(); - if (bop != null) { - ScannerInfoConsoleParser parserElement = bop.getScannerInfoConsoleParser(); - if (parserElement != null) { - return (IScannerInfoConsoleParser) parserElement.createScannerInfoConsoleParser(); - } - } + BuildOutputProvider bop = profile.getBuildOutputProviderElement(); + if (bop != null) { + ScannerInfoConsoleParser parserElement = bop.getScannerInfoConsoleParser(); + if (parserElement != null) { + return (IScannerInfoConsoleParser) parserElement.createScannerInfoConsoleParser(); + } + } return null; } + /** * @return Creates new externalSIProvider user object. */ @@ -153,6 +156,7 @@ public class SCProfileInstance { } return null; } + /** * @return Creates new esiProviderOutputParser user object. */ diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java index 5b848788dc5..dd5d36a1ab7 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java @@ -68,11 +68,11 @@ public class ScannerConfigInfoFactory2 { private static final String ARGUMENTS = "arguments"; //$NON-NLS-1$ // preferences private static final String DOT = ".";//$NON-NLS-1$ - private static final String SCD = "SCD.";//$NON-NLS-1$ + private static final String SCD = "SCD.";//$NON-NLS-1$ private static final String SCANNER_CONFIG_AUTODISCOVERY_ENABLED_SUFFIX = "enabled";//$NON-NLS-1$ private static final String SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX = "selectedProfileId";//$NON-NLS-1$ - private static final String SCANNER_CONFIG_PROBLEM_REPORTING_ENABLED_SUFFIX = "problemReportingEnabled"; //$NON-NLS-1$ -// following require prefix: profileId + private static final String SCANNER_CONFIG_PROBLEM_REPORTING_ENABLED_SUFFIX = "problemReportingEnabled"; //$NON-NLS-1$ + // following require prefix: profileId private static final String BUILD_OUTPUT_OPEN_ACTION_ENABLED = ".BOP.open.enabled";//$NON-NLS-1$ private static final String BUILD_OUTPUT_OPEN_ACTION_FILE_PATH = ".BOP.open.path";//$NON-NLS-1$ private static final String BUILD_OUTPUT_PARSER_ENABLED = ".BOP.parser.enabled";//$NON-NLS-1$ @@ -85,14 +85,13 @@ public class ScannerConfigInfoFactory2 { private static final String INFO_INSTANCE_IDS = SCD + "instanceIds";//$NON-NLS-1$ private static final String DELIMITER = ";";//$NON-NLS-1$ - private static final String ELEMENT_CS_INFO = "scannerConfigBuildInfo";//$NON-NLS-1$ private static final String ATTRIBUTE_CS_INFO_INSTANCE_ID = "instanceId";//$NON-NLS-1$ private static class ScannerConfigInfoSet extends StoreSet { private IProject fProject; - ScannerConfigInfoSet(IProject project, String profileId){ + ScannerConfigInfoSet(IProject project, String profileId) { this.fProject = project; load(profileId); } @@ -101,10 +100,13 @@ public class ScannerConfigInfoFactory2 { ICDescriptor descriptor; try { descriptor = CCorePlugin.getDefault().getCProjectDescription(fProject, false); - ICStorageElement rootEl = descriptor != null ? descriptor.getProjectStorageElement(SCANNER_CONFIG) : null; + ICStorageElement rootEl = descriptor != null ? descriptor.getProjectStorageElement(SCANNER_CONFIG) + : null; InfoContext defaultContext = new InfoContext(fProject); - if(rootEl == null || !rootEl.hasChildren()){ - BuildProperty prop = new BuildProperty(this, fProject, defaultContext, (Store)create(MakeCorePlugin.getDefault().getPluginPreferences(), profileId, false), profileId); + if (rootEl == null || !rootEl.hasChildren()) { + BuildProperty prop = new BuildProperty(this, fProject, defaultContext, + (Store) create(MakeCorePlugin.getDefault().getPluginPreferences(), profileId, false), + profileId); fMap.put(defaultContext, prop); prop.isDirty = true; } else { @@ -114,7 +116,7 @@ public class ScannerConfigInfoFactory2 { for (ICStorageElement sc : rootEl.getChildren()) { if (sc.getName().equals(ELEMENT_CS_INFO)) { String instanceId = sc.getAttribute(ATTRIBUTE_CS_INFO_INSTANCE_ID); - if(instanceId != null && instanceId.length() > 0){ + if (instanceId != null && instanceId.length() > 0) { InfoContext c = new InfoContext(fProject, instanceId); BuildProperty p = new BuildProperty(this, fProject, c, profileId, sc); fMap.put(c, p); @@ -140,21 +142,21 @@ public class ScannerConfigInfoFactory2 { // Clear all child settings sc.clear(); - BuildProperty prop = (BuildProperty)fMap.get(new InfoContext(fProject)); + BuildProperty prop = (BuildProperty) fMap.get(new InfoContext(fProject)); prop.store(sc); for (Entry entry : fMap.entrySet()) { InfoContext context = entry.getKey(); - if(context.isDefaultContext()) + if (context.isDefaultContext()) continue; String instanceId = context.getInstanceId(); - if(instanceId.length() == 0) + if (instanceId.length() == 0) continue; - BuildProperty p = (BuildProperty)entry.getValue(); - if(p == prop) + BuildProperty p = (BuildProperty) entry.getValue(); + if (p == prop) continue; ICStorageElement el = sc.createChild(ELEMENT_CS_INFO); @@ -162,7 +164,7 @@ public class ScannerConfigInfoFactory2 { p.store(el); } - if(serializeDescriptor) + if (serializeDescriptor) descriptor.saveProjectData(); fIsDirty = false; @@ -183,23 +185,24 @@ public class ScannerConfigInfoFactory2 { private static class PreferenceSet extends StoreSet { private Preferences prefs; private boolean useDefaults; - PreferenceSet(Preferences prefs, String profileId, boolean loadDefaults){ + + PreferenceSet(Preferences prefs, String profileId, boolean loadDefaults) { this.prefs = prefs; this.useDefaults = loadDefaults; load(profileId); } - private void load(String profileId) { + private void load(String profileId) { InfoContext defaultContext = new InfoContext(null); String instancesStr = getString(INFO_INSTANCE_IDS); String[] instanceIds = CDataUtil.stringToArray(instancesStr, DELIMITER); Preference pref = new Preference(this, prefs, defaultContext, profileId, useDefaults); fMap.put(defaultContext, pref); - if(instanceIds != null && instanceIds.length != 0){ - for(int i = 0; i < instanceIds.length; i++) { + if (instanceIds != null && instanceIds.length != 0) { + for (int i = 0; i < instanceIds.length; i++) { String id = instanceIds[i]; - if(id.length() == 0) + if (id.length() == 0) continue; InfoContext c = new InfoContext(null, id); @@ -217,20 +220,20 @@ public class ScannerConfigInfoFactory2 { Set idSet = new HashSet(fMap.size() - 1); - Preference pref = (Preference)fMap.get(new InfoContext(null)); + Preference pref = (Preference) fMap.get(new InfoContext(null)); pref.store(); for (Entry entry : fMap.entrySet()) { InfoContext context = entry.getKey(); - if(context.isDefaultContext()) + if (context.isDefaultContext()) continue; String instanceId = context.getInstanceId(); - if(instanceId.length() == 0) + if (instanceId.length() == 0) continue; - Preference p = (Preference)entry.getValue(); - if(p == pref) + Preference p = (Preference) entry.getValue(); + if (p == pref) continue; p.store(); @@ -238,7 +241,7 @@ public class ScannerConfigInfoFactory2 { idSet.add(instanceId); } - if(idSet.size() != 0){ + if (idSet.size() != 0) { String[] ids = idSet.toArray(new String[idSet.size()]); String idsString = CDataUtil.arrayToString(ids, DELIMITER); set(INFO_INSTANCE_IDS, idsString); @@ -268,26 +271,24 @@ public class ScannerConfigInfoFactory2 { private void set(String name, String value) { if (useDefaults) { prefs.setDefault(name, value); - } - else { + } else { prefs.setValue(name, value); } } } - private static abstract class StoreSet implements IScannerConfigBuilderInfo2Set { protected HashMap fMap = new HashMap(); protected boolean fIsDirty; - StoreSet(){ + StoreSet() { } @Override - public IScannerConfigBuilderInfo2 createInfo(InfoContext context, - IScannerConfigBuilderInfo2 base, String profileId){ + public IScannerConfigBuilderInfo2 createInfo(InfoContext context, IScannerConfigBuilderInfo2 base, + String profileId) { fIsDirty = true; - Store store = doCreateStore(context, (Store)base, profileId); + Store store = doCreateStore(context, (Store) base, profileId); fMap.put(context, store); return store; } @@ -295,8 +296,7 @@ public class ScannerConfigInfoFactory2 { protected abstract Store doCreateStore(InfoContext context, Store base, String profileId); @Override - public IScannerConfigBuilderInfo2 createInfo(InfoContext context, - IScannerConfigBuilderInfo2 base){ + public IScannerConfigBuilderInfo2 createInfo(InfoContext context, IScannerConfigBuilderInfo2 base) { fIsDirty = true; return createInfo(context, base, ScannerConfigProfileManager.NULL_PROFILE_ID); } @@ -323,16 +323,17 @@ public class ScannerConfigInfoFactory2 { return fMap.remove(context); } - private void checkRemoveInfo(InfoContext context) throws CoreException{ - if(context.isDefaultContext()) - throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, MakeConfigurationDataProviderMessages.getString("ScannerConfigInfoFactory2.0"))); //$NON-NLS-1$ + private void checkRemoveInfo(InfoContext context) throws CoreException { + if (context.isDefaultContext()) + throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, + MakeConfigurationDataProviderMessages.getString("ScannerConfigInfoFactory2.0"))); //$NON-NLS-1$ } - public boolean isDirty(){ - if(fIsDirty) + public boolean isDirty() { + if (fIsDirty) return true; for (IScannerConfigBuilderInfo2 prop : fMap.values()) { - if(((Store)prop).isDirty) + if (((Store) prop).isDirty) return true; } @@ -346,8 +347,7 @@ public class ScannerConfigInfoFactory2 { } @Override - public IScannerConfigBuilderInfo2 createInfo(InfoContext context, - String profileId) { + public IScannerConfigBuilderInfo2 createInfo(InfoContext context, String profileId) { fIsDirty = true; IScannerConfigBuilderInfo2 base = getInfo(new InfoContext(getProject())); return createInfo(context, base, profileId); @@ -356,54 +356,53 @@ public class ScannerConfigInfoFactory2 { private static abstract class Store implements IScannerConfigBuilderInfo2 { protected static final String EMPTY_STRING = ""; //$NON-NLS-1$ - protected boolean isDirty; // derived + protected boolean isDirty; // derived protected boolean autoDiscoveryEnabled; protected boolean problemReportingEnabled; protected String selectedProfile = EMPTY_STRING; /** Map from profile ID -> default ProfileOptions * allows us to avoid storing options to .cproject when they are default .*/ - protected static Map defaultProfiles = new ConcurrentHashMap(); + protected static Map defaultProfiles = new ConcurrentHashMap(); /** Map from profile ID -> ProfileOptions */ - protected Map profileOptionsMap = new LinkedHashMap(); - static class ProfileOptions implements Cloneable { - protected boolean buildOutputFileActionEnabled; - protected String buildOutputFilePath = EMPTY_STRING; - protected boolean buildOutputParserEnabled; - /** Map from provider ID -> providerOptions */ - protected Map providerOptionsMap; - static class ProviderOptions implements Cloneable { - protected String providerKind; // derived - protected boolean providerOutputParserEnabled; - protected boolean providerRunUseDefault; - protected String providerRunCommand = EMPTY_STRING; - protected String providerRunArguments = EMPTY_STRING; - protected String providerOpenFilePath = EMPTY_STRING; - - ProviderOptions(){ - } - - ProviderOptions(ProviderOptions base){ - this.providerKind = base.providerKind; - this.providerOutputParserEnabled = base.providerOutputParserEnabled; - this.providerRunUseDefault = base.providerRunUseDefault; - this.providerRunCommand = base.providerRunCommand; - this.providerRunArguments = base.providerRunArguments; - this.providerOpenFilePath = base.providerOpenFilePath; - } + protected Map profileOptionsMap = new LinkedHashMap(); + + static class ProfileOptions implements Cloneable { + protected boolean buildOutputFileActionEnabled; + protected String buildOutputFilePath = EMPTY_STRING; + protected boolean buildOutputParserEnabled; + /** Map from provider ID -> providerOptions */ + protected Map providerOptionsMap; + + static class ProviderOptions implements Cloneable { + protected String providerKind; // derived + protected boolean providerOutputParserEnabled; + protected boolean providerRunUseDefault; + protected String providerRunCommand = EMPTY_STRING; + protected String providerRunArguments = EMPTY_STRING; + protected String providerOpenFilePath = EMPTY_STRING; + + ProviderOptions() { + } + + ProviderOptions(ProviderOptions base) { + this.providerKind = base.providerKind; + this.providerOutputParserEnabled = base.providerOutputParserEnabled; + this.providerRunUseDefault = base.providerRunUseDefault; + this.providerRunCommand = base.providerRunCommand; + this.providerRunArguments = base.providerRunArguments; + this.providerOpenFilePath = base.providerOpenFilePath; + } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((providerKind == null) ? 0 : providerKind.hashCode()); - result = prime * result - + ((providerOpenFilePath == null) ? 0 : providerOpenFilePath.hashCode()); + result = prime * result + ((providerOpenFilePath == null) ? 0 : providerOpenFilePath.hashCode()); result = prime * result + (providerOutputParserEnabled ? 1231 : 1237); - result = prime * result - + ((providerRunArguments == null) ? 0 : providerRunArguments.hashCode()); - result = prime * result - + ((providerRunCommand == null) ? 0 : providerRunCommand.hashCode()); + result = prime * result + ((providerRunArguments == null) ? 0 : providerRunArguments.hashCode()); + result = prime * result + ((providerRunCommand == null) ? 0 : providerRunCommand.hashCode()); result = prime * result + (providerRunUseDefault ? 1231 : 1237); return result; } @@ -446,32 +445,31 @@ public class ScannerConfigInfoFactory2 { @Override protected ProviderOptions clone() throws CloneNotSupportedException { - return (ProviderOptions)super.clone(); + return (ProviderOptions) super.clone(); } - } + } - ProfileOptions(){ - } + ProfileOptions() { + } - ProfileOptions(ProfileOptions base){ - this.buildOutputFileActionEnabled = base.buildOutputFileActionEnabled; - this.buildOutputFilePath = base.buildOutputFilePath; - this.buildOutputParserEnabled = base.buildOutputParserEnabled; - this.providerOptionsMap = new LinkedHashMap(base.providerOptionsMap); - for (Map.Entry entry : providerOptionsMap.entrySet()) { - ProviderOptions basePo = entry.getValue(); - entry.setValue(new ProviderOptions(basePo)); - } - } + ProfileOptions(ProfileOptions base) { + this.buildOutputFileActionEnabled = base.buildOutputFileActionEnabled; + this.buildOutputFilePath = base.buildOutputFilePath; + this.buildOutputParserEnabled = base.buildOutputParserEnabled; + this.providerOptionsMap = new LinkedHashMap(base.providerOptionsMap); + for (Map.Entry entry : providerOptionsMap.entrySet()) { + ProviderOptions basePo = entry.getValue(); + entry.setValue(new ProviderOptions(basePo)); + } + } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (buildOutputFileActionEnabled ? 1231 : 1237); - result = prime * result - + ((buildOutputFilePath == null) ? 0 : buildOutputFilePath.hashCode()); + result = prime * result + ((buildOutputFilePath == null) ? 0 : buildOutputFilePath.hashCode()); result = prime * result + (buildOutputParserEnabled ? 1231 : 1237); result = prime * result + ((providerOptionsMap == null) ? 0 : providerOptionsMap.hashCode()); return result; @@ -506,7 +504,7 @@ public class ScannerConfigInfoFactory2 { @Override public ProfileOptions clone() { try { - ProfileOptions newProfOpts = (ProfileOptions)super.clone(); + ProfileOptions newProfOpts = (ProfileOptions) super.clone(); if (providerOptionsMap != null) { newProfOpts.providerOptionsMap = new LinkedHashMap(); for (Map.Entry e : providerOptionsMap.entrySet()) @@ -517,21 +515,22 @@ public class ScannerConfigInfoFactory2 { return null; } } - } + } protected Store() { } - protected Store(Store base, String profileId){ + protected Store(Store base, String profileId) { this.autoDiscoveryEnabled = base.autoDiscoveryEnabled; this.problemReportingEnabled = base.problemReportingEnabled; - this.selectedProfile = ScannerConfigProfileManager.NULL_PROFILE_ID.equals(profileId) ? base.selectedProfile : profileId; + this.selectedProfile = ScannerConfigProfileManager.NULL_PROFILE_ID.equals(profileId) ? base.selectedProfile + : profileId; this.selectedProfile = SafeStringInterner.safeIntern(this.selectedProfile); this.profileOptionsMap.putAll(base.profileOptionsMap); for (Map.Entry entry : profileOptionsMap.entrySet()) { - ProfileOptions basePo = entry.getValue(); - entry.setValue(new ProfileOptions(basePo)); - } + ProfileOptions basePo = entry.getValue(); + entry.setValue(new ProfileOptions(basePo)); + } isDirty = true; } @@ -549,7 +548,7 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setAutoDiscoveryEnabled(boolean enable) { - autoDiscoveryEnabled = setDirty(autoDiscoveryEnabled, enable); + autoDiscoveryEnabled = setDirty(autoDiscoveryEnabled, enable); } /* (non-Javadoc) @@ -559,13 +558,15 @@ public class ScannerConfigInfoFactory2 { public boolean isProblemReportingEnabled() { return problemReportingEnabled; } + /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setSIProblemGenerationEnabled(boolean) */ @Override public void setProblemReportingEnabled(boolean enable) { - problemReportingEnabled = setDirty(problemReportingEnabled, enable); + problemReportingEnabled = setDirty(problemReportingEnabled, enable); } + /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getSelectedProfileId() */ @@ -579,33 +580,33 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setSelectedProfileId(String profileId) { - selectedProfile = SafeStringInterner.safeIntern(setDirty(selectedProfile, profileId)); -// if (isDirty) { -// try { -// load(); -// isDirty = false; -// } catch (CoreException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getProfileIdList() - */ - @Override + selectedProfile = SafeStringInterner.safeIntern(setDirty(selectedProfile, profileId)); + // if (isDirty) { + // try { + // load(); + // isDirty = false; + // } catch (CoreException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // } + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getProfileIdList() + */ + @Override public List getProfileIdList() { - return new ArrayList(profileOptionsMap.keySet()); - } + return new ArrayList(profileOptionsMap.keySet()); + } - /* (non-Javadoc) + /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isBuildOutputFileActionEnabled() */ @Override public boolean isBuildOutputFileActionEnabled() { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - return (po != null) ? po.buildOutputFileActionEnabled : false; + ProfileOptions po = profileOptionsMap.get(selectedProfile); + return (po != null) ? po.buildOutputFileActionEnabled : false; } /* (non-Javadoc) @@ -613,10 +614,10 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setBuildOutputFileActionEnabled(boolean enable) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - po.buildOutputFileActionEnabled = setDirty(po.buildOutputFileActionEnabled, enable); - } + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + po.buildOutputFileActionEnabled = setDirty(po.buildOutputFileActionEnabled, enable); + } } /* (non-Javadoc) @@ -624,7 +625,7 @@ public class ScannerConfigInfoFactory2 { */ @Override public String getBuildOutputFilePath() { - ProfileOptions po = profileOptionsMap.get(selectedProfile); + ProfileOptions po = profileOptionsMap.get(selectedProfile); return (po != null) ? po.buildOutputFilePath : EMPTY_STRING; } @@ -633,10 +634,10 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setBuildOutputFilePath(String path) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - po.buildOutputFilePath = setDirty(po.buildOutputFilePath, path); - } + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + po.buildOutputFilePath = setDirty(po.buildOutputFilePath, path); + } } /* (non-Javadoc) @@ -644,7 +645,7 @@ public class ScannerConfigInfoFactory2 { */ @Override public boolean isBuildOutputParserEnabled() { - ProfileOptions po = profileOptionsMap.get(selectedProfile); + ProfileOptions po = profileOptionsMap.get(selectedProfile); return (po != null) ? po.buildOutputParserEnabled : true; } @@ -653,10 +654,10 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setBuildOutputParserEnabled(boolean enable) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - po.buildOutputParserEnabled = setDirty(po.buildOutputParserEnabled, enable); - } + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + po.buildOutputParserEnabled = setDirty(po.buildOutputParserEnabled, enable); + } } /* (non-Javadoc) @@ -664,35 +665,35 @@ public class ScannerConfigInfoFactory2 { */ @Override public List getProviderIdList() { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - return (po != null) ? new ArrayList(po.providerOptionsMap.keySet()) : new ArrayList(0); + ProfileOptions po = profileOptionsMap.get(selectedProfile); + return (po != null) ? new ArrayList(po.providerOptionsMap.keySet()) : new ArrayList(0); } /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#addSIProvider(java.lang.String) */ -// public void addSIProvider(String providerId) { -// providerOptionsMap.put(providerId, new ProviderOptions()); -// } + // public void addSIProvider(String providerId) { + // providerOptionsMap.put(providerId, new ProviderOptions()); + // } /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#removeSIProvider(java.lang.String) */ -// public void removeSIProvider(String providerId) { -// providerOptionsMap.put(providerId, null); -// } + // public void removeSIProvider(String providerId) { + // providerOptionsMap.put(providerId, null); + // } /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isSIProviderOutputParserEnabled(java.lang.String) */ @Override public boolean isProviderOutputParserEnabled(String providerId) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - return (ppo == null) ? false : ppo.providerOutputParserEnabled; - } - return false; + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + return (ppo == null) ? false : ppo.providerOutputParserEnabled; + } + return false; } /* (non-Javadoc) @@ -700,13 +701,13 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setProviderOutputParserEnabled(String providerId, boolean enable) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - if (ppo != null) { - ppo.providerOutputParserEnabled = setDirty(ppo.providerOutputParserEnabled, enable); - } - } + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + if (ppo != null) { + ppo.providerOutputParserEnabled = setDirty(ppo.providerOutputParserEnabled, enable); + } + } } /* (non-Javadoc) @@ -714,12 +715,12 @@ public class ScannerConfigInfoFactory2 { */ @Override public boolean isUseDefaultProviderCommand(String providerId) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - return (ppo == null) ? false : ppo.providerRunUseDefault; - } - return false; + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + return (ppo == null) ? false : ppo.providerRunUseDefault; + } + return false; } /* (non-Javadoc) @@ -727,13 +728,13 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setUseDefaultProviderCommand(String providerId, boolean enable) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - if (ppo != null) { - ppo.providerRunUseDefault = setDirty(ppo.providerRunUseDefault, enable); - } - } + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + if (ppo != null) { + ppo.providerRunUseDefault = setDirty(ppo.providerRunUseDefault, enable); + } + } } /* (non-Javadoc) @@ -741,12 +742,12 @@ public class ScannerConfigInfoFactory2 { */ @Override public String getProviderRunCommand(String providerId) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - return (ppo == null) ? null : ppo.providerRunCommand; - } - return null; + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + return (ppo == null) ? null : ppo.providerRunCommand; + } + return null; } /* (non-Javadoc) @@ -754,13 +755,13 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setProviderRunCommand(String providerId, String command) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - if (ppo != null) { - ppo.providerRunCommand = setDirty(ppo.providerRunCommand, command); - } - } + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + if (ppo != null) { + ppo.providerRunCommand = setDirty(ppo.providerRunCommand, command); + } + } } /* (non-Javadoc) @@ -768,12 +769,12 @@ public class ScannerConfigInfoFactory2 { */ @Override public String getProviderRunArguments(String providerId) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - return (ppo == null) ? null : ppo.providerRunArguments; - } - return null; + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + return (ppo == null) ? null : ppo.providerRunArguments; + } + return null; } /* (non-Javadoc) @@ -781,13 +782,13 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setProviderRunArguments(String providerId, String arguments) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - if (ppo != null) { - ppo.providerRunArguments = setDirty(ppo.providerRunArguments, arguments); - } - } + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + if (ppo != null) { + ppo.providerRunArguments = setDirty(ppo.providerRunArguments, arguments); + } + } } /* (non-Javadoc) @@ -795,12 +796,12 @@ public class ScannerConfigInfoFactory2 { */ @Override public String getProviderOpenFilePath(String providerId) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - return (ppo == null) ? null : ppo.providerOpenFilePath; - } - return null; + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + return (ppo == null) ? null : ppo.providerOpenFilePath; + } + return null; } /* (non-Javadoc) @@ -808,77 +809,78 @@ public class ScannerConfigInfoFactory2 { */ @Override public void setProviderOpenFilePath(String providerId, String filePath) { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - if (po != null) { - ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); - if (ppo != null) { - ppo.providerOpenFilePath = setDirty(ppo.providerOpenFilePath, filePath); - } - } + ProfileOptions po = profileOptionsMap.get(selectedProfile); + if (po != null) { + ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); + if (ppo != null) { + ppo.providerOpenFilePath = setDirty(ppo.providerOpenFilePath, filePath); + } + } } private boolean setDirty(boolean l, boolean r) { isDirty = isDirty || (l != r); return r; } + private String setDirty(String l, String r) { isDirty = isDirty || !l.equals(r); return r; } -// protected abstract void load(); -// public abstract void store(); - - /** - * Load defaults for the specified profileId. - * Returns a clone() of the default profile matching the passed in profileId - */ - protected static ProfileOptions getDefaultProfile(String profileId) { - if (defaultProfiles.containsKey(profileId)) - return defaultProfiles.get(profileId).clone(); - - ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). - getSCProfileConfiguration(profileId); - - ProfileOptions po = new ProfileOptions(); - po.buildOutputParserEnabled = false; - po.buildOutputFileActionEnabled = false; - po.buildOutputFilePath = EMPTY_STRING; - if (configuredProfile.getBuildOutputProviderElement() != null) { - po.buildOutputParserEnabled = true; - if (configuredProfile.getBuildOutputProviderElement().getAction() != null) { - po.buildOutputFileActionEnabled = true; - String buildOutputFilePath = configuredProfile.getBuildOutputProviderElement(). - getAction().getAttribute("file");//$NON-NLS-1$ - po.buildOutputFilePath = (buildOutputFilePath != null) ? buildOutputFilePath : EMPTY_STRING; - } - } - - po.providerOptionsMap = new LinkedHashMap(); - for (String providerId : configuredProfile.getSIProviderIds()) { - ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions(); - ScannerInfoProvider configuredProvider = configuredProfile.getScannerInfoProviderElement(providerId); - - ppo.providerOutputParserEnabled = true; - ppo.providerKind = configuredProvider.getProviderKind(); - String attrValue; - if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) { - ppo.providerRunUseDefault = true; - attrValue = configuredProvider.getAction().getAttribute(COMMAND); - ppo.providerRunCommand = (attrValue != null) ? attrValue : EMPTY_STRING; - attrValue = configuredProvider.getAction().getAttribute(ARGUMENTS); - ppo.providerRunArguments = (attrValue != null) ? attrValue : EMPTY_STRING; - } else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) { - attrValue = configuredProvider.getAction().getAttribute("file");//$NON-NLS-1$ - ppo.providerOpenFilePath = (attrValue != null) ? attrValue : EMPTY_STRING; - } - - po.providerOptionsMap.put(providerId, ppo); - } - - defaultProfiles.put(profileId, po); - return po.clone(); - } + // protected abstract void load(); + // public abstract void store(); + + /** + * Load defaults for the specified profileId. + * Returns a clone() of the default profile matching the passed in profileId + */ + protected static ProfileOptions getDefaultProfile(String profileId) { + if (defaultProfiles.containsKey(profileId)) + return defaultProfiles.get(profileId).clone(); + + ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance() + .getSCProfileConfiguration(profileId); + + ProfileOptions po = new ProfileOptions(); + po.buildOutputParserEnabled = false; + po.buildOutputFileActionEnabled = false; + po.buildOutputFilePath = EMPTY_STRING; + if (configuredProfile.getBuildOutputProviderElement() != null) { + po.buildOutputParserEnabled = true; + if (configuredProfile.getBuildOutputProviderElement().getAction() != null) { + po.buildOutputFileActionEnabled = true; + String buildOutputFilePath = configuredProfile.getBuildOutputProviderElement().getAction() + .getAttribute("file");//$NON-NLS-1$ + po.buildOutputFilePath = (buildOutputFilePath != null) ? buildOutputFilePath : EMPTY_STRING; + } + } + + po.providerOptionsMap = new LinkedHashMap(); + for (String providerId : configuredProfile.getSIProviderIds()) { + ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions(); + ScannerInfoProvider configuredProvider = configuredProfile.getScannerInfoProviderElement(providerId); + + ppo.providerOutputParserEnabled = true; + ppo.providerKind = configuredProvider.getProviderKind(); + String attrValue; + if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) { + ppo.providerRunUseDefault = true; + attrValue = configuredProvider.getAction().getAttribute(COMMAND); + ppo.providerRunCommand = (attrValue != null) ? attrValue : EMPTY_STRING; + attrValue = configuredProvider.getAction().getAttribute(ARGUMENTS); + ppo.providerRunArguments = (attrValue != null) ? attrValue : EMPTY_STRING; + } else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) { + attrValue = configuredProvider.getAction().getAttribute("file");//$NON-NLS-1$ + ppo.providerOpenFilePath = (attrValue != null) ? attrValue : EMPTY_STRING; + } + + po.providerOptionsMap.put(providerId, ppo); + } + + defaultProfiles.put(profileId, po); + return po.clone(); + } } @@ -890,111 +892,111 @@ public class ScannerConfigInfoFactory2 { private static class BuildProperty extends Store { private IProject project; private InfoContext context; - private String profileId; - private ScannerConfigInfoSet container; + private String profileId; + private ScannerConfigInfoSet container; - BuildProperty(ScannerConfigInfoSet container, IProject project, InfoContext context, String profileId, ICStorageElement element) { + BuildProperty(ScannerConfigInfoSet container, IProject project, InfoContext context, String profileId, + ICStorageElement element) { super(); this.project = project; this.context = context; - this.profileId = profileId; - this.container = container; + this.profileId = profileId; + this.container = container; load(element); } - BuildProperty(ScannerConfigInfoSet container, IProject project, InfoContext context, Store base, String profileId) { + BuildProperty(ScannerConfigInfoSet container, IProject project, InfoContext context, Store base, + String profileId) { super(base, profileId); this.project = project; this.context = context; this.container = container; - if(!profileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID)){ + if (!profileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID)) { this.profileId = profileId; - } else if(base instanceof BuildProperty){ - BuildProperty prop = (BuildProperty)base; + } else if (base instanceof BuildProperty) { + BuildProperty prop = (BuildProperty) base; this.profileId = prop.profileId; } else { - Preference pref = (Preference)base; + Preference pref = (Preference) base; this.profileId = pref.profileId; } } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load() - */ - protected void load(ICStorageElement element) { - List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context); - - // Load the default profiles - for (String profileId : profileIds) - profileOptionsMap.put(profileId, getDefaultProfile(profileId)); - - boolean performMigration = true; - - // Now load the profiles from the .cproject - for (ICStorageElement sc : element.getChildren()) { - if (sc.getName().equals(SC_AUTODISCOVERY)) { - autoDiscoveryEnabled = Boolean.valueOf( - sc.getAttribute(ENABLED)).booleanValue(); - selectedProfile = (profileId == ScannerConfigProfileManager.NULL_PROFILE_ID) - ? sc.getAttribute(SELECTED_PROFILE_ID) - : profileId; - selectedProfile = SafeStringInterner.safeIntern(selectedProfile); - problemReportingEnabled = Boolean.valueOf( - sc.getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue(); - performMigration = false; - } else if (sc.getName().equals(PROFILE)) { + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load() + */ + protected void load(ICStorageElement element) { + List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context); + + // Load the default profiles + for (String profileId : profileIds) + profileOptionsMap.put(profileId, getDefaultProfile(profileId)); + + boolean performMigration = true; + + // Now load the profiles from the .cproject + for (ICStorageElement sc : element.getChildren()) { + if (sc.getName().equals(SC_AUTODISCOVERY)) { + autoDiscoveryEnabled = Boolean.valueOf(sc.getAttribute(ENABLED)).booleanValue(); + selectedProfile = (profileId == ScannerConfigProfileManager.NULL_PROFILE_ID) + ? sc.getAttribute(SELECTED_PROFILE_ID) + : profileId; + selectedProfile = SafeStringInterner.safeIntern(selectedProfile); + problemReportingEnabled = Boolean.valueOf(sc.getAttribute(PROBLEM_REPORTING_ENABLED)) + .booleanValue(); + performMigration = false; + } else if (sc.getName().equals(PROFILE)) { if (profileIds.contains(sc.getAttribute(ID))) { loadProfile(sc); } - performMigration = false; + performMigration = false; } } if (performMigration) { - // No ScannerConfigDiscovery entry, try old project location - .project + // No ScannerConfigDiscovery entry, try old project location - .project if (!migrateScannerConfigBuildInfo(ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID)) { - // disable autodiscovery - autoDiscoveryEnabled = false; - } + // disable autodiscovery + autoDiscoveryEnabled = false; + } } } private boolean migrateScannerConfigBuildInfo(String profileId) { boolean rc = true; try { - IScannerConfigBuilderInfo oldInfo = MakeCorePlugin. - createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID); + IScannerConfigBuilderInfo oldInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, + ScannerConfigBuilder.BUILDER_ID); autoDiscoveryEnabled = oldInfo.isAutoDiscoveryEnabled(); problemReportingEnabled = oldInfo.isSIProblemGenerationEnabled(); // effectively a PerProject profile selectedProfile = SafeStringInterner.safeIntern(profileId); - ProfileOptions po = new ProfileOptions(); + ProfileOptions po = new ProfileOptions(); po.buildOutputFileActionEnabled = false; po.buildOutputParserEnabled = oldInfo.isMakeBuilderConsoleParserEnabled(); ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions(); - ppo.providerKind = ScannerConfigProfile.ScannerInfoProvider.RUN; + ppo.providerKind = ScannerConfigProfile.ScannerInfoProvider.RUN; ppo.providerOutputParserEnabled = oldInfo.isESIProviderCommandEnabled(); ppo.providerRunUseDefault = oldInfo.isDefaultESIProviderCmd(); ppo.providerRunCommand = oldInfo.getESIProviderCommand().toString(); ppo.providerRunArguments = oldInfo.getESIProviderArguments(); - ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). - getSCProfileConfiguration(selectedProfile); + ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance() + .getSCProfileConfiguration(selectedProfile); // get the one and only provider id String providerId = configuredProfile.getSIProviderIds().get(0); - po.providerOptionsMap = new LinkedHashMap(1); + po.providerOptionsMap = new LinkedHashMap(1); po.providerOptionsMap.put(providerId, ppo); - profileOptionsMap = new LinkedHashMap(1); - profileOptionsMap.put(profileId, po); + profileOptionsMap = new LinkedHashMap(1); + profileOptionsMap.put(profileId, po); - // store migrated data - isDirty = true; - save(); - } - catch (CoreException e) { + // store migrated data + isDirty = true; + save(); + } catch (CoreException e) { MakeCorePlugin.log(e); rc = false; } @@ -1002,65 +1004,61 @@ public class ScannerConfigInfoFactory2 { } private void loadProfile(ICStorageElement profile) { - ProfileOptions po = new ProfileOptions(); - String profileId = profile.getAttribute(ID); - profileOptionsMap.put(profileId, po); - // get the list of providers from the profile configuration - ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). - getSCProfileConfiguration(profileId); - List providerIds = configuredProfile.getSIProviderIds(); - int providerCounter = 0; - po.providerOptionsMap = new LinkedHashMap(providerIds.size()); - - for (ICStorageElement child : profile.getChildren()) { - // buildOutputProvider element - if (BUILD_OUTPUT_PROVIDER.equals(child.getName())) { - for (ICStorageElement grandchild : child.getChildren()) { - if (OPEN_ACTION.equals(grandchild.getName())) { - po.buildOutputFileActionEnabled = Boolean.valueOf( - grandchild.getAttribute(ENABLED)).booleanValue(); - po.buildOutputFilePath = grandchild.getAttribute(FILE_PATH); - } - else if (PARSER.equals(grandchild.getName())) { - po.buildOutputParserEnabled = Boolean.valueOf( - grandchild.getAttribute(ENABLED)).booleanValue(); - } - } - } - else if (SCANNER_INFO_PROVIDER.equals(child.getName())) { + ProfileOptions po = new ProfileOptions(); + String profileId = profile.getAttribute(ID); + profileOptionsMap.put(profileId, po); + // get the list of providers from the profile configuration + ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance() + .getSCProfileConfiguration(profileId); + List providerIds = configuredProfile.getSIProviderIds(); + int providerCounter = 0; + po.providerOptionsMap = new LinkedHashMap(providerIds.size()); + + for (ICStorageElement child : profile.getChildren()) { + // buildOutputProvider element + if (BUILD_OUTPUT_PROVIDER.equals(child.getName())) { + for (ICStorageElement grandchild : child.getChildren()) { + if (OPEN_ACTION.equals(grandchild.getName())) { + po.buildOutputFileActionEnabled = Boolean.valueOf(grandchild.getAttribute(ENABLED)) + .booleanValue(); + po.buildOutputFilePath = grandchild.getAttribute(FILE_PATH); + } else if (PARSER.equals(grandchild.getName())) { + po.buildOutputParserEnabled = Boolean.valueOf(grandchild.getAttribute(ENABLED)) + .booleanValue(); + } + } + } else if (SCANNER_INFO_PROVIDER.equals(child.getName())) { String providerId = child.getAttribute(ID); if (providerIds.get(providerCounter).equals(providerId)) { // new provider ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions(); po.providerOptionsMap.put(providerId, ppo); - ppo.providerKind = configuredProfile.getScannerInfoProviderElement( - providerId).getProviderKind(); - - for (ICStorageElement grandchild : child.getChildren()) { - // action - if (RUN_ACTION.equals(grandchild.getName())) { - ppo.providerRunUseDefault = Boolean.valueOf( - grandchild.getAttribute(USE_DEFAULT)).booleanValue(); - ppo.providerRunCommand = grandchild.getAttribute(COMMAND); - ppo.providerRunArguments = grandchild.getAttribute(ARGUMENTS); - } - else if (OPEN_ACTION.equals(grandchild.getName())) { - ppo.providerOpenFilePath = grandchild.getAttribute(FILE_PATH); - } - // parser - else if (PARSER.equals(grandchild.getName())) { - ppo.providerOutputParserEnabled = Boolean.valueOf( - grandchild.getAttribute(ENABLED)).booleanValue(); - } - } - ++providerCounter; + ppo.providerKind = configuredProfile.getScannerInfoProviderElement(providerId) + .getProviderKind(); + + for (ICStorageElement grandchild : child.getChildren()) { + // action + if (RUN_ACTION.equals(grandchild.getName())) { + ppo.providerRunUseDefault = Boolean.valueOf(grandchild.getAttribute(USE_DEFAULT)) + .booleanValue(); + ppo.providerRunCommand = grandchild.getAttribute(COMMAND); + ppo.providerRunArguments = grandchild.getAttribute(ARGUMENTS); + } else if (OPEN_ACTION.equals(grandchild.getName())) { + ppo.providerOpenFilePath = grandchild.getAttribute(FILE_PATH); + } + // parser + else if (PARSER.equals(grandchild.getName())) { + ppo.providerOutputParserEnabled = Boolean.valueOf(grandchild.getAttribute(ENABLED)) + .booleanValue(); + } + } + ++providerCounter; + } else { + // mismatch - error + // TODO Vmir define error } - else { - // mismatch - error - // TODO Vmir define error - } - } - } + } + } } /** @@ -1068,11 +1066,11 @@ public class ScannerConfigInfoFactory2 { * @param sc storage element in which to persist the settings. */ private void store(ICStorageElement sc) { - // Clear children - for (ICStorageElement child : sc.getChildren()) - sc.removeChild(child); + // Clear children + for (ICStorageElement child : sc.getChildren()) + sc.removeChild(child); - ICStorageElement autod = sc.createChild(SC_AUTODISCOVERY); + ICStorageElement autod = sc.createChild(SC_AUTODISCOVERY); autod.setAttribute(ENABLED, Boolean.toString(autoDiscoveryEnabled)); autod.setAttribute(SELECTED_PROFILE_ID, selectedProfile); autod.setAttribute(PROBLEM_REPORTING_ENABLED, Boolean.toString(problemReportingEnabled)); @@ -1081,10 +1079,10 @@ public class ScannerConfigInfoFactory2 { // If this profile is identical to the default, then no need to store if (entry.getValue().equals(defaultProfiles.get(entry.getKey()))) continue; - ICStorageElement profile = sc.createChild(PROFILE); + ICStorageElement profile = sc.createChild(PROFILE); profile.setAttribute(ID, entry.getKey()); store(profile, entry.getValue()); - } + } isDirty = false; } @@ -1099,16 +1097,16 @@ public class ScannerConfigInfoFactory2 { child = profile.createChild(BUILD_OUTPUT_PROVIDER); grandchild = child.createChild(OPEN_ACTION); grandchild.setAttribute(ENABLED, Boolean.toString(po.buildOutputFileActionEnabled)); - if(po.buildOutputFilePath != null) + if (po.buildOutputFilePath != null) grandchild.setAttribute(FILE_PATH, po.buildOutputFilePath); grandchild = child.createChild(PARSER); grandchild.setAttribute(ENABLED, Boolean.toString(po.buildOutputParserEnabled)); // scannerInfoProvider elements // get the list of providers from the profile configuration -// ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). -// getSCProfileConfiguration(selectedProfile); -// List providerIds = configuredProfile.getSIProviderIds(); - List providerIds = new ArrayList(po.providerOptionsMap.keySet()); + // ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). + // getSCProfileConfiguration(selectedProfile); + // List providerIds = configuredProfile.getSIProviderIds(); + List providerIds = new ArrayList(po.providerOptionsMap.keySet()); for (int i = 0; i < providerIds.size(); ++i) { String providerId = providerIds.get(i); ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); @@ -1118,49 +1116,47 @@ public class ScannerConfigInfoFactory2 { child.setAttribute(ID, providerId); // action -// String providerKind = configuredProfile.getScannerInfoProviderElement( -// providerId).getProviderKind(); - String providerKind = ppo.providerKind; + // String providerKind = configuredProfile.getScannerInfoProviderElement( + // providerId).getProviderKind(); + String providerKind = ppo.providerKind; if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) { grandchild = child.createChild(RUN_ACTION); grandchild.setAttribute(USE_DEFAULT, Boolean.toString(ppo.providerRunUseDefault)); - if(ppo.providerRunCommand != null) + if (ppo.providerRunCommand != null) grandchild.setAttribute(COMMAND, ppo.providerRunCommand); - if(ppo.providerRunArguments != null) + if (ppo.providerRunArguments != null) grandchild.setAttribute(ARGUMENTS, ppo.providerRunArguments); - } - else if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) { + } else if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) { grandchild = child.createChild(OPEN_ACTION); - if(ppo.providerOpenFilePath != null) + if (ppo.providerOpenFilePath != null) grandchild.setAttribute(FILE_PATH, ppo.providerOpenFilePath); } // parser grandchild = child.createChild(PARSER); - grandchild.setAttribute(ENABLED, Boolean.toString(ppo.providerOutputParserEnabled)); - } - else { + grandchild.setAttribute(ENABLED, Boolean.toString(ppo.providerOutputParserEnabled)); + } else { // missing provider options - error // TODO Vmir define error } } } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#save() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#save() + */ + @Override public synchronized void save() throws CoreException { - if(isDirty){ - container.save(true); - isDirty = false; - } - } + if (isDirty) { + container.save(true); + isDirty = false; + } + } - @Override - public InfoContext getContext(){ - return context; - } + @Override + public InfoContext getContext() { + return context; + } } @@ -1176,7 +1172,8 @@ public class ScannerConfigInfoFactory2 { private PreferenceSet prefsContainer; private InfoContext context; - public Preference(PreferenceSet container, Preferences prefs, InfoContext context, String profileId, boolean useDefaults) { + public Preference(PreferenceSet container, Preferences prefs, InfoContext context, String profileId, + boolean useDefaults) { super(); this.prefs = prefs; this.profileId = profileId; @@ -1186,88 +1183,89 @@ public class ScannerConfigInfoFactory2 { load(); } - Preference(PreferenceSet container, Preferences prefs, InfoContext context, Store base, String profileId, boolean useDefaults) { + Preference(PreferenceSet container, Preferences prefs, InfoContext context, Store base, String profileId, + boolean useDefaults) { super(base, profileId); this.prefs = prefs; this.prefsContainer = container; this.useDefaults = useDefaults; this.context = context; - if(!profileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID)){ + if (!profileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID)) { this.profileId = profileId; - } else if(base instanceof BuildProperty){ - BuildProperty prop = (BuildProperty)base; + } else if (base instanceof BuildProperty) { + BuildProperty prop = (BuildProperty) base; this.profileId = prop.profileId; } else { - Preference pref = (Preference)base; + Preference pref = (Preference) base; this.profileId = pref.profileId; } } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load() - */ - protected void load() { - String instanceId = context.getInstanceId(); - String prefix = instanceId.length() == 0 ? "" : ATTRIBUTE_CS_INFO_INSTANCE_ID + DOT + instanceId + DOT; //$NON-NLS-1$ + /* (non-Javadoc) + * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load() + */ + protected void load() { + String instanceId = context.getInstanceId(); + String prefix = instanceId.length() == 0 ? "" : ATTRIBUTE_CS_INFO_INSTANCE_ID + DOT + instanceId + DOT; //$NON-NLS-1$ autoDiscoveryEnabled = getBoolean(prefix + SCANNER_CONFIG_AUTODISCOVERY_ENABLED_SUFFIX); - selectedProfile = (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(profileId)) ? - getString(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX) : - profileId; + selectedProfile = (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(profileId)) + ? getString(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX) + : profileId; selectedProfile = SafeStringInterner.safeIntern(selectedProfile); problemReportingEnabled = getBoolean(prefix + SCANNER_CONFIG_PROBLEM_REPORTING_ENABLED_SUFFIX); - if (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(selectedProfile) && !useDefaults) { - // get the default value - selectedProfile = SafeStringInterner.safeIntern(prefs.getDefaultString(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX)); - } - List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context); - profileOptionsMap = new LinkedHashMap(profileIds.size()); - for (String profileId : profileIds) { - ProfileOptions po = new ProfileOptions(); - profileOptionsMap.put(profileId, po); - - boolean profileStored = getBoolean(SCD + prefix + profileId + DOT + ENABLED); - if (!profileStored && !useDefaults) { - profileOptionsMap.put(profileId, getDefaultProfile(profileId)); - continue; - } - - po.buildOutputFileActionEnabled = getBoolean(SCD + prefix + profileId + BUILD_OUTPUT_OPEN_ACTION_ENABLED); + if (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(selectedProfile) && !useDefaults) { + // get the default value + selectedProfile = SafeStringInterner + .safeIntern(prefs.getDefaultString(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX)); + } + List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context); + profileOptionsMap = new LinkedHashMap(profileIds.size()); + for (String profileId : profileIds) { + ProfileOptions po = new ProfileOptions(); + profileOptionsMap.put(profileId, po); + + boolean profileStored = getBoolean(SCD + prefix + profileId + DOT + ENABLED); + if (!profileStored && !useDefaults) { + profileOptionsMap.put(profileId, getDefaultProfile(profileId)); + continue; + } + + po.buildOutputFileActionEnabled = getBoolean( + SCD + prefix + profileId + BUILD_OUTPUT_OPEN_ACTION_ENABLED); po.buildOutputFilePath = getString(SCD + prefix + profileId + BUILD_OUTPUT_OPEN_ACTION_FILE_PATH); po.buildOutputParserEnabled = getBoolean(SCD + prefix + profileId + BUILD_OUTPUT_PARSER_ENABLED); - ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). - getSCProfileConfiguration(profileId); + ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance() + .getSCProfileConfiguration(profileId); List providerIds = configuredProfile.getSIProviderIds(); po.providerOptionsMap = new LinkedHashMap(providerIds.size()); for (String providerId : providerIds) { ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions(); po.providerOptionsMap.put(providerId, ppo); - ppo.providerKind = configuredProfile.getScannerInfoProviderElement( - providerId).getProviderKind(); + ppo.providerKind = configuredProfile.getScannerInfoProviderElement(providerId).getProviderKind(); - ppo.providerOutputParserEnabled = getBoolean(SCD + prefix + profileId + DOT + - providerId + SI_PROVIDER_PARSER_ENABLED); + ppo.providerOutputParserEnabled = getBoolean( + SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_PARSER_ENABLED); if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) { - ppo.providerRunUseDefault = getBoolean(SCD + prefix + profileId + DOT + providerId + - SI_PROVIDER_RUN_ACTION_USE_DEFAULT); - ppo.providerRunCommand = getString(SCD + prefix + profileId + DOT + providerId + - SI_PROVIDER_RUN_ACTION_COMMAND); - ppo.providerRunArguments = getString(SCD + prefix + profileId + DOT + providerId + - SI_PROVIDER_RUN_ACTION_ARGUMENTS); - } - else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) { - ppo.providerOpenFilePath = getString(SCD + prefix + profileId + DOT + providerId + - SI_PROVIDER_OPEN_ACTION_FILE_PATH); + ppo.providerRunUseDefault = getBoolean( + SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_RUN_ACTION_USE_DEFAULT); + ppo.providerRunCommand = getString( + SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_RUN_ACTION_COMMAND); + ppo.providerRunArguments = getString( + SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_RUN_ACTION_ARGUMENTS); + } else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) { + ppo.providerOpenFilePath = getString( + SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_OPEN_ACTION_FILE_PATH); } } - } + } } private void store() { - String instanceId = context.getInstanceId(); - String prefix = instanceId.length() == 0 ? "" : ATTRIBUTE_CS_INFO_INSTANCE_ID + DOT + instanceId + DOT; //$NON-NLS-1$ + String instanceId = context.getInstanceId(); + String prefix = instanceId.length() == 0 ? "" : ATTRIBUTE_CS_INFO_INSTANCE_ID + DOT + instanceId + DOT; //$NON-NLS-1$ if (isDirty) { set(prefix + SCANNER_CONFIG_AUTODISCOVERY_ENABLED_SUFFIX, autoDiscoveryEnabled); set(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX, selectedProfile); @@ -1276,21 +1274,21 @@ public class ScannerConfigInfoFactory2 { for (String profileId : profileOptionsMap.keySet()) { ProfileOptions po = profileOptionsMap.get(profileId); - set(SCD + prefix + profileId + DOT + ENABLED, !useDefaults); + set(SCD + prefix + profileId + DOT + ENABLED, !useDefaults); set(SCD + prefix + profileId + BUILD_OUTPUT_OPEN_ACTION_ENABLED, po.buildOutputFileActionEnabled); set(SCD + prefix + profileId + BUILD_OUTPUT_OPEN_ACTION_FILE_PATH, po.buildOutputFilePath); set(SCD + prefix + profileId + BUILD_OUTPUT_PARSER_ENABLED, po.buildOutputParserEnabled); - ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). - getSCProfileConfiguration(profileId); + ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance() + .getSCProfileConfiguration(profileId); List providerIds = configuredProfile.getSIProviderIds(); for (String providerId : providerIds) { ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); set(SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_PARSER_ENABLED, ppo.providerOutputParserEnabled); -// String providerKind = configuredProfile.getScannerInfoProviderElement( -// providerId).getProviderKind(); + // String providerKind = configuredProfile.getScannerInfoProviderElement( + // providerId).getProviderKind(); String providerKind = ppo.providerKind; if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) { @@ -1300,8 +1298,7 @@ public class ScannerConfigInfoFactory2 { ppo.providerRunCommand); set(SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_RUN_ACTION_ARGUMENTS, ppo.providerRunArguments); - } - else if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) { + } else if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) { set(SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_OPEN_ACTION_FILE_PATH, ppo.providerOpenFilePath); } @@ -1318,11 +1315,11 @@ public class ScannerConfigInfoFactory2 { } return prefs.getBoolean(name); } + private void set(String name, boolean value) { if (useDefaults) { prefs.setDefault(name, value); - } - else { + } else { prefs.setValue(name, value); } } @@ -1333,28 +1330,28 @@ public class ScannerConfigInfoFactory2 { } return prefs.getString(name); } + private void set(String name, String value) { if (useDefaults) { prefs.setDefault(name, value); - } - else { + } else { prefs.setValue(name, value); } } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#save() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#save() + */ + @Override public void save() throws CoreException { - if(isDirty) - prefsContainer.save(); - } - - @Override - public InfoContext getContext(){ - return context; - } + if (isDirty) + prefsContainer.save(); + } + + @Override + public InfoContext getContext() { + return context; + } } public static IScannerConfigBuilderInfo2 create(IProject project, String profileId) throws CoreException { @@ -1367,11 +1364,12 @@ public class ScannerConfigInfoFactory2 { return container.getInfo(new InfoContext(null)); } - public static IScannerConfigBuilderInfo2Set createInfoSet(Preferences prefs, String profileId, boolean useDefaults){ + public static IScannerConfigBuilderInfo2Set createInfoSet(Preferences prefs, String profileId, + boolean useDefaults) { return new ScannerConfigInfoFactory2.PreferenceSet(prefs, profileId, useDefaults); } - public static IScannerConfigBuilderInfo2Set createInfoSet(IProject project, String profileId){ + public static IScannerConfigBuilderInfo2Set createInfoSet(IProject project, String profileId) { return new ScannerConfigInfoFactory2.ScannerConfigInfoSet(project, profileId); } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java index 04fe9f58101..015e369677f 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM - Initial API and implementation *******************************************************************************/ @@ -28,24 +28,24 @@ import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; - /** * SCD Profile extension point object model - * + * * @author vhirsl */ public class ScannerConfigProfile { - /** + /** * scannerInfoCollector element - * + * * @author vhirsl */ public class ScannerInfoCollector { private IConfigurationElement configElem; - + public ScannerInfoCollector(IConfigurationElement configElem) { this.configElem = configElem; } + public IScannerInfoCollector createScannerInfoCollector() { try { return (IScannerInfoCollector) configElem.createExecutableExtension("class"); //$NON-NLS-1$ @@ -54,21 +54,24 @@ public class ScannerConfigProfile { return null; } } - public String getScope() { - return configElem.getAttribute("scope"); //$NON-NLS-1$ - } + + public String getScope() { + return configElem.getAttribute("scope"); //$NON-NLS-1$ + } } + /** * scannerInfoConsoleParser element - * + * * @author vhirsl */ public final class ScannerInfoConsoleParser { private IConfigurationElement configElem; - + public ScannerInfoConsoleParser(IConfigurationElement configElem) { this.configElem = configElem; } + public Object createScannerInfoConsoleParser() { try { return configElem.createExecutableExtension("class"); //$NON-NLS-1$ @@ -77,13 +80,15 @@ public class ScannerConfigProfile { return null; } } - public String getCompilerCommands() { - return configElem.getAttribute("compilerCommands"); //$NON-NLS-1$ - } + + public String getCompilerCommands() { + return configElem.getAttribute("compilerCommands"); //$NON-NLS-1$ + } } + /** * tag interface, a placeholder for either run or open element - * + * * @author vhirsl */ protected abstract class Action { @@ -92,7 +97,7 @@ public class ScannerConfigProfile { protected Action(IConfigurationElement configElem) { this.configElem = configElem; } - + public Object createExternalScannerInfoProvider() { if (configElem.getAttribute("class") != null) { //$NON-NLS-1$ try { @@ -103,20 +108,22 @@ public class ScannerConfigProfile { } return null; } - - public String getAttribute(String name) { - return configElem.getAttribute(name); - } + + public String getAttribute(String name) { + return configElem.getAttribute(name); + } } + /** * run element - * + * * @author vhirsl */ public final class Run extends Action { public Run(IConfigurationElement run) { super(run); } + /* (non-Javadoc) * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager.IAction#getNewExternalScannerInfoProvider() */ @@ -130,15 +137,17 @@ public class ScannerConfigProfile { return provider; } } + /** * open element - * + * * @author vhirsl */ public final class Open extends Action { public Open(IConfigurationElement open) { super(open); } + /* (non-Javadoc) * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager.IAction#getNewExternalScannerInfoProvider() */ @@ -152,15 +161,16 @@ public class ScannerConfigProfile { return provider; } } + /** * buildOutputProvider element - * + * * @author vhirsl */ public final class BuildOutputProvider { private Open openFileAction; private ScannerInfoConsoleParser scannerInfoConsoleParser; - + public BuildOutputProvider(IConfigurationElement provider) { IConfigurationElement[] actions = provider.getChildren("open"); //$NON-NLS-1$ // take the first one @@ -171,79 +181,83 @@ public class ScannerConfigProfile { // take the first one this.scannerInfoConsoleParser = new ScannerConfigProfile.ScannerInfoConsoleParser(parsers[0]); } - + public Action getAction() { return openFileAction; } + public ScannerInfoConsoleParser getScannerInfoConsoleParser() { return scannerInfoConsoleParser; } } + /** * scannerInfoProvider element - * + * * @author vhirsl */ public final class ScannerInfoProvider { public static final String RUN = "run";//$NON-NLS-1$ public static final String OPEN = "open";//$NON-NLS-1$ - + private String providerId; private String providerKind; // derived attribute private Action action; private ScannerInfoConsoleParser scannerInfoConsoleParser; - + public ScannerInfoProvider(IConfigurationElement provider) { providerId = provider.getAttribute("providerId"); //$NON-NLS-1$ IConfigurationElement[] actions = provider.getChildren(); providerKind = actions[0].getName(); if (providerKind.equals(RUN)) { this.action = new ScannerConfigProfile.Run(actions[0]); - } - else if (providerKind.equals(OPEN)) { + } else if (providerKind.equals(OPEN)) { this.action = new ScannerConfigProfile.Open(actions[0]); - } - else { + } else { // TODO Vmir generate an error } IConfigurationElement[] parsers = provider.getChildren("scannerInfoConsoleParser"); //$NON-NLS-1$ // take the first one scannerInfoConsoleParser = new ScannerConfigProfile.ScannerInfoConsoleParser(parsers[0]); } - + public String getProviderId() { return providerId; } + public String getProviderKind() { return providerKind; } + public Action getAction() { return action; } + public ScannerInfoConsoleParser getScannerInfoConsoleParser() { return scannerInfoConsoleParser; } } - + // ScannerConfigProfile members private final String id; - + private ScannerInfoCollector scannerInfoCollector; private BuildOutputProvider buildOutputProvider; private Map scannerInfoProviders = new LinkedHashMap(); - + private Boolean supportsContext; public ScannerConfigProfile(String profileId) { id = profileId; load(); } + /** * loads the profile from the manifest file. */ private void load() { - IExtensionPoint extension = Platform.getExtensionRegistry(). - getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID); + IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.PLUGIN_ID, + ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID); if (extension != null) { IExtension[] extensions = extension.getExtensions(); for (int i = 0; i < extensions.length; ++i) { @@ -252,17 +266,14 @@ public class ScannerConfigProfile { IConfigurationElement[] configElements = extensions[i].getConfigurationElements(); for (int j = 0; j < configElements.length; ++j) { String name = configElements[j].getName(); - if (scannerInfoCollector == null && - name.equals("scannerInfoCollector")) { //$NON-NLS-1$ + if (scannerInfoCollector == null && name.equals("scannerInfoCollector")) { //$NON-NLS-1$ scannerInfoCollector = new ScannerConfigProfile.ScannerInfoCollector(configElements[j]); - } - else if (name.equals("buildOutputProvider")) { //$NON-NLS-1$ + } else if (name.equals("buildOutputProvider")) { //$NON-NLS-1$ buildOutputProvider = new ScannerConfigProfile.BuildOutputProvider(configElements[j]); - } - else if (name.equals("scannerInfoProvider")) { //$NON-NLS-1$ + } else if (name.equals("scannerInfoProvider")) { //$NON-NLS-1$ String providerId = configElements[j].getAttribute("providerId"); //$NON-NLS-1$ if (providerId != null && scannerInfoProviders.get(providerId) == null) { - scannerInfoProviders.put(providerId, + scannerInfoProviders.put(providerId, new ScannerConfigProfile.ScannerInfoProvider(configElements[j])); } } @@ -272,13 +283,14 @@ public class ScannerConfigProfile { } } } + /** * @return Returns the id. */ public String getId() { return id; } - + // access to model objects /** * @return Returns the list of providerIds @@ -286,56 +298,57 @@ public class ScannerConfigProfile { public List getSIProviderIds() { return new ArrayList(scannerInfoProviders.keySet()); } + /** * @return Returns the buildOutputProvider. */ public BuildOutputProvider getBuildOutputProviderElement() { return buildOutputProvider; } + /** * @return Returns the scannerInfoCollector. */ public ScannerInfoCollector getScannerInfoCollectorElement() { return scannerInfoCollector; } - - public ScannerConfigScope getProfileScope() { - ScannerConfigScope scope = null; - if (scannerInfoCollector != null) { - if (scannerInfoCollector.getScope().equals(ScannerConfigScope.PROJECT_SCOPE.toString())) { - scope = ScannerConfigScope.PROJECT_SCOPE; - } - else if (scannerInfoCollector.getScope().equals(ScannerConfigScope.FILE_SCOPE.toString())) { - scope = ScannerConfigScope.FILE_SCOPE; - } - } - return scope; - } - + + public ScannerConfigScope getProfileScope() { + ScannerConfigScope scope = null; + if (scannerInfoCollector != null) { + if (scannerInfoCollector.getScope().equals(ScannerConfigScope.PROJECT_SCOPE.toString())) { + scope = ScannerConfigScope.PROJECT_SCOPE; + } else if (scannerInfoCollector.getScope().equals(ScannerConfigScope.FILE_SCOPE.toString())) { + scope = ScannerConfigScope.FILE_SCOPE; + } + } + return scope; + } + /** * @return Returns the scannerInfoProviders. */ public ScannerInfoProvider getScannerInfoProviderElement(String providerId) { return scannerInfoProviders.get(providerId); } - - public boolean supportsContext(){ - if(supportsContext == null){ + + public boolean supportsContext() { + if (supportsContext == null) { ScannerInfoCollector cr = getScannerInfoCollectorElement(); - if(cr != null){ + if (cr != null) { IScannerInfoCollector collector = cr.createScannerInfoCollector(); - if(collector != null){ + if (collector != null) { Class clazz = collector.getClass(); try { - clazz.getMethod("setInfoContext", new Class[] {InfoContext.class}); //$NON-NLS-1$ + clazz.getMethod("setInfoContext", new Class[] { InfoContext.class }); //$NON-NLS-1$ supportsContext = Boolean.TRUE; } catch (SecurityException e) { } catch (NoSuchMethodException e) { } } } - - if(supportsContext == null) + + if (supportsContext == null) supportsContext = Boolean.FALSE; } return supportsContext.booleanValue(); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java index 2a16b8b0905..a65cd3f5c79 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java @@ -33,15 +33,16 @@ import org.eclipse.core.runtime.Preferences; /** * Manages profiles per project - * + * * @author vhirsl */ public final class ScannerConfigProfileManager { - public static final String SI_PROFILE_SIMPLE_ID = "ScannerConfigurationDiscoveryProfile"; //$NON-NLS-1$ - public static final String PER_PROJECT_PROFILE_ID = MakeCorePlugin.getUniqueIdentifier() + ".GCCStandardMakePerProjectProfile"; //$NON-NLS-1$ + public static final String SI_PROFILE_SIMPLE_ID = "ScannerConfigurationDiscoveryProfile"; //$NON-NLS-1$ + public static final String PER_PROJECT_PROFILE_ID = MakeCorePlugin.getUniqueIdentifier() + + ".GCCStandardMakePerProjectProfile"; //$NON-NLS-1$ public static final String NULL_PROFILE_ID = "";//$NON-NLS-1$ public static final String DEFAULT_SI_PROFILE_ID = NULL_PROFILE_ID; - + private final Map> projectToProfileInstanceMap; private List profileIds; private List contextAwareProfileIds; @@ -53,6 +54,7 @@ public final class ScannerConfigProfileManager { private ScannerConfigProfileManager() { projectToProfileInstanceMap = new HashMap>(); } + private static final ScannerConfigProfileManager instance = new ScannerConfigProfileManager(); public static ScannerConfigProfileManager getInstance() { @@ -64,7 +66,7 @@ public final class ScannerConfigProfileManager { try { IScannerConfigBuilderInfo2Set container = createScannerConfigBuildInfo2Set(project); IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context); - if(buildInfo == null) + if (buildInfo == null) buildInfo = container.getInfo(new InfoContext(project)); profileId = buildInfo.getSelectedProfileId(); } catch (CoreException e) { @@ -85,24 +87,24 @@ public final class ScannerConfigProfileManager { public void addProfile(IProject project, InfoContext context, ScannerConfigProfile profile) { getProfileMap(project, true).put(context, profile); } - - private Map getProfileMap(IProject project, boolean create){ + + private Map getProfileMap(IProject project, boolean create) { synchronized (fLock) { Map map = projectToProfileInstanceMap.get(project); - if(map == null && create){ + if (map == null && create) { map = new HashMap(); projectToProfileInstanceMap.put(project, map); } return Collections.synchronizedMap(map); } } - - public void handleProjectRemoved(IProject project){ + + public void handleProjectRemoved(IProject project) { synchronized (fLock) { projectToProfileInstanceMap.remove(project); } } - + /** * @param profileId - if null, get the one associated with the project * @return the scannerConfigProfile instance for a project. @@ -114,30 +116,32 @@ public final class ScannerConfigProfileManager { public SCProfileInstance getSCProfileInstance(IProject project, InfoContext context, String profileId) { // if not specified read from .project file - if (profileId == NULL_PROFILE_ID) { - profileId = getProfileId(project, context); - } + if (profileId == NULL_PROFILE_ID) { + profileId = getProfileId(project, context); + } synchronized (fLock) { - // is the project's profile already loaded? - Map map = getProfileMap(project, true); - SoftReference profileInstanceReference = (SoftReference) map.get(context); - SCProfileInstance profileInstance = profileInstanceReference != null ? profileInstanceReference.get() : null; - - if (profileInstance == null || !profileInstance.getProfile().getId().equals(profileId)) { - profileInstance = new SCProfileInstance(project, context, getSCProfileConfiguration(profileId)); - map.put(context, new SoftReference(profileInstance)); - } - return profileInstance; + // is the project's profile already loaded? + Map map = getProfileMap(project, true); + SoftReference profileInstanceReference = (SoftReference) map + .get(context); + SCProfileInstance profileInstance = profileInstanceReference != null ? profileInstanceReference.get() + : null; + + if (profileInstance == null || !profileInstance.getProfile().getId().equals(profileId)) { + profileInstance = new SCProfileInstance(project, context, getSCProfileConfiguration(profileId)); + map.put(context, new SoftReference(profileInstance)); + } + return profileInstance; } } - public SCProfileInstance getSCProfileInstance(String profileId) { - SCProfileInstance profileInstance = null; - if (profileId != NULL_PROFILE_ID) { - profileInstance = new SCProfileInstance(null, getSCProfileConfiguration(profileId)); - } - return profileInstance; - } + public SCProfileInstance getSCProfileInstance(String profileId) { + SCProfileInstance profileInstance = null; + if (profileId != NULL_PROFILE_ID) { + profileInstance = new SCProfileInstance(null, getSCProfileConfiguration(profileId)); + } + return profileInstance; + } /** * @param profileId - if null, get the default one @@ -155,8 +159,8 @@ public final class ScannerConfigProfileManager { synchronized (fLock) { if (profileIds == null) { profileIds = new ArrayList(); - IExtensionPoint extension = Platform.getExtensionRegistry(). - getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID); + IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.PLUGIN_ID, + ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID); if (extension != null) { IExtension[] extensions = extension.getExtensions(); for (int i = 0; i < extensions.length; ++i) { @@ -166,25 +170,25 @@ public final class ScannerConfigProfileManager { } } } - return Collections.unmodifiableList(profileIds); + return Collections.unmodifiableList(profileIds); } - + /** * @return the list of profile IDs supported for this context */ - public List getProfileIds(InfoContext context){ - if(context.isDefaultContext() || context.getProject() == null) + public List getProfileIds(InfoContext context) { + if (context.isDefaultContext() || context.getProject() == null) return getProfileIds(); - + synchronized (fLock) { - if(contextAwareProfileIds == null){ + if (contextAwareProfileIds == null) { contextAwareProfileIds = new ArrayList(); List all = getProfileIds(); - for(int i = 0; i < all.size(); i++){ + for (int i = 0; i < all.size(); i++) { String id = all.get(i); ScannerConfigProfile profile = getSCProfileConfiguration(id); - if(profile.supportsContext()) + if (profile.supportsContext()) contextAwareProfileIds.add(id); } } @@ -198,49 +202,55 @@ public final class ScannerConfigProfileManager { public static String getDefaultSIProfileId() { return DEFAULT_SI_PROFILE_ID; } - + /** - * Set selectedProfile to profileId + * Set selectedProfile to profileId */ - public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project, String profileId) throws CoreException { + public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project, String profileId) + throws CoreException { return ScannerConfigInfoFactory2.create(project, profileId); } - /** - * Use stored selectedProfile - */ - public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project) throws CoreException { - return ScannerConfigInfoFactory2.create(project, ScannerConfigProfileManager.NULL_PROFILE_ID); - } - - public static IScannerConfigBuilderInfo2Set createScannerConfigBuildInfo2Set(IProject project) throws CoreException { - return ScannerConfigInfoFactory2.createInfoSet(project, ScannerConfigProfileManager.NULL_PROFILE_ID); - } + /** + * Use stored selectedProfile + */ + public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project) throws CoreException { + return ScannerConfigInfoFactory2.create(project, ScannerConfigProfileManager.NULL_PROFILE_ID); + } + + public static IScannerConfigBuilderInfo2Set createScannerConfigBuildInfo2Set(IProject project) + throws CoreException { + return ScannerConfigInfoFactory2.createInfoSet(project, ScannerConfigProfileManager.NULL_PROFILE_ID); + } - public static IScannerConfigBuilderInfo2Set createScannerConfigBuildInfo2Set(IProject project, String profileId) throws CoreException { - return ScannerConfigInfoFactory2.createInfoSet(project, profileId); - } + public static IScannerConfigBuilderInfo2Set createScannerConfigBuildInfo2Set(IProject project, String profileId) + throws CoreException { + return ScannerConfigInfoFactory2.createInfoSet(project, profileId); + } - public static IScannerConfigBuilderInfo2Set createScannerConfigBuildInfo2Set(Preferences prefs, boolean useDefaults) throws CoreException { - return ScannerConfigInfoFactory2.createInfoSet(prefs, ScannerConfigProfileManager.NULL_PROFILE_ID, useDefaults); - } + public static IScannerConfigBuilderInfo2Set createScannerConfigBuildInfo2Set(Preferences prefs, boolean useDefaults) + throws CoreException { + return ScannerConfigInfoFactory2.createInfoSet(prefs, ScannerConfigProfileManager.NULL_PROFILE_ID, useDefaults); + } - public static IScannerConfigBuilderInfo2Set createScannerConfigBuildInfo2Set(Preferences prefs, String profileId, boolean useDefaults) throws CoreException { - return ScannerConfigInfoFactory2.createInfoSet(prefs, profileId, useDefaults); - } + public static IScannerConfigBuilderInfo2Set createScannerConfigBuildInfo2Set(Preferences prefs, String profileId, + boolean useDefaults) throws CoreException { + return ScannerConfigInfoFactory2.createInfoSet(prefs, profileId, useDefaults); + } /** - * Set selectedProfile to profileId + * Set selectedProfile to profileId */ - public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(Preferences prefs, String profileId, boolean useDefaults) { + public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(Preferences prefs, String profileId, + boolean useDefaults) { return ScannerConfigInfoFactory2.create(prefs, profileId, useDefaults); } - /** - * Use stored selectedProfile - */ - public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(Preferences prefs, boolean useDefaults) { - return ScannerConfigInfoFactory2.create(prefs, ScannerConfigProfileManager.NULL_PROFILE_ID, useDefaults); - } + /** + * Use stored selectedProfile + */ + public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(Preferences prefs, boolean useDefaults) { + return ScannerConfigInfoFactory2.create(prefs, ScannerConfigProfileManager.NULL_PROFILE_ID, useDefaults); + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/templateengine/AddMakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/templateengine/AddMakeTarget.java index 13d9b24ca42..208d4326bbd 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/templateengine/AddMakeTarget.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/templateengine/AddMakeTarget.java @@ -50,15 +50,16 @@ public class AddMakeTarget extends ProcessRunner { private static final String PROJECTNAME_VARNAME = "projectName"; //$NON-NLS-1$ private static final String TARGETNAME_VARNAME = "targetName"; //$NON-NLS-1$ - private static final String MAKETARGET_VARNAME = "makeTarget"; //$NON-NLS-1$ - private static final String BUILDCOMMAND_VARNAME = "buildCommand"; //$NON-NLS-1$ - private static final String BUILDARGUMENTS_COMMAND_VARNAME = "buildArguments"; //$NON-NLS-1$ + private static final String MAKETARGET_VARNAME = "makeTarget"; //$NON-NLS-1$ + private static final String BUILDCOMMAND_VARNAME = "buildCommand"; //$NON-NLS-1$ + private static final String BUILDARGUMENTS_COMMAND_VARNAME = "buildArguments"; //$NON-NLS-1$ - private static final String BUILDCOMMAND_DEFAULT = "make"; //$NON-NLS-1$ - private static final String BUILDARGUMENTS_DEFAULT = ""; //$NON-NLS-1$ + private static final String BUILDCOMMAND_DEFAULT = "make"; //$NON-NLS-1$ + private static final String BUILDARGUMENTS_DEFAULT = ""; //$NON-NLS-1$ @Override - public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException { + public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) + throws ProcessFailureException { IProject project = null; String targetName = null; String makeTarget = null; @@ -75,7 +76,7 @@ public class AddMakeTarget extends ProcessRunner { makeTarget = arg.getSimpleValue(); else if (BUILDCOMMAND_VARNAME.equals(argName)) buildCommand = arg.getSimpleValue(); - else if(BUILDARGUMENTS_COMMAND_VARNAME.equals(argName)) + else if (BUILDARGUMENTS_COMMAND_VARNAME.equals(argName)) buildArguments = arg.getSimpleValue(); } @@ -91,11 +92,13 @@ public class AddMakeTarget extends ProcessRunner { target.setBuildAttribute(IMakeTarget.BUILD_TARGET, makeTarget == null ? targetName : makeTarget); target.setUseDefaultBuildCmd(buildCommand == null); - target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, buildCommand == null ? BUILDCOMMAND_DEFAULT : buildCommand); - target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, buildArguments == null ? BUILDARGUMENTS_DEFAULT : buildArguments); + target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, + buildCommand == null ? BUILDCOMMAND_DEFAULT : buildCommand); + target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, + buildArguments == null ? BUILDARGUMENTS_DEFAULT : buildArguments); makeTargetManager.addTarget(target); - } catch(CoreException e) { + } catch (CoreException e) { throw new ProcessFailureException(e); } } -- cgit v1.2.3