1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-05 14:43:36 +02:00

Bug #218078 : Tool chain editor doesn't properly update configuration

This commit is contained in:
Oleg Krasilnikov 2008-02-07 17:20:59 +00:00
parent 21b8ccf0a5
commit 6a80d1f5da
4 changed files with 119 additions and 151 deletions

View file

@ -30,8 +30,6 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.OptionStringValue; import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
import org.eclipse.cdt.managedbuilder.internal.tcmodification.ToolListModification;
import org.eclipse.cdt.managedbuilder.tcmodification.IToolListModification;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -470,9 +468,9 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
public abstract boolean isExtensionElement(); public abstract boolean isExtensionElement();
public abstract Set contributeErrorParsers(Set set); public abstract Set<String> contributeErrorParsers(Set<String> set);
protected Set contributeErrorParsers(ITool[] tools, Set set){ protected Set<String> contributeErrorParsers(ITool[] tools, Set<String> set){
// if(set == null) // if(set == null)
// set = new HashSet(); // set = new HashSet();
for(int i = 0; i < tools.length; i++){ for(int i = 0; i < tools.length; i++){
@ -491,9 +489,9 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
} }
} }
abstract void removeErrorParsers(Set set); abstract void removeErrorParsers(Set<String> set);
protected void removeErrorParsers(ITool tools[], Set set){ protected void removeErrorParsers(ITool tools[], Set<String> set){
for(int i = 0; i < tools.length; i++){ for(int i = 0; i < tools.length; i++){
Tool tool = (Tool)tools[i]; Tool tool = (Tool)tools[i];
tool.removeErrorParsers(set); tool.removeErrorParsers(set);
@ -579,7 +577,7 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
return cr.getResourceInfos(); return cr.getResourceInfos();
} }
public List getChildResourceInfoList(boolean includeCurrent){ public List<IResourceInfo> getChildResourceInfoList(boolean includeCurrent){
return getRcInfo().getRcInfoList(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER, includeCurrent); return getRcInfo().getRcInfoList(ICSettingBase.SETTING_FILE | ICSettingBase.SETTING_FOLDER, includeCurrent);
} }
} }

View file

