diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java index 53c89de0473..de9d9b0c382 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java @@ -2322,71 +2322,12 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider return rBld == ManagedBuildManager.getRealBuilder(builder); } - public boolean performMatchComparison(IBuilder builder){ - if(builder == null) - return false; - - if(builder == this) - return true; - -// if(tool.isReal() && isReal()) -// return false; -// if(!tool.getToolCommand().equals(getToolCommand())) -// return false; - - if(!builder.getName().equals(getName())) - return false; - - String thisVersion = ManagedBuildManager.getVersionFromIdAndVersion(getId()); - String otherVersion = ManagedBuildManager.getVersionFromIdAndVersion(builder.getId()); - if(thisVersion == null || thisVersion.length() == 0){ - if(otherVersion != null && otherVersion.length() != 0) - return false; - } else { - if(!thisVersion.equals(otherVersion)) - return false; - } - - return true; - } - - private class MatchKey { - Builder builder; - - public MatchKey(Builder builder) { - this.builder = builder; - } - - @Override - public boolean equals(Object obj) { - if(obj == this) - return true; - if(!(obj instanceof MatchKey)) - return false; - MatchKey other = (MatchKey)obj; - return builder.performMatchComparison(other.builder); - } - - @Override - public int hashCode() { - String name = getName(); - if(name == null) - name = getId(); - int code = name.hashCode(); - String version = ManagedBuildManager.getVersionFromIdAndVersion(getId()); - if(version != null) - code += version.hashCode(); - return code; - } - - } - public Object getMatchKey() { if(isAbstract()) return null; if(!isExtensionBuilder) return null; - return new MatchKey(this); + return new MatchKey(this); } public void setIdenticalList(List list) { diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MatchKey.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MatchKey.java new file mode 100644 index 00000000000..692edfb02fa --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MatchKey.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2004, 2011 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.internal.core; + +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; + +public class MatchKey { + private T buildObject; + + public MatchKey(T builder) { + this.buildObject = builder; + } + + @Override + public boolean equals(Object obj) { + if(obj == this) + return true; + if(!(obj instanceof MatchKey)) + return false; + @SuppressWarnings("unchecked") + MatchKey other = (MatchKey)obj; + return performMatchComparison(other.buildObject); + } + + @Override + public int hashCode() { + String name = buildObject.getName(); + if(name == null) + name = buildObject.getId(); + int code = name.hashCode(); + String version = ManagedBuildManager.getVersionFromIdAndVersion(buildObject.getId()); + if(version != null) + code += version.hashCode(); + return code; + } + + boolean performMatchComparison(T bo){ + if(bo == null) + return false; + + if(bo == buildObject) + return true; + +// if(bo.isReal() && buildObject.isReal()) +// return false; +// if(!bo.getToolCommand().equals(buildObject.getToolCommand())) +// return false; + + if(!bo.getName().equals(buildObject.getName())) + return false; + + String thisVersion = ManagedBuildManager.getVersionFromIdAndVersion(buildObject.getId()); + String otherVersion = ManagedBuildManager.getVersionFromIdAndVersion(bo.getId()); + if(thisVersion == null || thisVersion.length() == 0){ + if(otherVersion != null && otherVersion.length() != 0) + return false; + } else { + if(!thisVersion.equals(otherVersion)) + return false; + } + + return true; +/* IOption options[] = buildObject.getOptions(); + IOption otherOptions[] = bo.getOptions(); + + if(!ListComparator.match(options, + otherOptions, + new Comparator(){ + public boolean equal(Object o1, Object o2){ + return ((Option)o1).matches((Option)o2); + } + })) + return false; + + return true; + */ + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java index 70a1ac0f32e..46cb0be1239 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java @@ -3590,48 +3590,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch return rT == ManagedBuildManager.getRealTool(tool); } - boolean performMatchComparison(ITool tool){ - if(tool == null) - return false; - - if(tool == this) - return true; - -// if(tool.isReal() && isReal()) -// return false; -// if(!tool.getToolCommand().equals(getToolCommand())) -// return false; - - if(!tool.getName().equals(getName())) - return false; - - String thisVersion = ManagedBuildManager.getVersionFromIdAndVersion(getId()); - String otherVersion = ManagedBuildManager.getVersionFromIdAndVersion(tool.getId()); - if(thisVersion == null || thisVersion.length() == 0){ - if(otherVersion != null && otherVersion.length() != 0) - return false; - } else { - if(!thisVersion.equals(otherVersion)) - return false; - } - - return true; -/* IOption options[] = getOptions(); - IOption otherOptions[] = tool.getOptions(); - - if(!ListComparator.match(options, - otherOptions, - new Comparator(){ - public boolean equal(Object o1, Object o2){ - return ((Option)o1).matches((Option)o2); - } - })) - return false; - - return true; - */ - } - /* public SupportedProperties getSupportedProperties(){ Map map = findSupportedProperties(); if(map != null) @@ -3658,43 +3616,12 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch return supportsManagedBuild.booleanValue(); } - private static class MatchKey { - Tool tool; - - public MatchKey(Tool tch) { - tool = tch; - } - - @Override - public boolean equals(Object obj) { - if(obj == this) - return true; - if(!(obj instanceof MatchKey)) - return false; - MatchKey other = (MatchKey)obj; - return tool.performMatchComparison(other.tool); - } - - @Override - public int hashCode() { - String name = tool.getName(); - if(name == null) - name = tool.getId(); - int code = name.hashCode(); - String version = ManagedBuildManager.getVersionFromIdAndVersion(tool.getId()); - if(version != null) - code += version.hashCode(); - return code; - } - - } - public Object getMatchKey() { if(isAbstract()) return null; if(!isExtensionTool) return null; - return new MatchKey(this); + return new MatchKey(this); } public void setIdenticalList(List list) { diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java index 01a147a0ff9..2cb5de10054 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java @@ -2249,57 +2249,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert return rTc == ManagedBuildManager.getRealToolChain(tc); } - private boolean performMatchCompatison(IToolChain tCh){ - if(tCh == null) - return false; - - if(tCh == this) - return true; - -// if(tCh.isReal() && isReal()) -// return false; - - String name = tCh.getName(); - if(name == null){ - if(getName() != null) - return false; - } else if(!name.equals(getName())){ - return false; - } - - String thisVersion = ManagedBuildManager.getVersionFromIdAndVersion(getId()); - String otherVersion = ManagedBuildManager.getVersionFromIdAndVersion(tCh.getId()); - if(thisVersion == null || thisVersion.length() == 0){ - if(otherVersion != null && otherVersion.length() != 0) - return false; - } else { - if(!thisVersion.equals(otherVersion)) - return false; - } - - return true; - -// if(true) -// return true; -// -// ITool tools[] = getTools(); -// ITool otherTools[] = tCh.getTools(); -// -// if(tools.length != otherTools.length) -// return false; -// -// if(!ListComparator.match(tools, -// otherTools, -// new Comparator(){ -// public boolean equal(Object o1, Object o2){ -// return ((Tool)o1).performMatchComparison((Tool)o2); -// } -// })) -// return false; -// -// return true; - } - public List getIdenticalList(){ return identicalList;//;(ArrayList)identicalToolChainsList.clone(); } @@ -2344,43 +2293,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert return false; } - private class MatchKey { - ToolChain toolChain; - - public MatchKey(ToolChain tch) { - toolChain = tch; - } - - @Override - public boolean equals(Object obj) { - if(obj == this) - return true; - if(!(obj instanceof MatchKey)) - return false; - MatchKey other = (MatchKey)obj; - return toolChain.performMatchCompatison(other.toolChain); - } - - @Override - public int hashCode() { - String name = getName(); - if(name == null) - name = getId(); - int code = name.hashCode(); - String version = ManagedBuildManager.getVersionFromIdAndVersion(getId()); - if(version != null) - code += version.hashCode(); - return code; - } - - } - public Object getMatchKey() { if(isAbstract()) return null; if(!isExtensionToolChain) return null; - return new MatchKey(this); + return new MatchKey(this); } public void setIdenticalList(List list) {