mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Bug 207851 - [Scanner Discovery] scannerConfigBuildInfo replicated in each Config
This commit is contained in:
parent
b048b41484
commit
741eb6dd08
4 changed files with 241 additions and 180 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
* Copyright (c) 2004, 2011 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* James Blackburn (Broadcom Corp.)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.make.internal.core;
|
package org.eclipse.cdt.make.internal.core;
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||||
scInfo2.setAutoDiscoveryEnabled(true);
|
scInfo2.setAutoDiscoveryEnabled(true);
|
||||||
scInfo2.setProblemReportingEnabled(true);
|
scInfo2.setProblemReportingEnabled(true);
|
||||||
scInfo2.setSelectedProfileId(ScannerConfigProfileManager.DEFAULT_SI_PROFILE_ID);
|
scInfo2.setSelectedProfileId(ScannerConfigProfileManager.DEFAULT_SI_PROFILE_ID);
|
||||||
scInfo2.setBuildOutputFileActionEnabled(false);
|
scInfo2.setBuildOutputFileActionEnabled(true);
|
||||||
scInfo2.setBuildOutputFilePath(""); //$NON-NLS-1$
|
scInfo2.setBuildOutputFilePath(""); //$NON-NLS-1$
|
||||||
scInfo2.setBuildOutputParserEnabled(true);
|
scInfo2.setBuildOutputParserEnabled(true);
|
||||||
String providerId = "specsFile"; //$NON-NLS-1$
|
String providerId = "specsFile"; //$NON-NLS-1$
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -18,8 +18,9 @@ import java.util.HashSet;
|
||||||
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.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
@ -344,15 +345,18 @@ public class ScannerConfigInfoFactory2 {
|
||||||
protected boolean autoDiscoveryEnabled;
|
protected boolean autoDiscoveryEnabled;
|
||||||
protected boolean problemReportingEnabled;
|
protected boolean problemReportingEnabled;
|
||||||
protected String selectedProfile = EMPTY_STRING;
|
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>();
|
||||||
/** Map from profile ID -> ProfileOptions */
|
/** Map from profile ID -> ProfileOptions */
|
||||||
protected Map<String, ProfileOptions> profileOptionsMap;
|
protected Map<String, ProfileOptions> profileOptionsMap = new LinkedHashMap<String, ProfileOptions>();
|
||||||
static class ProfileOptions {
|
static class ProfileOptions implements Cloneable {
|
||||||
protected boolean buildOutputFileActionEnabled;
|
protected boolean buildOutputFileActionEnabled;
|
||||||
protected String buildOutputFilePath = EMPTY_STRING;
|
protected String buildOutputFilePath = EMPTY_STRING;
|
||||||
protected boolean buildOutputParserEnabled;
|
protected boolean buildOutputParserEnabled;
|
||||||
/** Map from provider ID -> providerOptions */
|
/** Map from provider ID -> providerOptions */
|
||||||
protected Map<String, ProviderOptions> providerOptionsMap;
|
protected Map<String, ProviderOptions> providerOptionsMap;
|
||||||
static class ProviderOptions {
|
static class ProviderOptions implements Cloneable {
|
||||||
protected String providerKind; // derived
|
protected String providerKind; // derived
|
||||||
protected boolean providerOutputParserEnabled;
|
protected boolean providerOutputParserEnabled;
|
||||||
protected boolean providerRunUseDefault;
|
protected boolean providerRunUseDefault;
|
||||||
|
@ -372,11 +376,68 @@ public class ScannerConfigInfoFactory2 {
|
||||||
this.providerOpenFilePath = base.providerOpenFilePath;
|
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 + (providerOutputParserEnabled ? 1231 : 1237);
|
||||||
|
result = prime * result
|
||||||
|
+ ((providerRunArguments == null) ? 0 : providerRunArguments.hashCode());
|
||||||
|
result = prime * result
|
||||||
|
+ ((providerRunCommand == null) ? 0 : providerRunCommand.hashCode());
|
||||||
|
result = prime * result + (providerRunUseDefault ? 1231 : 1237);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ProviderOptions other = (ProviderOptions) obj;
|
||||||
|
if (providerKind == null) {
|
||||||
|
if (other.providerKind != null)
|
||||||
|
return false;
|
||||||
|
} else if (!providerKind.equals(other.providerKind))
|
||||||
|
return false;
|
||||||
|
if (providerOpenFilePath == null) {
|
||||||
|
if (other.providerOpenFilePath != null)
|
||||||
|
return false;
|
||||||
|
} else if (!providerOpenFilePath.equals(other.providerOpenFilePath))
|
||||||
|
return false;
|
||||||
|
if (providerOutputParserEnabled != other.providerOutputParserEnabled)
|
||||||
|
return false;
|
||||||
|
if (providerRunArguments == null) {
|
||||||
|
if (other.providerRunArguments != null)
|
||||||
|
return false;
|
||||||
|
} else if (!providerRunArguments.equals(other.providerRunArguments))
|
||||||
|
return false;
|
||||||
|
if (providerRunCommand == null) {
|
||||||
|
if (other.providerRunCommand != null)
|
||||||
|
return false;
|
||||||
|
} else if (!providerRunCommand.equals(other.providerRunCommand))
|
||||||
|
return false;
|
||||||
|
if (providerRunUseDefault != other.providerRunUseDefault)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ProviderOptions clone() throws CloneNotSupportedException {
|
||||||
|
return (ProviderOptions)super.clone();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileOptions(){
|
ProfileOptions(){
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileOptions(ProfileOptions base){
|
ProfileOptions(ProfileOptions base){
|
||||||
this.buildOutputFileActionEnabled = base.buildOutputFileActionEnabled;
|
this.buildOutputFileActionEnabled = base.buildOutputFileActionEnabled;
|
||||||
this.buildOutputFilePath = base.buildOutputFilePath;
|
this.buildOutputFilePath = base.buildOutputFilePath;
|
||||||
|
@ -388,17 +449,68 @@ public class ScannerConfigInfoFactory2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 + (buildOutputParserEnabled ? 1231 : 1237);
|
||||||
|
result = prime * result + ((providerOptionsMap == null) ? 0 : providerOptionsMap.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ProfileOptions other = (ProfileOptions) obj;
|
||||||
|
if (buildOutputFileActionEnabled != other.buildOutputFileActionEnabled)
|
||||||
|
return false;
|
||||||
|
if (buildOutputFilePath == null) {
|
||||||
|
if (other.buildOutputFilePath != null)
|
||||||
|
return false;
|
||||||
|
} else if (!buildOutputFilePath.equals(other.buildOutputFilePath))
|
||||||
|
return false;
|
||||||
|
if (buildOutputParserEnabled != other.buildOutputParserEnabled)
|
||||||
|
return false;
|
||||||
|
if (providerOptionsMap == null) {
|
||||||
|
if (other.providerOptionsMap != null)
|
||||||
|
return false;
|
||||||
|
} else if (!providerOptionsMap.equals(other.providerOptionsMap))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProfileOptions clone() {
|
||||||
|
try {
|
||||||
|
ProfileOptions newProfOpts = (ProfileOptions)super.clone();
|
||||||
|
if (providerOptionsMap != null) {
|
||||||
|
newProfOpts.providerOptionsMap = new LinkedHashMap<String, ProviderOptions>();
|
||||||
|
for (Map.Entry<String, ProviderOptions> e : providerOptionsMap.entrySet())
|
||||||
|
newProfOpts.providerOptionsMap.put(e.getKey(), e.getValue().clone());
|
||||||
|
}
|
||||||
|
return newProfOpts;
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Store() {
|
protected Store() {
|
||||||
isDirty = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Store(Store base, String profileId){
|
protected Store(Store base, String profileId){
|
||||||
this.autoDiscoveryEnabled = base.autoDiscoveryEnabled;
|
this.autoDiscoveryEnabled = base.autoDiscoveryEnabled;
|
||||||
this.problemReportingEnabled = base.problemReportingEnabled;
|
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.profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(base.profileOptionsMap);
|
this.profileOptionsMap.putAll(base.profileOptionsMap);
|
||||||
for (Map.Entry<String, ProfileOptions> entry : profileOptionsMap.entrySet()) {
|
for (Map.Entry<String, ProfileOptions> entry : profileOptionsMap.entrySet()) {
|
||||||
ProfileOptions basePo = entry.getValue();
|
ProfileOptions basePo = entry.getValue();
|
||||||
entry.setValue(new ProfileOptions(basePo));
|
entry.setValue(new ProfileOptions(basePo));
|
||||||
|
@ -406,7 +518,7 @@ public class ScannerConfigInfoFactory2 {
|
||||||
|
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isAutoDiscoveryEnabled()
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isAutoDiscoveryEnabled()
|
||||||
*/
|
*/
|
||||||
|
@ -677,13 +789,17 @@ public class ScannerConfigInfoFactory2 {
|
||||||
// public abstract void store();
|
// public abstract void store();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate buildInfo based on profile configuration
|
* Load defaults for the specified profileId.
|
||||||
|
* Returns a clone() of the default profile matching the passed in profileId
|
||||||
*/
|
*/
|
||||||
protected void loadFromProfileConfiguration(ProfileOptions po, String profileId) {
|
protected static ProfileOptions getDefaultProfile(String profileId) {
|
||||||
ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
|
if (defaultProfiles.containsKey(profileId))
|
||||||
|
return defaultProfiles.get(profileId).clone();
|
||||||
|
|
||||||
|
ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
|
||||||
getSCProfileConfiguration(profileId);
|
getSCProfileConfiguration(profileId);
|
||||||
List<String> providerIds = configuredProfile.getSIProviderIds();
|
|
||||||
|
ProfileOptions po = new ProfileOptions();
|
||||||
po.buildOutputParserEnabled = false;
|
po.buildOutputParserEnabled = false;
|
||||||
po.buildOutputFileActionEnabled = false;
|
po.buildOutputFileActionEnabled = false;
|
||||||
po.buildOutputFilePath = EMPTY_STRING;
|
po.buildOutputFilePath = EMPTY_STRING;
|
||||||
|
@ -696,39 +812,39 @@ public class ScannerConfigInfoFactory2 {
|
||||||
po.buildOutputFilePath = (buildOutputFilePath != null) ? buildOutputFilePath : EMPTY_STRING;
|
po.buildOutputFilePath = (buildOutputFilePath != null) ? buildOutputFilePath : EMPTY_STRING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>(providerIds.size());
|
|
||||||
for (int i = 0; i < providerIds.size(); ++i) {
|
po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>();
|
||||||
|
for (String providerId : configuredProfile.getSIProviderIds()) {
|
||||||
ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
|
ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
|
||||||
String providerId = providerIds.get(i);
|
ScannerInfoProvider configuredProvider = configuredProfile.getScannerInfoProviderElement(providerId);
|
||||||
po.providerOptionsMap.put(providerId, ppo);
|
|
||||||
|
ppo.providerOutputParserEnabled = true;
|
||||||
ppo.providerOutputParserEnabled = (configuredProfile.getScannerInfoProviderElement(providerId) == null) ? false : true;
|
ppo.providerKind = configuredProvider.getProviderKind();
|
||||||
ppo.providerKind = configuredProfile.getScannerInfoProviderElement(providerId).getProviderKind();
|
|
||||||
String attrValue;
|
String attrValue;
|
||||||
if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
|
if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
|
||||||
attrValue = configuredProfile.getScannerInfoProviderElement(providerId).
|
|
||||||
getAction().getAttribute(COMMAND);
|
|
||||||
ppo.providerRunCommand = (attrValue != null) ? attrValue : EMPTY_STRING;
|
|
||||||
attrValue = configuredProfile.getScannerInfoProviderElement(providerId).
|
|
||||||
getAction().getAttribute(ARGUMENTS);
|
|
||||||
ppo.providerRunArguments = (attrValue != null) ? attrValue : EMPTY_STRING;
|
|
||||||
|
|
||||||
ppo.providerRunUseDefault = true;
|
ppo.providerRunUseDefault = true;
|
||||||
}
|
attrValue = configuredProvider.getAction().getAttribute(COMMAND);
|
||||||
else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) {
|
ppo.providerRunCommand = (attrValue != null) ? attrValue : EMPTY_STRING;
|
||||||
attrValue = configuredProfile.getScannerInfoProviderElement(providerId).
|
attrValue = configuredProvider.getAction().getAttribute(ARGUMENTS);
|
||||||
getAction().getAttribute("file");//$NON-NLS-1$
|
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;
|
ppo.providerOpenFilePath = (attrValue != null) ? attrValue : EMPTY_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
po.providerOptionsMap.put(providerId, ppo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaultProfiles.put(profileId, po);
|
||||||
|
return po.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build properties stored in .cdtproject file
|
* Build properties stored in .cproject file
|
||||||
*
|
*
|
||||||
* @author vhirsl
|
* Responsible for both load and store. Doesn't store profile settings if they're identical to the default.
|
||||||
*/
|
*/
|
||||||
private static class BuildProperty extends Store {
|
private static class BuildProperty extends Store {
|
||||||
private IProject project;
|
private IProject project;
|
||||||
|
@ -765,94 +881,42 @@ public class ScannerConfigInfoFactory2 {
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load()
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load()
|
||||||
*/
|
*/
|
||||||
protected void load(ICStorageElement element) {
|
protected void load(ICStorageElement element) {
|
||||||
// ICDescriptor descriptor;
|
|
||||||
List<String> profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context);
|
List<String> profileIds = ScannerConfigProfileManager.getInstance().getProfileIds(context);
|
||||||
List<String> loadedProfiles = new ArrayList<String>();
|
|
||||||
// try {
|
// Load the default profiles
|
||||||
// descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
for (String profileId : profileIds)
|
||||||
for (ICStorageElement sc : element.getChildren()) {
|
profileOptionsMap.put(profileId, getDefaultProfile(profileId));
|
||||||
if (sc.getName().equals(SC_AUTODISCOVERY)) {
|
|
||||||
autoDiscoveryEnabled = Boolean.valueOf(
|
boolean performMigration = true;
|
||||||
sc.getAttribute(ENABLED)).booleanValue();
|
|
||||||
selectedProfile = (profileId == ScannerConfigProfileManager.NULL_PROFILE_ID)
|
// Now load the profiles from the .cproject
|
||||||
? sc.getAttribute(SELECTED_PROFILE_ID)
|
for (ICStorageElement sc : element.getChildren()) {
|
||||||
: profileId;
|
if (sc.getName().equals(SC_AUTODISCOVERY)) {
|
||||||
problemReportingEnabled = Boolean.valueOf(
|
autoDiscoveryEnabled = Boolean.valueOf(
|
||||||
sc.getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue();
|
sc.getAttribute(ENABLED)).booleanValue();
|
||||||
}
|
selectedProfile = (profileId == ScannerConfigProfileManager.NULL_PROFILE_ID)
|
||||||
else if (sc.getName().equals(PROFILE)) {
|
? sc.getAttribute(SELECTED_PROFILE_ID)
|
||||||
if (profileIds.contains(sc.getAttribute(ID))) {
|
: profileId;
|
||||||
loadProfile(sc);
|
problemReportingEnabled = Boolean.valueOf(
|
||||||
loadedProfiles.add(sc.getAttribute(ID));
|
sc.getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue();
|
||||||
}
|
performMigration = false;
|
||||||
|
} else if (sc.getName().equals(PROFILE)) {
|
||||||
|
if (profileIds.contains(sc.getAttribute(ID))) {
|
||||||
|
loadProfile(sc);
|
||||||
}
|
}
|
||||||
|
performMigration = false;
|
||||||
}
|
}
|
||||||
if (loadedProfiles.size() < 1) {
|
}
|
||||||
// No ScannerConfigDiscovery entry, try old project location - .project
|
|
||||||
if (migrateScannerConfigBuildInfo(ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID)) {
|
if (performMigration) {
|
||||||
loadedProfiles.add(ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID);
|
// No ScannerConfigDiscovery entry, try old project location - .project
|
||||||
}
|
if (!migrateScannerConfigBuildInfo(ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID)) {
|
||||||
else {
|
// disable autodiscovery
|
||||||
// disable autodiscovery
|
autoDiscoveryEnabled = false;
|
||||||
autoDiscoveryEnabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (loadedProfiles.size() < profileIds.size()) {
|
|
||||||
// initialize remaining profiles with default values
|
|
||||||
for (String profileId : profileIds) {
|
|
||||||
if (!loadedProfiles.contains(profileId)) {
|
|
||||||
loadDefaults(profileId);
|
|
||||||
loadedProfiles.add(profileId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// // store migrated data
|
|
||||||
// isDirty = true;
|
|
||||||
// store();
|
|
||||||
// save();
|
|
||||||
}
|
}
|
||||||
// } catch (CoreException e) {
|
}
|
||||||
// MakeCorePlugin.log(e);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load profile defaults
|
|
||||||
*/
|
|
||||||
private void loadDefaults(String profileId) {
|
|
||||||
ProfileOptions po = new ProfileOptions();
|
|
||||||
po.buildOutputFileActionEnabled = false;
|
|
||||||
po.buildOutputParserEnabled = true;
|
|
||||||
|
|
||||||
ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
|
|
||||||
getSCProfileConfiguration(profileId);
|
|
||||||
|
|
||||||
po.providerOptionsMap = new LinkedHashMap<String, ProfileOptions.ProviderOptions>();
|
|
||||||
|
|
||||||
List<String> providerIds = configuredProfile.getSIProviderIds();
|
|
||||||
for (String providerId : providerIds) {
|
|
||||||
ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
|
|
||||||
ScannerInfoProvider configuredProvider = configuredProfile.
|
|
||||||
getScannerInfoProviderElement(providerId);
|
|
||||||
ppo.providerKind = configuredProvider.getProviderKind();
|
|
||||||
ppo.providerOutputParserEnabled = false;
|
|
||||||
if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
|
|
||||||
ppo.providerRunUseDefault = true;
|
|
||||||
ppo.providerRunCommand = configuredProvider.getAction().getAttribute(COMMAND);
|
|
||||||
ppo.providerRunArguments = configuredProvider.getAction().getAttribute(ARGUMENTS);
|
|
||||||
}
|
|
||||||
else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) {
|
|
||||||
ppo.providerOpenFilePath = configuredProvider.getAction().getAttribute("file");//$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
po.providerOptionsMap.put(providerId, ppo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profileOptionsMap == null) {
|
|
||||||
profileOptionsMap = new LinkedHashMap<String, ProfileOptions>();
|
|
||||||
}
|
|
||||||
profileOptionsMap.put(profileId, po);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean migrateScannerConfigBuildInfo(String profileId) {
|
private boolean migrateScannerConfigBuildInfo(String profileId) {
|
||||||
boolean rc = true;
|
boolean rc = true;
|
||||||
try {
|
try {
|
||||||
|
@ -896,9 +960,6 @@ public class ScannerConfigInfoFactory2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadProfile(ICStorageElement profile) {
|
private void loadProfile(ICStorageElement profile) {
|
||||||
if (profileOptionsMap == null) {
|
|
||||||
profileOptionsMap = new LinkedHashMap<String, ProfileOptions>(1);
|
|
||||||
}
|
|
||||||
ProfileOptions po = new ProfileOptions();
|
ProfileOptions po = new ProfileOptions();
|
||||||
String profileId = profile.getAttribute(ID);
|
String profileId = profile.getAttribute(ID);
|
||||||
profileOptionsMap.put(profileId, po);
|
profileOptionsMap.put(profileId, po);
|
||||||
|
@ -960,30 +1021,30 @@ public class ScannerConfigInfoFactory2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void store(ICStorageElement sc)/* throws CoreException */{
|
/**
|
||||||
// if (isDirty || force) {
|
* Store the contents of the scanner discovery profiles into the ICStorageElement
|
||||||
// ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true);
|
* @param sc storage element in which to persist the settings.
|
||||||
// Element sc = descriptor.getProjectData(SCANNER_CONFIG);
|
*/
|
||||||
|
private void store(ICStorageElement sc) {
|
||||||
|
// Clear children
|
||||||
|
for (ICStorageElement child : sc.getChildren())
|
||||||
|
sc.removeChild(child);
|
||||||
|
|
||||||
// Clear children
|
ICStorageElement autod = sc.createChild(SC_AUTODISCOVERY);
|
||||||
for (ICStorageElement child : sc.getChildren())
|
autod.setAttribute(ENABLED, Boolean.toString(autoDiscoveryEnabled));
|
||||||
sc.removeChild(child);
|
autod.setAttribute(SELECTED_PROFILE_ID, selectedProfile);
|
||||||
|
autod.setAttribute(PROBLEM_REPORTING_ENABLED, Boolean.toString(problemReportingEnabled));
|
||||||
|
|
||||||
ICStorageElement autod = sc.createChild(SC_AUTODISCOVERY);
|
for (Map.Entry<String, ProfileOptions> entry : profileOptionsMap.entrySet()) {
|
||||||
autod.setAttribute(ENABLED, Boolean.toString(autoDiscoveryEnabled));
|
// If this profile is identical to the default, then no need to store
|
||||||
autod.setAttribute(SELECTED_PROFILE_ID, selectedProfile);
|
if (entry.getValue().equals(defaultProfiles.get(entry.getKey())))
|
||||||
autod.setAttribute(PROBLEM_REPORTING_ENABLED, Boolean.toString(problemReportingEnabled));
|
continue;
|
||||||
|
ICStorageElement profile = sc.createChild(PROFILE);
|
||||||
|
profile.setAttribute(ID, entry.getKey());
|
||||||
|
store(profile, entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
for (String profileId : profileOptionsMap.keySet()) {
|
isDirty = false;
|
||||||
ICStorageElement profile = sc.createChild(PROFILE);
|
|
||||||
profile.setAttribute(ID, profileId);
|
|
||||||
store(profile, profileOptionsMap.get(profileId));
|
|
||||||
}
|
|
||||||
|
|
||||||
isDirty = false;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1120,10 +1181,10 @@ public class ScannerConfigInfoFactory2 {
|
||||||
for (String profileId : profileIds) {
|
for (String profileId : profileIds) {
|
||||||
ProfileOptions po = new ProfileOptions();
|
ProfileOptions po = new ProfileOptions();
|
||||||
profileOptionsMap.put(profileId, po);
|
profileOptionsMap.put(profileId, po);
|
||||||
|
|
||||||
boolean profileStored = getBoolean(SCD + prefix + profileId + DOT + ENABLED);
|
boolean profileStored = getBoolean(SCD + prefix + profileId + DOT + ENABLED);
|
||||||
if (!profileStored && !useDefaults) {
|
if (!profileStored && !useDefaults) {
|
||||||
loadFromProfileConfiguration(po, profileId);
|
profileOptionsMap.put(profileId, getDefaultProfile(profileId));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2010 Intel Corporation and others.
|
* Copyright (c) 2007, 2011 Intel Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.core;
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -56,11 +55,13 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
import com.ibm.icu.text.MessageFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concrete ICDescriptor for a Project.
|
* Concrete ICDescriptor for a Project.
|
||||||
*
|
*
|
||||||
* There is only one of these per project. Settings are serialized into all the
|
* There is only one of these per project. Settings are serialized as storage elements
|
||||||
* ICConfigurationDescriptions of the project. Methods which change or access data
|
* as children of the root of the project description. Methods which change or access data
|
||||||
* on the descriptor use the Eclipse ILock 'fLock' on the given descriptor instance.
|
* on the descriptor use the Eclipse ILock 'fLock' on the given descriptor instance.
|
||||||
*
|
*
|
||||||
* Structural changes made to extension elements are persisted immediately to
|
* Structural changes made to extension elements are persisted immediately to
|
||||||
|
@ -434,7 +435,12 @@ final public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
// Check if the storage element already exists in our local map
|
// Check if the storage element already exists in our local map
|
||||||
SynchronizedStorageElement storageEl = fStorageDataElMap.get(id);
|
SynchronizedStorageElement storageEl = fStorageDataElMap.get(id);
|
||||||
if(storageEl == null){
|
if(storageEl == null){
|
||||||
ICStorageElement el = fCfgDes.getStorage(id, true);
|
// Check in the Proejct Description
|
||||||
|
ICStorageElement el = fCfgDes.getProjectDescription().getStorage(id, false);
|
||||||
|
|
||||||
|
// Fall-back to checking in the configuration (which is how it used ot be)
|
||||||
|
if (el == null)
|
||||||
|
el = fCfgDes.getStorage(id, true);
|
||||||
try {
|
try {
|
||||||
el = el.createCopy();
|
el = el.createCopy();
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
|
@ -461,7 +467,9 @@ final public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
SynchronizedStorageElement storageEl = fStorageDataElMap.get(id);
|
SynchronizedStorageElement storageEl = fStorageDataElMap.get(id);
|
||||||
ICStorageElement el;
|
ICStorageElement el;
|
||||||
if(storageEl == null) {
|
if(storageEl == null) {
|
||||||
el = fCfgDes.getStorage(id, true);
|
el = fCfgDes.getProjectDescription().getStorage(id, false);
|
||||||
|
if (el == null)
|
||||||
|
el = fCfgDes.getStorage(id, true);
|
||||||
try {
|
try {
|
||||||
el = el.createCopy();
|
el = el.createCopy();
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
|
@ -697,7 +705,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
* @param des
|
* @param des
|
||||||
* @return boolean indicating whether changes were made
|
* @return boolean indicating whether changes were made
|
||||||
*/
|
*/
|
||||||
public static boolean reconcile(CConfigBasedDescriptor descriptor, ICProjectDescription des){
|
public static boolean reconcile(CConfigBasedDescriptor descriptor, ICProjectDescription des) throws CoreException {
|
||||||
try {
|
try {
|
||||||
descriptor.fLock.acquire();
|
descriptor.fLock.acquire();
|
||||||
|
|
||||||
|
@ -726,44 +734,36 @@ final public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean reconcile(String id, ICStorageElement newStorEl, ICProjectDescription des) {
|
private static boolean reconcile(String id, ICStorageElement newStorEl, ICProjectDescription des) throws CoreException {
|
||||||
ICConfigurationDescription cfgs[] = des.getConfigurations();
|
ICStorageElement storEl = des.getStorage(id, false);
|
||||||
boolean reconciled = false;
|
|
||||||
|
|
||||||
for(int i = 0; i < cfgs.length; i++){
|
|
||||||
try {
|
|
||||||
if(reconcile(id, newStorEl, cfgs[i]))
|
|
||||||
reconciled = true;
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return reconciled;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean reconcile(String id, ICStorageElement newStorEl, ICConfigurationDescription cfg) throws CoreException{
|
|
||||||
CConfigurationSpecSettings setting = ((IInternalCCfgInfo)cfg).getSpecSettings();
|
|
||||||
ICStorageElement storEl = setting.getStorage(id, false);
|
|
||||||
|
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
|
|
||||||
if(storEl != null){
|
if(storEl != null){
|
||||||
if(newStorEl == null){
|
if(newStorEl == null){
|
||||||
setting.removeStorage(id);
|
des.removeStorage(id);
|
||||||
modified = true;
|
modified = true;
|
||||||
} else {
|
} else {
|
||||||
if(!newStorEl.equals(storEl)){
|
if(!newStorEl.equals(storEl)){
|
||||||
setting.importStorage(id, newStorEl);
|
des.importStorage(id, newStorEl);
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(newStorEl != null){
|
if(newStorEl != null){
|
||||||
setting.importStorage(id, newStorEl);
|
des.importStorage(id, newStorEl);
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now storing the descriptor info directly in the Project Description.
|
||||||
|
// Ensure that the setting is no longer stored in all the configurations
|
||||||
|
for (ICConfigurationDescription cfgDes : des.getConfigurations()) {
|
||||||
|
ICStorageElement el = cfgDes.getStorage(id, false);
|
||||||
|
if (el != null)
|
||||||
|
cfgDes.removeStorage(id);
|
||||||
|
}
|
||||||
|
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2010 Intel Corporation and others.
|
* Copyright (c) 2007, 2011 Intel Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -56,8 +56,7 @@ import org.eclipse.core.runtime.Status;
|
||||||
/**
|
/**
|
||||||
* CConfigBasedDescriptorManager
|
* CConfigBasedDescriptorManager
|
||||||
*
|
*
|
||||||
* ICDescriptor settings are set on all the ICConfigurationDescriptions in the
|
* ICDescriptor settings are set directly within the project description.
|
||||||
* project's "org.eclipse.core.cdt.settings" storageModule.
|
|
||||||
*
|
*
|
||||||
* The ICDescriptorManager can be used to fetch the current ICDescriptor
|
* The ICDescriptorManager can be used to fetch the current ICDescriptor
|
||||||
* for the project get and set settings in this module in a safe manner.
|
* for the project get and set settings in this module in a safe manner.
|
||||||
|
@ -72,7 +71,7 @@ import org.eclipse.core.runtime.Status;
|
||||||
* Usage:
|
* Usage:
|
||||||
* Users should consider making changes to project ICDescriptors using an {@link ICDescriptorOperation}
|
* Users should consider making changes to project ICDescriptors using an {@link ICDescriptorOperation}
|
||||||
* with the {@link #runDescriptorOperation} method.
|
* with the {@link #runDescriptorOperation} method.
|
||||||
* The ICDescriptor's returned for {@link #getDescriptor} are shared between multiple thread,
|
* The ICDescriptor's returned for {@link #getDescriptor} are shared between multiple threads,
|
||||||
* but they are synchronized. This is safe as long as structural changes aren't made to the same
|
* but they are synchronized. This is safe as long as structural changes aren't made to the same
|
||||||
* project storage element from multiple threads.
|
* project storage element from multiple threads.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue