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

bug 289608: [Scanner Discovery] Discovery options does not offer profiles defined in supertypes in project properties

cleanup only: java generics + loops to enhanced
This commit is contained in:
Andrew Gvozdev 2009-09-16 15:12:47 +00:00
parent f0475b4959
commit 5ab8ef70df

View file

@ -15,11 +15,11 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.ICDescriptor;
@ -137,10 +137,9 @@ public class ScannerConfigInfoFactory2 {
BuildProperty prop = (BuildProperty)fMap.get(new InfoContext(fProject)); BuildProperty prop = (BuildProperty)fMap.get(new InfoContext(fProject));
prop.store(sc); prop.store(sc);
for(Iterator iter = fMap.entrySet().iterator(); iter.hasNext();){ for (Entry<InfoContext, IScannerConfigBuilderInfo2> entry : fMap.entrySet()) {
Map.Entry entry = (Map.Entry)iter.next();
InfoContext context = (InfoContext)entry.getKey(); InfoContext context = entry.getKey();
if(context.isDefaultContext()) if(context.isDefaultContext())
continue; continue;
@ -168,8 +167,8 @@ public class ScannerConfigInfoFactory2 {
return fProject; return fProject;
} }
protected Store doCreateStore(InfoContext context, Store base, @Override
String profileId) { protected Store doCreateStore(InfoContext context, Store base, String profileId) {
return new BuildProperty(this, fProject, context, base, profileId); return new BuildProperty(this, fProject, context, base, profileId);
} }
} }
@ -213,10 +212,8 @@ public class ScannerConfigInfoFactory2 {
Preference pref = (Preference)fMap.get(new InfoContext(null)); Preference pref = (Preference)fMap.get(new InfoContext(null));
pref.store(); pref.store();
for(Iterator iter = fMap.entrySet().iterator(); iter.hasNext();){ for (Entry<InfoContext, IScannerConfigBuilderInfo2> entry : fMap.entrySet()) {
Map.Entry entry = (Map.Entry)iter.next(); InfoContext context = entry.getKey();
InfoContext context = (InfoContext)entry.getKey();
if(context.isDefaultContext()) if(context.isDefaultContext())
continue; continue;
@ -247,8 +244,8 @@ public class ScannerConfigInfoFactory2 {
return null; return null;
} }
protected Store doCreateStore(InfoContext context, Store base, @Override
String profileId) { protected Store doCreateStore(InfoContext context, Store base, String profileId) {
return new Preference(this, prefs, context, base, profileId, useDefaults); return new Preference(this, prefs, context, base, profileId, useDefaults);
} }
@ -271,7 +268,7 @@ public class ScannerConfigInfoFactory2 {
private static abstract class StoreSet implements IScannerConfigBuilderInfo2Set { private static abstract class StoreSet implements IScannerConfigBuilderInfo2Set {
protected HashMap<InfoContext, Store> fMap = new HashMap<InfoContext, Store>(); protected HashMap<InfoContext, IScannerConfigBuilderInfo2> fMap = new HashMap<InfoContext, IScannerConfigBuilderInfo2>();
protected boolean fIsDirty; protected boolean fIsDirty;
StoreSet(){ StoreSet(){
@ -301,7 +298,7 @@ public class ScannerConfigInfoFactory2 {
return fMap.get(context); return fMap.get(context);
} }
public Map<InfoContext, Store> getInfoMap() { public Map<InfoContext, IScannerConfigBuilderInfo2> getInfoMap() {
return Collections.unmodifiableMap(fMap); return Collections.unmodifiableMap(fMap);
} }
@ -319,9 +316,8 @@ public class ScannerConfigInfoFactory2 {
public boolean isDirty(){ public boolean isDirty(){
if(fIsDirty) if(fIsDirty)
return true; return true;
for(Iterator<Store> iter = fMap.values().iterator(); iter.hasNext();){ for (IScannerConfigBuilderInfo2 prop : fMap.values()) {
Store prop = iter.next(); if(((Store)prop).isDirty)
if(prop.isDirty)
return true; return true;
} }
@ -524,7 +520,6 @@ public class ScannerConfigInfoFactory2 {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getSIProviderIdList() * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getSIProviderIdList()
*/ */
@SuppressWarnings("unchecked")
public List<String> getProviderIdList() { public List<String> getProviderIdList() {
ProfileOptions po = profileOptionsMap.get(selectedProfile); ProfileOptions po = profileOptionsMap.get(selectedProfile);
return (po != null) ? new ArrayList<String>(po.providerOptionsMap.keySet()) : new ArrayList<String>(0); return (po != null) ? new ArrayList<String>(po.providerOptionsMap.keySet()) : new ArrayList<String>(0);
@ -687,7 +682,7 @@ public class ScannerConfigInfoFactory2 {
protected void loadFromProfileConfiguration(ProfileOptions po, String profileId) { protected void loadFromProfileConfiguration(ProfileOptions po, String profileId) {
ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
getSCProfileConfiguration(profileId); getSCProfileConfiguration(profileId);
List providerIds = configuredProfile.getSIProviderIds(); List<String> providerIds = configuredProfile.getSIProviderIds();
po.buildOutputParserEnabled = false; po.buildOutputParserEnabled = false;
po.buildOutputFileActionEnabled = false; po.buildOutputFileActionEnabled = false;
@ -704,7 +699,7 @@ public class ScannerConfigInfoFactory2 {
po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(providerIds.size()); po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(providerIds.size());
for (int i = 0; i < providerIds.size(); ++i) { for (int i = 0; i < providerIds.size(); ++i) {
ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions(); ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
String providerId = (String) providerIds.get(i); String providerId = providerIds.get(i);
po.providerOptionsMap.put(providerId, ppo); po.providerOptionsMap.put(providerId, ppo);
ppo.providerOutputParserEnabled = (configuredProfile.getScannerInfoProviderElement(providerId) == null) ? false : true; ppo.providerOutputParserEnabled = (configuredProfile.getScannerInfoProviderElement(providerId) == null) ? false : true;
@ -804,8 +799,7 @@ public class ScannerConfigInfoFactory2 {
} }
if (loadedProfiles.size() < profileIds.size()) { if (loadedProfiles.size() < profileIds.size()) {
// initialize remaining profiles with default values // initialize remaining profiles with default values
for (Iterator i = profileIds.iterator(); i.hasNext(); ) { for (String profileId : profileIds) {
String profileId = (String) i.next();
if (!loadedProfiles.contains(profileId)) { if (!loadedProfiles.contains(profileId)) {
loadDefaults(profileId); loadDefaults(profileId);
loadedProfiles.add(profileId); loadedProfiles.add(profileId);
@ -834,8 +828,9 @@ public class ScannerConfigInfoFactory2 {
getSCProfileConfiguration(profileId); getSCProfileConfiguration(profileId);
po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(); po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>();
for (Iterator i = configuredProfile.getSIProviderIds().iterator(); i.hasNext(); ) {
String providerId = (String) i.next(); List<String> providerIds = configuredProfile.getSIProviderIds();
for (String providerId : providerIds) {
ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions(); ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
ScannerInfoProvider configuredProvider = configuredProfile. ScannerInfoProvider configuredProvider = configuredProfile.
getScannerInfoProviderElement(providerId); getScannerInfoProviderElement(providerId);
@ -986,8 +981,7 @@ public class ScannerConfigInfoFactory2 {
autod.setAttribute(SELECTED_PROFILE_ID, selectedProfile); autod.setAttribute(SELECTED_PROFILE_ID, selectedProfile);
autod.setAttribute(PROBLEM_REPORTING_ENABLED, Boolean.toString(problemReportingEnabled)); autod.setAttribute(PROBLEM_REPORTING_ENABLED, Boolean.toString(problemReportingEnabled));
for (Iterator<String> i = profileOptionsMap.keySet().iterator(); i.hasNext();) { for (String profileId : profileOptionsMap.keySet()) {
String profileId = i.next();
ICStorageElement profile = sc.createChild(PROFILE); ICStorageElement profile = sc.createChild(PROFILE);
profile.setAttribute(ID, profileId); profile.setAttribute(ID, profileId);
store(profile, profileOptionsMap.get(profileId)); store(profile, profileOptionsMap.get(profileId));
@ -1133,10 +1127,9 @@ public class ScannerConfigInfoFactory2 {
// get the default value // get the default value
selectedProfile = prefs.getDefaultString(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX); selectedProfile = prefs.getDefaultString(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX);
} }
List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context); List<String> profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context);
profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(profileIds.size()); profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(profileIds.size());
for (Iterator I = profileIds.iterator(); I.hasNext(); ) { for (String profileId : profileIds) {
String profileId = (String) I.next();
ProfileOptions po = new ProfileOptions(); ProfileOptions po = new ProfileOptions();
profileOptionsMap.put(profileId, po); profileOptionsMap.put(profileId, po);
@ -1152,10 +1145,9 @@ public class ScannerConfigInfoFactory2 {
ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
getSCProfileConfiguration(profileId); getSCProfileConfiguration(profileId);
List providerIds = configuredProfile.getSIProviderIds(); List<String> providerIds = configuredProfile.getSIProviderIds();
po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(providerIds.size()); po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(providerIds.size());
for (int i = 0; i < providerIds.size(); ++i) { for (String providerId : providerIds) {
String providerId = (String) providerIds.get(i);
ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions(); ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
po.providerOptionsMap.put(providerId, ppo); po.providerOptionsMap.put(providerId, ppo);
ppo.providerKind = configuredProfile.getScannerInfoProviderElement( ppo.providerKind = configuredProfile.getScannerInfoProviderElement(
@ -1187,9 +1179,7 @@ public class ScannerConfigInfoFactory2 {
set(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX, selectedProfile); set(prefix + SCANNER_CONFIG_SELECTED_PROFILE_ID_SUFFIX, selectedProfile);
set(prefix + SCANNER_CONFIG_PROBLEM_REPORTING_ENABLED_SUFFIX, problemReportingEnabled); set(prefix + SCANNER_CONFIG_PROBLEM_REPORTING_ENABLED_SUFFIX, problemReportingEnabled);
List<String> profileIds = new ArrayList<String>(profileOptionsMap.keySet()); for (String profileId : profileOptionsMap.keySet()) {
for (Iterator<String> I = profileIds.iterator(); I.hasNext(); ) {
String profileId = I.next();
ProfileOptions po = profileOptionsMap.get(profileId); ProfileOptions po = profileOptionsMap.get(profileId);
set(SCD + prefix + profileId + DOT + ENABLED, !useDefaults); set(SCD + prefix + profileId + DOT + ENABLED, !useDefaults);
@ -1199,9 +1189,8 @@ public class ScannerConfigInfoFactory2 {
ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance(). ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
getSCProfileConfiguration(profileId); getSCProfileConfiguration(profileId);
List providerIds = configuredProfile.getSIProviderIds(); List<String> providerIds = configuredProfile.getSIProviderIds();
for (int i = 0; i < providerIds.size(); ++i) { for (String providerId : providerIds) {
String providerId = (String) providerIds.get(i);
ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId); ProfileOptions.ProviderOptions ppo = po.providerOptionsMap.get(providerId);
set(SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_PARSER_ENABLED, set(SCD + prefix + profileId + DOT + providerId + SI_PROVIDER_PARSER_ENABLED,