1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Add getToolBySuperClassId convenience method

This commit is contained in:
Leo Treggiari 2005-11-13 23:28:42 +00:00
parent b8b795c2fb
commit d58486e66d
4 changed files with 58 additions and 0 deletions

View file

@ -221,6 +221,20 @@ public interface IConfiguration extends IBuildObject {
* @return ITool * @return ITool
*/ */
public ITool getTool(String id); public ITool getTool(String id);
/**
* Returns the <code>ITool</code> in this configuration's tool-chain with
* the specified ID, or a tool with a superclass with this id.
*
* <p>If the tool-chain does not have a tool with that ID, the method
* returns <code>null</code>. It is the responsibility of the caller to
* verify the return value.
*
* @param id unique identifier of the tool to search for
* @return <code>ITool</code>
* @since 3.0.2
*/
public ITool getToolBySuperClassId(String id);
/** /**
* Returns the <code>IToolChain</code> child of this configuration. * Returns the <code>IToolChain</code> child of this configuration.

View file

@ -161,6 +161,20 @@ public interface IToolChain extends IBuildObject, IHoldsOptions {
*/ */
public ITool getTool(String id); public ITool getTool(String id);
/**
* Returns the <code>ITool</code> in the tool-chain with the specified
* ID, or a tool with a superclass with this id.
*
* <p>If the tool-chain does not have a tool with that ID, the method
* returns <code>null</code>. It is the responsibility of the caller to
* verify the return value.
*
* @param id unique identifier of the tool to search for
* @return <code>ITool</code>
* @since 3.0.2
*/
public ITool getToolBySuperClassId(String id);
/** /**
* Returns the <code>IToolChain</code> that is the superclass of this * Returns the <code>IToolChain</code> that is the superclass of this
* tool-chain, or <code>null</code> if the attribute was not specified. * tool-chain, or <code>null</code> if the attribute was not specified.

View file

@ -660,6 +660,13 @@ public class Configuration extends BuildObject implements IConfiguration {
return toolChain.getTool(id); return toolChain.getTool(id);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getToolBySuperClassId(java.lang.String)
*/
public ITool getToolBySuperClassId(String id) {
return toolChain.getToolBySuperClassId(id);
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool() * @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool()
*/ */

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported; import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOutputType; import org.eclipse.cdt.managedbuilder.core.IOutputType;
import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform; import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
@ -820,6 +821,28 @@ public class ToolChain extends HoldsOptions implements IToolChain {
Tool tool = (Tool)getToolMap().get(id); Tool tool = (Tool)getToolMap().get(id);
return (ITool)tool; return (ITool)tool;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getToolBySuperClassId(java.lang.String)
*/
public ITool getToolBySuperClassId(String id) {
if (id == null) return null;
// Look for a tool with this ID, or a tool with a superclass with this id
ITool[] tools = getTools();
for (int i = 0; i < tools.length; i++) {
ITool targetTool = tools[i];
ITool tool = targetTool;
do {
if (id.equals(tool.getId())) {
return targetTool;
}
tool = tool.getSuperClass();
} while (tool != null);
}
return null;
}
/* (non-Javadoc) /* (non-Javadoc)
* Safe accessor for the list of tools. * Safe accessor for the list of tools.