1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

tool-chain modification functionality for the per-file settings

This commit is contained in:
Mikhail Sennikovsky 2007-04-19 09:49:44 +00:00
parent 43f5e1eb30
commit cf6f4568d2
2 changed files with 80 additions and 0 deletions

View file

@ -229,4 +229,6 @@ public interface IResourceConfiguration extends IResourceInfo {
* @param rebuild
*/
void setRebuildState(boolean rebuild);
void setTools(ITool[] tools);
}

View file

@ -983,5 +983,83 @@ public class ResourceConfiguration extends ResourceInfo implements IFileInfo {
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]);
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){
if(isExtensionElement())
return;
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;
}
}