fix 6
This commit is contained in:
@@ -437,7 +437,7 @@ public class CallGraphBuilder {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (initializer[0] != null) {
|
if (initializer[0] != null) {
|
||||||
Expression expr = traceVariable(initializer[0]);
|
Expression expr = traceVariable(initializer[0], new HashSet<>());
|
||||||
if (expr instanceof MethodInvocation mi) {
|
if (expr instanceof MethodInvocation mi) {
|
||||||
// Unwrapper logic: If wrapper method is called, extract its arguments recursively
|
// Unwrapper logic: If wrapper method is called, extract its arguments recursively
|
||||||
Expression innerMost = unwrapMethodInvocation(mi, 0);
|
Expression innerMost = unwrapMethodInvocation(mi, 0);
|
||||||
@@ -636,7 +636,7 @@ public class CallGraphBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract from constructor args (e.g., new CustomMessage(OrderEvent.PROCESS, ...))
|
// Extract from constructor args (e.g., new CustomMessage(OrderEvent.PROCESS, ...))
|
||||||
Expression tracedExpr = traceVariable(expr);
|
Expression tracedExpr = traceVariable(expr, new HashSet<>());
|
||||||
if (tracedExpr instanceof QualifiedName || tracedExpr instanceof ClassInstanceCreation || tracedExpr instanceof StringLiteral || tracedExpr instanceof NumberLiteral) {
|
if (tracedExpr instanceof QualifiedName || tracedExpr instanceof ClassInstanceCreation || tracedExpr instanceof StringLiteral || tracedExpr instanceof NumberLiteral) {
|
||||||
expr = tracedExpr; // Only accept trace if it resolves to a pure constant/primitive/constructor
|
expr = tracedExpr; // Only accept trace if it resolves to a pure constant/primitive/constructor
|
||||||
}
|
}
|
||||||
@@ -917,7 +917,10 @@ public class CallGraphBuilder {
|
|||||||
}
|
}
|
||||||
return (TypeDeclaration) parent;
|
return (TypeDeclaration) parent;
|
||||||
}
|
}
|
||||||
private Expression traceVariable(Expression expr) {
|
private Expression traceVariable(Expression expr, Set<Expression> visited) {
|
||||||
|
if (!visited.add(expr)) {
|
||||||
|
return expr; // Cycle detected
|
||||||
|
}
|
||||||
if (expr instanceof SimpleName sn) {
|
if (expr instanceof SimpleName sn) {
|
||||||
String varName = sn.getIdentifier();
|
String varName = sn.getIdentifier();
|
||||||
MethodDeclaration enclosingMethod = findEnclosingMethod(expr);
|
MethodDeclaration enclosingMethod = findEnclosingMethod(expr);
|
||||||
@@ -940,7 +943,7 @@ public class CallGraphBuilder {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (initializer[0] != null) {
|
if (initializer[0] != null) {
|
||||||
return traceVariable(initializer[0]);
|
return traceVariable(initializer[0], visited);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user