diff options
Diffstat (limited to 'build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java')
-rw-r--r-- | build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java | 960 |
1 files changed, 479 insertions, 481 deletions
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<InfoContext, IScannerConfigBuilderInfo2> 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<String> idSet = new HashSet<String>(fMap.size() - 1); - Preference pref = (Preference)fMap.get(new InfoContext(null)); + Preference pref = (Preference) fMap.get(new InfoContext(null)); pref.store(); for (Entry<InfoContext, IScannerConfigBuilderInfo2> 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<InfoContext, IScannerConfigBuilderInfo2> fMap = new HashMap<InfoContext, IScannerConfigBuilderInfo2>(); 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<String, ProfileOptions> defaultProfiles = new ConcurrentHashMap<String, ProfileOptions>(); + protected static Map<String, ProfileOptions> defaultProfiles = new ConcurrentHashMap<String, ProfileOptions>(); /** Map from profile ID -> ProfileOptions */ - protected Map<String, ProfileOptions> profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(); - static class ProfileOptions implements Cloneable { - protected boolean buildOutputFileActionEnabled; - protected String buildOutputFilePath = EMPTY_STRING; - protected boolean buildOutputParserEnabled; - /** Map from provider ID -> providerOptions */ - protected Map<String, ProviderOptions> 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<String, ProfileOptions> profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(); + + static class ProfileOptions implements Cloneable { + protected boolean buildOutputFileActionEnabled; + protected String buildOutputFilePath = EMPTY_STRING; + protected boolean buildOutputParserEnabled; + /** Map from provider ID -> providerOptions */ + protected Map<String, ProviderOptions> 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<String, ProviderOptions>(base.providerOptionsMap); - for (Map.Entry<String, ProviderOptions> 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<String, ProviderOptions>(base.providerOptionsMap); + for (Map.Entry<String, ProviderOptions> 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<String, ProviderOptions>(); for (Map.Entry<String, ProviderOptions> 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<String, ProfileOptions> 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<String> getProfileIdList() { - return new ArrayList<String>(profileOptionsMap.keySet()); - } + return new ArrayList<String>(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<String> getProviderIdList() { - ProfileOptions po = profileOptionsMap.get(selectedProfile); - return (po != null) ? new ArrayList<String>(po.providerOptionsMap.keySet()) : new ArrayList<String>(0); + ProfileOptions po = profileOptionsMap.get(selectedProfile); + return (po != null) ? new ArrayList<String>(po.providerOptionsMap.keySet()) : new ArrayList<String>(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<String, ProfileOptions.ProviderOptions>(); - 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<String, ProfileOptions.ProviderOptions>(); + 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<String> 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<String> 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<String, ProfileOptions.ProviderOptions>(1); + po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(1); po.providerOptionsMap.put(providerId, ppo); - profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(1); - profileOptionsMap.put(profileId, po); + profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(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<String> providerIds = configuredProfile.getSIProviderIds(); - int providerCounter = 0; - po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(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<String> providerIds = configuredProfile.getSIProviderIds(); + int providerCounter = 0; + po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(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<String> providerIds = new ArrayList<String>(po.providerOptionsMap.keySet()); + // ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). + // getSCProfileConfiguration(selectedProfile); + // List providerIds = configuredProfile.getSIProviderIds(); + List<String> providerIds = new ArrayList<String>(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<String> profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context); - profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(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<String> profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context); + profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(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<String> providerIds = configuredProfile.getSIProviderIds(); po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(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<String> 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); } } |