mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
refactor after review IDEA-CR-33048
This commit is contained in:
+1
-15
@@ -117,12 +117,7 @@ public abstract class BaseConvertToLocalQuickFix<V extends PsiVariable> implemen
|
||||
variable,
|
||||
refsSet,
|
||||
delete,
|
||||
declaration -> {
|
||||
if (!mayBeFinal(firstElement, references)) {
|
||||
PsiUtil.setModifierProperty((PsiModifierListOwner)declaration.getDeclaredElements()[0], PsiModifier.FINAL, false);
|
||||
}
|
||||
return anchor.replace(declaration);
|
||||
}
|
||||
declaration -> anchor.replace(declaration)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -219,15 +214,6 @@ public abstract class BaseConvertToLocalQuickFix<V extends PsiVariable> implemen
|
||||
@NotNull
|
||||
protected abstract String suggestLocalName(@NotNull Project project, @NotNull V variable, @NotNull PsiCodeBlock scope);
|
||||
|
||||
private static boolean mayBeFinal(PsiElement firstElement, @NotNull Collection<PsiReference> references) {
|
||||
for (PsiReference reference : references) {
|
||||
final PsiElement element = reference.getElement();
|
||||
if (element == firstElement) continue;
|
||||
if (element instanceof PsiExpression && PsiUtil.isAccessedForWriting((PsiExpression)element)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void retargetReferences(PsiElementFactory elementFactory, String localName, Collection<PsiReference> refs)
|
||||
throws IncorrectOperationException {
|
||||
final PsiReferenceExpression refExpr = (PsiReferenceExpression)elementFactory.createExpressionFromText(localName, null);
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
class Test {
|
||||
|
||||
int getFoo1() {
|
||||
int myFoo = 1;
|
||||
myFoo = 5;
|
||||
int myFoo;
|
||||
while (true) myFoo = 1;
|
||||
return myFoo;
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -3,8 +3,7 @@ class Test {
|
||||
private int my<caret>Foo;
|
||||
|
||||
int getFoo1() {
|
||||
myFoo = 1;
|
||||
myFoo = 5;
|
||||
while (true) myFoo = 1;
|
||||
return myFoo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user