mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 13:25:45 +02:00
[184053] recursiveFindExactMatches to find exact match when hash lookup fails
This commit is contained in:
parent
8a2f96ce75
commit
b5980ec2a6
1 changed files with 51 additions and 3 deletions
|
@ -2608,7 +2608,7 @@ public class SystemView extends SafeTreeViewer
|
||||||
disassociate(match);
|
disassociate(match);
|
||||||
match.dispose();
|
match.dispose();
|
||||||
} else {
|
} else {
|
||||||
toRemove.add(data);
|
toRemove.add(match);
|
||||||
//System.out.println(".....calling remove(data) on this match");
|
//System.out.println(".....calling remove(data) on this match");
|
||||||
//remove(data); // remove this item from the tree
|
//remove(data); // remove this item from the tree
|
||||||
}
|
}
|
||||||
|
@ -2616,7 +2616,12 @@ public class SystemView extends SafeTreeViewer
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the remove now
|
// 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
|
// STEP 4: if we removed a selected item, select its parent
|
||||||
if (wasSelected && (parentItem != null) && (parentItem instanceof TreeItem) && (parentItem.getData() != null)) {
|
if (wasSelected && (parentItem != null) && (parentItem instanceof TreeItem) && (parentItem.getData() != null)) {
|
||||||
|
@ -3992,13 +3997,56 @@ public class SystemView extends SafeTreeViewer
|
||||||
|
|
||||||
// try new map lookup method - won't work in cases of rename
|
// try new map lookup method - won't work in cases of rename
|
||||||
if (!mappedFindAllRemoteItemReferences(elementObject, matches)){
|
if (!mappedFindAllRemoteItemReferences(elementObject, matches)){
|
||||||
|
|
||||||
|
boolean foundExact = false;
|
||||||
|
for (int idx = 0; idx < roots.length; idx++){
|
||||||
|
if (recursiveFindExactMatches((TreeItem)roots[idx], elementObject, subsystem, matches)){
|
||||||
|
foundExact = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundExact)
|
||||||
|
{
|
||||||
for (int idx = 0; idx < roots.length; idx++){
|
for (int idx = 0; idx < roots.length; idx++){
|
||||||
matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches);
|
matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 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.
|
* Recursively tries to find the first occurrence of a given remote object, starting at the tree root.
|
||||||
* Optionally scoped to a specific subsystem.
|
* Optionally scoped to a specific subsystem.
|
||||||
|
|
Loading…
Add table
Reference in a new issue