mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-65831 ("instance field accessed not qualified with this"-inspection is broken)
This commit is contained in:
+3
-10
@@ -112,11 +112,9 @@ public class UnqualifiedFieldAccessInspection extends BaseInspection {
|
||||
@Override public void visitReferenceExpression(
|
||||
@NotNull PsiReferenceExpression expression) {
|
||||
super.visitReferenceExpression(expression);
|
||||
final PsiElement parent =
|
||||
expression.getParent();
|
||||
if (parent instanceof PsiReferenceExpression ||
|
||||
parent instanceof PsiCallExpression) {
|
||||
// optimization
|
||||
final PsiExpression qualifierExpression =
|
||||
expression.getQualifierExpression();
|
||||
if (qualifierExpression != null) {
|
||||
return;
|
||||
}
|
||||
final PsiReferenceParameterList parameterList =
|
||||
@@ -129,11 +127,6 @@ public class UnqualifiedFieldAccessInspection extends BaseInspection {
|
||||
// definitely not references to fields.
|
||||
return;
|
||||
}
|
||||
final PsiExpression qualifierExpression =
|
||||
expression.getQualifierExpression();
|
||||
if (qualifierExpression != null) {
|
||||
return;
|
||||
}
|
||||
final PsiElement element = expression.resolve();
|
||||
if (!(element instanceof PsiField)) {
|
||||
return;
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.siyeh.igtest.style.unqualified_field_access;
|
||||
|
||||
public class UnqualifiedFieldAccess {
|
||||
|
||||
private String field;
|
||||
|
||||
public void x () {
|
||||
field = "foofoo";
|
||||
final String s = String.valueOf(field.hashCode());
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>UnqualifiedFieldAccess.java</file>
|
||||
<line>8</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Instance field access not qualified with 'this'</problem_class>
|
||||
<description>Instance field access <code>field</code> is not qualified with 'this' #loc</description>
|
||||
</problem>
|
||||
|
||||
|
||||
<problem>
|
||||
<file>UnqualifiedFieldAccess.java</file>
|
||||
<line>9</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Instance field access not qualified with 'this'</problem_class>
|
||||
<description>Instance field access <code>field</code> is not qualified with 'this' #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.IGInspectionTestCase;
|
||||
|
||||
public class UnqualifiedFieldAccessInspectionTest
|
||||
extends IGInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/style/unqualified_field_access",
|
||||
new UnqualifiedFieldAccessInspection());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user