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:
parent
b8b795c2fb
commit
d58486e66d
4 changed files with 58 additions and 0 deletions
|
@ -222,6 +222,20 @@ public interface IConfiguration extends IBuildObject {
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -161,6 +161,20 @@ public interface IToolChain extends IBuildObject, IHoldsOptions {
|
|||
*/
|
||||
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
|
||||
* tool-chain, or <code>null</code> if the attribute was not specified.
|
||||
|
|
|
@ -660,6 +660,13 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
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)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getTargetTool()
|
||||
*/
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
|||
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
|
||||
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.IProjectType;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
|
||||
|
@ -821,6 +822,28 @@ public class ToolChain extends HoldsOptions implements IToolChain {
|
|||
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)
|
||||
* Safe accessor for the list of tools.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue