mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
tool-chain modification functionality for the per-file settings
This commit is contained in:
parent
43f5e1eb30
commit
cf6f4568d2
2 changed files with 80 additions and 0 deletions
|
@ -229,4 +229,6 @@ public interface IResourceConfiguration extends IResourceInfo {
|
||||||
* @param rebuild
|
* @param rebuild
|
||||||
*/
|
*/
|
||||||
void setRebuildState(boolean rebuild);
|
void setRebuildState(boolean rebuild);
|
||||||
|
|
||||||
|
void setTools(ITool[] tools);
|
||||||
}
|
}
|
||||||
|
|
|
@ -983,5 +983,83 @@ 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]);
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue