another ai fix
This commit is contained in:
@@ -798,12 +798,51 @@ public class ConstantResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check superclass
|
||||||
|
if (td.getSuperclassType() != null) {
|
||||||
|
String superclassName = click.kamil.springstatemachineexporter.ast.common.AstUtils.extractSimpleTypeName(td.getSuperclassType());
|
||||||
|
String resolvedSuperclass = resolveTypeFqn(superclassName, context, td);
|
||||||
|
if (resolvedSuperclass != null) {
|
||||||
|
TypeDeclaration superTd = context.getTypeDeclaration(resolvedSuperclass);
|
||||||
|
if (superTd != null) {
|
||||||
|
String result = resolveFieldInType(superTd, fieldName, resolvedSuperclass, context, visited);
|
||||||
|
if (result != null) return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check superinterfaces
|
||||||
|
for (Object intfObj : td.superInterfaceTypes()) {
|
||||||
|
Type intfType = (Type) intfObj;
|
||||||
|
String intfName = click.kamil.springstatemachineexporter.ast.common.AstUtils.extractSimpleTypeName(intfType);
|
||||||
|
String resolvedIntf = resolveTypeFqn(intfName, context, td);
|
||||||
|
if (resolvedIntf != null) {
|
||||||
|
TypeDeclaration intfTd = context.getTypeDeclaration(resolvedIntf);
|
||||||
|
if (intfTd != null) {
|
||||||
|
String result = resolveFieldInType(intfTd, fieldName, resolvedIntf, context, visited);
|
||||||
|
if (result != null) return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
visited.remove(fieldId);
|
visited.remove(fieldId);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String resolveTypeFqn(String simpleName, CodebaseContext context, TypeDeclaration td) {
|
||||||
|
CompilationUnit cu = (CompilationUnit) td.getRoot();
|
||||||
|
for (Object impObj : cu.imports()) {
|
||||||
|
ImportDeclaration imp = (ImportDeclaration) impObj;
|
||||||
|
String name = imp.getName().getFullyQualifiedName();
|
||||||
|
if (name.endsWith("." + simpleName)) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cu.getPackage().getName().getFullyQualifiedName() + "." + simpleName;
|
||||||
|
}
|
||||||
|
|
||||||
private String findValueFromAnnotation(FieldDeclaration fd) {
|
private String findValueFromAnnotation(FieldDeclaration fd) {
|
||||||
for (Object mod : fd.modifiers()) {
|
for (Object mod : fd.modifiers()) {
|
||||||
if (mod instanceof Annotation ann) {
|
if (mod instanceof Annotation ann) {
|
||||||
|
|||||||
@@ -372,7 +372,32 @@ public abstract class AbstractCallGraphEngine implements CallGraphEngine {
|
|||||||
|
|
||||||
if (exprNode instanceof MethodInvocation mi) {
|
if (exprNode instanceof MethodInvocation mi) {
|
||||||
methodName = mi.getName().getIdentifier();
|
methodName = mi.getName().getIdentifier();
|
||||||
if (mi.getExpression() instanceof SimpleName sn) {
|
boolean handledStaticEnum = false;
|
||||||
|
if (methodName.equals("valueOf") && mi.arguments().size() == 1) {
|
||||||
|
Object arg = mi.arguments().get(0);
|
||||||
|
if (arg instanceof StringLiteral sl) {
|
||||||
|
polymorphicEvents.add(sl.getLiteralValue());
|
||||||
|
methodName = null;
|
||||||
|
handledStaticEnum = true;
|
||||||
|
} else if (arg instanceof QualifiedName qn) {
|
||||||
|
polymorphicEvents.add(qn.getName().getIdentifier());
|
||||||
|
methodName = null;
|
||||||
|
handledStaticEnum = true;
|
||||||
|
}
|
||||||
|
} else if (methodName.equals("name") && mi.arguments().isEmpty()) {
|
||||||
|
if (mi.getExpression() instanceof QualifiedName qn) {
|
||||||
|
polymorphicEvents.add(qn.getName().getIdentifier());
|
||||||
|
methodName = null;
|
||||||
|
handledStaticEnum = true;
|
||||||
|
} else if (mi.getExpression() instanceof SimpleName sn) {
|
||||||
|
polymorphicEvents.add(sn.getIdentifier());
|
||||||
|
methodName = null;
|
||||||
|
handledStaticEnum = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!handledStaticEnum) {
|
||||||
|
if (mi.getExpression() instanceof SimpleName sn) {
|
||||||
varName = sn.getIdentifier();
|
varName = sn.getIdentifier();
|
||||||
} else if (mi.getExpression() instanceof ParenthesizedExpression pe &&
|
} else if (mi.getExpression() instanceof ParenthesizedExpression pe &&
|
||||||
pe.getExpression() instanceof CastExpression ce &&
|
pe.getExpression() instanceof CastExpression ce &&
|
||||||
@@ -449,6 +474,7 @@ public abstract class AbstractCallGraphEngine implements CallGraphEngine {
|
|||||||
varName = exprStr;
|
varName = exprStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (exprNode instanceof ClassInstanceCreation cic) {
|
} else if (exprNode instanceof ClassInstanceCreation cic) {
|
||||||
declaredType = click.kamil.springstatemachineexporter.ast.common.AstUtils.extractSimpleTypeName(cic.getType());
|
declaredType = click.kamil.springstatemachineexporter.ast.common.AstUtils.extractSimpleTypeName(cic.getType());
|
||||||
sourceMethod = "inline-instantiation";
|
sourceMethod = "inline-instantiation";
|
||||||
|
|||||||
Reference in New Issue
Block a user