mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-99829 (Problem with inspection "Raw use of parameterized class" option "Ignore where a type parameter would not compile.)
This commit is contained in:
+5
-3
@@ -17,7 +17,6 @@ package com.siyeh.ig.migration;
|
||||
|
||||
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -25,7 +24,6 @@ import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.psiutils.MethodUtils;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -89,6 +87,10 @@ public class RawUseOfParameterizedTypeInspection extends BaseInspection {
|
||||
if (ignoreObjectConstruction) {
|
||||
return;
|
||||
}
|
||||
if (ignoreUncompilable && (expression.getArrayInitializer() != null || expression.getArrayDimensions().length > 0)) {
|
||||
//array creation can (almost) never be generic
|
||||
return;
|
||||
}
|
||||
final PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
|
||||
checkReferenceElement(classReference);
|
||||
}
|
||||
@@ -99,7 +101,7 @@ public class RawUseOfParameterizedTypeInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
final PsiType type = typeElement.getType();
|
||||
if (type instanceof PsiArrayType) {
|
||||
if (!(type instanceof PsiClassType)) {
|
||||
return;
|
||||
}
|
||||
super.visitTypeElement(typeElement);
|
||||
|
||||
+2
-2
@@ -12,9 +12,9 @@ import java.util.concurrent.Callable;
|
||||
}
|
||||
class RawUseOfParameterizedType {
|
||||
void array() {
|
||||
final ArrayList[] array = new ArrayList[10];
|
||||
final ArrayList[] array =
|
||||
new ArrayList[10];
|
||||
}
|
||||
|
||||
void anonymous() {
|
||||
new Callable() {
|
||||
@Override
|
||||
|
||||
+7
@@ -15,6 +15,13 @@
|
||||
<description>Raw use of parameterized class <code>ArrayList</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>RawUseOfParameterizedType.java</file>
|
||||
<line>19</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Raw use of parameterized class</problem_class>
|
||||
<description>Raw use of parameterized class <code>Callable</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>RawUseOfParameterizedType.java</file>
|
||||
<line>32</line>
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ public class RawUseOfParameterizedTypeInspectionTest extends IGInspectionTestCas
|
||||
|
||||
public void test() throws Exception {
|
||||
final RawUseOfParameterizedTypeInspection tool = new RawUseOfParameterizedTypeInspection();
|
||||
tool.ignoreObjectConstruction = false;
|
||||
tool.ignoreUncompilable = true;
|
||||
tool.ignoreParametersOfOverridingMethods = true;
|
||||
doTest("com/siyeh/igtest/migration/raw_use_of_parameterized_type", tool);
|
||||
|
||||
Reference in New Issue
Block a user