mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unnecessarily qualified statically imported elements: do not ignore chained calls (IDEA-124806)
This commit is contained in:
+1
-1
@@ -94,7 +94,7 @@ public class UnnecessarilyQualifiedStaticallyImportedElementInspection extends B
|
||||
if (!(qualifier instanceof PsiJavaCodeReferenceElement)) {
|
||||
return;
|
||||
}
|
||||
if (PsiTreeUtil.getParentOfType(reference, PsiReferenceExpression.class, PsiImportStatementBase.class) != null) {
|
||||
if (PsiTreeUtil.getParentOfType(reference, PsiImportStatementBase.class) != null) {
|
||||
return;
|
||||
}
|
||||
if (UnnecessarilyQualifiedStaticUsageInspection.isGenericReference(reference, (PsiJavaCodeReferenceElement)qualifier)) return;
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>7</line>
|
||||
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Unnecessarily qualified statically imported element</problem_class>
|
||||
<description>Statically imported element 'foo' is unnecessarily qualified with <code>A</code> #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package p;
|
||||
|
||||
import static p.A.foo;
|
||||
|
||||
class StaticImport {
|
||||
void example() {
|
||||
A.foo().toString();
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
static Object foo() {return null;}
|
||||
}
|
||||
+5
-1
@@ -21,7 +21,7 @@ public class UnnecessarilyQualifiedStaticallyImportedElementInspectionTest
|
||||
extends IGInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doTest("com/siyeh/igtest/style/unnecessarily_qualified_statically_imported_element",
|
||||
doTest("com/siyeh/igtest/style/unnecessarily_qualified_statically_imported_element/simple",
|
||||
new UnnecessarilyQualifiedStaticallyImportedElementInspection());
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ public class UnnecessarilyQualifiedStaticallyImportedElementInspectionTest
|
||||
doTest(getTestName(true));
|
||||
}
|
||||
|
||||
public void testChainedMethodCall() throws Exception {
|
||||
doTest(getTestName(true));
|
||||
}
|
||||
|
||||
private void doTest(String testName) throws Exception {
|
||||
doTest("com/siyeh/igtest/style/unnecessarily_qualified_statically_imported_element/" + testName,
|
||||
new UnnecessarilyQualifiedStaticallyImportedElementInspection());
|
||||
|
||||
Reference in New Issue
Block a user