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
30dd1fc86f
commit
e6d91ec735
1 changed files with 28 additions and 45 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 Symbian Ltd and others.
|
* Copyright (c) 2005, 2010 Symbian Ltd 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
|
||||||
|
@ -15,7 +15,6 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -31,7 +30,6 @@ import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
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.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -100,9 +98,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
|
|
||||||
boolean copyIds = id.equals(source.id);
|
boolean copyIds = id.equals(source.id);
|
||||||
if (source.optionMap != null) {
|
if (source.optionMap != null) {
|
||||||
Iterator<Option> iter = source.getOptionCollection().iterator();
|
for (Option option : source.getOptionCollection()) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
Option option = iter.next();
|
|
||||||
int nnn = ManagedBuildManager.getRandomNumber();
|
int nnn = ManagedBuildManager.getRandomNumber();
|
||||||
String subId;
|
String subId;
|
||||||
String subName;
|
String subName;
|
||||||
|
@ -161,11 +157,11 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
* @return true when a child has been loaded, false otherwise
|
* @return true when a child has been loaded, false otherwise
|
||||||
*/
|
*/
|
||||||
protected boolean loadChild(ICStorageElement element) {
|
protected boolean loadChild(ICStorageElement element) {
|
||||||
if (element.getName().equals(ITool.OPTION)) {
|
if (element.getName().equals(IHoldsOptions.OPTION)) {
|
||||||
Option option = new Option(this, element);
|
Option option = new Option(this, element);
|
||||||
addOption(option);
|
addOption(option);
|
||||||
return true;
|
return true;
|
||||||
} else if (element.getName().equals(ITool.OPTION_CAT)) {
|
} else if (element.getName().equals(IHoldsOptions.OPTION_CAT)) {
|
||||||
new OptionCategory(this, element);
|
new OptionCategory(this, element);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -179,11 +175,11 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
* @return true when a child has been loaded, false otherwise
|
* @return true when a child has been loaded, false otherwise
|
||||||
*/
|
*/
|
||||||
protected boolean loadChild(IManagedConfigElement element) {
|
protected boolean loadChild(IManagedConfigElement element) {
|
||||||
if (element.getName().equals(ITool.OPTION)) {
|
if (element.getName().equals(IHoldsOptions.OPTION)) {
|
||||||
Option option = new Option(this, element);
|
Option option = new Option(this, element);
|
||||||
addOption(option);
|
addOption(option);
|
||||||
return true;
|
return true;
|
||||||
} else if (element.getName().equals(ITool.OPTION_CAT)) {
|
} else if (element.getName().equals(IHoldsOptions.OPTION_CAT)) {
|
||||||
new OptionCategory(this, element);
|
new OptionCategory(this, element);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -191,30 +187,22 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persist the tool to the project file. Intended to be called by derived
|
* Persist the tool to the XML storage element. Intended to be called by derived
|
||||||
* class only, thus do not handle exceptions.
|
* class only, thus do not handle exceptions.
|
||||||
*
|
*
|
||||||
* @param doc
|
* @param element where to serialize the tool
|
||||||
* @param element
|
|
||||||
* @throws BuildException
|
* @throws BuildException
|
||||||
*/
|
*/
|
||||||
protected void serialize(ICStorageElement element) throws BuildException {
|
protected void serialize(ICStorageElement element) throws BuildException {
|
||||||
|
|
||||||
Iterator<IOptionCategory> iter;
|
|
||||||
|
|
||||||
if (childOptionCategories != null) {
|
if (childOptionCategories != null) {
|
||||||
iter = childOptionCategories.listIterator();
|
for (IOptionCategory optCat : childOptionCategories) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
OptionCategory optCat = (OptionCategory)iter.next();
|
|
||||||
ICStorageElement optCatElement = element.createChild(OPTION);
|
ICStorageElement optCatElement = element.createChild(OPTION);
|
||||||
optCat.serialize(optCatElement);
|
((OptionCategory)optCat).serialize(optCatElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<Option> optionElements = getOptionCollection();
|
Collection<Option> optionElements = getOptionCollection();
|
||||||
Iterator<Option> iter2 = optionElements.iterator();
|
for (Option option : optionElements) {
|
||||||
while (iter2.hasNext()) {
|
|
||||||
Option option = iter2.next();
|
|
||||||
ICStorageElement optionElement = element.createChild(OPTION);
|
ICStorageElement optionElement = element.createChild(OPTION);
|
||||||
option.serialize(optionElement);
|
option.serialize(optionElement);
|
||||||
}
|
}
|
||||||
|
@ -241,9 +229,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
* @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOptions(IHoldsOptions)
|
* @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOptions(IHoldsOptions)
|
||||||
*/
|
*/
|
||||||
public void createOptions(IHoldsOptions superClass) {
|
public void createOptions(IHoldsOptions superClass) {
|
||||||
Iterator<Option> iter = ((HoldsOptions)superClass).getOptionCollection().iterator();
|
for (Option optionChild : ((HoldsOptions)superClass).getOptionCollection()) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
Option optionChild = (Option) iter.next();
|
|
||||||
int nnn = ManagedBuildManager.getRandomNumber();
|
int nnn = ManagedBuildManager.getRandomNumber();
|
||||||
String subId = optionChild.getId() + "." + nnn; //$NON-NLS-1$
|
String subId = optionChild.getId() + "." + nnn; //$NON-NLS-1$
|
||||||
createOption(optionChild, subId, optionChild.getName(), false);
|
createOption(optionChild, subId, optionChild.getName(), false);
|
||||||
|
@ -278,11 +264,9 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
}
|
}
|
||||||
// Our options take precedence.
|
// Our options take precedence.
|
||||||
Collection<Option> ourOpts = getOptionCollection();
|
Collection<Option> ourOpts = getOptionCollection();
|
||||||
Iterator<Option> iter = ourOpts.iterator();
|
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
while(iter.hasNext()) {
|
for (Option ourOpt : ourOpts) {
|
||||||
int j = options.length;
|
int j = options.length;
|
||||||
IOption ourOpt = iter.next();
|
|
||||||
if (ourOpt.getSuperClass() != null) {
|
if (ourOpt.getSuperClass() != null) {
|
||||||
String matchId = ourOpt.getSuperClass().getId();
|
String matchId = ourOpt.getSuperClass().getId();
|
||||||
search:
|
search:
|
||||||
|
@ -311,7 +295,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options = (IOption[])ourOpts.toArray(new IOption[ourOpts.size()]);
|
options = ourOpts.toArray(new IOption[ourOpts.size()]);
|
||||||
}
|
}
|
||||||
// Check for any invalid options.
|
// Check for any invalid options.
|
||||||
int numInvalidOptions = 0;
|
int numInvalidOptions = 0;
|
||||||
|
@ -347,7 +331,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
* @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionById(java.lang.String)
|
* @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionById(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public IOption getOptionById(String id) {
|
public IOption getOptionById(String id) {
|
||||||
IOption opt = (IOption)getOptionMap().get(id);
|
IOption opt = getOptionMap().get(id);
|
||||||
if (opt == null) {
|
if (opt == null) {
|
||||||
if (superClass != null) {
|
if (superClass != null) {
|
||||||
return superClass.getOptionById(id);
|
return superClass.getOptionById(id);
|
||||||
|
@ -365,8 +349,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
|
|
||||||
// Look for an option with this ID, or an option with a superclass with this id
|
// Look for an option with this ID, or an option with a superclass with this id
|
||||||
IOption[] options = getOptions();
|
IOption[] options = getOptions();
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (IOption targetOption : options) {
|
||||||
IOption targetOption = options[i];
|
|
||||||
IOption option = targetOption;
|
IOption option = targetOption;
|
||||||
do {
|
do {
|
||||||
if (optionId.equals(option.getId())) {
|
if (optionId.equals(option.getId())) {
|
||||||
|
@ -393,7 +376,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
superCats = superClass.getChildCategories();
|
superCats = superClass.getChildCategories();
|
||||||
}
|
}
|
||||||
if ( childOptionCategories != null ) {
|
if ( childOptionCategories != null ) {
|
||||||
ourCats = (IOptionCategory[])childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
|
ourCats = childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
|
||||||
}
|
}
|
||||||
// Add the two arrays together;
|
// Add the two arrays together;
|
||||||
if (superCats.length > 0 || ourCats.length > 0) {
|
if (superCats.length > 0 || ourCats.length > 0) {
|
||||||
|
@ -482,7 +465,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
* org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionCategory()
|
* org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionCategory()
|
||||||
*/
|
*/
|
||||||
public IOptionCategory getOptionCategory(String id) {
|
public IOptionCategory getOptionCategory(String id) {
|
||||||
IOptionCategory cat = (IOptionCategory)getCategoryMap().get(id);
|
IOptionCategory cat = getCategoryMap().get(id);
|
||||||
if (cat == null && superClass != null) {
|
if (cat == null && superClass != null) {
|
||||||
// Look up the holders superclasses to find the category
|
// Look up the holders superclasses to find the category
|
||||||
return superClass.getOptionCategory(id);
|
return superClass.getOptionCategory(id);
|
||||||
|
@ -537,7 +520,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
}
|
}
|
||||||
// Somewhat wasteful, but use the vector to retrieve the categories in proper order
|
// Somewhat wasteful, but use the vector to retrieve the categories in proper order
|
||||||
for (String id : getCategoryIds()) {
|
for (String id : getCategoryIds()) {
|
||||||
IOptionCategory current = (IOptionCategory)getCategoryMap().get(id);
|
IOptionCategory current = getCategoryMap().get(id);
|
||||||
if (current instanceof Tool) {
|
if (current instanceof Tool) {
|
||||||
((Tool)current).resolveReferences();
|
((Tool)current).resolveReferences();
|
||||||
} else if (current instanceof ToolChain) {
|
} else if (current instanceof ToolChain) {
|
||||||
|
@ -668,8 +651,8 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
public void adjustOptions(boolean extensions){
|
public void adjustOptions(boolean extensions){
|
||||||
IOption options[] = getOptions();
|
IOption options[] = getOptions();
|
||||||
|
|
||||||
for(int i = 0; i < options.length; i++){
|
for (IOption opt : options) {
|
||||||
Option option = (Option)options[i];
|
Option option = (Option)opt;
|
||||||
BooleanExpressionApplicabilityCalculator calc =
|
BooleanExpressionApplicabilityCalculator calc =
|
||||||
option.getBooleanExpressionCalculator(extensions);
|
option.getBooleanExpressionCalculator(extensions);
|
||||||
|
|
||||||
|
@ -681,8 +664,8 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
public boolean supportsType(String type) {
|
public boolean supportsType(String type) {
|
||||||
IOption options[] = getOptions();
|
IOption options[] = getOptions();
|
||||||
boolean supports = false;
|
boolean supports = false;
|
||||||
for(int i = 0; i < options.length; i++){
|
for (IOption opt : options) {
|
||||||
Option option = (Option)options[i];
|
Option option = (Option)opt;
|
||||||
if(option.supportsType(type)){
|
if(option.supportsType(type)){
|
||||||
supports = true;
|
supports = true;
|
||||||
break;
|
break;
|
||||||
|
@ -698,8 +681,8 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
public boolean supportsValue(String type, String value){
|
public boolean supportsValue(String type, String value){
|
||||||
IOption options[] = getOptions();
|
IOption options[] = getOptions();
|
||||||
boolean supports = false;
|
boolean supports = false;
|
||||||
for(int i = 0; i < options.length; i++){
|
for (IOption opt : options) {
|
||||||
Option option = (Option)options[i];
|
Option option = (Option)opt;
|
||||||
if(option.supportsValue(type, value)){
|
if(option.supportsValue(type, value)){
|
||||||
supports = true;
|
supports = true;
|
||||||
break;
|
break;
|
||||||
|
@ -741,8 +724,8 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
|
||||||
public boolean requiresType(String typeId) {
|
public boolean requiresType(String typeId) {
|
||||||
IOption options[] = getOptions();
|
IOption options[] = getOptions();
|
||||||
boolean requires = false;
|
boolean requires = false;
|
||||||
for(int i = 0; i < options.length; i++){
|
for (IOption opt : options) {
|
||||||
Option option = (Option)options[i];
|
Option option = (Option)opt;
|
||||||
if(option.requiresType(typeId)){
|
if(option.requiresType(typeId)){
|
||||||
requires = true;
|
requires = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue