mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for [Bug 203092] Available tools only lists one flavor of a tool
This commit is contained in:
parent
104ed95619
commit
6e9c019ae5
2 changed files with 98 additions and 18 deletions
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.internal.core;
|
|||
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -452,30 +453,95 @@ class ToolChainModificationHelper {
|
|||
iter.set(new ToolInfo(rcInfo, t, ToolInfo.REMOVED));
|
||||
}
|
||||
|
||||
calculateConverterTools(rcInfo, removedList, addedList, null, null);
|
||||
ToolInfo[] added = listToArray(addedList);
|
||||
ToolInfo[] removed = listToArray(removedList);
|
||||
|
||||
adjustAddedList(added, removed);
|
||||
|
||||
calculateConverterTools(rcInfo, removed, added, null, null);
|
||||
|
||||
return new ToolListModificationInfo(rcInfo,
|
||||
listToArray(resultingList),
|
||||
listToArray(addedList),
|
||||
listToArray(removedList),
|
||||
added,
|
||||
removed,
|
||||
listToArray(remainedList));
|
||||
}
|
||||
|
||||
private static ITool getCommonSuperClass(ITool tool1, ITool tool2){
|
||||
for(int i = 0; tool2 != null; tool2 = tool2.getSuperClass(), i++){
|
||||
if(getSuperClassLevel(tool1, tool2) != -1)
|
||||
return tool2;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int getSuperClassLevel(ITool tool, ITool superClass){
|
||||
for(int i = 0; tool != null; tool = tool.getSuperClass(), i++){
|
||||
if(superClass == tool)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static int getLevel(ITool tool){
|
||||
int i= 0;
|
||||
for(; tool != null; tool = tool.getSuperClass(), i++);
|
||||
return i;
|
||||
}
|
||||
|
||||
private static ITool getBestMatchTool(ITool realTool, ToolInfo[] tools){
|
||||
int num = -1;
|
||||
ITool bestMatch = null;
|
||||
ITool[] identicTools = ManagedBuildManager.findIdenticalTools(realTool);
|
||||
|
||||
for(int i = 0; i < tools.length; i++){
|
||||
ITool extTool = ManagedBuildManager.getExtensionTool(tools[i].getInitialTool());
|
||||
|
||||
for(int k = 0; k < identicTools.length; k++){
|
||||
ITool identic = identicTools[k];
|
||||
ITool commonSuper = getCommonSuperClass(extTool, identic);
|
||||
|
||||
if(commonSuper != null){
|
||||
int level = getLevel(commonSuper);
|
||||
if(level > num){
|
||||
bestMatch = identic;
|
||||
num = level;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
private static void adjustAddedList(ToolInfo[] adds, ToolInfo[] removes){
|
||||
for(int i = 0; i < adds.length; i++){
|
||||
ToolInfo add = adds[i];
|
||||
|
||||
ITool bestMatch = getBestMatchTool(add.getRealTool(), removes);
|
||||
if(bestMatch != null){
|
||||
add.updateInitialTool(bestMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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){
|
||||
private static Map calculateConverterTools(IResourceInfo rcInfo, ToolInfo[] removed, ToolInfo[] added, List remainingRemoved, List remainingAdded){
|
||||
if(remainingAdded == null)
|
||||
remainingAdded = new ArrayList(addedList.size());
|
||||
remainingAdded = new ArrayList(added.length);
|
||||
if(remainingRemoved == null)
|
||||
remainingRemoved = new ArrayList(removedList.size());
|
||||
remainingRemoved = new ArrayList(removed.length);
|
||||
|
||||
remainingAdded.clear();
|
||||
remainingRemoved.clear();
|
||||
|
||||
remainingAdded.addAll(addedList);
|
||||
remainingRemoved.addAll(removedList);
|
||||
remainingAdded.addAll(Arrays.asList(added));
|
||||
remainingRemoved.addAll(Arrays.asList(removed));
|
||||
|
||||
Map resultMap = new HashMap();
|
||||
|
||||
|
|
|
@ -35,9 +35,8 @@ class ToolInfo {
|
|||
|
||||
ToolInfo(IResourceInfo rcInfo, ITool tool, int flag){
|
||||
fRcInfo = rcInfo;
|
||||
fInitialTool = tool;
|
||||
|
||||
fBaseTool = calculateBaseTool(rcInfo, tool);
|
||||
updateInitialTool(tool);
|
||||
|
||||
fFlag = flag;
|
||||
}
|
||||
|
@ -57,14 +56,15 @@ class ToolInfo {
|
|||
if(realTool == null){
|
||||
baseTool = tool;
|
||||
} else {
|
||||
ITool[] tcTools = baseTc.getTools();
|
||||
for(int i = 0; i < tcTools.length; i++){
|
||||
ITool extTool = ManagedBuildManager.getExtensionTool(tcTools[i]);
|
||||
if(extTool != null && realTool == ManagedBuildManager.getRealTool(extTool)){
|
||||
baseTool = extTool;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ITool[] tcTools = baseTc.getTools();
|
||||
// baseTool = getBestMatchTool(realTool, tcTools);
|
||||
//
|
||||
// if(baseTool == null){
|
||||
// IToolChain extTc = ManagedBuildManager.getExtensionToolChain(baseTc);
|
||||
// if(extTc != null){
|
||||
// baseTool = getBestMatchTool(realTool, extTc.getTools());
|
||||
// }
|
||||
// }
|
||||
|
||||
if(baseTool == null){
|
||||
baseTool = tool;
|
||||
|
@ -91,6 +91,20 @@ class ToolInfo {
|
|||
return fRealTool;
|
||||
}
|
||||
|
||||
void updateInitialTool(ITool tool){
|
||||
if(fInitialTool == tool)
|
||||
return;
|
||||
|
||||
fResultingTool = null;
|
||||
fRealTool = null;
|
||||
|
||||
fInitialTool = tool;
|
||||
|
||||
fModificationStatus = null;
|
||||
|
||||
fBaseTool = calculateBaseTool(fRcInfo, tool);
|
||||
}
|
||||
|
||||
public ITool getBaseTool(){
|
||||
if(fBaseTool == null){
|
||||
fBaseTool = ManagedBuildManager.getExtensionTool(fInitialTool);
|
||||
|
|
Loading…
Add table
Reference in a new issue