This commit is contained in:
2026-07-05 20:02:02 +02:00
parent cc352432a4
commit 23af434504
4 changed files with 116 additions and 1 deletions

View File

@@ -357,6 +357,36 @@ public abstract class AbstractCallGraphEngine implements CallGraphEngine {
} else if (mi.getExpression() instanceof ClassInstanceCreation cic) {
declaredType = click.kamil.springstatemachineexporter.ast.common.AstUtils.extractSimpleTypeName(cic.getType());
sourceMethod = "inline-instantiation";
List<String> getterResults = constructorAnalyzer.resolveInlineInstantiationGetterResult(cic, methodName, context, new java.util.HashSet<>());
if (getterResults != null && !getterResults.isEmpty()) {
for (String gr : getterResults) {
if (gr.startsWith("ENUM_SET:")) {
for (String eVal : gr.substring(9).split(",")) {
String parsed = constantExtractor.parseEnumSetElement(eVal);
if (!polymorphicEvents.contains(parsed)) polymorphicEvents.add(parsed);
}
} else {
if (!polymorphicEvents.contains(gr)) polymorphicEvents.add(gr);
}
}
return TriggerPoint.builder()
.event(tp.getEvent())
.className(tp.getClassName())
.methodName(tp.getMethodName())
.sourceFile(tp.getSourceFile())
.sourceModule(tp.getSourceModule())
.stateMachineId(tp.getStateMachineId())
.sourceState(tp.getSourceState())
.lineNumber(tp.getLineNumber())
.polymorphicEvents(polymorphicEvents)
.constraint(tp.getConstraint())
.stateTypeFqn(tp.getStateTypeFqn())
.eventTypeFqn(tp.getEventTypeFqn())
.external(tp.isExternal())
.build();
}
if (cic.getAnonymousClassDeclaration() != null) {
final List<String> polyEventsRef = polymorphicEvents;
for (Object declObj : cic.getAnonymousClassDeclaration().bodyDeclarations()) {

View File

@@ -62,6 +62,7 @@ public class CallGraphPathFinder {
if (neighbors != null) {
for (CallEdge edge : neighbors) {
String neighbor = edge.getTargetMethod();
if (neighbor.startsWith("java.") || neighbor.startsWith("javax.") || neighbor.startsWith("jakarta.") || neighbor.startsWith("org.springframework.")) continue;
if (neighbor.equals(target) || isHeuristicMatch(neighbor, target)) {
List<String> path = new ArrayList<>(List.of(start, target));
result.add(path);

View File

@@ -223,7 +223,10 @@ public class JdtCallGraphEngine extends AbstractCallGraphEngine {
}
if (typeName != null && !typeName.isEmpty()) {
return typeName + "." + methodName;
org.eclipse.jdt.core.dom.TypeDeclaration resolvedTd = context.getTypeDeclaration(typeName);
if (resolvedTd != null && context.findMethodDeclaration(resolvedTd, methodName, true) != null) {
return typeName + "." + methodName;
}
}
}