mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not suggest to remove unnecessary qualifiers in presence of type arguments (IDEA-84450)
This commit is contained in:
+21
-20
@@ -152,26 +152,8 @@ public class UnnecessarilyQualifiedStaticUsageInspection
|
||||
if (!(qualifierElement instanceof PsiJavaCodeReferenceElement)) {
|
||||
return false;
|
||||
}
|
||||
final PsiJavaCodeReferenceElement qualifier =
|
||||
(PsiJavaCodeReferenceElement)qualifierElement;
|
||||
final PsiReferenceParameterList qualifierParameterList =
|
||||
qualifier.getParameterList();
|
||||
if (qualifierParameterList != null) {
|
||||
final PsiTypeElement[] typeParameterElements =
|
||||
qualifierParameterList.getTypeParameterElements();
|
||||
if (typeParameterElements.length > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final PsiReferenceParameterList parameterList =
|
||||
referenceElement.getParameterList();
|
||||
if (parameterList != null) {
|
||||
final PsiTypeElement[] typeParameterElements =
|
||||
parameterList.getTypeParameterElements();
|
||||
if (typeParameterElements.length > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final PsiJavaCodeReferenceElement qualifier = (PsiJavaCodeReferenceElement)qualifierElement;
|
||||
if (isGenericReference(referenceElement, qualifier)) return false;
|
||||
final PsiElement target = referenceElement.resolve();
|
||||
if ((!(target instanceof PsiField) || m_ignoreStaticFieldAccesses) &&
|
||||
(!(target instanceof PsiMethod) || m_ignoreStaticMethodCalls)) {
|
||||
@@ -259,4 +241,23 @@ public class UnnecessarilyQualifiedStaticUsageInspection
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isGenericReference(PsiJavaCodeReferenceElement referenceElement, PsiJavaCodeReferenceElement qualifierElement) {
|
||||
final PsiReferenceParameterList qualifierParameterList = qualifierElement.getParameterList();
|
||||
if (qualifierParameterList != null) {
|
||||
final PsiTypeElement[] typeParameterElements = qualifierParameterList.getTypeParameterElements();
|
||||
if (typeParameterElements.length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final PsiReferenceParameterList parameterList = referenceElement.getParameterList();
|
||||
if (parameterList != null) {
|
||||
final PsiTypeElement[] typeParameterElements = parameterList.getTypeParameterElements();
|
||||
if (typeParameterElements.length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+1
@@ -99,6 +99,7 @@ public class UnnecessarilyQualifiedStaticallyImportedElementInspection
|
||||
if (parent instanceof PsiImportStatementBase) {
|
||||
return;
|
||||
}
|
||||
if (UnnecessarilyQualifiedStaticUsageInspection.isGenericReference(reference, (PsiJavaCodeReferenceElement)qualifier)) return;
|
||||
final PsiElement target = reference.resolve();
|
||||
if (!(target instanceof PsiMember)) {
|
||||
return;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>U.java</file>
|
||||
<line>14</line>
|
||||
<line>15</line>
|
||||
<package>p</package>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Unnecessarily qualified statically imported element</problem_class>
|
||||
<description>Statically imported element 'a' is unnecessarily qualified with <code>B</code> #loc</description>
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
class Foo {
|
||||
static <T> void foo() {}
|
||||
}
|
||||
+4
@@ -2,6 +2,7 @@ package p;
|
||||
|
||||
import static p.EnumA.values;
|
||||
import static p.A.a;
|
||||
import static p.Foo.*;
|
||||
|
||||
class U {
|
||||
void foo() {
|
||||
@@ -14,4 +15,7 @@ class U {
|
||||
B.a();
|
||||
}
|
||||
|
||||
void aaaa() {
|
||||
Foo.<String>foo();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user