1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

[184053] recursiveFindExactMatches to find exact match when hash lookup fails

This commit is contained in:
David McKnight 2007-04-25 16:39:34 +00:00
parent 8a2f96ce75
commit b5980ec2a6

View file

@ -2608,7 +2608,7 @@ public class SystemView extends SafeTreeViewer
disassociate(match);
match.dispose();
} else {
toRemove.add(data);
toRemove.add(match);
//System.out.println(".....calling remove(data) on this match");
//remove(data); // remove this item from the tree
}
@ -2616,7 +2616,12 @@ public class SystemView extends SafeTreeViewer
}
// do the remove now
remove(toRemove.toArray());
for (int i = 0; i < toRemove.size(); i++)
{
Item childItem = (Item)toRemove.get(i);
disassociate(childItem);
childItem.dispose();
}
// STEP 4: if we removed a selected item, select its parent
if (wasSelected && (parentItem != null) && (parentItem instanceof TreeItem) && (parentItem.getData() != null)) {
@ -3992,12 +3997,55 @@ public class SystemView extends SafeTreeViewer
// try new map lookup method - won't work in cases of rename
if (!mappedFindAllRemoteItemReferences(elementObject, matches)){
boolean foundExact = false;
for (int idx = 0; idx < roots.length; idx++){
matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches);
if (recursiveFindExactMatches((TreeItem)roots[idx], elementObject, subsystem, matches)){
foundExact = true;
}
}
if (!foundExact)
{
for (int idx = 0; idx < roots.length; idx++){
matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches);
}
}
}
return matches;
}
private boolean recursiveFindExactMatches(TreeItem root, Object elementObject, ISubSystem subsystem, Vector matches)
{
boolean foundSomething = false;
Object data = root.getData();
if (data == elementObject)
{
matches.add(root);
foundSomething = true;
}
if (subsystem != null){
if (data instanceof ISubSystem){
if (data != subsystem)
return false;
}
else if (data instanceof IHost){
if (subsystem.getHost() != data)
return false;
}
}
TreeItem[] children = root.getItems();
for (int i = 0; i < children.length; i++)
{
if (recursiveFindExactMatches(children[i], elementObject, subsystem, matches))
{
foundSomething = true;
}
}
return foundSomething;
}
/**
* Recursively tries to find the first occurrence of a given remote object, starting at the tree root.