mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Tests - fixed CallNodes to correctly allow duplicates
This commit is contained in:
@@ -48,11 +48,13 @@ public abstract class CallNode extends GTreeSlowLoadingNode {
|
||||
|
||||
/**
|
||||
* Returns a location that represents the caller of the callee.
|
||||
* @return the location
|
||||
*/
|
||||
public abstract ProgramLocation getLocation();
|
||||
|
||||
/**
|
||||
* Returns the address that for the caller of the callee.
|
||||
* @return the address
|
||||
*/
|
||||
public abstract Address getSourceAddress();
|
||||
|
||||
@@ -83,34 +85,23 @@ public abstract class CallNode extends GTreeSlowLoadingNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Signals that this node should not override the equals method to treat all nodes with the
|
||||
* same name as the same. When the user wants to see duplicates, each node should rely on
|
||||
* Java's default notion of equality; otherwise, the JTree goes out to lunch.
|
||||
* True allows this node to contains children with the same name
|
||||
*
|
||||
* @param allowDuplicates true to allow duplicate nodes
|
||||
*/
|
||||
protected void setAllowsDuplicates(boolean allowDuplicates) {
|
||||
this.allowDuplicates = allowDuplicates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
protected void addNode(List<GTreeNode> nodes, GTreeNode node) {
|
||||
if (allowDuplicates) {
|
||||
return super.equals(other);
|
||||
nodes.add(node);
|
||||
return;
|
||||
}
|
||||
|
||||
if (other == this) {
|
||||
return true;
|
||||
if (!nodes.contains(node)) {
|
||||
nodes.add(node);
|
||||
}
|
||||
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getClass().equals(other.getClass())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CallNode otherCallNode = (CallNode) other;
|
||||
return getName().equals(otherCallNode.getName());
|
||||
}
|
||||
|
||||
protected class CallNodeComparator implements Comparator<GTreeNode> {
|
||||
|
||||
@@ -91,13 +91,13 @@ public class IncomingCallNode extends CallNode {
|
||||
for (Address fromAddress : addresses) {
|
||||
monitor.checkCanceled();
|
||||
Function callerFunction = functionManager.getFunctionContaining(fromAddress);
|
||||
if (callerFunction != null) {
|
||||
IncomingCallNode node = new IncomingCallNode(program, callerFunction, fromAddress,
|
||||
filterDuplicates, filterDepth);
|
||||
if (!nodes.contains(node)) {
|
||||
nodes.add(node);
|
||||
}
|
||||
if (callerFunction == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IncomingCallNode node = new IncomingCallNode(program, callerFunction, fromAddress,
|
||||
filterDuplicates, filterDepth);
|
||||
addNode(nodes, node);
|
||||
}
|
||||
|
||||
Collections.sort(nodes, new CallNodeComparator());
|
||||
|
||||
@@ -148,12 +148,6 @@ public abstract class OutgoingCallNode extends CallNode {
|
||||
return calledFunction.isExternal();
|
||||
}
|
||||
|
||||
private void addNode(List<GTreeNode> nodes, GTreeNode node) {
|
||||
if (!nodes.contains(node)) {
|
||||
nodes.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCallReference(Reference reference) {
|
||||
RefType type = reference.getReferenceType();
|
||||
if (type.isCall()) {
|
||||
|
||||
Reference in New Issue
Block a user