mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Thomas Fletcher added new method replacePersistenttarget()
This commit is contained in:
parent
dab6ba3ae7
commit
088b72acaf
1 changed files with 102 additions and 72 deletions
|
@ -141,6 +141,36 @@ public class MakeUtil {
|
|||
MakeUtil.setPersistentTargets(resource, newTargets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace a tag on a resource. Functionally equivalent to
|
||||
* removePersistantTag(resource, oldtarget)
|
||||
* addPersistantTag(resource, newtarget)
|
||||
* If the oldtarget doesn't exist, the newtarget is added.
|
||||
* If the newtarget is null, the oldtarget is removed.
|
||||
* @param resource The resource the tag applies to
|
||||
* @param oldtarget The oldtarget tag
|
||||
* @param newtarget The newtarget tag to replace the old target tag or null. If
|
||||
* newtarget is null then this call is the same as removePersistantTarget(resource, oldtarget)
|
||||
*/
|
||||
public static void replacePersistentTarget(IResource resource, String oldtarget, String newtarget) {
|
||||
if (newtarget == null) {
|
||||
removePersistentTarget(resource, oldtarget);
|
||||
return;
|
||||
}
|
||||
|
||||
String[] targets = getPersistentTargets(resource);
|
||||
for (int i = 0; i < targets.length; i++) {
|
||||
if (targets[i].equals(oldtarget)) {
|
||||
targets[i] = newtarget;
|
||||
setPersistentTargets(resource, targets);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//The target wasn't found, create a new one
|
||||
addPersistentTarget(resource, newtarget);
|
||||
}
|
||||
|
||||
private MakeUtil() {
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue