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