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