@ -63,11 +63,11 @@ public class ResourceInfoContainer {
} }
public IResourceInfo[] getResourceInfos(int kind, Class clazz){ public IResourceInfo[] getResourceInfos(int kind, Class clazz){
List list = getRcInfoList(kind); List<IResourceInfo> list = getRcInfoList(kind);
IResourceInfo datas[] = (IResourceInfo[])Array.newInstance(clazz, list.size()); IResourceInfo datas[] = (IResourceInfo[])Array.newInstance(clazz, list.size());
return (IResourceInfo[])list.toArray(datas); return list.toArray(datas);
} }
public IResourceInfo[] getDirectChildResourceInfos(){ public IResourceInfo[] getDirectChildResourceInfos(){
@ -82,12 +82,12 @@ public class ResourceInfoContainer {
return datas; return datas;
} }
public List getRcInfoList(final int kind){ public List<IResourceInfo> getRcInfoList(final int kind){
return getRcInfoList(kind, fIncludeCurrent); return getRcInfoList(kind, fIncludeCurrent);
} }
public List getRcInfoList(final int kind, final boolean includeCurrent){ public List<IResourceInfo> getRcInfoList(final int kind, final boolean includeCurrent){
final List list = new ArrayList(); final List<IResourceInfo> list = new ArrayList<IResourceInfo>();
fRcDataContainer.accept(new IPathSettingsContainerVisitor(){ fRcDataContainer.accept(new IPathSettingsContainerVisitor(){
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2003, 2007 IBM Corporation and others. * Copyright (c) 2003, 2008 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
@ -115,16 +115,16 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
private String superClassId; private String superClassId;
// Parent and children // Parent and children
private IBuildObject parent; private IBuildObject parent;
private Vector inputTypeList; private Vector<InputType> inputTypeList;
private Map inputTypeMap; private Map<String, InputType> inputTypeMap;
private Vector outputTypeList; private Vector<OutputType> outputTypeList;
private Map outputTypeMap; private Map<String, OutputType> outputTypeMap;
private List envVarBuildPathList; private List 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 inputExtensions; private List<String> inputExtensions;
private List interfaceExtensions; private List interfaceExtensions;
private Integer natureFilter; private Integer natureFilter;
private String outputExtensions; private String outputExtensions;
@ -693,7 +693,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (inputs != null) { if (inputs != null) {
StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR); StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
while (tokenizer.hasMoreElements()) { while (tokenizer.hasMoreElements()) {
getInputExtensionsList().add(tokenizer.nextElement()); getInputExtensionsList().add((String)tokenizer.nextElement());
} }
} }
@ -856,7 +856,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (inputs != null) { if (inputs != null) {
StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR); StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
while (tokenizer.hasMoreElements()) { while (tokenizer.hasMoreElements()) {
getInputExtensionsList().add(tokenizer.nextElement()); getInputExtensionsList().add((String)tokenizer.nextElement());
} }
} }
} }
@ -1366,7 +1366,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if(isExtensionTool || types.length == 0) if(isExtensionTool || types.length == 0)
return types; return types;
List list = new ArrayList(types.length); List<OutputType> list = new ArrayList<OutputType>(types.length);
OutputType type; OutputType type;
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
type = (OutputType)types[i]; type = (OutputType)types[i];
@ -1374,14 +1374,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
list.add(type); list.add(type);
} }
return (OutputType[])list.toArray(new OutputType[list.size()]); return list.toArray(new OutputType[list.size()]);
} }
private IInputType[] filterInputTypes(IInputType types[]){ private IInputType[] filterInputTypes(IInputType types[]){
if(isExtensionTool || types.length == 0) if(isExtensionTool || types.length == 0)
return types; return types;
List list = new ArrayList(types.length); List<InputType> list = new ArrayList<InputType>(types.length);
InputType type; InputType type;
for(int i = 0; i < types.length; i++){ for(int i = 0; i < types.length; i++){
type = (InputType)types[i]; type = (InputType)types[i];
@ -1389,11 +1389,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
list.add(type); list.add(type);
} }
return (InputType[])list.toArray(new InputType[list.size()]); return list.toArray(new InputType[list.size()]);
} }
private boolean hasOutputTypes() { private boolean hasOutputTypes() {
Vector ourTypes = getOutputTypeList(); Vector<OutputType> ourTypes = getOutputTypeList();
if (ourTypes.size() > 0) return true; if (ourTypes.size() > 0) return true;
return false; return false;
} }
@ -1558,9 +1558,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
/* (non-Javadoc) /* (non-Javadoc)
* Memory-safe way to access the list of input types * Memory-safe way to access the list of input types
*/ */
private Vector getInputTypeList() { private Vector<InputType> getInputTypeList() {
if (inputTypeList == null) { if (inputTypeList == null) {
inputTypeList = new Vector(); inputTypeList = new Vector<InputType>();
} }
return inputTypeList; return inputTypeList;
} }
@ -1568,9 +1568,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
/* (non-Javadoc) /* (non-Javadoc)
* Memory-safe way to access the list of IDs to input types * Memory-safe way to access the list of IDs to input types
*/ */
private Map getInputTypeMap() { private Map<String, InputType> getInputTypeMap() {
if (inputTypeMap == null) { if (inputTypeMap == null) {
inputTypeMap = new HashMap(); inputTypeMap = new HashMap<String, InputType>();
} }
return inputTypeMap; return inputTypeMap;
} }
@ -1586,9 +1586,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
/* (non-Javadoc) /* (non-Javadoc)
* Memory-safe way to access the list of output types * Memory-safe way to access the list of output types
*/ */
private Vector getOutputTypeList() { private Vector<OutputType> getOutputTypeList() {
if (outputTypeList == null) { if (outputTypeList == null) {
outputTypeList = new Vector(); outputTypeList = new Vector<OutputType>();
} }
return outputTypeList; return outputTypeList;
} }
@ -1596,9 +1596,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
/* (non-Javadoc) /* (non-Javadoc)
* Memory-safe way to access the list of IDs to output types * Memory-safe way to access the list of IDs to output types
*/ */
private Map getOutputTypeMap() { private Map<String, OutputType> getOutputTypeMap() {
if (outputTypeMap == null) { if (outputTypeMap == null) {
outputTypeMap = new HashMap(); outputTypeMap = new HashMap<String, OutputType>();
} }
return outputTypeMap; return outputTypeMap;
} }
@ -1706,7 +1706,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
errorParsers = new String[0]; errorParsers = new String[0];
} else { } else {
StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
List list = new ArrayList(tok.countTokens()); List<String> list = new ArrayList<String>(tok.countTokens());
while (tok.hasMoreElements()) { while (tok.hasMoreElements()) {
list.add(tok.nextToken()); list.add(tok.nextToken());
} }
@ -1719,10 +1719,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
return errorParsers; return errorParsers;
} }
public Set contributeErrorParsers(Set set){ public Set<String> contributeErrorParsers(Set<String> set){
if(getErrorParserIds() != null){ if(getErrorParserIds() != null){
if(set == null) if(set == null)
set = new HashSet(); set = new HashSet<String>();
String ids[] = getErrorParserList(); String ids[] = getErrorParserList();
if(ids.length != 0) if(ids.length != 0)
set.addAll(Arrays.asList(ids)); set.addAll(Arrays.asList(ids));
@ -1734,30 +1734,30 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
* @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions() * @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions()
* @deprecated * @deprecated
*/ */
public List getInputExtensions() { public List<String> getInputExtensions() {
String[] exts = getPrimaryInputExtensions(); String[] exts = getPrimaryInputExtensions();
List extList = new ArrayList(); List<String> extList = new ArrayList<String>();
for (int i=0; i<exts.length; i++) { for (int i=0; i<exts.length; i++) {
extList.add(exts[i]); extList.add(exts[i]);
} }
return extList; return extList;
} }
private List getInputExtensionsAttribute() { private List<String> getInputExtensionsAttribute() {
if( (inputExtensions == null) || ( inputExtensions.size() == 0) ) { if( (inputExtensions == null) || ( inputExtensions.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()).getInputExtensionsAttribute(); return ((Tool)getSuperClass()).getInputExtensionsAttribute();
} else { } else {
inputExtensions = new ArrayList(); inputExtensions = new ArrayList<String>();
} }
} }
return inputExtensions; return inputExtensions;
} }
private List getInputExtensionsList() { private List<String> getInputExtensionsList() {
if (inputExtensions == null) { if (inputExtensions == null) {
inputExtensions = new ArrayList(); inputExtensions = new ArrayList<String>();
} }
return inputExtensions; return inputExtensions;
} }
@ -1774,7 +1774,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (exts.length > 0) return exts[0]; if (exts.length > 0) return exts[0];
} }
// 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) return (String)extsList.get(0); if (extsList != null && extsList.size() > 0) return (String)extsList.get(0);
return EMPTY_STRING; return EMPTY_STRING;
@ -1978,7 +1978,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
} }
// 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 extsList = getHeaderExtensionsAttribute(); List<String> extsList = getHeaderExtensionsAttribute();
if (extsList != null && extsList.size() > 0) { if (extsList != null && extsList.size() > 0) {
return (String[])extsList.toArray(new String[extsList.size()]); return (String[])extsList.toArray(new String[extsList.size()]);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2007 Intel Corporation and others. * Copyright (c) 2004, 2008 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
@ -53,6 +53,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PluginVersionIdentifier; import org.eclipse.core.runtime.PluginVersionIdentifier;
@ -71,15 +72,15 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
private String superClassId; private String superClassId;
// Parent and children // Parent and children
private IConfiguration config; private IConfiguration config;
private List toolList; private List<Tool> toolList;
private Map toolMap; private Map<String, Tool> toolMap;
private TargetPlatform targetPlatform; private TargetPlatform targetPlatform;
private Builder builder; private Builder builder;
// Managed Build model attributes // Managed Build model attributes
private String unusedChildren; private String unusedChildren;
private String errorParserIds; private String errorParserIds;
private List osList; private List<String> osList;
private List archList; private List<String> archList;
private String targetToolIds; private String targetToolIds;
private String secondaryOutputIds; private String secondaryOutputIds;
private Boolean isAbstract; private Boolean isAbstract;
@ -115,7 +116,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator; private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
private List identicalList; private List identicalList;
private Set unusedChildrenSet; private Set<String> unusedChildrenSet;
private IFolderInfo parentFolderInfo; private IFolderInfo parentFolderInfo;
@ -290,7 +291,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
* @param parent The <code>IConfiguration</code> the tool-chain will be added to. * @param parent The <code>IConfiguration</code> the tool-chain will be added to.
* @param toolChain The existing tool-chain to clone. * @param toolChain The existing tool-chain to clone.
*/ */
public ToolChain(IFolderInfo folderInfo, String Id, String name, Map superIdMap, ToolChain toolChain) { public ToolChain(IFolderInfo folderInfo, String Id, String name, Map<IPath, Map<String, String>> superIdMap, ToolChain toolChain) {
super(resolvedDefault); super(resolvedDefault);
this.config = folderInfo.getParent(); this.config = folderInfo.getParent();
parentFolderInfo = folderInfo; parentFolderInfo = folderInfo;
@ -324,10 +325,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
errorParserIds = new String(toolChain.errorParserIds); errorParserIds = new String(toolChain.errorParserIds);
} }
if (toolChain.osList != null) { if (toolChain.osList != null) {
osList = new ArrayList(toolChain.osList); osList = new ArrayList<String>(toolChain.osList);
} }
if (toolChain.archList != null) { if (toolChain.archList != null) {
archList = new ArrayList(toolChain.archList); archList = new ArrayList<String>(toolChain.archList);
} }
if (toolChain.targetToolIds != null) { if (toolChain.targetToolIds != null) {
targetToolIds = new String(toolChain.targetToolIds); targetToolIds = new String(toolChain.targetToolIds);
@ -416,16 +417,13 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
IConfiguration cfg = parentFolderInfo.getParent(); IConfiguration cfg = parentFolderInfo.getParent();
if (toolChain.toolList != null) { if (toolChain.toolList != null) {
Iterator iter = toolChain.getToolList().listIterator(); for (Tool toolChild : toolChain.getToolList()) {
while (iter.hasNext()) {
Tool toolChild = (Tool) iter.next();
// int nnn = ManagedBuildManager.getRandomNumber();
String subId = null; String subId = null;
// String tmpId; // String tmpId;
String subName; String subName;
// String version; // String version;
ITool extTool = ManagedBuildManager.getExtensionTool(toolChild); ITool extTool = ManagedBuildManager.getExtensionTool(toolChild);
Map curIdMap = (Map)superIdMap.get(folderInfo.getPath()); Map<String, String> curIdMap = (Map<String, String>)superIdMap.get(folderInfo.getPath());
if(curIdMap != null){ if(curIdMap != null){
if(extTool != null) if(extTool != null)
subId = (String)curIdMap.get(extTool.getId()); subId = (String)curIdMap.get(extTool.getId());
@ -476,9 +474,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
} else { } else {
superId = copyIds ? otherSuperTool.getId() : ManagedBuildManager.calculateChildId(otherExtTool.getId(), null); superId = copyIds ? otherSuperTool.getId() : ManagedBuildManager.calculateChildId(otherExtTool.getId(), null);
Map idMap = (Map)superIdMap.get(otherRcInfo.getPath()); Map<String, String> idMap = (Map<String, String>)superIdMap.get(otherRcInfo.getPath());
if(idMap == null){ if(idMap == null){
idMap = new HashMap(); idMap = new HashMap<String, String>();
superIdMap.put(otherRcInfo.getPath(), idMap); superIdMap.put(otherRcInfo.getPath(), idMap);
} }
idMap.put(otherExtTool.getId(), superId); idMap.put(otherExtTool.getId(), superId);
@ -579,7 +577,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
// Get the comma-separated list of valid OS // Get the comma-separated list of valid OS
String os = element.getAttribute(OS_LIST); String os = element.getAttribute(OS_LIST);
if (os != null) { if (os != null) {
osList = new ArrayList(); osList = new ArrayList<String>();
String[] osTokens = os.split(","); //$NON-NLS-1$ String[] osTokens = os.split(","); //$NON-NLS-1$
for (int i = 0; i < osTokens.length; ++i) { for (int i = 0; i < osTokens.length; ++i) {
osList.add(osTokens[i].trim()); osList.add(osTokens[i].trim());
@ -589,7 +587,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
// Get the comma-separated list of valid Architectures // Get the comma-separated list of valid Architectures
String arch = element.getAttribute(ARCH_LIST); String arch = element.getAttribute(ARCH_LIST);
if (arch != null) { if (arch != null) {
archList = new ArrayList(); archList = new ArrayList<String>();
String[] archTokens = arch.split(","); //$NON-NLS-1$ String[] archTokens = arch.split(","); //$NON-NLS-1$
for (int j = 0; j < archTokens.length; ++j) { for (int j = 0; j < archTokens.length; ++j) {
archList.add(archTokens[j].trim()); archList.add(archTokens[j].trim());
@ -698,7 +696,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
if (element.getAttribute(OS_LIST) != null) { if (element.getAttribute(OS_LIST) != null) {
String os = element.getAttribute(OS_LIST); String os = element.getAttribute(OS_LIST);
if (os != null) { if (os != null) {
osList = new ArrayList(); osList = new ArrayList<String>();
String[] osTokens = os.split(","); //$NON-NLS-1$ String[] osTokens = os.split(","); //$NON-NLS-1$
for (int i = 0; i < osTokens.length; ++i) { for (int i = 0; i < osTokens.length; ++i) {
osList.add(osTokens[i].trim()); osList.add(osTokens[i].trim());
@ -710,7 +708,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
if (element.getAttribute(ARCH_LIST) != null) { if (element.getAttribute(ARCH_LIST) != null) {
String arch = element.getAttribute(ARCH_LIST); String arch = element.getAttribute(ARCH_LIST);
if (arch != null) { if (arch != null) {
archList = new ArrayList(); archList = new ArrayList<String>();
String[] archTokens = arch.split(","); //$NON-NLS-1$ String[] archTokens = arch.split(","); //$NON-NLS-1$
for (int j = 0; j < archTokens.length; ++j) { for (int j = 0; j < archTokens.length; ++j) {
archList.add(archTokens[j].trim()); archList.add(archTokens[j].trim());
@ -787,7 +785,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
if (osList != null) { if (osList != null) {
Iterator osIter = osList.listIterator(); Iterator<String> osIter = osList.listIterator();
String listValue = EMPTY_STRING; String listValue = EMPTY_STRING;
while (osIter.hasNext()) { while (osIter.hasNext()) {
String current = (String) osIter.next(); String current = (String) osIter.next();
@ -800,7 +798,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
if (archList != null) { if (archList != null) {
Iterator archIter = archList.listIterator(); Iterator<String> archIter = archList.listIterator();
String listValue = EMPTY_STRING; String listValue = EMPTY_STRING;
while (archIter.hasNext()) { while (archIter.hasNext()) {
String current = (String) archIter.next(); String current = (String) archIter.next();
@ -824,10 +822,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
ICStorageElement builderElement = element.createChild(IBuilder.BUILDER_ELEMENT_NAME); ICStorageElement builderElement = element.createChild(IBuilder.BUILDER_ELEMENT_NAME);
builder.serialize(builderElement); builder.serialize(builderElement);
} }
List toolElements = getToolList(); for (Tool tool : getToolList()) {
Iterator iter = toolElements.listIterator();
while (iter.hasNext()) {
Tool tool = (Tool) iter.next();
ICStorageElement toolElement = element.createChild(ITool.TOOL_ELEMENT_NAME); ICStorageElement toolElement = element.createChild(ITool.TOOL_ELEMENT_NAME);
tool.serialize(toolElement); tool.serialize(toolElement);
} }
@ -992,28 +987,17 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
// Our tools take precedence // Our tools take precedence
if (tools != null) { if (tools != null) {
Iterator iter = getToolList().listIterator(); for (Tool tool : getToolList()) {
while (iter.hasNext()) { int j = 0;
Tool tool = (Tool)iter.next(); for (; j < tools.length; j++) {
int j;
for (j = 0; j < tools.length; j++) {
ITool superTool = tool.getSuperClass(); ITool superTool = tool.getSuperClass();
if(superTool != null){ if(superTool != null){
superTool = ManagedBuildManager.getExtensionTool(superTool); superTool = ManagedBuildManager.getExtensionTool(superTool);
// if(!superTool.isExtensionElement())
// superTool = superTool.getSuperClass();
if(superTool != null && superTool.getId().equals(tools[j].getId())){ if(superTool != null && superTool.getId().equals(tools[j].getId())){
tools[j] = tool; tools[j] = tool;
break; break;
} }
} }
// if (tool.getSuperClass() != null // Remove assumption that ALL tools must have superclasses
// && tool.getSuperClass().getId().equals(tools[j].getId())) {
// tools[j] = tool;
// break;
// }
} }
// No Match? Insert it (may be re-ordered) // No Match? Insert it (may be re-ordered)
if (j == tools.length) { if (j == tools.length) {
@ -1042,11 +1026,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
// } // }
} else { } else {
tools = new Tool[getToolList().size()]; tools = new Tool[getToolList().size()];
Iterator iter = getToolList().listIterator();
int i = 0; int i = 0;
while (iter.hasNext()) { for (Tool tool : getToolList()) {
Tool tool = (Tool)iter.next(); tools[i++] = tool;
tools[i++] = (Tool)tool;
} }
} }
if(includeCurrentUnused) if(includeCurrentUnused)
@ -1055,17 +1037,16 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
private Tool[] filterUsedTools(Tool tools[], boolean used){ private Tool[] filterUsedTools(Tool tools[], boolean used){
Set set = getUnusedChilrenSet(); Set<String> set = getUnusedChilrenSet();
if(set.size() == 0) if(set.size() == 0)
return used ? tools : new Tool[0]; return used ? tools : new Tool[0];
List list = new ArrayList(tools.length); List<Tool> list = new ArrayList<Tool>(tools.length);
for(int i = 0; i < tools.length; i++){ for(Tool t : tools){
if(set.contains(tools[i].getId()) != used) if(set.contains(t.getId()) != used)
list.add(tools[i]); list.add(t);
} }
return list.toArray(new Tool[list.size()]);
return (Tool[])list.toArray(new Tool[list.size()]);
} }
public Tool[] getUnusedTools(){ public Tool[] getUnusedTools(){
@ -1085,12 +1066,11 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getToolsBySuperClassId(java.lang.String) * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getToolsBySuperClassId(java.lang.String)
*/ */
public ITool[] getToolsBySuperClassId(String id) { public ITool[] getToolsBySuperClassId(String id) {
List retTools = new ArrayList(); List<ITool> retTools = new ArrayList<ITool>();
if (id != null) { if (id != null) {
// Look for a tool with this ID, or the tool(s) with a superclass with this id // Look for a tool with this ID, or the tool(s) with a superclass with this id
ITool[] tools = getTools(); ITool[] tools = getTools();
for (int i = 0; i < tools.length; i++) { for (ITool targetTool : tools) {
ITool targetTool = tools[i];
ITool tool = targetTool; ITool tool = targetTool;
do { do {
if (id.equals(tool.getId())) { if (id.equals(tool.getId())) {
@ -1101,7 +1081,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} while (tool != null); } while (tool != null);
} }
} }
return (ITool[])retTools.toArray( new ITool[retTools.size()]); return retTools.toArray( new ITool[retTools.size()]);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -1109,9 +1089,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
* *
* @return List containing the tools * @return List containing the tools
*/ */
public List getToolList() { public List<Tool> getToolList() {
if (toolList == null) { if (toolList == null) {
toolList = new ArrayList(); toolList = new ArrayList<Tool>();
} }
return toolList; return toolList;
} }
@ -1121,9 +1101,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
* *
* @return * @return
*/ */
private Map getToolMap() { private Map<String, Tool> getToolMap() {
if (toolMap == null) { if (toolMap == null) {
toolMap = new HashMap(); toolMap = new HashMap<String, Tool>();
} }
return toolMap; return toolMap;
} }
@ -1139,16 +1119,15 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
void setToolsInternal(ITool[] tools){ void setToolsInternal(ITool[] tools){
List list = getToolList(); List<Tool> list = getToolList();
Map map = getToolMap(); Map<String, Tool> map = getToolMap();
list.clear(); list.clear();
map.clear(); map.clear();
list.addAll(Arrays.asList(tools)); for (ITool t : tools) {
for(int i = 0; i < tools.length; i++){ list.add((Tool)t);
ITool tool = tools[i]; map.put(t.getId(), (Tool)t);
map.put(tool.getId(), tool);
} }
} }
@ -1322,7 +1301,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
targetTools = new String[0]; targetTools = new String[0];
} else { } else {
StringTokenizer tok = new StringTokenizer(IDs, ";"); //$NON-NLS-1$ StringTokenizer tok = new StringTokenizer(IDs, ";"); //$NON-NLS-1$
List list = new ArrayList(tok.countTokens()); List<String> list = new ArrayList<String>(tok.countTokens());
while (tok.hasMoreElements()) { while (tok.hasMoreElements()) {
list.add(tok.nextToken()); list.add(tok.nextToken());
} }
@ -1380,7 +1359,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
errorParsers = new String[0]; errorParsers = new String[0];
} else { } else {
StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
List list = new ArrayList(tok.countTokens()); List<String> list = new ArrayList<String>(tok.countTokens());
while (tok.hasMoreElements()) { while (tok.hasMoreElements()) {
list.add(tok.nextToken()); list.add(tok.nextToken());
} }
@ -1393,11 +1372,11 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
return errorParsers; return errorParsers;
} }
public Set contributeErrorParsers(FolderInfo info, Set set, boolean includeChildren){ public Set<String> contributeErrorParsers(FolderInfo info, Set<String> set, boolean includeChildren){
String parserIDs = getErrorParserIdsAttribute(); String parserIDs = getErrorParserIdsAttribute();
if (parserIDs != null){ if (parserIDs != null){
if(set == null) if(set == null)
set = new HashSet(); set = new HashSet<String>();
if(parserIDs.length() != 0) { if(parserIDs.length() != 0) {
StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
while (tok.hasMoreElements()) { while (tok.hasMoreElements()) {
@ -1497,7 +1476,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
*/ */
public void setOSList(String[] OSs) { public void setOSList(String[] OSs) {
if (osList == null) { if (osList == null) {
osList = new ArrayList(); osList = new ArrayList<String>();
} else { } else {
osList.clear(); osList.clear();
} }
@ -1512,7 +1491,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
*/ */
public void setArchList(String[] archs) { public void setArchList(String[] archs) {
if (archList == null) { if (archList == null) {
archList = new ArrayList(); archList = new ArrayList<String>();
} else { } else {
archList.clear(); archList.clear();
} }
@ -1611,10 +1590,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
return true; return true;
// Otherwise see if any tools need saving // Otherwise see if any tools need saving
Iterator iter = getToolList().listIterator(); for (Tool toolChild : getToolList()) {
while (iter.hasNext()) { if (toolChild.isDirty())
Tool toolChild = (Tool) iter.next(); return true;
if (toolChild.isDirty()) return true;
} }
// Otherwise see if any options need saving // Otherwise see if any options need saving
@ -1634,11 +1612,8 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
super.setDirty(isDirty); super.setDirty(isDirty);
// Propagate "false" to the children // Propagate "false" to the children
if (!isDirty) { if (!isDirty) {
Iterator iter = getToolList().listIterator(); for (Tool toolChild : getToolList())
while (iter.hasNext()) {
Tool toolChild = (Tool) iter.next();
toolChild.setDirty(false); toolChild.setDirty(false);
}
} }
} }
@ -1673,11 +1648,8 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
if (builder != null) { if (builder != null) {
builder.resolveReferences(); builder.resolveReferences();
} }
Iterator iter = getToolList().listIterator(); for (Tool toolChild : getToolList())
while (iter.hasNext()) {
Tool toolChild = (Tool) iter.next();
toolChild.resolveReferences(); toolChild.resolveReferences();
}
} }
} }
@ -1921,7 +1893,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
String baseId = ManagedBuildManager.getIdFromIdAndVersion(superClassId); String baseId = ManagedBuildManager.getIdFromIdAndVersion(superClassId);
String version = getVersionFromId().toString(); String version = getVersionFromId().toString();
Collection c = subMap.values(); Collection<IToolChain[]> c = subMap.values();
IToolChain[] toolChainElements = (IToolChain[]) c.toArray(new IToolChain[c.size()]); IToolChain[] toolChainElements = (IToolChain[]) c.toArray(new IToolChain[c.size()]);
for (int i = 0; i < toolChainElements.length; i++) { for (int i = 0; i < toolChainElements.length; i++) {
@ -2075,9 +2047,8 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
public void updateManagedBuildRevision(String revision){ public void updateManagedBuildRevision(String revision){
super.updateManagedBuildRevision(revision); super.updateManagedBuildRevision(revision);
for(Iterator iter = getToolList().iterator(); iter.hasNext();){ for (Tool t : getToolList())
((Tool)iter.next()).updateManagedBuildRevision(revision); t.updateManagedBuildRevision(revision);
}
if(builder != null) if(builder != null)
builder.updateManagedBuildRevision(revision); builder.updateManagedBuildRevision(revision);
@ -2239,6 +2210,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
calculator.adjustToolChain(getParentFolderInfo(), this, false); calculator.adjustToolChain(getParentFolderInfo(), this, false);
super.propertiesChanged(); super.propertiesChanged();
for (ITool t : getTools())
((Tool)t).propertiesChanged();
} }
public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){ public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
@ -2411,11 +2385,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
public IConfigurationElement getConverterModificationElement(IToolChain tc){ public IConfigurationElement getConverterModificationElement(IToolChain tc){
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$
IToolChain toTc = tc; IToolChain toTc = tc;
if(toId != null){ if(toId != null){
@ -2424,14 +2397,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
break; break;
} }
} }
if(toTc != null){ if(toTc != null){
element = el; element = el;
break; break;
} }
} }
} }
return element; return element;
} }
@ -2450,7 +2421,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
public String[] getRequiredTypeIds(boolean checkTools) { public String[] getRequiredTypeIds(boolean checkTools) {
SupportedProperties props = findSupportedProperties(); SupportedProperties props = findSupportedProperties();
List result = new ArrayList(); List<String> result = new ArrayList<String>();
if(props != null) { if(props != null) {
result.addAll(Arrays.asList(props.getRequiredTypeIds())); result.addAll(Arrays.asList(props.getRequiredTypeIds()));
} else { } else {
@ -2478,7 +2449,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
public String[] getSupportedTypeIds(boolean checkTools) { public String[] getSupportedTypeIds(boolean checkTools) {
SupportedProperties props = findSupportedProperties(); SupportedProperties props = findSupportedProperties();
List result = new ArrayList(); List<String> result = new ArrayList<String>();
if(props != null) { if(props != null) {
result.addAll(Arrays.asList(props.getSupportedTypeIds())); result.addAll(Arrays.asList(props.getSupportedTypeIds()));
} else { } else {
@ -2497,7 +2468,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
result.addAll(Arrays.asList(((Tool)tools[i]).getSupportedTypeIds())); result.addAll(Arrays.asList(((Tool)tools[i]).getSupportedTypeIds()));
} }
} }
return (String[])result.toArray(new String[result.size()]); return result.toArray(new String[result.size()]);
} }
public String[] getSupportedValueIds(String typeId) { public String[] getSupportedValueIds(String typeId) {
@ -2506,7 +2477,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
public String[] getSupportedValueIds(String typeId, boolean checkTools) { public String[] getSupportedValueIds(String typeId, boolean checkTools) {
SupportedProperties props = findSupportedProperties(); SupportedProperties props = findSupportedProperties();
List result = new ArrayList(); List<String> result = new ArrayList<String>();
if(props != null) { if(props != null) {
result.addAll(Arrays.asList(props.getSupportedValueIds(typeId))); result.addAll(Arrays.asList(props.getSupportedValueIds(typeId)));
} else { } else {
@ -2525,7 +2496,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
result.addAll(Arrays.asList(((Tool)tools[i]).getSupportedValueIds(typeId))); result.addAll(Arrays.asList(((Tool)tools[i]).getSupportedValueIds(typeId)));
} }
} }
return (String[])result.toArray(new String[result.size()]); return result.toArray(new String[result.size()]);
} }
public boolean requiresType(String typeId) { public boolean requiresType(String typeId) {
@ -2592,10 +2563,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
} }
void removeErrorParsers(FolderInfo info, Set set){ void removeErrorParsers(FolderInfo info, Set<String> set){
Set oldSet = contributeErrorParsers(info, null, false); Set<String> oldSet = contributeErrorParsers(info, null, false);
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((String[])oldSet.toArray(new String[oldSet.size()]));
@ -2641,8 +2612,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
void resolveProjectReferences(boolean onLoad){ void resolveProjectReferences(boolean onLoad){
for(Iterator iter = getToolList().iterator(); iter.hasNext();){ for(Tool tool : getToolList()){
Tool tool = (Tool)iter.next();
tool.resolveProjectReferences(onLoad); tool.resolveProjectReferences(onLoad);
} }
} }
@ -2732,13 +2702,13 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
return getSuperClassNum() - other.getSuperClassNum(); return getSuperClassNum() - other.getSuperClassNum();
} }
private Set getUnusedChilrenSet(){ private Set<String> getUnusedChilrenSet(){
if(unusedChildrenSet == null){ if(unusedChildrenSet == null){
String childIds[] = CDataUtil.stringToArray(unusedChildren, ";"); //$NON-NLS-1$ String childIds[] = CDataUtil.stringToArray(unusedChildren, ";"); //$NON-NLS-1$
if(childIds == null) if(childIds == null)
unusedChildrenSet = new HashSet(); unusedChildrenSet = new HashSet<String>();
else { else {
unusedChildrenSet = new HashSet(); unusedChildrenSet = new HashSet<String>();
unusedChildrenSet.addAll(Arrays.asList(childIds)); unusedChildrenSet.addAll(Arrays.asList(childIds));
} }
} }
@ -2746,7 +2716,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
} }
void addUnusedChild(ITool tool){ void addUnusedChild(ITool tool){
Set set = getUnusedChilrenSet(); Set<String> set = getUnusedChilrenSet();
set.add(tool.getId()); set.add(tool.getId());
unusedChildrenSet = set; unusedChildrenSet = set;
unusedChildren = translateUnusedIdSetToString(set); unusedChildren = translateUnusedIdSetToString(set);
@ -2760,7 +2730,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
unusedChildren = children; unusedChildren = children;
} }
private String translateUnusedIdSetToString(Set set){ private String translateUnusedIdSetToString(Set<String> set){
return CDataUtil.arrayToString(set.toArray(), ";"); //$NON-NLS-1$ return CDataUtil.arrayToString(set.toArray(), ";"); //$NON-NLS-1$
} }