mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
VariableAccessUtils: avoid using ReferencesSearch
GitOrigin-RevId: d842446850b5e0357d727bfa023a9a6ed8612efc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
868aa78cf3
commit
1df2a19a7a
+4
-4
@@ -544,10 +544,10 @@ public class VariableAccessUtils {
|
||||
public static boolean canUseAsNonFinal(PsiLocalVariable var) {
|
||||
if (var == null) return false;
|
||||
PsiElement block = PsiUtil.getVariableCodeBlock(var, null);
|
||||
return block != null && ReferencesSearch.search(var).allMatch(ref -> {
|
||||
PsiElement context = PsiTreeUtil.getParentOfType(ref.getElement(), PsiClass.class, PsiLambdaExpression.class);
|
||||
return context == null || PsiTreeUtil.isAncestor(context, block, false);
|
||||
});
|
||||
return block != null &&
|
||||
getVariableReferences(var, block).stream()
|
||||
.map(ref -> PsiTreeUtil.getParentOfType(ref, PsiClass.class, PsiLambdaExpression.class))
|
||||
.allMatch(context -> context == null || PsiTreeUtil.isAncestor(context, block, false));
|
||||
}
|
||||
|
||||
private static class VariableCollectingVisitor extends JavaRecursiveElementWalkingVisitor {
|
||||
|
||||
Reference in New Issue
Block a user