SillyAssignmentInspection: fix finality check in quickfix creation: skip parentheses

This commit is contained in:
Tagir Valeev
2018-07-09 10:35:21 +07:00
parent 893a4e1e06
commit 3f3f06b4da
3 changed files with 5 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ public class SillyAssignmentInspection extends SillyAssignmentInspectionBase {
@Override
protected LocalQuickFix createRemoveAssignmentFix(PsiReferenceExpression expression) {
final PsiElement parent = expression.getParent();
final PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent());
if (parent instanceof PsiVariable) {
final PsiVariable variable = (PsiVariable)parent;
if (variable.hasModifierProperty(PsiModifier.FINAL)) {

View File

@@ -0,0 +1,3 @@
class X {
private final String s = ((this).<caret>s);
}

View File

@@ -33,6 +33,7 @@ public class RemoveSillyAssignmentFixTest extends LightCodeInsightFixtureTestCas
public void testSillyButIncomplete() { doTest(); }
public void testFinalField() { assertQuickfixNotAvailable(); }
public void testFinalField2() { assertQuickfixNotAvailable(); }
public void doTest() {
myFixture.enableInspections(SillyAssignmentInspection.class);