mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for [Bug 201600] tool-integrator converter is not invoked for file-level tool modification
This commit is contained in:
parent
ec2fd1ebff
commit
10365b4ff8
9 changed files with 929 additions and 80 deletions
|
@ -1559,4 +1559,19 @@ public class FolderInfo extends ResourceInfo implements IFolderInfo {
|
||||||
public boolean isFolderInfo() {
|
public boolean isFolderInfo() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void performPostModificationAdjustments(ToolListModificationInfo info) {
|
||||||
|
adjustTargetTools(info.getRemovedTools(), info.getAddedTools(true));
|
||||||
|
|
||||||
|
super.performPostModificationAdjustments(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void applyToolsInternal(ITool[] resultingTools,
|
||||||
|
ToolListModificationInfo info) {
|
||||||
|
toolChain.setToolsInternal(resultingTools);
|
||||||
|
|
||||||
|
adjustTargetTools(info.getRemovedTools(), info.getAddedTools(true));
|
||||||
|
|
||||||
|
setRebuildState(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,23 @@ public class ModificationStatus extends Status implements IModificationStatus {
|
||||||
private HashSet fUndefinedProperties = new HashSet();
|
private HashSet fUndefinedProperties = new HashSet();
|
||||||
private ITool[][] fToolConflicts;
|
private ITool[][] fToolConflicts;
|
||||||
private ITool[] fNonManagedBuildTools;
|
private ITool[] fNonManagedBuildTools;
|
||||||
|
|
||||||
|
public static final ModificationStatus OK = new ModificationStatus(IStatus.OK, "", null);
|
||||||
|
|
||||||
|
ModificationStatus(String msg){
|
||||||
|
this(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
ModificationStatus(String msg, Throwable t){
|
||||||
|
this(IStatus.ERROR, msg, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
ModificationStatus(int severity, String msg, Throwable t){
|
||||||
|
super(severity, ManagedBuilderCorePlugin.getUniqueIdentifier(), msg, t);
|
||||||
|
fToolConflicts = new ITool[0][];
|
||||||
|
fNonManagedBuildTools = new ITool[0];
|
||||||
|
}
|
||||||
|
|
||||||
ModificationStatus(Map unsupportedRequiredProps,
|
ModificationStatus(Map unsupportedRequiredProps,
|
||||||
Map unsupportedProps,
|
Map unsupportedProps,
|
||||||
Set undefinedProps,
|
Set undefinedProps,
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -86,7 +87,8 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
||||||
IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
|
IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
|
||||||
for (int n = 0; n < tools.length; ++n) {
|
for (int n = 0; n < tools.length; ++n) {
|
||||||
Tool toolChild = new Tool(this, tools[n], getManagedBuildRevision());
|
Tool toolChild = new Tool(this, tools[n], getManagedBuildRevision());
|
||||||
toolList.add(toolChild);
|
getToolList().add(toolChild);
|
||||||
|
getToolMap().put(toolChild.getId(), toolChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
setDirty(false);
|
setDirty(false);
|
||||||
|
@ -1003,89 +1005,29 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITool[][] getRealPairs(ITool[] tools){
|
|
||||||
ITool[][] pairs = new ITool[tools.length][];
|
|
||||||
for(int i = 0; i < tools.length; i++){
|
|
||||||
ITool[] pair = new ITool[2];
|
|
||||||
pair[0] = ManagedBuildManager.getRealTool(tools[i]);
|
|
||||||
if(pair[0] == null)
|
|
||||||
pair[0] = tools[i];
|
|
||||||
pair[1] = tools[i];
|
|
||||||
pairs[i] = pair;
|
|
||||||
}
|
|
||||||
return pairs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getPairIndex(ITool[][] pairs, ITool tool, int startIndex){
|
|
||||||
for(; startIndex < pairs.length; startIndex++){
|
|
||||||
if(pairs[startIndex][0] == tool)
|
|
||||||
return startIndex;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getNextIndex(Map map, ITool[][] pairs, ITool tool){
|
|
||||||
Integer indexInt = (Integer)map.get(tool.getId());
|
|
||||||
int index = 0;
|
|
||||||
if(indexInt != null){
|
|
||||||
index = indexInt.intValue();
|
|
||||||
if(index >= 0)
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(index >= 0){
|
|
||||||
index = getPairIndex(pairs, tool, index);
|
|
||||||
map.put(tool.getId(), new Integer(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IConfiguration getConfiguration(ITool tool){
|
|
||||||
IBuildObject bo = tool.getParent();
|
|
||||||
if(bo instanceof IToolChain)
|
|
||||||
return ((IToolChain)bo).getParent();
|
|
||||||
else if(bo instanceof IFileInfo)
|
|
||||||
return ((IFileInfo)bo).getParent();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTools(ITool[] tools){
|
public void setTools(ITool[] tools){
|
||||||
if(isExtensionElement())
|
ToolListModificationInfo info = getToolListModificationInfo(tools);
|
||||||
return;
|
info.apply();
|
||||||
|
|
||||||
ITool[][] newPairs = getRealPairs(tools);
|
|
||||||
ITool[][] curPairs = getRealPairs(getTools());
|
|
||||||
Map realIdToPickedIndexMap = new HashMap();
|
|
||||||
|
|
||||||
List newToolList = new ArrayList(tools.length);
|
|
||||||
|
|
||||||
for(int i = 0; i < newPairs.length; i++){
|
|
||||||
ITool[] pair = newPairs[i];
|
|
||||||
int index = getNextIndex(realIdToPickedIndexMap, curPairs, pair[0]);
|
|
||||||
if(index >= 0){
|
|
||||||
newToolList.add(curPairs[index][1]);
|
|
||||||
} else {
|
|
||||||
ITool newBase = pair[1];
|
|
||||||
IConfiguration cfg = getConfiguration(newBase);
|
|
||||||
if(cfg != getParent()){
|
|
||||||
newBase = ManagedBuildManager.getExtensionTool(newBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
Tool newTool = new Tool(this,
|
|
||||||
newBase,
|
|
||||||
ManagedBuildManager.calculateChildId(newBase.getId(), null),
|
|
||||||
pair[1].getName(),
|
|
||||||
false);
|
|
||||||
|
|
||||||
newToolList.add(newTool);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toolList = newToolList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFolderInfo() {
|
public boolean isFolderInfo() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void applyToolsInternal(ITool[] resultingTools,
|
||||||
|
ToolListModificationInfo info) {
|
||||||
|
List list = getToolList();
|
||||||
|
Map map = getToolMap();
|
||||||
|
|
||||||
|
list.clear();
|
||||||
|
map.clear();
|
||||||
|
|
||||||
|
list.addAll(Arrays.asList(resultingTools));
|
||||||
|
for(int i = 0; i < resultingTools.length; i++){
|
||||||
|
ITool tool = resultingTools[i];
|
||||||
|
map.put(tool.getId(), tool);
|
||||||
|
}
|
||||||
|
|
||||||
|
setRebuildState(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
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.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
|
import org.eclipse.cdt.managedbuilder.core.OptionStringValue;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
@ -527,4 +528,40 @@ public abstract class ResourceInfo extends BuildObject implements IResourceInfo
|
||||||
abstract void resolveProjectReferences(boolean onLoad);
|
abstract void resolveProjectReferences(boolean onLoad);
|
||||||
|
|
||||||
abstract public boolean hasCustomSettings();
|
abstract public boolean hasCustomSettings();
|
||||||
|
|
||||||
|
public ToolListModificationInfo getToolListModificationInfo(ITool[] tools) {
|
||||||
|
ITool[] curTools = getTools();
|
||||||
|
return ToolChainModificationHelper.getModificationInfo(this, curTools, tools);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ITool[][] getRealPairs(ITool[] tools){
|
||||||
|
ITool[][] pairs = new ITool[tools.length][];
|
||||||
|
for(int i = 0; i < tools.length; i++){
|
||||||
|
ITool[] pair = new ITool[2];
|
||||||
|
pair[0] = ManagedBuildManager.getRealTool(tools[i]);
|
||||||
|
if(pair[0] == null)
|
||||||
|
pair[0] = tools[i];
|
||||||
|
pair[1] = tools[i];
|
||||||
|
pairs[i] = pair;
|
||||||
|
}
|
||||||
|
return pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract void applyToolsInternal(ITool[] resultingTools, ToolListModificationInfo info);
|
||||||
|
|
||||||
|
void doApply(ToolListModificationInfo info){
|
||||||
|
ITool[] resulting = info.getResultingTools();
|
||||||
|
|
||||||
|
ITool[] removed = info.getRemovedTools();
|
||||||
|
|
||||||
|
BuildSettingsUtil.disconnectDepentents(getParent(), removed);
|
||||||
|
|
||||||
|
applyToolsInternal(resulting, info);
|
||||||
|
|
||||||
|
performPostModificationAdjustments(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void performPostModificationAdjustments(ToolListModificationInfo info){
|
||||||
|
propertiesChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
|
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IInputType;
|
import org.eclipse.cdt.managedbuilder.core.IInputType;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||||
|
@ -3825,6 +3826,13 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateParentResourceInfo(IResourceInfo rcInfo){
|
||||||
|
if(rcInfo instanceof IFileInfo)
|
||||||
|
this.parent = rcInfo;
|
||||||
|
else
|
||||||
|
this.parent = ((IFolderInfo)rcInfo).getToolChain();
|
||||||
|
}
|
||||||
|
|
||||||
public List getIdenticalList() {
|
public List getIdenticalList() {
|
||||||
return identicalList;
|
return identicalList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1135,6 +1135,20 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
|
||||||
getToolMap().put(tool.getId(), tool);
|
getToolMap().put(tool.getId(), tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setToolsInternal(ITool[] tools){
|
||||||
|
List list = getToolList();
|
||||||
|
Map map = getToolMap();
|
||||||
|
|
||||||
|
list.clear();
|
||||||
|
map.clear();
|
||||||
|
|
||||||
|
list.addAll(Arrays.asList(tools));
|
||||||
|
for(int i = 0; i < tools.length; i++){
|
||||||
|
ITool tool = tools[i];
|
||||||
|
map.put(tool.getId(), tool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeTool(Tool tool){
|
public void removeTool(Tool tool){
|
||||||
getToolList().remove(tool);
|
getToolList().remove(tool);
|
||||||
getToolMap().remove(tool.getId());
|
getToolMap().remove(tool.getId());
|
||||||
|
|
|
@ -0,0 +1,446 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 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 java.util.AbstractSet;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
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.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.ToolChainModificationHelper.ListMap.CollectionEntry;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
|
||||||
|
class ToolChainModificationHelper {
|
||||||
|
|
||||||
|
static class ListMap implements Cloneable {
|
||||||
|
private HashMap fMap;
|
||||||
|
private CollectionEntrySet fCollectionEntrySet;
|
||||||
|
|
||||||
|
public ListMap(){
|
||||||
|
fMap = new HashMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ValueIter {
|
||||||
|
private Map fIterMap;
|
||||||
|
|
||||||
|
public ValueIter() {
|
||||||
|
fIterMap = new HashMap(fMap);
|
||||||
|
for(Iterator iter = fIterMap.entrySet().iterator(); iter.hasNext();){
|
||||||
|
Map.Entry entry = (Map.Entry)iter.next();
|
||||||
|
Collection c = (Collection)entry.getValue();
|
||||||
|
entry.setValue(c.iterator());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator get(Object key){
|
||||||
|
Iterator iter = (Iterator)fIterMap.get(key);
|
||||||
|
if(iter != null && !iter.hasNext()){
|
||||||
|
fIterMap.remove(key);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CollectionEntry {
|
||||||
|
private Map.Entry fEntry;
|
||||||
|
|
||||||
|
CollectionEntry(Map.Entry entry){
|
||||||
|
fEntry = entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKey(){
|
||||||
|
return fEntry.getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection getValue(){
|
||||||
|
return (Collection)fEntry.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if(obj == this)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if(obj == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!(obj instanceof CollectionEntry))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return fEntry.equals(((CollectionEntry)obj).fEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return fEntry.hashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CollectionEntrySet extends AbstractSet {
|
||||||
|
private Set fMapEntrySet;
|
||||||
|
|
||||||
|
private class Iter implements Iterator {
|
||||||
|
private Iterator fIter;
|
||||||
|
|
||||||
|
private Iter(){
|
||||||
|
fIter = fMapEntrySet.iterator();
|
||||||
|
}
|
||||||
|
public boolean hasNext() {
|
||||||
|
return fIter.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object next() {
|
||||||
|
return new CollectionEntry((Map.Entry)fIter.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
fIter.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private CollectionEntrySet(){
|
||||||
|
fMapEntrySet = fMap.entrySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator iterator() {
|
||||||
|
return new Iter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return fMapEntrySet.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void add(Object key, Object value){
|
||||||
|
List l = get(key, true);
|
||||||
|
l.add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List get(Object key, boolean create){
|
||||||
|
List l = (List)fMap.get(key);
|
||||||
|
if(l == null && create){
|
||||||
|
l = newList(1);
|
||||||
|
fMap.put(key, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection valuesToCollection(Collection c){
|
||||||
|
if(c == null)
|
||||||
|
c = newList(20);
|
||||||
|
|
||||||
|
for(Iterator iter = fMap.values().iterator(); iter.hasNext(); ){
|
||||||
|
List l = (List)iter.next();
|
||||||
|
c.addAll(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List newList(int size){
|
||||||
|
return new ArrayList(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List cloneList(List l){
|
||||||
|
return (List)((ArrayList)l).clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Object key, Object value){
|
||||||
|
Collection c = get(key, false);
|
||||||
|
if(c != null){
|
||||||
|
if(c.remove(value) && c.size() == 0){
|
||||||
|
fMap.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object get(Object key, int num){
|
||||||
|
List l = get(key, false);
|
||||||
|
if(l != null){
|
||||||
|
return l.get(num);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object remove(Object key, int num){
|
||||||
|
List l = get(key, false);
|
||||||
|
if(l != null){
|
||||||
|
Object result = null;
|
||||||
|
if(l.size() > num){
|
||||||
|
result = l.remove(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object removeLast(Object key){
|
||||||
|
List l = get(key, false);
|
||||||
|
if(l != null){
|
||||||
|
Object result = null;
|
||||||
|
if(l.size() > 0){
|
||||||
|
result = l.remove(l.size() - 1);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAll(Object key, Collection values){
|
||||||
|
Collection c = get(key, false);
|
||||||
|
if(c != null){
|
||||||
|
if(c.removeAll(values) && c.size() == 0){
|
||||||
|
fMap.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearEmptyLists(){
|
||||||
|
for(Iterator iter = fMap.entrySet().iterator(); iter.hasNext(); ){
|
||||||
|
Map.Entry entry = (Map.Entry)iter.next();
|
||||||
|
if(((List)entry.getValue()).size() == 0)
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set collectionEntrySet(){
|
||||||
|
if(fCollectionEntrySet == null)
|
||||||
|
fCollectionEntrySet = new CollectionEntrySet();
|
||||||
|
return fCollectionEntrySet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void difference(ListMap map){
|
||||||
|
for(Iterator iter = map.fMap.entrySet().iterator(); iter.hasNext(); ){
|
||||||
|
Map.Entry entry = (Map.Entry)iter.next();
|
||||||
|
Collection thisC = (Collection)fMap.get(entry.getKey());
|
||||||
|
if(thisC != null){
|
||||||
|
if(thisC.removeAll((Collection)entry.getValue()) && thisC == null){
|
||||||
|
fMap.remove(entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValueIter valueIter(){
|
||||||
|
return new ValueIter();
|
||||||
|
}
|
||||||
|
|
||||||
|
// protected Collection createCollection(Object key){
|
||||||
|
// return new ArrayList(1);
|
||||||
|
// }
|
||||||
|
|
||||||
|
protected Object clone() {
|
||||||
|
try {
|
||||||
|
ListMap clone = (ListMap)super.clone();
|
||||||
|
clone.fMap = (HashMap)fMap.clone();
|
||||||
|
for(Iterator iter = clone.fMap.entrySet().iterator(); iter.hasNext();){
|
||||||
|
Map.Entry entry = (Map.Entry)iter.next();
|
||||||
|
entry.setValue(cloneList((List)entry.getValue()));
|
||||||
|
}
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
ManagedBuilderCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// protected Map getMap(boolean create){
|
||||||
|
// if(fMap == null && create)
|
||||||
|
// fMap = createMap();
|
||||||
|
// return fMap;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// protected Map createMap(){
|
||||||
|
// return new HashMap();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private static class RealToolToToolIter {
|
||||||
|
// private Map fMap;
|
||||||
|
//
|
||||||
|
// public RealToolToToolIter(Map rtListMap) {
|
||||||
|
// fMap = getRealToToolIteratorMap(rtListMap, null);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public ITool next(ITool realTool){
|
||||||
|
// Iterator iter = (Iterator)fMap.get(realTool);
|
||||||
|
// ITool tool = iter.hasNext() ? (ITool)iter.next() : null;
|
||||||
|
// if(!iter.hasNext())
|
||||||
|
// fMap.remove(realTool);
|
||||||
|
//
|
||||||
|
// return tool;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private static ITool[] createRealToolArray(ITool[] tools){
|
||||||
|
// ITool[] rts = new ITool[tools.length];
|
||||||
|
// for(int i = 0; i < tools.length; i++){
|
||||||
|
// ITool t = tools[i];
|
||||||
|
// ITool rt = ManagedBuildManager.getRealTool(t);
|
||||||
|
// if(rt == null)
|
||||||
|
// rt = t;
|
||||||
|
// rts[i] = rt;
|
||||||
|
// }
|
||||||
|
// return rts;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
private static ListMap createRealToToolMap(ITool[] tools, boolean ext){
|
||||||
|
ListMap lMap = new ListMap();
|
||||||
|
for(int i = 0; i < tools.length; i++){
|
||||||
|
ITool tool = tools[i];
|
||||||
|
ITool rt = ManagedBuildManager.getRealTool(tool);
|
||||||
|
if(rt == null)
|
||||||
|
rt = tool;
|
||||||
|
ITool t = ext ? ManagedBuildManager.getExtensionTool(tool) : tool;
|
||||||
|
if(t == null)
|
||||||
|
t = tool;
|
||||||
|
lMap.add(rt, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ListMap calculateDifference(ListMap m1, ListMap m2){
|
||||||
|
m1 = (ListMap)m1.clone();
|
||||||
|
Set ceSet2 = m2.collectionEntrySet();
|
||||||
|
|
||||||
|
for(Iterator iter = ceSet2.iterator(); iter.hasNext(); ){
|
||||||
|
CollectionEntry entry = (CollectionEntry)iter.next();
|
||||||
|
Collection c1 = (Collection)m2.get(entry.getKey(), false);
|
||||||
|
if(c1 != null){
|
||||||
|
Collection c2 = entry.getValue();
|
||||||
|
int i = c2.size();
|
||||||
|
for(Iterator c1Iter = c1.iterator(); i >= 0 && c1Iter.hasNext(); i--){
|
||||||
|
c1Iter.next();
|
||||||
|
c1Iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public ToolListModificationInfo getModificationInfo(IResourceInfo rcInfo, ITool[] fromTools, ITool[] toTools){
|
||||||
|
|
||||||
|
ListMap curMap = createRealToToolMap(fromTools, false);
|
||||||
|
List resultingList = new ArrayList();
|
||||||
|
List addedList = new ArrayList(7);
|
||||||
|
List remainedList = new ArrayList(7);
|
||||||
|
List removedList = new ArrayList(7);
|
||||||
|
|
||||||
|
for(int i = 0; i < toTools.length; i++){
|
||||||
|
ITool tool = toTools[i];
|
||||||
|
ITool realTool = ManagedBuildManager.getRealTool(tool);
|
||||||
|
if(realTool == null)
|
||||||
|
realTool = tool;
|
||||||
|
|
||||||
|
ITool remaining = (ITool)curMap.remove(realTool, 0);
|
||||||
|
ToolInfo tInfo;
|
||||||
|
if(remaining != null){
|
||||||
|
tInfo = new ToolInfo(rcInfo, remaining, ToolInfo.REMAINED);
|
||||||
|
remainedList.add(tInfo);
|
||||||
|
} else {
|
||||||
|
tInfo = new ToolInfo(rcInfo, tool, ToolInfo.ADDED);
|
||||||
|
addedList.add(tInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
resultingList.add(tInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
curMap.valuesToCollection(removedList);
|
||||||
|
for(ListIterator iter = removedList.listIterator(); iter.hasNext(); ){
|
||||||
|
ITool t = (ITool)iter.next();
|
||||||
|
iter.set(new ToolInfo(rcInfo, t, ToolInfo.REMOVED));
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateConverterTools(rcInfo, removedList, addedList, null, null);
|
||||||
|
|
||||||
|
return new ToolListModificationInfo(rcInfo,
|
||||||
|
listToArray(resultingList),
|
||||||
|
listToArray(addedList),
|
||||||
|
listToArray(removedList),
|
||||||
|
listToArray(remainedList));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ToolInfo[] listToArray(List list){
|
||||||
|
return (ToolInfo[])list.toArray(new ToolInfo[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map calculateConverterTools(IResourceInfo rcInfo, List removedList, List addedList, List remainingRemoved, List remainingAdded){
|
||||||
|
if(remainingAdded == null)
|
||||||
|
remainingAdded = new ArrayList(addedList.size());
|
||||||
|
if(remainingRemoved == null)
|
||||||
|
remainingRemoved = new ArrayList(removedList.size());
|
||||||
|
|
||||||
|
remainingAdded.clear();
|
||||||
|
remainingRemoved.clear();
|
||||||
|
|
||||||
|
remainingAdded.addAll(addedList);
|
||||||
|
remainingRemoved.addAll(removedList);
|
||||||
|
|
||||||
|
Map resultMap = new HashMap();
|
||||||
|
|
||||||
|
for(Iterator rIter = remainingRemoved.iterator(); rIter.hasNext();){
|
||||||
|
ToolInfo rti = (ToolInfo)rIter.next();
|
||||||
|
ITool r = rti.getInitialTool();
|
||||||
|
|
||||||
|
if(r == null || r.getParentResourceInfo() != rcInfo)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
Map map = ManagedBuildManager.getConversionElements(r);
|
||||||
|
if(map.size() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for(Iterator aIter = remainingAdded.iterator(); aIter.hasNext();){
|
||||||
|
ToolInfo ati = (ToolInfo)aIter.next();
|
||||||
|
ITool a = ati.getBaseTool();
|
||||||
|
|
||||||
|
if(a == null || a.getParentResourceInfo() == rcInfo)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
a = ati.getBaseExtensionTool();
|
||||||
|
if(a == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
IConfigurationElement el = getToolConverterElement(r, a);
|
||||||
|
if(el != null){
|
||||||
|
ConverterInfo ci = new ConverterInfo(rcInfo, r, a, el);
|
||||||
|
resultMap.put(r, ci);
|
||||||
|
rIter.remove();
|
||||||
|
aIter.remove();
|
||||||
|
ati.setConversionInfo(rti, ci);
|
||||||
|
rti.setConversionInfo(ati, ci);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IConfigurationElement getToolConverterElement(ITool fromTool, ITool toTool){
|
||||||
|
return ((Tool)fromTool).getConverterModificationElement(toTool);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,146 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 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.IBuildObject;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
|
||||||
|
class ToolInfo {
|
||||||
|
private ITool fResultingTool;
|
||||||
|
private ITool fInitialTool;
|
||||||
|
private ITool fBaseTool;
|
||||||
|
private ITool fRealTool;
|
||||||
|
private IResourceInfo fRcInfo;
|
||||||
|
private int fFlag;
|
||||||
|
private ToolInfo fCorInfo;
|
||||||
|
private ConverterInfo fConverterInfo;
|
||||||
|
private IModificationStatus fModificationStatus;
|
||||||
|
|
||||||
|
public static final int ADDED = 1;
|
||||||
|
public static final int REMOVED = 1 << 1;
|
||||||
|
public static final int REMAINED = 1 << 2;
|
||||||
|
|
||||||
|
ToolInfo(IResourceInfo rcInfo, ITool tool, int flag){
|
||||||
|
fRcInfo = rcInfo;
|
||||||
|
fInitialTool = tool;
|
||||||
|
|
||||||
|
if(tool.isExtensionElement())
|
||||||
|
fBaseTool = tool;
|
||||||
|
else if (rcInfo != tool.getParentResourceInfo())
|
||||||
|
fBaseTool = tool;
|
||||||
|
|
||||||
|
fFlag = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType(){
|
||||||
|
return fFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool getRealTool(){
|
||||||
|
if(fRealTool == null){
|
||||||
|
ITool baseTool = getBaseTool();
|
||||||
|
fRealTool = ManagedBuildManager.getRealTool(baseTool);
|
||||||
|
if(fRealTool == null)
|
||||||
|
fRealTool = fBaseTool;
|
||||||
|
}
|
||||||
|
return fRealTool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool getBaseTool(){
|
||||||
|
if(fBaseTool == null){
|
||||||
|
fBaseTool = ManagedBuildManager.getExtensionTool(fInitialTool);
|
||||||
|
if(fBaseTool == null)
|
||||||
|
fBaseTool = fInitialTool;
|
||||||
|
}
|
||||||
|
return fBaseTool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool getBaseExtensionTool(){
|
||||||
|
ITool tool = getBaseTool();
|
||||||
|
return ManagedBuildManager.getExtensionTool(tool);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool getInitialTool(){
|
||||||
|
return fInitialTool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IModificationStatus getModificationStatus(){
|
||||||
|
if(fModificationStatus == null){
|
||||||
|
getResultingTool();
|
||||||
|
}
|
||||||
|
return fModificationStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool getResultingTool() {
|
||||||
|
switch(fFlag){
|
||||||
|
case ADDED:
|
||||||
|
if(fResultingTool == null || fResultingTool.getParentResourceInfo() != fRcInfo){
|
||||||
|
Tool result = null;
|
||||||
|
ModificationStatus status = null;
|
||||||
|
if(fConverterInfo != null){
|
||||||
|
IBuildObject resultBo = fConverterInfo.getConvertedFromObject();
|
||||||
|
if(!(resultBo instanceof Tool)) {
|
||||||
|
status = new ModificationStatus("conversion failure");
|
||||||
|
} else {
|
||||||
|
result = (Tool)resultBo;
|
||||||
|
status = ModificationStatus.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(status != ModificationStatus.OK){
|
||||||
|
ITool baseTool = getBaseTool();
|
||||||
|
|
||||||
|
if(fRcInfo instanceof IFolderInfo){
|
||||||
|
IFolderInfo foInfo = (IFolderInfo)fRcInfo;
|
||||||
|
if(baseTool.isExtensionElement()){
|
||||||
|
result = new Tool((ToolChain)foInfo.getToolChain(), baseTool, ManagedBuildManager.calculateChildId(baseTool.getId(), null), baseTool.getName(), false);
|
||||||
|
} else {
|
||||||
|
ITool extTool = ManagedBuildManager.getExtensionTool(baseTool);
|
||||||
|
result = new Tool(foInfo.getToolChain(), extTool, ManagedBuildManager.calculateChildId(extTool.getId(), null), baseTool.getName(), (Tool)baseTool);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ResourceConfiguration fiInfo = (ResourceConfiguration)fRcInfo;
|
||||||
|
if(baseTool.isExtensionElement()){
|
||||||
|
result = new Tool(fiInfo, baseTool, ManagedBuildManager.calculateChildId(baseTool.getId(), null), baseTool.getName(), false);
|
||||||
|
} else {
|
||||||
|
ITool extTool = ManagedBuildManager.getExtensionTool(baseTool);
|
||||||
|
result = new Tool(fiInfo, extTool, ManagedBuildManager.calculateChildId(extTool.getId(), null), baseTool.getName(), (Tool)baseTool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(status == null)
|
||||||
|
status = ModificationStatus.OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.updateParentResourceInfo(fRcInfo);
|
||||||
|
fResultingTool = result;
|
||||||
|
fModificationStatus = status;
|
||||||
|
}
|
||||||
|
return fResultingTool;
|
||||||
|
case REMOVED:
|
||||||
|
fModificationStatus = new ModificationStatus("the tool is removed");
|
||||||
|
return null;
|
||||||
|
case REMAINED:
|
||||||
|
default:
|
||||||
|
fModificationStatus = ModificationStatus.OK;
|
||||||
|
return fResultingTool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setConversionInfo(ToolInfo corInfo, ConverterInfo converterInfo){
|
||||||
|
fCorInfo = corInfo;
|
||||||
|
fConverterInfo = converterInfo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,225 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 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 java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IModificationStatus;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
|
||||||
|
public class ToolListModificationInfo {
|
||||||
|
private ToolInfo[] fResultingTools;
|
||||||
|
private ToolInfo[] fAddedTools;
|
||||||
|
private ToolInfo[] fRemovedTools;
|
||||||
|
private IResourceInfo fRcInfo;
|
||||||
|
|
||||||
|
ToolListModificationInfo(IResourceInfo rcInfo, ToolInfo[] resultingTools, ToolInfo[] added, ToolInfo[] removed, ToolInfo[] remaining){
|
||||||
|
fResultingTools = resultingTools;
|
||||||
|
fRemovedTools = removed;
|
||||||
|
fAddedTools = added;
|
||||||
|
fRcInfo = rcInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IResourceInfo getResourceInfo(){
|
||||||
|
return fRcInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getResultingToolList(List list) {
|
||||||
|
if(list == null)
|
||||||
|
list = new ArrayList(fResultingTools.length);
|
||||||
|
|
||||||
|
for(int i = 0; i < fResultingTools.length; i++){
|
||||||
|
list.add(fResultingTools[i].getResultingTool());
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool[] getResultingTools() {
|
||||||
|
ITool[] tools = new ITool[fResultingTools.length];
|
||||||
|
|
||||||
|
|
||||||
|
for(int i = 0; i < fResultingTools.length; i++){
|
||||||
|
tools[i] = fResultingTools[i].getResultingTool();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tools;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool[] getRemovedTools() {
|
||||||
|
return toToolArray(fRemovedTools, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool[] getAddedTools(boolean resulting) {
|
||||||
|
return toToolArray(fAddedTools, !resulting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITool[] getRemainedTools() {
|
||||||
|
return toToolArray(fAddedTools, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ITool[] toToolArray(ToolInfo[] infos, boolean initialTools){
|
||||||
|
ITool[] tools = new ITool[infos.length];
|
||||||
|
|
||||||
|
for(int i = 0; i < infos.length; i++){
|
||||||
|
tools[i] = initialTools ? infos[i].getInitialTool() : infos[i].getResultingTool();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tools;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ITool[][] toToolArray(ToolInfo[][] infos, boolean initialTools){
|
||||||
|
ITool[][] tools = new ITool[infos.length][];
|
||||||
|
|
||||||
|
for(int i = 0; i < infos.length; i++){
|
||||||
|
tools[i] = toToolArray(infos[i], initialTools);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tools;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public MultiStatus getModificationStatus(){
|
||||||
|
List statusList = new ArrayList();
|
||||||
|
|
||||||
|
ToolInfo[][] conflictInfos = calculateConflictingTools(fResultingTools);
|
||||||
|
ITool[][] conflicting = toToolArray(conflictInfos, true);
|
||||||
|
|
||||||
|
Map unspecifiedRequiredProps = new HashMap();
|
||||||
|
Map unspecifiedProps = new HashMap();
|
||||||
|
Set undefinedSet = new HashSet();
|
||||||
|
IConfiguration cfg = fRcInfo.getParent();
|
||||||
|
ITool[] nonManagedTools = null;
|
||||||
|
if(cfg.isManagedBuildOn() && cfg.supportsBuild(true)){
|
||||||
|
List list = new ArrayList();
|
||||||
|
for(int i = 0; i < fResultingTools.length; i++){
|
||||||
|
if(!fResultingTools[i].getInitialTool().supportsBuild(true)){
|
||||||
|
list.add(fResultingTools[i].getInitialTool());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(list.size() != 0){
|
||||||
|
nonManagedTools = (ITool[])list.toArray(new Tool[list.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IModificationStatus status = new ModificationStatus(unspecifiedRequiredProps, unspecifiedProps, undefinedSet, conflicting, nonManagedTools);
|
||||||
|
|
||||||
|
if(status.getSeverity() != IStatus.OK)
|
||||||
|
statusList.add(status);
|
||||||
|
|
||||||
|
for(int i = 0; i < fResultingTools.length; i++){
|
||||||
|
status = fResultingTools[i].getModificationStatus();
|
||||||
|
if(status.getSeverity() != IStatus.OK)
|
||||||
|
statusList.add(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(statusList.size() != 0)
|
||||||
|
return new MultiStatus(ManagedBuilderCorePlugin.getUniqueIdentifier(), IStatus.INFO, "", null);
|
||||||
|
return new MultiStatus(ManagedBuilderCorePlugin.getUniqueIdentifier(), IStatus.ERROR, "", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ToolInfo[][] calculateConflictingTools(ToolInfo[] infos){
|
||||||
|
infos = filterInfos(infos);
|
||||||
|
|
||||||
|
return doCalculateConflictingTools(infos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ToolInfo[] filterInfos(ToolInfo[] infos){
|
||||||
|
if(fRcInfo instanceof FolderInfo){
|
||||||
|
Map map = createInitialToolToToolInfoMap(infos);
|
||||||
|
ITool[] tools = (ITool[])new ArrayList(map.keySet()).toArray(new ITool[map.size()]);
|
||||||
|
|
||||||
|
tools = ((FolderInfo)fRcInfo).filterTools(tools, fRcInfo.getParent().getManagedProject());
|
||||||
|
|
||||||
|
if(tools.length < infos.length){
|
||||||
|
infos = new ToolInfo[tools.length];
|
||||||
|
for(int i = 0; i < infos.length; i++){
|
||||||
|
infos[i] = (ToolInfo)map.get(tools[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map createInitialToolToToolInfoMap(ToolInfo[] infos){
|
||||||
|
Map map = new LinkedHashMap();
|
||||||
|
for(int i = 0; i < infos.length; i++){
|
||||||
|
map.put(infos[i].getInitialTool(), infos[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ToolInfo[][] doCalculateConflictingTools(ToolInfo[] infos){
|
||||||
|
HashSet set = new HashSet();
|
||||||
|
set.addAll(Arrays.asList(infos));
|
||||||
|
List result = new ArrayList();
|
||||||
|
for(Iterator iter = set.iterator(); iter.hasNext();){
|
||||||
|
ToolInfo ti = (ToolInfo)iter.next();
|
||||||
|
ITool t = ti.getInitialTool();
|
||||||
|
iter.remove();
|
||||||
|
HashSet tmp = (HashSet)set.clone();
|
||||||
|
List list = new ArrayList();
|
||||||
|
for(Iterator tmpIt = tmp.iterator(); tmpIt.hasNext();){
|
||||||
|
ToolInfo otherTi = (ToolInfo)tmpIt.next();
|
||||||
|
ITool other = otherTi.getInitialTool();
|
||||||
|
String conflicts[] = getConflictingInputExts(t, other);
|
||||||
|
if(conflicts.length != 0){
|
||||||
|
list.add(other);
|
||||||
|
tmpIt.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(list.size() != 0){
|
||||||
|
list.add(t);
|
||||||
|
result.add(list.toArray(new ToolInfo[list.size()]));
|
||||||
|
}
|
||||||
|
set = tmp;
|
||||||
|
iter = set.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ToolInfo[][])result.toArray(new ToolInfo[result.size()][]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getConflictingInputExts(ITool tool1, ITool tool2){
|
||||||
|
IProject project = fRcInfo.getParent().getOwner().getProject();
|
||||||
|
String ext1[] = ((Tool)tool1).getAllInputExtensions(project);
|
||||||
|
String ext2[] = ((Tool)tool2).getAllInputExtensions(project);
|
||||||
|
Set set1 = new HashSet(Arrays.asList(ext1));
|
||||||
|
Set result = new HashSet();
|
||||||
|
for(int i = 0; i < ext2.length; i++){
|
||||||
|
if(set1.remove(ext2[i]))
|
||||||
|
result.add(ext2[i]);
|
||||||
|
}
|
||||||
|
return (String[])result.toArray(new String[result.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void apply(){
|
||||||
|
((ResourceInfo)fRcInfo).doApply(this);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue