gemini back 3
This commit is contained in:
@@ -2138,10 +2138,20 @@ import java.util.*;
|
||||
List<Expression> results = new ArrayList<>();
|
||||
if (expr instanceof SimpleName sn) {
|
||||
String varName = sn.getIdentifier();
|
||||
if (!visitedVariables.add(varName)) {
|
||||
String methodKey = "";
|
||||
MethodDeclaration enclosingMethod = findEnclosingMethod(expr);
|
||||
if (enclosingMethod != null) {
|
||||
TypeDeclaration enclosingType = findEnclosingType(enclosingMethod);
|
||||
if (enclosingType != null) {
|
||||
methodKey = context.getFqn(enclosingType) + "." + enclosingMethod.getName().getIdentifier() + "#" + varName;
|
||||
}
|
||||
}
|
||||
if (methodKey.isEmpty()) {
|
||||
methodKey = varName;
|
||||
}
|
||||
if (!visitedVariables.add(methodKey)) {
|
||||
return results; // Break infinite loop
|
||||
}
|
||||
MethodDeclaration enclosingMethod = findEnclosingMethod(expr);
|
||||
if (enclosingMethod != null) {
|
||||
enclosingMethod.accept(new ASTVisitor() {
|
||||
@Override
|
||||
@@ -2160,7 +2170,7 @@ import java.util.*;
|
||||
}
|
||||
});
|
||||
if (!results.isEmpty()) {
|
||||
visitedVariables.remove(varName);
|
||||
visitedVariables.remove(methodKey);
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -2200,14 +2210,14 @@ import java.util.*;
|
||||
}
|
||||
});
|
||||
if (!callerExprs.isEmpty()) {
|
||||
visitedVariables.remove(varName);
|
||||
visitedVariables.remove(methodKey);
|
||||
return callerExprs;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
visitedVariables.remove(varName);
|
||||
visitedVariables.remove(methodKey);
|
||||
}
|
||||
results.add(expr);
|
||||
return results;
|
||||
|
||||
Reference in New Issue
Block a user