mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Removed the AbstractToolReference class because there is no longer any need for it with the introduction of a dynamic styrategy for model element creation. I kept the IToolReference interface, though. Moved several public methods into it and changed the clients of those methods so that the interface is used.
This commit is contained in:
parent
481715a2b8
commit
d980d24f00
9 changed files with 974 additions and 945 deletions
|
@ -1,6 +1,5 @@
|
|||
pluginName=C/C++ Managed Builder Core
|
||||
providerName=Eclipse.org
|
||||
|
||||
ExtensionPoint.name=Managed Build Tools
|
||||
GeneratedMakefileCBuilder.name=Generated Makefile Builder
|
||||
ManagedBuildNature.name=Managed Builder Project
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</requires>
|
||||
|
||||
|
||||
<extension-point id="ManagedBuildInfo" name="%ExtensionPoint.name" schema="schema/ManagedBuildTools.exsd"/>
|
||||
<extension-point id="ManagedBuildInfo" name="Managed Build Tools" schema="schema/ManagedBuildTools.exsd"/>
|
||||
|
||||
<!-- =================================================================================== -->
|
||||
<!-- Extension Point: IScannerInfoProvider for the managed Builder -->
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
package org.eclipse.cdt.managedbuilder.core;
|
||||
|
||||
/**********************************************************************
|
||||
* Copyright (c) 2004 TimeSys Corporation and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* TimeSys Corporation - initial API and implementation
|
||||
**********************************************************************/
|
||||
|
||||
public abstract class AbstractToolReference implements IToolReference {
|
||||
|
||||
protected ITool parent;
|
||||
|
||||
public AbstractToolReference() {
|
||||
}
|
||||
|
||||
public AbstractToolReference(ITool parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public boolean references(ITool target) {
|
||||
if (equals(target)) {
|
||||
// we are the target
|
||||
return true;
|
||||
}
|
||||
else if (parent instanceof IToolReference) {
|
||||
// check the reference we are overriding
|
||||
return ((IToolReference)parent).references(target);
|
||||
}
|
||||
else if (target instanceof IToolReference) {
|
||||
return parent.equals(((IToolReference)target).getTool());
|
||||
}
|
||||
else {
|
||||
// the real reference
|
||||
return parent.equals(target);
|
||||
}
|
||||
}
|
||||
|
||||
public ITool getTool() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean buildsFileType(String extension) {
|
||||
return parent.buildsFileType(extension);
|
||||
}
|
||||
|
||||
public int getNatureFilter() {
|
||||
return parent.getNatureFilter();
|
||||
}
|
||||
|
||||
public IOption getOption(String id) {
|
||||
return parent.getOption(id);
|
||||
}
|
||||
|
||||
public IOption[] getOptions() {
|
||||
return parent.getOptions();
|
||||
}
|
||||
|
||||
public String getOutputExtension(String inputExtension) {
|
||||
return parent.getOutputExtension(inputExtension);
|
||||
}
|
||||
|
||||
public String getOutputFlag() {
|
||||
return parent.getOutputFlag();
|
||||
}
|
||||
|
||||
public String getOutputPrefix() {
|
||||
return parent.getOutputPrefix();
|
||||
}
|
||||
|
||||
public String getToolCommand() {
|
||||
return parent.getToolCommand();
|
||||
}
|
||||
|
||||
public String getToolFlags() throws BuildException {
|
||||
return parent.getToolFlags();
|
||||
}
|
||||
|
||||
public IOptionCategory getTopOptionCategory() {
|
||||
return parent.getTopOptionCategory();
|
||||
}
|
||||
|
||||
public boolean isHeaderFile(String ext) {
|
||||
return parent.isHeaderFile(ext);
|
||||
}
|
||||
|
||||
public boolean producesFileType(String outputExtension) {
|
||||
return parent.producesFileType(outputExtension);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return parent.getId();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return parent.getName();
|
||||
}
|
||||
}
|
|
@ -10,8 +10,36 @@
|
|||
* TimeSys Corporation - initial API and implementation
|
||||
**********************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.OptionReference;
|
||||
|
||||
public interface IToolReference extends ITool {
|
||||
|
||||
/**
|
||||
* Answers a reference to the option. If the reference does not exist,
|
||||
* a new reference is created.
|
||||
*
|
||||
* @param option
|
||||
* @return OptionReference
|
||||
*/
|
||||
public OptionReference createOptionReference(IOption option);
|
||||
|
||||
/**
|
||||
* Answers the list of option references contained in the receiver.
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
public List getOptionReferenceList();
|
||||
|
||||
/**
|
||||
* Answers the tool that the reference has been created for.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ITool getTool();
|
||||
|
||||
/**
|
||||
* Answers <code>true</code> if the reference is a reference to the
|
||||
* tool specified in the argument.
|
||||
|
@ -21,11 +49,13 @@ public interface IToolReference extends ITool {
|
|||
*/
|
||||
public boolean references(ITool tool);
|
||||
|
||||
|
||||
/**
|
||||
* Answers the tool that the reference has been created for.
|
||||
* Set the tool command in the receiver to be the argument.
|
||||
*
|
||||
* @return
|
||||
* @param cmd
|
||||
* @return <code>true</code> if the command is changed, else <code>false</code>
|
||||
*/
|
||||
public ITool getTool();
|
||||
public boolean setToolCommand(String cmd);
|
||||
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
|||
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ToolReference;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Target;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -282,9 +280,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
*/
|
||||
public static void setToolCommand(IConfiguration config, ITool tool, String command) {
|
||||
// The tool may be a reference.
|
||||
if (tool instanceof ToolReference) {
|
||||
if (tool instanceof IToolReference) {
|
||||
// If so, just set the command in the reference
|
||||
((ToolReference)tool).setToolCommand(command);
|
||||
((IToolReference)tool).setToolCommand(command);
|
||||
} else {
|
||||
config.setToolCommand(tool, command);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
|||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolReference;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -225,7 +226,7 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
return toolRef.createOptionReference(option);
|
||||
}
|
||||
} else {
|
||||
ToolReference toolRef = getToolReference(option.getTool());
|
||||
IToolReference toolRef = getToolReference(option.getTool());
|
||||
if (toolRef == null)
|
||||
toolRef = new ToolReference(this, option.getTool());
|
||||
return toolRef.createOptionReference(option);
|
||||
|
@ -299,7 +300,7 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
|
||||
// Replace tools with local overrides
|
||||
for (int i = 0; i < tools.length; ++i) {
|
||||
ToolReference ref = getToolReference(tools[i]);
|
||||
IToolReference ref = getToolReference(tools[i]);
|
||||
if (ref != null)
|
||||
tools[i] = ref;
|
||||
}
|
||||
|
@ -331,7 +332,7 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
List references = new ArrayList();
|
||||
|
||||
// Get all the option references I add for this tool
|
||||
ToolReference toolRef = getToolReference(tool);
|
||||
IToolReference toolRef = getToolReference(tool);
|
||||
if (toolRef != null) {
|
||||
references.addAll(toolRef.getOptionReferenceList());
|
||||
}
|
||||
|
@ -372,7 +373,7 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
* @param tool
|
||||
* @return ToolReference
|
||||
*/
|
||||
private ToolReference getToolReference(ITool tool) {
|
||||
private IToolReference getToolReference(ITool tool) {
|
||||
// See if the receiver has a reference to the tool
|
||||
ToolReference ref = null;
|
||||
if (tool == null) return ref;
|
||||
|
@ -506,7 +507,7 @@ public class Configuration extends BuildObject implements IConfiguration {
|
|||
// Make sure the command is different
|
||||
if (command != null) {
|
||||
// Does this config have a ref to the tool
|
||||
ToolReference ref = getToolReference(tool);
|
||||
IToolReference ref = getToolReference(tool);
|
||||
if (ref == null) {
|
||||
// Then make one
|
||||
ref = new ToolReference(this, tool);
|
||||
|
|
|
@ -14,23 +14,25 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.AbstractToolReference;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||
import org.eclipse.cdt.managedbuilder.core.IToolReference;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class ToolReference extends AbstractToolReference {
|
||||
public class ToolReference implements IToolReference {
|
||||
private String command;
|
||||
private List optionReferences;
|
||||
private IBuildObject owner;
|
||||
protected ITool parent;
|
||||
private boolean resolved = true;
|
||||
|
||||
/**
|
||||
|
@ -110,7 +112,7 @@ public class ToolReference extends AbstractToolReference {
|
|||
* @param parent The <code>ITool</code>tool the reference will be based on.
|
||||
*/
|
||||
public ToolReference(BuildObject owner, ITool parent) {
|
||||
super(parent);
|
||||
this.parent = parent;
|
||||
this.owner = owner;
|
||||
|
||||
if (owner instanceof Configuration) {
|
||||
|
@ -120,6 +122,27 @@ public class ToolReference extends AbstractToolReference {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolReference#references(org.eclipse.cdt.managedbuilder.core.ITool)
|
||||
*/
|
||||
public boolean references(ITool target) {
|
||||
if (equals(target)) {
|
||||
// we are the target
|
||||
return true;
|
||||
}
|
||||
else if (parent instanceof IToolReference) {
|
||||
// check the reference we are overriding
|
||||
return ((IToolReference)parent).references(target);
|
||||
}
|
||||
else if (target instanceof IToolReference) {
|
||||
return parent.equals(((IToolReference)target).getTool());
|
||||
}
|
||||
else {
|
||||
// the real reference
|
||||
return parent.equals(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void resolveReferences() {
|
||||
if (!resolved) {
|
||||
resolved = true;
|
||||
|
@ -155,23 +178,15 @@ public class ToolReference extends AbstractToolReference {
|
|||
getOptionReferenceList().add(optionRef);
|
||||
}
|
||||
|
||||
private OptionReference getOptionReference(String id) {
|
||||
Iterator it = getOptionReferenceList().iterator();
|
||||
while (it.hasNext()) {
|
||||
OptionReference current = (OptionReference)it.next();
|
||||
if (current.getId().equals(id)) {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#buildsFileType(java.lang.String)
|
||||
*/
|
||||
public boolean buildsFileType(String extension) {
|
||||
return parent.buildsFileType(extension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers a reference to the option. If the reference does not exist,
|
||||
* a new reference is created.
|
||||
*
|
||||
* @param option
|
||||
* @return OptionReference
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolReference#createOptionReference(org.eclipse.cdt.managedbuilder.core.IOption)
|
||||
*/
|
||||
public OptionReference createOptionReference(IOption option) {
|
||||
// Check if the option reference already exists
|
||||
|
@ -182,6 +197,70 @@ public class ToolReference extends AbstractToolReference {
|
|||
return ref;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @return
|
||||
*/
|
||||
protected List getAllOptionRefs() {
|
||||
// First get all the option references this tool reference contains
|
||||
if (owner instanceof Configuration) {
|
||||
return ((Configuration)owner).getOptionReferences(parent);
|
||||
} else if (owner instanceof Target) {
|
||||
return ((Target)owner).getOptionReferences(parent);
|
||||
} else {
|
||||
// this shouldn't happen
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getId()
|
||||
*/
|
||||
public String getId() {
|
||||
return parent.getId();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return parent.getName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getNatureFilter()
|
||||
*/
|
||||
public int getNatureFilter() {
|
||||
return parent.getNatureFilter();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
||||
*/
|
||||
public IOption getOption(String id) {
|
||||
IOption[] options = getOptions();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
IOption current = options[i];
|
||||
if (current.getId().equals(id)) {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#producesFileType(java.lang.String)
|
||||
*/
|
||||
public boolean producesFileType(String outputExtension) {
|
||||
return parent.producesFileType(outputExtension);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolReference#getTool()
|
||||
*/
|
||||
public ITool getTool() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getToolCommand()
|
||||
*/
|
||||
|
@ -256,34 +335,13 @@ public class ToolReference extends AbstractToolReference {
|
|||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOptions()
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getTopOptionCategory()
|
||||
*/
|
||||
public IOption[] getOptions() {
|
||||
IOption[] options = parent.getOptions();
|
||||
|
||||
// Replace with our references
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
OptionReference ref = getOptionReference(options[i]);
|
||||
if (ref != null)
|
||||
options[i] = ref;
|
||||
}
|
||||
|
||||
return options;
|
||||
public IOptionCategory getTopOptionCategory() {
|
||||
return parent.getTopOptionCategory();
|
||||
}
|
||||
|
||||
protected List getAllOptionRefs() {
|
||||
// First get all the option references this tool reference contains
|
||||
if (owner instanceof Configuration) {
|
||||
return ((Configuration)owner).getOptionReferences(parent);
|
||||
} else if (owner instanceof Target) {
|
||||
return ((Target)owner).getOptionReferences(parent);
|
||||
} else {
|
||||
// this shouldn't happen
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-javadoc)
|
||||
/* (non-Javadoc)
|
||||
* Answers an option reference that overrides the option, or <code>null</code>
|
||||
*
|
||||
* @param option
|
||||
|
@ -301,7 +359,26 @@ public class ToolReference extends AbstractToolReference {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected List getOptionReferenceList() {
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private OptionReference getOptionReference(String id) {
|
||||
Iterator it = getOptionReferenceList().iterator();
|
||||
while (it.hasNext()) {
|
||||
OptionReference current = (OptionReference)it.next();
|
||||
if (current.getId().equals(id)) {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolReference#getOptionReferenceList()
|
||||
*/
|
||||
public List getOptionReferenceList() {
|
||||
if (optionReferences == null) {
|
||||
optionReferences = new ArrayList();
|
||||
optionReferences.clear();
|
||||
|
@ -311,17 +388,47 @@ public class ToolReference extends AbstractToolReference {
|
|||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOption(java.lang.String)
|
||||
* @see org.eclipse.cdt.core.build.managed.ITool#getOptions()
|
||||
*/
|
||||
public IOption getOption(String id) {
|
||||
IOption[] options = getOptions();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
IOption current = options[i];
|
||||
if (current.getId().equals(id)) {
|
||||
return current;
|
||||
}
|
||||
public IOption[] getOptions() {
|
||||
IOption[] options = parent.getOptions();
|
||||
|
||||
// Replace with our references
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
OptionReference ref = getOptionReference(options[i]);
|
||||
if (ref != null)
|
||||
options[i] = ref;
|
||||
}
|
||||
return null;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputExtension(java.lang.String)
|
||||
*/
|
||||
public String getOutputExtension(String inputExtension) {
|
||||
return parent.getOutputExtension(inputExtension);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputFlag()
|
||||
*/
|
||||
public String getOutputFlag() {
|
||||
return parent.getOutputFlag();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputPrefix()
|
||||
*/
|
||||
public String getOutputPrefix() {
|
||||
return parent.getOutputPrefix();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.ITool#isHeaderFile(java.lang.String)
|
||||
*/
|
||||
public boolean isHeaderFile(String ext) {
|
||||
return parent.isHeaderFile(ext);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,11 +470,8 @@ public class ToolReference extends AbstractToolReference {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command in the receiver to be the argument.
|
||||
*
|
||||
* @param cmd
|
||||
* @return <code>true</code> if the call results in a chnaged command, else <code>false</code>
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolReference#setToolCommand(java.lang.String)
|
||||
*/
|
||||
public boolean setToolCommand(String cmd) {
|
||||
if (cmd != null && !cmd.equals(command)) {
|
||||
|
@ -393,4 +497,5 @@ public class ToolReference extends AbstractToolReference {
|
|||
return super.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ MngCCWizard.description=Create a new C++ project and let Eclipse create and mana
|
|||
MngBuildProp.name=C/C++ Build
|
||||
|
||||
# Build Model Names
|
||||
Extension.name=Managed Build Tools Description
|
||||
TargetName.cygw=Cygwin
|
||||
TargetName.cygw.exe=Cygwin Executable
|
||||
TargetName.cygw.so=Cygwin Shared Library
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue