mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
cosmetics: ehnanced loops etc
This commit is contained in:
parent
e6d91ec735
commit
3e29fc70a1
1 changed files with 54 additions and 65 deletions
|
@ -353,6 +353,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
*
|
*
|
||||||
* @param parent The {@link IToolChain} or {@link IResourceConfiguration}
|
* @param parent The {@link IToolChain} or {@link IResourceConfiguration}
|
||||||
* the tool will be added to.
|
* the tool will be added to.
|
||||||
|
* @param toolSuperClass superclass of the tool
|
||||||
* @param Id The new Tool ID
|
* @param Id The new Tool ID
|
||||||
* @param name The new Tool name
|
* @param name The new Tool name
|
||||||
* @param tool The existing tool to clone.
|
* @param tool The existing tool to clone.
|
||||||
|
@ -661,10 +662,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
ManagedBuildManager.putConfigElement(this, element);
|
ManagedBuildManager.putConfigElement(this, element);
|
||||||
|
|
||||||
// id
|
// id
|
||||||
setId(element.getAttribute(ITool.ID));
|
setId(element.getAttribute(IBuildObject.ID));
|
||||||
|
|
||||||
// name
|
// name
|
||||||
setName(element.getAttribute(ITool.NAME));
|
setName(element.getAttribute(IBuildObject.NAME));
|
||||||
|
|
||||||
// version
|
// version
|
||||||
setVersion(getVersionFromId());
|
setVersion(getVersionFromId());
|
||||||
|
@ -1330,9 +1331,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
return types;
|
return types;
|
||||||
|
|
||||||
List<OutputType> list = new ArrayList<OutputType>(types.length);
|
List<OutputType> list = new ArrayList<OutputType>(types.length);
|
||||||
OutputType type;
|
for (IOutputType itype : types) {
|
||||||
for(int i = 0; i < types.length; i++){
|
OutputType type = (OutputType)itype;
|
||||||
type = (OutputType)types[i];
|
|
||||||
if(type.isEnabled(this))
|
if(type.isEnabled(this))
|
||||||
list.add(type);
|
list.add(type);
|
||||||
}
|
}
|
||||||
|
@ -1345,9 +1345,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
return types;
|
return types;
|
||||||
|
|
||||||
List<InputType> list = new ArrayList<InputType>(types.length);
|
List<InputType> list = new ArrayList<InputType>(types.length);
|
||||||
InputType type;
|
for (IInputType itype : types) {
|
||||||
for(int i = 0; i < types.length; i++){
|
InputType type = (InputType)itype;
|
||||||
type = (InputType)types[i];
|
|
||||||
if(type.isEnabled(this))
|
if(type.isEnabled(this))
|
||||||
list.add(type);
|
list.add(type);
|
||||||
}
|
}
|
||||||
|
@ -1457,14 +1456,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
private Object[][] getOptions(ITool[] tools) {
|
private Object[][] getOptions(ITool[] tools) {
|
||||||
ITool catTool = this;
|
ITool catTool = this;
|
||||||
ITool tool = null;
|
ITool tool = null;
|
||||||
for (int i = 0; i < tools.length; ++i) {
|
for (ITool curTool : tools) {
|
||||||
ITool current = tools[i];
|
ITool superTool = curTool;
|
||||||
do {
|
do {
|
||||||
if (catTool == current) {
|
if (catTool == superTool) {
|
||||||
tool = tools[i];
|
tool = curTool;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while ((current = current.getSuperClass()) != null);
|
} while ((superTool = superTool.getSuperClass()) != null);
|
||||||
if (tool != null) break;
|
if (tool != null) break;
|
||||||
}
|
}
|
||||||
// Get all of the tool's options and see which ones are part of
|
// Get all of the tool's options and see which ones are part of
|
||||||
|
@ -1479,8 +1478,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
IOption[] allOptions = tool.getOptions();
|
IOption[] allOptions = tool.getOptions();
|
||||||
Object[][] myOptions = new Object[allOptions.length][2];
|
Object[][] myOptions = new Object[allOptions.length][2];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < allOptions.length; ++i) {
|
for (IOption option : allOptions) {
|
||||||
IOption option = allOptions[i];
|
|
||||||
IOptionCategory optCat = option.getCategory();
|
IOptionCategory optCat = option.getCategory();
|
||||||
if (optCat instanceof ITool) {
|
if (optCat instanceof ITool) {
|
||||||
// Determine if the category is this tool or a superclass
|
// Determine if the category is this tool or a superclass
|
||||||
|
@ -1701,8 +1699,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
public List<String> getInputExtensions() {
|
public List<String> getInputExtensions() {
|
||||||
String[] exts = getPrimaryInputExtensions();
|
String[] exts = getPrimaryInputExtensions();
|
||||||
List<String> extList = new ArrayList<String>();
|
List<String> extList = new ArrayList<String>();
|
||||||
for (int i=0; i<exts.length; i++) {
|
for (String ext : exts) {
|
||||||
extList.add(exts[i]);
|
extList.add(ext);
|
||||||
}
|
}
|
||||||
return extList;
|
return extList;
|
||||||
}
|
}
|
||||||
|
@ -1774,10 +1772,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
IInputType[] types = getInputTypes();
|
IInputType[] types = getInputTypes();
|
||||||
if (types != null && types.length > 0) {
|
if (types != null && types.length > 0) {
|
||||||
List<String> allExts = new ArrayList<String>();
|
List<String> allExts = new ArrayList<String>();
|
||||||
for (int i=0; i<types.length; i++) {
|
for (IInputType type : types) {
|
||||||
String[] exts = ((InputType)types[i]).getSourceExtensions(this, project);
|
String[] exts = ((InputType)type).getSourceExtensions(this, project);
|
||||||
for (int j=0; j<exts.length; j++) {
|
for (String ext : exts) {
|
||||||
allExts.add(exts[j]);
|
allExts.add(ext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allExts.size() > 0) {
|
if (allExts.size() > 0) {
|
||||||
|
@ -1818,9 +1816,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
IInputType type = null;
|
IInputType type = null;
|
||||||
IInputType[] types = getInputTypes();
|
IInputType[] types = getInputTypes();
|
||||||
if (types != null && types.length > 0) {
|
if (types != null && types.length > 0) {
|
||||||
for (int i=0; i<types.length; i++) {
|
for (IInputType t : types) {
|
||||||
if (((InputType)types[i]).isSourceExtension(this, inputExtension, project)) {
|
if (((InputType)t).isSourceExtension(this, inputExtension, project)) {
|
||||||
type = types[i];
|
type = t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1835,8 +1833,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
public IPath[] getAdditionalDependencies() {
|
public IPath[] getAdditionalDependencies() {
|
||||||
List<IPath> allDeps = new ArrayList<IPath>();
|
List<IPath> allDeps = new ArrayList<IPath>();
|
||||||
IInputType[] types = getInputTypes();
|
IInputType[] types = getInputTypes();
|
||||||
for (int i=0; i<types.length; i++) {
|
for (IInputType type : types) {
|
||||||
IInputType type = types[i];
|
|
||||||
// Additional dependencies come from 2 places.
|
// Additional dependencies come from 2 places.
|
||||||
// 1. From AdditionalInput childen
|
// 1. From AdditionalInput childen
|
||||||
for (IPath p : type.getAdditionalDependencies())
|
for (IPath p : type.getAdditionalDependencies())
|
||||||
|
@ -2144,9 +2141,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
public IConfigurationElement getDependencyGeneratorElementForExtension(String sourceExt) {
|
public IConfigurationElement getDependencyGeneratorElementForExtension(String sourceExt) {
|
||||||
IInputType[] types = getInputTypes();
|
IInputType[] types = getInputTypes();
|
||||||
if (types != null) {
|
if (types != null) {
|
||||||
for (int i=0; i<types.length; i++) {
|
for (IInputType type : types) {
|
||||||
if (types[i].isSourceExtension(this, sourceExt)) {
|
if (type.isSourceExtension(this, sourceExt)) {
|
||||||
return ((InputType)types[i]).getDependencyGeneratorElement();
|
return ((InputType)type).getDependencyGeneratorElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2339,9 +2336,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
IOutputType type = null;
|
IOutputType type = null;
|
||||||
IOutputType[] types = getOutputTypes();
|
IOutputType[] types = getOutputTypes();
|
||||||
if (types != null && types.length > 0) {
|
if (types != null && types.length > 0) {
|
||||||
for (int i=0; i<types.length; i++) {
|
for (IOutputType t : types) {
|
||||||
if (types[i].isOutputExtension(this, outputExtension)) {
|
if (t.isOutputExtension(this, outputExtension)) {
|
||||||
type = types[i];
|
type = t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2489,13 +2486,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method used internally by the Tool to obtain the command flags with the build macros resolved,
|
* This method used internally by the Tool to obtain the command flags with the build macros resolved,
|
||||||
* but could be also used by other MBS components to adjust the tool flags resolution
|
* but could be also used by other MBS components to adjust the tool flags resolution
|
||||||
* behavior by passing the method some custom macro substitutor
|
* behavior by passing the method some custom macro substitutor
|
||||||
*
|
*
|
||||||
* @param inputFileLocation
|
* @param inputFileLocation
|
||||||
* @param outputFileLocation
|
* @param outputFileLocation
|
||||||
* @param macroSubstitutor
|
* @param macroSubstitutor
|
||||||
|
* @return the command flags with the build macros resolved
|
||||||
* @throws BuildException
|
* @throws BuildException
|
||||||
*/
|
*/
|
||||||
public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation,
|
public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation,
|
||||||
|
@ -2558,7 +2556,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
case IOption.STRING :{
|
case IOption.STRING :{
|
||||||
String strCmd = option.getCommand();
|
String strCmd = option.getCommand();
|
||||||
String val = option.getStringValue();
|
String val = option.getStringValue();
|
||||||
IMacroContextInfo info = provider.getMacroContextInfo(BuildMacroProvider.CONTEXT_FILE, new FileContextData(inputFileLocation, outputFileLocation, option, this));
|
IMacroContextInfo info = provider.getMacroContextInfo(IBuildMacroProvider.CONTEXT_FILE, new FileContextData(inputFileLocation, outputFileLocation, option, this));
|
||||||
if(info != null){
|
if(info != null){
|
||||||
macroSubstitutor.setMacroContextInfo(info);
|
macroSubstitutor.setMacroContextInfo(info);
|
||||||
if (val.length() > 0
|
if (val.length() > 0
|
||||||
|
@ -2585,8 +2583,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
macroSubstitutor.setMacroContextInfo(info);
|
macroSubstitutor.setMacroContextInfo(info);
|
||||||
String[] list = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true);
|
String[] list = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true);
|
||||||
if(list != null){
|
if(list != null){
|
||||||
for (int j = 0; j < list.length; j++) {
|
for (String temp : list) {
|
||||||
String temp = list[j];
|
|
||||||
if(temp.length() > 0)
|
if(temp.length() > 0)
|
||||||
sb.append( evaluateCommand( listCmd, temp ) + WHITE_SPACE );
|
sb.append( evaluateCommand( listCmd, temp ) + WHITE_SPACE );
|
||||||
}
|
}
|
||||||
|
@ -2604,8 +2601,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
macroSubstitutor.setMacroContextInfo(info);
|
macroSubstitutor.setMacroContextInfo(info);
|
||||||
String[] paths = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true);
|
String[] paths = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true);
|
||||||
if(paths != null){
|
if(paths != null){
|
||||||
for (int j = 0; j < paths.length; j++) {
|
for (String temp : paths) {
|
||||||
String temp = paths[j];
|
|
||||||
if(temp.length() > 0 && !temp.equals(EMPTY_QUOTED_STRING))
|
if(temp.length() > 0 && !temp.equals(EMPTY_QUOTED_STRING))
|
||||||
sb.append( evaluateCommand( incCmd, temp ) + WHITE_SPACE);
|
sb.append( evaluateCommand( incCmd, temp ) + WHITE_SPACE);
|
||||||
}
|
}
|
||||||
|
@ -2623,8 +2619,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
macroSubstitutor.setMacroContextInfo(info);
|
macroSubstitutor.setMacroContextInfo(info);
|
||||||
String[] symbols = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true);
|
String[] symbols = CdtVariableResolver.resolveStringListValues(option.getBasicStringListValue(), macroSubstitutor, true);
|
||||||
if(symbols != null){
|
if(symbols != null){
|
||||||
for (int j = 0; j < symbols.length; j++) {
|
for (String temp : symbols) {
|
||||||
String temp = symbols[j];
|
|
||||||
if(temp.length() > 0)
|
if(temp.length() > 0)
|
||||||
sb.append( evaluateCommand( defCmd, temp ) + WHITE_SPACE);
|
sb.append( evaluateCommand( defCmd, temp ) + WHITE_SPACE);
|
||||||
}
|
}
|
||||||
|
@ -2663,9 +2658,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
// Get all of the optionList
|
// Get all of the optionList
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
String[] flags = getToolCommandFlags(inputFileLocation,outputFileLocation);
|
String[] flags = getToolCommandFlags(inputFileLocation,outputFileLocation);
|
||||||
for (int index = 0; index < flags.length; index++) {
|
for (String flag : flags) {
|
||||||
if( flags[ index ] != null ) {
|
if( flag != null ) {
|
||||||
buf.append( flags[ index ] + WHITE_SPACE );
|
buf.append( flag + WHITE_SPACE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2680,8 +2675,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String[] exts = getAllDependencyExtensions();
|
String[] exts = getAllDependencyExtensions();
|
||||||
for (int i=0; i<exts.length; i++) {
|
for (String dep : exts) {
|
||||||
if (ext.equals(exts[i])) return true;
|
if (ext.equals(dep)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2757,8 +2752,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
if (!hasOutputTypes()) {
|
if (!hasOutputTypes()) {
|
||||||
String[] exts = getOutputsAttribute();
|
String[] exts = getOutputsAttribute();
|
||||||
if (exts != null) {
|
if (exts != null) {
|
||||||
for (int i = 0; i < exts.length; i++) {
|
for (String ext : exts) {
|
||||||
if (exts[i].equals(extension))
|
if (ext.equals(extension))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3115,8 +3110,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
&& (!versionsSupported.equals(""))) { //$NON-NLS-1$
|
&& (!versionsSupported.equals(""))) { //$NON-NLS-1$
|
||||||
String[] tmpVersions = versionsSupported.split(","); //$NON-NLS-1$
|
String[] tmpVersions = versionsSupported.split(","); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int j = 0; j < tmpVersions.length; j++) {
|
for (String tmpVersion : tmpVersions) {
|
||||||
if (new Version(version).equals(new Version(tmpVersions[j]))) {
|
if (new Version(version).equals(new Version(tmpVersion))) {
|
||||||
// version is supported.
|
// version is supported.
|
||||||
// Do the automatic conversion without
|
// Do the automatic conversion without
|
||||||
// prompting the user.
|
// prompting the user.
|
||||||
|
@ -3192,13 +3187,11 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
if (extensionPoint != null) {
|
if (extensionPoint != null) {
|
||||||
// Get the extensions
|
// Get the extensions
|
||||||
IExtension[] extensions = extensionPoint.getExtensions();
|
IExtension[] extensions = extensionPoint.getExtensions();
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (IExtension extension : extensions) {
|
||||||
// Get the configuration elements of each extension
|
// Get the configuration elements of each extension
|
||||||
IConfigurationElement[] configElements = extensions[i]
|
IConfigurationElement[] configElements = extension
|
||||||
.getConfigurationElements();
|
.getConfigurationElements();
|
||||||
for (int j = 0; j < configElements.length; j++) {
|
for (IConfigurationElement element : configElements) {
|
||||||
|
|
||||||
IConfigurationElement element = configElements[j];
|
|
||||||
|
|
||||||
if (element.getName().equals("converter")) { //$NON-NLS-1$
|
if (element.getName().equals("converter")) { //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -3216,9 +3209,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
.getBuildInfoVersion();
|
.getBuildInfoVersion();
|
||||||
|
|
||||||
// set the converter element based on the MbsVersion
|
// set the converter element based on the MbsVersion
|
||||||
if (currentMbsVersion
|
if (currentMbsVersion.isGreaterThan(new PluginVersionIdentifier(mbsVersion))) {
|
||||||
.isGreaterThan(new PluginVersionIdentifier(
|
|
||||||
mbsVersion))) {
|
|
||||||
previousMbsVersionConversionElement = element;
|
previousMbsVersionConversionElement = element;
|
||||||
} else {
|
} else {
|
||||||
currentMbsVersionConversionElement = element;
|
currentMbsVersionConversionElement = element;
|
||||||
|
@ -3287,12 +3278,12 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
int total = globalSpecs.length + specs.length;
|
int total = globalSpecs.length + specs.length;
|
||||||
String[] projSpecs = new String[total];
|
String[] projSpecs = new String[total];
|
||||||
int i=0;
|
int i=0;
|
||||||
for (int j=0; j<specs.length; j++) {
|
for (String spec : specs) {
|
||||||
projSpecs[i] = specs[j];
|
projSpecs[i] = spec;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
for (int j=0; j<globalSpecs.length; j++) {
|
for (String spec : globalSpecs) {
|
||||||
projSpecs[i] = globalSpecs[j];
|
projSpecs[i] = spec;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return projSpecs;
|
return projSpecs;
|
||||||
|
@ -3416,8 +3407,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
public boolean supportsLanguageSettings(){
|
public boolean supportsLanguageSettings(){
|
||||||
IOption options[] = getOptions();
|
IOption options[] = getOptions();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for(int i = 0; i < options.length; i++){
|
for (IOption option : options) {
|
||||||
IOption option = options[i];
|
|
||||||
try {
|
try {
|
||||||
int type = option.getValueType();
|
int type = option.getValueType();
|
||||||
if(ManagedBuildManager.optionTypeToEntryKind(type) != 0){
|
if(ManagedBuildManager.optionTypeToEntryKind(type) != 0){
|
||||||
|
@ -3494,8 +3484,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
}
|
}
|
||||||
InputType newType = (InputType)createInputType(base, id, base.getName(), false);
|
InputType newType = (InputType)createInputType(base, id, base.getName(), false);
|
||||||
IAdditionalInput addlInputs[] = base.getAdditionalInputs();
|
IAdditionalInput addlInputs[] = base.getAdditionalInputs();
|
||||||
for(int i = 0; i < addlInputs.length; i++){
|
for (IAdditionalInput addlInput : addlInputs) {
|
||||||
IAdditionalInput addlInput = addlInputs[i];
|
|
||||||
newType.createAdditionalInput(addlInput);
|
newType.createAdditionalInput(addlInput);
|
||||||
}
|
}
|
||||||
return newType;
|
return newType;
|
||||||
|
|
Loading…
Add table
Reference in a new issue