IDEA-76287 (Incorrect "Instance method access not qualified with 'this'" inspection warning)

This commit is contained in:
Bas Leijdekkers
2011-11-01 10:04:57 +01:00
parent cd7f0ec05c
commit 006dc66731
6 changed files with 43 additions and 26 deletions
@@ -1564,8 +1564,6 @@ reflection.for.unavailable.annotation.problem.descriptor=Annotation '#ref' is no
access.to.static.field.locked.on.instance.display.name=Access to static field locked on instance data
access.to.static.field.locked.on.instance.problem.descriptor=Access to static field <code>#ref</code> locked on instance data #loc
make.method.ctr.quickfix=Make method constructor
annotate.with.nonnls.quickfix=Annotate ''{0}'' with @NonNls
annotate.method.with.nonnls.quickfix=Annotate ''{0}()'' with @NonNls
replace.all.dot.display.name=Call to String.replaceAll(".", ...)
replace.all.dot.problem.descriptor=Call to <code>String.#ref(".", ...)</code> #loc
constant.string.intern.display.name=Call to 'intern()' on String constant
@@ -1579,7 +1577,6 @@ type.parameter.extends.final.class.display.name=Type parameter extends final cla
type.parameter.extends.final.class.problem.descriptor1=Type parameter <code>#ref</code> extends final class ''{0}'' #loc
type.parameter.extends.final.class.problem.descriptor2=Wildcard type argument <code>#ref</code> extends final class ''{0}'' #loc
type.parameter.extends.final.class.quickfix=Replace type parameter with actual class
non.serializable.field.in.serializable.ignore.option=Ignore classes serializable due to inheritance
double.negation.display.name=Double negation
double.negation.problem.descriptor=Double negation in <code>#ref</code> #loc
double.negation.quickfix=Remove double negation
@@ -1588,8 +1585,8 @@ comparable.implemented.but.equals.not.overridden.display.name=Comparable impleme
comparable.implemented.but.equals.not.overridden.problem.descriptor=Class <code>#ref</code> implements 'java.lang.Comparable' but does not override 'equals()' #loc
unqualified.field.access.display.name=Instance field access not qualified with 'this'
unqualified.field.access.problem.descriptor=Instance field access <code>#ref</code> is not qualified with 'this' #loc
unqualified.method.access.display.name=Instance method access not qualified with 'this'
unqualified.method.access.problem.descriptor=Instance field access <code>#ref</code> is not qualified with 'this' #loc
unqualified.method.access.display.name=Instance method call not qualified with 'this'
unqualified.method.access.problem.descriptor=Instance method call <code>#ref</code> is not qualified with 'this' #loc
add.this.qualifier.quickfix=Add 'this' qualifier
feature.envy.ignore.test.cases.option=Ignore feature envy in tests
while.loop.spins.on.field.ignore.non.empty.loops.option=Only warn if the loop is empty
@@ -1605,7 +1602,6 @@ assertequals.between.inconvertible.types.problem.descriptor=<code>#ref()</code>
enumeration.can.be.iteration.display.name=Enumeration can be iteration
enumeration.can.be.iteration.problem.descriptor=<code>#ref()</code> can be replaced with ''{0}'' construct #loc
enumeration.can.be.iteration.quickfix=Replace with 'Iterator' construct
missing.override.annotation.jdk6.option=Use JDK6 @Override rules
equals.hashcode.called.on.url.display.name='equals()' or 'hashCode()' called on java.net.URL object
equals.hashcode.called.on.url.problem.descriptor=Call to <code>#ref()</code> on URL object #loc
collection.contains.url.problem.decriptor={0} <code>#ref</code> may contain URL objects #loc
@@ -65,7 +65,7 @@ public class UnqualifiedMethodAccessInspection extends BaseInspection {
return;
}
final PsiMethod method = (PsiMethod)element;
if (method.hasModifierProperty(PsiModifier.STATIC)) {
if (method.isConstructor() || method.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
registerError(expression);
@@ -0,0 +1,18 @@
package com.siyeh.igtest.style.unqualified_method_access;
import javax.swing.*;
public class UnqualifiedMethodAccess extends JPanel {
public UnqualifiedMethodAccess(boolean isDoubleBuffered) {
super(isDoubleBuffered);
}
void foo() {}
void bar() {
foo();
}
void foo(String s) {
this.foo();
}
}
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>UnqualifiedMethodAccess.java</file>
<line>12</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Instance method call not qualified with 'this'</problem_class>
<description>Instance method call &lt;code&gt;foo&lt;/code&gt; is not qualified with 'this' #loc</description>
</problem>
</problems>
@@ -1,27 +1,10 @@
/*
* 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.siyeh.ig.IGInspectionTestCase;
public class UnqualifiedFieldAccessInspectionTest
extends IGInspectionTestCase {
public class UnqualifiedFieldAccessInspectionTest extends IGInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/style/unqualified_field_access",
new UnqualifiedFieldAccessInspection());
doTest("com/siyeh/igtest/style/unqualified_field_access", new UnqualifiedFieldAccessInspection());
}
}
@@ -0,0 +1,11 @@
package com.siyeh.ig.style;
import com.siyeh.ig.IGInspectionTestCase;
public class UnqualifiedMethodAccessInspectionTest
extends IGInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/style/unqualified_method_access", new UnqualifiedMethodAccessInspection());
}
}