claude bugs (question mark)
This commit is contained in:
@@ -1029,10 +1029,7 @@ import java.util.*;
|
||||
for (Object expObj : ai.expressions()) {
|
||||
extractConstantsFromArgument((org.eclipse.jdt.core.dom.Expression) expObj, constants);
|
||||
}
|
||||
} else if (expr instanceof org.eclipse.jdt.core.dom.ClassInstanceCreation cic) {
|
||||
for (Object argObj : cic.arguments()) {
|
||||
extractConstantsFromArgument((org.eclipse.jdt.core.dom.Expression) argObj, constants);
|
||||
}
|
||||
|
||||
} else if (expr instanceof org.eclipse.jdt.core.dom.MethodInvocation mi) {
|
||||
String methodName = mi.getName().getIdentifier();
|
||||
|
||||
@@ -2610,4 +2607,18 @@ import java.util.*;
|
||||
});
|
||||
return initExpr[0];
|
||||
}
|
||||
|
||||
protected String resolveMethodInType(TypeDeclaration td, String methodName) {
|
||||
MethodDeclaration md = context.findMethodDeclaration(td, methodName, true);
|
||||
if (md != null) {
|
||||
TypeDeclaration declaringTd = findEnclosingType(md);
|
||||
return context.getFqn(declaringTd) + "." + methodName;
|
||||
}
|
||||
CompilationUnit cu = td.getRoot() instanceof CompilationUnit ? (CompilationUnit) td.getRoot() : null;
|
||||
TypeDeclaration targetTd = context.resolveStaticImport(methodName, cu);
|
||||
if (targetTd != null) {
|
||||
return context.getFqn(targetTd) + "." + methodName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -315,15 +315,6 @@ public class HeuristicCallGraphEngine extends AbstractCallGraphEngine {
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
protected String resolveMethodInType(TypeDeclaration td, String methodName) {
|
||||
MethodDeclaration md = context.findMethodDeclaration(td, methodName, true);
|
||||
if (md != null) {
|
||||
TypeDeclaration declaringTd = findEnclosingType(md);
|
||||
return context.getFqn(declaringTd) + "." + methodName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to narrow the resolution of {@code instanceVar.getterMethod()} when the
|
||||
* instance variable is initialised from a {@link org.eclipse.jdt.core.dom.ClassInstanceCreation}
|
||||
|
||||
@@ -323,15 +323,6 @@ public class JdtCallGraphEngine extends AbstractCallGraphEngine {
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
private String resolveMethodInType(TypeDeclaration td, String methodName) {
|
||||
MethodDeclaration md = context.findMethodDeclaration(td, methodName, true);
|
||||
if (md != null) {
|
||||
TypeDeclaration declaringTd = findEnclosingType(md);
|
||||
return context.getFqn(declaringTd) + "." + methodName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Expression unwrapMessageBuilder(Expression expr) {
|
||||
if (expr instanceof MethodInvocation mi) {
|
||||
MethodInvocation current = mi;
|
||||
|
||||
@@ -135,7 +135,7 @@ public class CodebaseContext {
|
||||
if (imp.isOnDemand()) {
|
||||
// Star import: import static com.example.C.*;
|
||||
TypeDeclaration td = getTypeDeclaration(impName, contextCu);
|
||||
if (td != null && hasField(td, memberName)) {
|
||||
if (td != null && (hasField(td, memberName) || hasMethod(td, memberName))) {
|
||||
return td;
|
||||
}
|
||||
} else {
|
||||
@@ -150,6 +150,15 @@ public class CodebaseContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasMethod(TypeDeclaration td, String name) {
|
||||
for (MethodDeclaration md : td.getMethods()) {
|
||||
if (md.getName().getIdentifier().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasField(TypeDeclaration td, String name) {
|
||||
for (FieldDeclaration fd : td.getFields()) {
|
||||
for (Object fragObj : fd.fragments()) {
|
||||
@@ -486,6 +495,14 @@ public class CodebaseContext {
|
||||
|
||||
// 2. Check imports in contextCu
|
||||
if (contextCu != null) {
|
||||
for (Object typeObj : contextCu.types()) {
|
||||
if (typeObj instanceof TypeDeclaration tdDecl) {
|
||||
if (tdDecl.getName().getIdentifier().equals(name)) {
|
||||
return tdDecl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Object impObj : contextCu.imports()) {
|
||||
ImportDeclaration imp = (ImportDeclaration) impObj;
|
||||
String impName = imp.getName().getFullyQualifiedName();
|
||||
|
||||
Reference in New Issue
Block a user