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

Bug #222562 : Regression in per-resource build option settings

This commit is contained in:
Oleg Krasilnikov 2008-03-13 17:29:04 +00:00
parent 69bcea9658
commit b90fa70285
2 changed files with 130 additions and 256 deletions

View file

@ -204,7 +204,7 @@ public class ManagedBuildManager extends AbstractCExtension {
// Tool-chains defined in the manifest files // Tool-chains defined in the manifest files
private static SortedMap extensionToolChainMap; private static SortedMap extensionToolChainMap;
// Tools defined in the manifest files // Tools defined in the manifest files
private static SortedMap extensionToolMap; private static SortedMap<String, Tool> extensionToolMap;
// Target Platforms defined in the manifest files // Target Platforms defined in the manifest files
private static Map extensionTargetPlatformMap; private static Map extensionTargetPlatformMap;
// Builders defined in the manifest files // Builders defined in the manifest files
@ -440,13 +440,13 @@ public class ManagedBuildManager extends AbstractCExtension {
* *
* @return Map * @return Map
*/ */
public static SortedMap getExtensionToolMap() { public static SortedMap<String, Tool> getExtensionToolMap() {
try { try {
loadExtensions(); loadExtensions();
} catch (BuildException e) { } catch (BuildException e) {
} }
if (extensionToolMap == null) { if (extensionToolMap == null) {
extensionToolMap = new TreeMap(); extensionToolMap = new TreeMap<String, Tool>();
} }
return extensionToolMap; return extensionToolMap;
} }
@ -457,9 +457,9 @@ public class ManagedBuildManager extends AbstractCExtension {
} catch (BuildException e) { } catch (BuildException e) {
} }
if (extensionToolMap == null) { if (extensionToolMap == null) {
extensionToolMap = new TreeMap(); extensionToolMap = new TreeMap<String, Tool>();
} }
return (Tool[])extensionToolMap.values().toArray(new Tool[extensionToolMap.size()]); return extensionToolMap.values().toArray(new Tool[extensionToolMap.size()]);
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -14,7 +14,6 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -119,13 +118,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
private Map<String, InputType> inputTypeMap; private Map<String, InputType> inputTypeMap;
private Vector<OutputType> outputTypeList; private Vector<OutputType> outputTypeList;
private Map<String, OutputType> outputTypeMap; private Map<String, OutputType> outputTypeMap;
private List envVarBuildPathList; private List<IEnvVarBuildPath> envVarBuildPathList;
// Managed Build model attributes // Managed Build model attributes
private String unusedChildren; private String unusedChildren;
private Boolean isAbstract; private Boolean isAbstract;
private String command; private String command;
private List<String> inputExtensions; private List<String> inputExtensions;
private List interfaceExtensions; private List<String> interfaceExtensions;
private Integer natureFilter; private Integer natureFilter;
private String outputExtensions; private String outputExtensions;
private String outputFlag; private String outputFlag;
@ -156,10 +155,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
private boolean rebuildState; private boolean rebuildState;
private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator; private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
private HashMap typeToDataMap = new HashMap(2); private HashMap<IInputType, CLanguageData> typeToDataMap = new HashMap<IInputType, CLanguageData>(2);
private boolean fDataMapInited; private boolean fDataMapInited;
private List identicalList; private List identicalList;
private HashMap discoveredInfoMap = new HashMap(2); private HashMap<Object, PathInfoCache> discoveredInfoMap = new HashMap<Object, PathInfoCache>(2);
private String scannerConfigDiscoveryProfileId; private String scannerConfigDiscoveryProfileId;
/* /*
@ -360,6 +359,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
setSuperClassInternal(toolSuperClass); setSuperClassInternal(toolSuperClass);
} }
@SuppressWarnings("unchecked")
public Tool(IBuildObject parent, String toolSuperClassId, String Id, String name, Tool tool){ public Tool(IBuildObject parent, String toolSuperClassId, String Id, String name, Tool tool){
super(resolvedDefault); super(resolvedDefault);
this.parent = parent; this.parent = parent;
@ -404,10 +404,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
commandLinePattern = new String(tool.commandLinePattern); commandLinePattern = new String(tool.commandLinePattern);
} }
if (tool.inputExtensions != null) { if (tool.inputExtensions != null) {
inputExtensions = new ArrayList(tool.inputExtensions); inputExtensions = new ArrayList<String>(tool.inputExtensions);
} }
if (tool.interfaceExtensions != null) { if (tool.interfaceExtensions != null) {
interfaceExtensions = new ArrayList(tool.interfaceExtensions); interfaceExtensions = new ArrayList<String>(tool.interfaceExtensions);
} }
if (tool.natureFilter != null) { if (tool.natureFilter != null) {
natureFilter = new Integer(tool.natureFilter.intValue()); natureFilter = new Integer(tool.natureFilter.intValue());
@ -441,7 +441,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
optionPathConverter = tool.optionPathConverter ; optionPathConverter = tool.optionPathConverter ;
if(tool.envVarBuildPathList != null) if(tool.envVarBuildPathList != null)
envVarBuildPathList = new ArrayList(tool.envVarBuildPathList); envVarBuildPathList = new ArrayList<IEnvVarBuildPath>(tool.envVarBuildPathList);
// tool.updateScannerInfoSettingsToInputTypes(); // tool.updateScannerInfoSettingsToInputTypes();
@ -449,10 +449,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
super.copyChildren(tool); super.copyChildren(tool);
// Clone the children // Clone the children
if (tool.inputTypeList != null) { if (tool.inputTypeList != null) {
discoveredInfoMap = (HashMap)tool.discoveredInfoMap.clone(); discoveredInfoMap = (HashMap<Object, PathInfoCache>)tool.discoveredInfoMap.clone();
Iterator iter = tool.getInputTypeList().listIterator(); for (InputType inputType : tool.getInputTypeList()) {
while (iter.hasNext()) {
InputType inputType = (InputType) iter.next();
PathInfoCache cache = (PathInfoCache)discoveredInfoMap.remove(getTypeKey(inputType)); PathInfoCache cache = (PathInfoCache)discoveredInfoMap.remove(getTypeKey(inputType));
int nnn = ManagedBuildManager.getRandomNumber(); int nnn = ManagedBuildManager.getRandomNumber();
String subId; String subId;
@ -472,9 +470,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
} }
if (tool.outputTypeList != null) { if (tool.outputTypeList != null) {
Iterator iter = tool.getOutputTypeList().listIterator(); for (OutputType outputType : tool.getOutputTypeList()) {
while (iter.hasNext()) {
OutputType outputType = (OutputType) iter.next();
int nnn = ManagedBuildManager.getRandomNumber(); int nnn = ManagedBuildManager.getRandomNumber();
String subId; String subId;
String subName; String subName;
@ -535,10 +531,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
commandLinePattern = tool.commandLinePattern; commandLinePattern = tool.commandLinePattern;
} }
if (inputExtensions == null && tool.inputExtensions != null) { if (inputExtensions == null && tool.inputExtensions != null) {
inputExtensions = new ArrayList(tool.inputExtensions); inputExtensions = new ArrayList<String>(tool.inputExtensions);
} }
if (interfaceExtensions == null && tool.interfaceExtensions != null) { if (interfaceExtensions == null && tool.interfaceExtensions != null) {
interfaceExtensions = new ArrayList(tool.interfaceExtensions); interfaceExtensions = new ArrayList<String>(tool.interfaceExtensions);
} }
if (natureFilter == null) { if (natureFilter == null) {
natureFilter = tool.natureFilter; natureFilter = tool.natureFilter;
@ -580,15 +576,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
optionPathConverter = tool.optionPathConverter ; optionPathConverter = tool.optionPathConverter ;
if(envVarBuildPathList == null && tool.envVarBuildPathList != null) if(envVarBuildPathList == null && tool.envVarBuildPathList != null)
envVarBuildPathList = new ArrayList(tool.envVarBuildPathList); envVarBuildPathList = new ArrayList<IEnvVarBuildPath>(tool.envVarBuildPathList);
// Clone the children in superclass // Clone the children in superclass
super.copyNonoverriddenSettings(tool); super.copyNonoverriddenSettings(tool);
// Clone the children // Clone the children
if (inputTypeList == null && tool.inputTypeList != null) { if (inputTypeList == null && tool.inputTypeList != null) {
Iterator iter = tool.getInputTypeList().listIterator(); for (InputType inputType : tool.getInputTypeList()) {
while (iter.hasNext()) {
InputType inputType = (InputType) iter.next();
int nnn = ManagedBuildManager.getRandomNumber(); int nnn = ManagedBuildManager.getRandomNumber();
String subId; String subId;
String subName; String subName;
@ -604,9 +598,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
} }
if (outputTypeList == null && tool.outputTypeList != null) { if (outputTypeList == null && tool.outputTypeList != null) {
Iterator iter = tool.getOutputTypeList().listIterator(); for (OutputType outputType : tool.getOutputTypeList()) {
while (iter.hasNext()) {
OutputType outputType = (OutputType) iter.next();
int nnn = ManagedBuildManager.getRandomNumber(); int nnn = ManagedBuildManager.getRandomNumber();
String subId; String subId;
String subName; String subName;
@ -702,7 +694,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (headers != null) { if (headers != null) {
StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR); StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
while (tokenizer.hasMoreElements()) { while (tokenizer.hasMoreElements()) {
getInterfaceExtensionsList().add(tokenizer.nextElement()); getInterfaceExtensionsList().add((String)tokenizer.nextElement());
} }
} }
@ -867,7 +859,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (headers != null) { if (headers != null) {
StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR); StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
while (tokenizer.hasMoreElements()) { while (tokenizer.hasMoreElements()) {
getInterfaceExtensionsList().add(tokenizer.nextElement()); getInterfaceExtensionsList().add((String)tokenizer.nextElement());
} }
} }
} }
@ -1013,10 +1005,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
// input file extensions // input file extensions
if (getInputExtensionsList().size() > 0) { if (getInputExtensionsList().size() > 0) {
String inputs; Iterator<String> iter = getInputExtensionsList().listIterator();
List list = getInputExtensionsList(); String inputs = iter.next();
Iterator iter = list.listIterator();
inputs = (String)iter.next();
while (iter.hasNext()) { while (iter.hasNext()) {
inputs += DEFAULT_SEPARATOR; inputs += DEFAULT_SEPARATOR;
inputs += iter.next(); inputs += iter.next();
@ -1026,10 +1016,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
// interface (header file) extensions // interface (header file) extensions
if (getInterfaceExtensionsList().size() > 0) { if (getInterfaceExtensionsList().size() > 0) {
String headers; Iterator<String> iter = getInterfaceExtensionsList().listIterator();
List list = getInterfaceExtensionsList(); String headers = iter.next();
Iterator iter = list.listIterator();
headers = (String)iter.next();
while (iter.hasNext()) { while (iter.hasNext()) {
headers += DEFAULT_SEPARATOR; headers += DEFAULT_SEPARATOR;
headers += iter.next(); headers += iter.next();
@ -1081,23 +1069,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
super.serialize(element); super.serialize(element);
// Serialize my children // Serialize my children
// updateScannerInfoSettingsToInputTypes(); for (InputType type : getInputTypeList())
type.serialize(element.createChild(INPUT_TYPE));
Iterator iter;
List typeElements = getInputTypeList(); for (OutputType type : getOutputTypeList())
iter = typeElements.listIterator(); type.serialize(element.createChild(OUTPUT_TYPE));
while (iter.hasNext()) {
InputType type = (InputType) iter.next();
ICStorageElement typeElement = element.createChild(INPUT_TYPE);
type.serialize(typeElement);
}
typeElements = getOutputTypeList();
iter = typeElements.listIterator();
while (iter.hasNext()) {
OutputType type = (OutputType) iter.next();
ICStorageElement typeElement = element.createChild(OUTPUT_TYPE);
type.serialize(typeElement);
}
// Note: command line generator cannot be specified in a project file because // Note: command line generator cannot be specified in a project file because
// an IConfigurationElement is needed to load it! // an IConfigurationElement is needed to load it!
@ -1133,34 +1109,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
// TODO: issue an error message // TODO: issue an error message
} }
} }
// private void updateScannerInfoSettingsToInputTypes(){
// if(isExtensionTool)
// return;
//
// HashMap scannerCfgMap = getScannerInfoMap(false);
// if(scannerCfgMap != null){
// scannerCfgMap = (HashMap)scannerCfgMap.clone();
// for(Iterator iter = scannerCfgMap.entrySet().iterator(); iter.hasNext();){
// Map.Entry entry = (Map.Entry)iter.next();
// String id = (String)entry.getKey();
// InputType type = (InputType)getInputTypeById(id);
// if(type == null)
// continue;
//
// ScannerConfigInfoFactory2.BuildProperty info = (ScannerConfigInfoFactory2.BuildProperty)entry.getValue();
// if(info.isDirty()){
// if(type.isExtensionElement()){
// type = (InputType)getEdtableInputType(type);
// }
// type.setScannerConfigBuilderInfo(info);
// } else {
// if(type.getScannerConfigBuilderInfoElement(false) != null)
// type.setScannerConfigBuilderInfo(info);
// }
// }
// }
// }
/* /*
* P A R E N T A N D C H I L D H A N D L I N G * P A R E N T A N D C H I L D H A N D L I N G
@ -1201,15 +1149,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
data.updateInputType(type); data.updateInputType(type);
typeToDataMap.put(type, data); typeToDataMap.put(type, data);
} }
// HashMap scannerInfoMap = getScannerInfoMap(false);
// if(scannerInfoMap != null){
// IScannerConfigBuilderInfo2 info = (IScannerConfigBuilderInfo2)scannerInfoMap.get(getTypeKey(superClass));
// if(info != null){
// info = ScannerConfigInfoFactory2.create(new CfgInfoContext(getParentResourceInfo(), this, type), info, info.getSelectedProfileId());
// scannerInfoMap.put(getTypeKey(type), info);
// }
// }
} }
addInputType(type); addInputType(type);
setDirty(true); setDirty(true);
@ -1241,7 +1180,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
types = ((Tool)getSuperClass()).getAllInputTypes(); types = ((Tool)getSuperClass()).getAllInputTypes();
} }
// Our options take precedence. // Our options take precedence.
Vector ourTypes = getInputTypeList(); Vector<InputType> ourTypes = getInputTypeList();
if (types != null) { if (types != null) {
for (int i = 0; i < ourTypes.size(); i++) { for (int i = 0; i < ourTypes.size(); i++) {
IInputType ourType = (IInputType)ourTypes.get(i); IInputType ourType = (IInputType)ourTypes.get(i);
@ -1268,15 +1207,15 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
} }
} else { } else {
types = (IInputType[])ourTypes.toArray(new IInputType[ourTypes.size()]); types = ourTypes.toArray(new IInputType[ourTypes.size()]);
} }
return types; return types;
} }
private boolean hasInputTypes() { private boolean hasInputTypes() {
Vector ourTypes = getInputTypeList(); if (getInputTypeList().size() > 0)
if (ourTypes.size() > 0) return true; return true;
return false; return false;
} }
@ -1334,7 +1273,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
types = ((Tool)getSuperClass()).getAllOutputTypes(); types = ((Tool)getSuperClass()).getAllOutputTypes();
} }
// Our options take precedence. // Our options take precedence.
Vector ourTypes = getOutputTypeList(); Vector<OutputType> ourTypes = getOutputTypeList();
if (types != null) { if (types != null) {
for (int i = 0; i < ourTypes.size(); i++) { for (int i = 0; i < ourTypes.size(); i++) {
IOutputType ourType = (IOutputType)ourTypes.get(i); IOutputType ourType = (IOutputType)ourTypes.get(i);
@ -1357,7 +1296,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
} }
} else { } else {
types = (IOutputType[])ourTypes.toArray(new IOutputType[ourTypes.size()]); types = ourTypes.toArray(new IOutputType[ourTypes.size()]);
} }
return types; return types;
} }
@ -1791,10 +1730,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (exts.length > 0) return exts; if (exts.length > 0) return exts;
} }
// If none, use the input extensions specified for the Tool (backwards compatibility) // If none, use the input extensions specified for the Tool (backwards compatibility)
List extsList = getInputExtensionsAttribute(); List<String> extsList = getInputExtensionsAttribute();
// Use the first entry in the list // Use the first entry in the list
if (extsList != null && extsList.size() > 0) { if (extsList != null && extsList.size() > 0) {
return (String[])extsList.toArray(new String[extsList.size()]); return extsList.toArray(new String[extsList.size()]);
} }
return EMPTY_STRING_ARRAY; return EMPTY_STRING_ARRAY;
} }
@ -1803,32 +1742,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
* @see org.eclipse.cdt.managedbuilder.core.ITool#getAllInputExtensions() * @see org.eclipse.cdt.managedbuilder.core.ITool#getAllInputExtensions()
*/ */
public String[] getAllInputExtensions() { public String[] getAllInputExtensions() {
// IInputType[] types = getInputTypes();
// if (types != null && types.length > 0) {
// List allExts = new ArrayList();
// for (int i=0; i<types.length; i++) {
// String[] exts = types[i].getSourceExtensions(this);
// for (int j=0; j<exts.length; j++) {
// allExts.add(exts[j]);
// }
// }
// if (allExts.size() > 0) {
// return (String[])allExts.toArray(new String[allExts.size()]);
// }
// }
// // If none, use the input extensions specified for the Tool (backwards compatibility)
// List extsList = getInputExtensionsAttribute();
// if (extsList != null && extsList.size() > 0) {
// return (String[])extsList.toArray(new String[extsList.size()]);
// }
// return EMPTY_STRING_ARRAY;
return getAllInputExtensions(getProject()); return getAllInputExtensions(getProject());
} }
public String[] getAllInputExtensions(IProject project) { public String[] getAllInputExtensions(IProject project) {
IInputType[] types = getInputTypes(); IInputType[] types = getInputTypes();
if (types != null && types.length > 0) { if (types != null && types.length > 0) {
List allExts = new ArrayList(); List<String> allExts = new ArrayList<String>();
for (int i=0; i<types.length; i++) { for (int i=0; i<types.length; i++) {
String[] exts = ((InputType)types[i]).getSourceExtensions(this, project); String[] exts = ((InputType)types[i]).getSourceExtensions(this, project);
for (int j=0; j<exts.length; j++) { for (int j=0; j<exts.length; j++) {
@ -1836,13 +1756,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
} }
if (allExts.size() > 0) { if (allExts.size() > 0) {
return (String[])allExts.toArray(new String[allExts.size()]); return allExts.toArray(new String[allExts.size()]);
} }
} }
// If none, use the input extensions specified for the Tool (backwards compatibility) // If none, use the input extensions specified for the Tool (backwards compatibility)
List extsList = getInputExtensionsAttribute(); List<String> extsList = getInputExtensionsAttribute();
if (extsList != null && extsList.size() > 0) { if (extsList != null && extsList.size() > 0) {
return (String[])extsList.toArray(new String[extsList.size()]); return extsList.toArray(new String[extsList.size()]);
} }
return EMPTY_STRING_ARRAY; return EMPTY_STRING_ARRAY;
} }
@ -1886,24 +1806,24 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.ITool#getAdditionalDependencies() * @see org.eclipse.cdt.managedbuilder.core.ITool#getAdditionalDependencies()
*/ */
@SuppressWarnings("unchecked")
public IPath[] getAdditionalDependencies() { public IPath[] getAdditionalDependencies() {
List allDeps = new ArrayList(); List<IPath> allDeps = new ArrayList<IPath>();
IInputType[] types = getInputTypes(); IInputType[] types = getInputTypes();
for (int i=0; i<types.length; i++) { for (int i=0; i<types.length; i++) {
IInputType type = types[i]; IInputType type = types[i];
// Additional dependencies come from 2 places. // Additional dependencies come from 2 places.
// 1. From AdditionalInput childen // 1. From AdditionalInput childen
IPath[] deps = type.getAdditionalDependencies(); for (IPath p : type.getAdditionalDependencies())
for (int j=0; j<deps.length; j++) { allDeps.add(p);
allDeps.add(deps[j]);
}
// 2. From InputTypes that other than the primary input type // 2. From InputTypes that other than the primary input type
if (type != getPrimaryInputType()) { if (type != getPrimaryInputType()) {
if (type.getOptionId() != null) { if (type.getOptionId() != null) {
IOption option = getOptionBySuperClassId(type.getOptionId()); IOption option = getOptionBySuperClassId(type.getOptionId());
if (option != null) { if (option != null) {
try { try {
List inputs = new ArrayList(); List<IPath> inputs = new ArrayList<IPath>();
int optType = option.getValueType(); int optType = option.getValueType();
if (optType == IOption.STRING) { if (optType == IOption.STRING) {
inputs.add(Path.fromOSString(option.getStringValue())); inputs.add(Path.fromOSString(option.getStringValue()));
@ -1916,12 +1836,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
optType == IOption.LIBRARY_FILES || optType == IOption.LIBRARY_FILES ||
optType == IOption.MACRO_FILES optType == IOption.MACRO_FILES
) { ) {
List inputNames = (List)option.getValue(); List<String> inputNames = (List<String>)option.getValue();
filterValues(optType, inputNames); filterValues(optType, inputNames);
for (int j=0; j<inputNames.size(); j++) { for (String s : inputNames)
inputs.add(Path.fromOSString(s));
inputs.add(Path.fromOSString((String)inputNames.get(j)));
}
} }
allDeps.addAll(inputs); allDeps.addAll(inputs);
} catch( BuildException ex ) { } catch( BuildException ex ) {
@ -1939,16 +1857,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
* @see org.eclipse.cdt.managedbuilder.core.ITool#getAdditionalResources() * @see org.eclipse.cdt.managedbuilder.core.ITool#getAdditionalResources()
*/ */
public IPath[] getAdditionalResources() { public IPath[] getAdditionalResources() {
List allRes = new ArrayList(); List<IPath> allRes = new ArrayList<IPath>();
IInputType[] types = getInputTypes(); for (IInputType type : getInputTypes()) {
for (int i=0; i<types.length; i++) {
IInputType type = types[i];
// Additional resources come from 2 places. // Additional resources come from 2 places.
// 1. From AdditionalInput childen // 1. From AdditionalInput childen
IPath[] res = type.getAdditionalResources(); for (IPath r : type.getAdditionalResources())
for (int j=0; j<res.length; j++) { allRes.add(r);
allRes.add(res[j]);
}
// 2. From InputTypes that other than the primary input type // 2. From InputTypes that other than the primary input type
if (type != getPrimaryInputType()) { if (type != getPrimaryInputType()) {
String var = type.getBuildVariable(); String var = type.getBuildVariable();
@ -1957,7 +1872,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
} }
} }
return (IPath[])allRes.toArray(new IPath[allRes.size()]); return allRes.toArray(new IPath[allRes.size()]);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -1966,16 +1881,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
public String[] getAllDependencyExtensions() { public String[] getAllDependencyExtensions() {
IInputType[] types = getInputTypes(); IInputType[] types = getInputTypes();
if (types != null && types.length > 0) { if (types != null && types.length > 0) {
List allExts = new ArrayList(); List<String> allExts = new ArrayList<String>();
for (int i=0; i<types.length; i++) { for (IInputType t : types)
String[] exts = types[i].getDependencyExtensions(this); for (String s : t.getDependencyExtensions(this))
for (int j=0; j<exts.length; j++) { allExts.add(s);
allExts.add(exts[j]);
} if (allExts.size() > 0)
} return allExts.toArray(new String[allExts.size()]);
if (allExts.size() > 0) {
return (String[])allExts.toArray(new String[allExts.size()]);
}
} }
// If none, use the header extensions specified for the Tool (backwards compatibility) // If none, use the header extensions specified for the Tool (backwards compatibility)
List<String> extsList = getHeaderExtensionsAttribute(); List<String> extsList = getHeaderExtensionsAttribute();
@ -1989,27 +1901,27 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
* @see org.eclipse.cdt.managedbuilder.core.ITool#getInterfaceExtension() * @see org.eclipse.cdt.managedbuilder.core.ITool#getInterfaceExtension()
* @deprecated * @deprecated
*/ */
public List getInterfaceExtensions() { public List<String> getInterfaceExtensions() {
return getHeaderExtensionsAttribute(); return getHeaderExtensionsAttribute();
} }
private List getHeaderExtensionsAttribute() { private List<String> getHeaderExtensionsAttribute() {
if (interfaceExtensions == null || interfaceExtensions.size() == 0) { if (interfaceExtensions == null || interfaceExtensions.size() == 0) {
// If I have a superClass, ask it // If I have a superClass, ask it
if (getSuperClass() != null) { if (getSuperClass() != null) {
return ((Tool)getSuperClass()).getHeaderExtensionsAttribute(); return ((Tool)getSuperClass()).getHeaderExtensionsAttribute();
} else { } else {
if (interfaceExtensions == null) { if (interfaceExtensions == null) {
interfaceExtensions = new ArrayList(); interfaceExtensions = new ArrayList<String>();
} }
} }
} }
return interfaceExtensions; return interfaceExtensions;
} }
private List getInterfaceExtensionsList() { private List<String> getInterfaceExtensionsList() {
if (interfaceExtensions == null) { if (interfaceExtensions == null) {
interfaceExtensions = new ArrayList(); interfaceExtensions = new ArrayList<String>();
} }
return interfaceExtensions; return interfaceExtensions;
} }
@ -2566,12 +2478,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
SupplierBasedCdtVariableSubstitutor macroSubstitutor, SupplierBasedCdtVariableSubstitutor macroSubstitutor,
IMacroContextInfoProvider provider) throws BuildException { IMacroContextInfoProvider provider) throws BuildException {
IOption[] opts = getOptions(); IOption[] opts = getOptions();
ArrayList flags = new ArrayList(); ArrayList<String> flags = new ArrayList<String>();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int index = 0; index < opts.length; index++) { for (IOption op : opts) {
IOption option = getOptionToSet(opts[index], false); IOption option = getOptionToSet(op, false);
if (option == null) if (option == null)
continue; continue;
option.setValue(op.getValue());
sb.setLength( 0 ); sb.setLength( 0 );
// check to see if the option has an applicability calculator // check to see if the option has an applicability calculator
@ -2893,23 +2807,16 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (isDirty) return true; if (isDirty) return true;
// Check my children // Check my children
List typeElements = getInputTypeList(); for (InputType type : getInputTypeList())
Iterator iter = typeElements.listIterator(); if (type.isDirty())
while (iter.hasNext()) { return true;
InputType type = (InputType) iter.next(); for (OutputType type : getOutputTypeList())
if (type.isDirty()) return true; if (type.isDirty())
} return true;
typeElements = getOutputTypeList();
iter = typeElements.listIterator();
while (iter.hasNext()) {
OutputType type = (OutputType) iter.next();
if (type.isDirty()) return true;
}
// Otherwise see if any options need saving // Otherwise see if any options need saving
if (super.isDirty()) { if (super.isDirty())
return true; return true;
}
return isDirty; return isDirty;
} }
@ -2923,18 +2830,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
super.setDirty(isDirty); super.setDirty(isDirty);
// Propagate "false" to the children // Propagate "false" to the children
if (!isDirty) { if (!isDirty) {
List typeElements = getInputTypeList(); for (InputType type : getInputTypeList())
Iterator iter = typeElements.listIterator();
while (iter.hasNext()) {
InputType type = (InputType) iter.next();
type.setDirty(false); type.setDirty(false);
}
typeElements = getOutputTypeList(); for (OutputType type : getOutputTypeList())
iter = typeElements.listIterator();
while (iter.hasNext()) {
OutputType type = (OutputType) iter.next();
type.setDirty(false); type.setDirty(false);
}
} }
} }
@ -2963,16 +2863,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
// Resolve HoldsOptions // Resolve HoldsOptions
super.resolveReferences(); super.resolveReferences();
// Call resolveReferences on our children // Call resolveReferences on our children
Iterator typeIter = getInputTypeList().iterator(); for (InputType current : getInputTypeList())
while (typeIter.hasNext()) {
InputType current = (InputType)typeIter.next();
current.resolveReferences(); current.resolveReferences();
}
typeIter = getOutputTypeList().iterator(); for (OutputType current : getOutputTypeList())
while (typeIter.hasNext()) {
OutputType current = (OutputType)typeIter.next();
current.resolveReferences(); current.resolveReferences();
}
} }
} }
@ -3110,7 +3005,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if(path == null) if(path == null)
return; return;
if(envVarBuildPathList == null) if(envVarBuildPathList == null)
envVarBuildPathList = new ArrayList(); envVarBuildPathList = new ArrayList<IEnvVarBuildPath>();
envVarBuildPathList.add(path); envVarBuildPathList.add(path);
} }
@ -3132,7 +3027,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
String high = (String) ManagedBuildManager.getExtensionToolMap() String high = (String) ManagedBuildManager.getExtensionToolMap()
.lastKey(); .lastKey();
SortedMap subMap = null; SortedMap<String, Tool> subMap = null;
if (superClassId.compareTo(high) <= 0) { if (superClassId.compareTo(high) <= 0) {
subMap = ManagedBuildManager.getExtensionToolMap().subMap( subMap = ManagedBuildManager.getExtensionToolMap().subMap(
superClassId, high + "\0"); //$NON-NLS-1$ superClassId, high + "\0"); //$NON-NLS-1$
@ -3162,12 +3057,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
String version = ManagedBuildManager String version = ManagedBuildManager
.getVersionFromIdAndVersion(superClassId); .getVersionFromIdAndVersion(superClassId);
Collection c = subMap.values(); for (ITool toolElement : subMap.values()) {
ITool[] toolElements = (ITool[]) c.toArray(new ITool[c.size()]);
for (int i = 0; i < toolElements.length; i++) {
ITool toolElement = toolElements[i];
if (ManagedBuildManager.getIdFromIdAndVersion( if (ManagedBuildManager.getIdFromIdAndVersion(
toolElement.getId()).compareTo(baseId) > 0) toolElement.getId()).compareTo(baseId) > 0)
break; break;
@ -3381,18 +3271,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
return true; return true;
// Check my children // Check my children
List typeElements = getInputTypeList(); for (InputType type : getInputTypeList())
Iterator iter = typeElements.listIterator(); if (type.needsRebuild())
while (iter.hasNext()) { return true;
InputType type = (InputType) iter.next();
if (type.needsRebuild()) return true; for (OutputType type : getOutputTypeList())
} if (type.needsRebuild())
typeElements = getOutputTypeList(); return true;
iter = typeElements.listIterator();
while (iter.hasNext()) {
OutputType type = (OutputType) iter.next();
if (type.needsRebuild()) return true;
}
return super.needsRebuild(); return super.needsRebuild();
} }
@ -3413,18 +3298,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
super.setRebuildState(rebuild); super.setRebuildState(rebuild);
if (!rebuild) { if (!rebuild) {
List typeElements = getInputTypeList(); for (InputType type : getInputTypeList())
Iterator iter = typeElements.listIterator();
while (iter.hasNext()) {
InputType type = (InputType) iter.next();
type.setRebuildState(false); type.setRebuildState(false);
}
typeElements = getOutputTypeList(); for (OutputType type : getOutputTypeList())
iter = typeElements.listIterator();
while (iter.hasNext()) {
OutputType type = (OutputType) iter.next();
type.setRebuildState(false); type.setRebuildState(false);
}
} }
} }
} }
@ -3442,7 +3320,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if(fDataMapInited) if(fDataMapInited)
return; return;
List types = getLanguageInputTypes(); List<IInputType> types = getLanguageInputTypes();
// List datas = new ArrayList(); // List datas = new ArrayList();
if(types != null){ if(types != null){
@ -3520,11 +3398,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
return found; return found;
} }
private List getLanguageInputTypes(){ private List<IInputType> getLanguageInputTypes(){
List list = new ArrayList(); List<IInputType> list = new ArrayList<IInputType>();
IInputType types[] = getInputTypes(); IInputType[] types = getInputTypes();
for(int i = 0; i < types.length; i++){ for(IInputType t : types){
InputType type = (InputType)types[i]; InputType type = (InputType)t;
if(isLanguageInputType(type, false)) if(isLanguageInputType(type, false))
list.add(type); list.add(type);
} }
@ -3532,9 +3410,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if(types.length == 1){ if(types.length == 1){
list.add(types[0]); list.add(types[0]);
} else { } else {
for(int i = 0; i < types.length; i++){ for(IInputType t : types){
if(types[i].getPrimaryInput()){ if(t.getPrimaryInput()){
list.add(types[i]); list.add(t);
break; break;
} }
} }
@ -3549,7 +3427,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
public CLanguageData[] getCLanguageDatas() { public CLanguageData[] getCLanguageDatas() {
initDataMap(); initDataMap();
return (CLanguageData[])typeToDataMap.values().toArray(new BuildLanguageData[typeToDataMap.size()]); return typeToDataMap.values().toArray(new BuildLanguageData[typeToDataMap.size()]);
} }
public IInputType getInputTypeForCLanguageData(CLanguageData data) { public IInputType getInputTypeForCLanguageData(CLanguageData data) {
@ -3811,11 +3689,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
public IConfigurationElement getConverterModificationElement(ITool toTool){ public IConfigurationElement getConverterModificationElement(ITool toTool){
Map map = ManagedBuildManager.getConversionElements(this); Map<String, IConfigurationElement> map = ManagedBuildManager.getConversionElements(this);
IConfigurationElement element = null; IConfigurationElement element = null;
if(!map.isEmpty()){ if(!map.isEmpty()){
for(Iterator iter = map.values().iterator(); iter.hasNext();){ for(IConfigurationElement el : map.values()){
IConfigurationElement el = (IConfigurationElement)iter.next();
String toId = el.getAttribute("toId"); //$NON-NLS-1$ String toId = el.getAttribute("toId"); //$NON-NLS-1$
ITool to = toTool; ITool to = toTool;
if(toId != null){ if(toId != null){
@ -3868,13 +3745,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
supported = props.getSupportedTypeIds(); supported = props.getSupportedTypeIds();
} else { } else {
BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator(); BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
List list = new ArrayList(); List<String> list = new ArrayList<String>();
if(calc != null){ if(calc != null){
list.addAll(Arrays.asList(calc.getReferencedPropertyIds())); list.addAll(Arrays.asList(calc.getReferencedPropertyIds()));
} }
list.addAll(Arrays.asList(super.getSupportedTypeIds())); list.addAll(Arrays.asList(super.getSupportedTypeIds()));
supported = (String[])list.toArray(new String[list.size()]); supported = list.toArray(new String[list.size()]);
} }
return supported; return supported;
} }
@ -3886,13 +3763,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
supported = props.getSupportedValueIds(typeId); supported = props.getSupportedValueIds(typeId);
} else { } else {
BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator(); BooleanExpressionApplicabilityCalculator calc = getBooleanExpressionCalculator();
List list = new ArrayList(); List<String> list = new ArrayList<String>();
if(calc != null){ if(calc != null){
list.addAll(Arrays.asList(calc.getReferencedValueIds(typeId))); list.addAll(Arrays.asList(calc.getReferencedValueIds(typeId)));
} }
list.addAll(Arrays.asList(super.getSupportedValueIds(typeId))); list.addAll(Arrays.asList(super.getSupportedValueIds(typeId)));
supported = (String[])list.toArray(new String[list.size()]); supported = list.toArray(new String[list.size()]);
} }
return supported; return supported;
} }
@ -3912,13 +3789,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
errorParserIds = null; errorParserIds = null;
} }
void removeErrorParsers(Set set){ void removeErrorParsers(Set<String> set){
Set oldSet = contributeErrorParsers(null); Set<String> oldSet = contributeErrorParsers(null);
if(oldSet == null) if(oldSet == null)
oldSet = new HashSet(); oldSet = new HashSet<String>();
oldSet.removeAll(set); oldSet.removeAll(set);
setErrorParserList((String[])oldSet.toArray(new String[oldSet.size()])); setErrorParserList(oldSet.toArray(new String[oldSet.size()]));
} }
public void setErrorParserList(String[] ids) { public void setErrorParserList(String[] ids) {
@ -4130,13 +4007,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
public IOption[] getOptionsOfType(int type){ public IOption[] getOptionsOfType(int type){
IOption options[] = getOptions(); List<IOption> list = new ArrayList<IOption>();
List list = new ArrayList(); for(IOption op : getOptions()){
for(int i = 0; i < options.length; i++){
try { try {
if(options[i].getValueType() == type){ if(op.getValueType() == type)
list.add(options[i]); list.add(op);
}
} catch (BuildException e) { } catch (BuildException e) {
ManagedBuilderCorePlugin.log(e); ManagedBuilderCorePlugin.log(e);
} }
@ -4144,17 +4019,16 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
return (Option[])list.toArray(new Option[list.size()]); return (Option[])list.toArray(new Option[list.size()]);
} }
@SuppressWarnings("unchecked")
public void filterValues(int type, List values){ public void filterValues(int type, List values){
if(values.size() == 0) if(values.size() == 0)
return; return;
int opType = Option.getOppositeType(type); int opType = Option.getOppositeType(type);
if(opType != 0){ if(opType != 0){
IOption opOptions[] = getOptionsOfType(opType); Set<Object> filterSet = new HashSet<Object>();
Set filterSet = new HashSet(); for(IOption op : getOptionsOfType(opType)){
for(int i = 0; i < opOptions.length; i++){ filterSet.addAll((List<Object>)op.getValue());
List opList = (List)opOptions[i].getValue();
filterSet.addAll(opList);
} }
if(filterSet.size() != 0){ if(filterSet.size() != 0){