mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
redundant suppressions: remove suppression from local variable annotation fixed
This commit is contained in:
+1
-1
@@ -64,7 +64,7 @@ public class RemoveSuppressWarningAction implements LocalQuickFix {
|
||||
PsiElement element = descriptor.getPsiElement();
|
||||
try {
|
||||
if (element != null) {
|
||||
final PsiJavaDocumentedElement commentOwner = PsiTreeUtil.getParentOfType(element, PsiJavaDocumentedElement.class, false);
|
||||
final PsiModifierListOwner commentOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class, false);
|
||||
if (commentOwner != null) {
|
||||
final PsiElement psiElement = JavaSuppressionUtil.getElementMemberSuppressedIn(commentOwner, myID);
|
||||
if (psiElement instanceof PsiAnnotation) {
|
||||
|
||||
@@ -90,8 +90,11 @@ public class JavaSuppressionUtil {
|
||||
JavaSuppressionUtil::getInspectionIdSuppressedInAnnotationAttribute);
|
||||
}
|
||||
|
||||
public static PsiElement getElementMemberSuppressedIn(@NotNull PsiJavaDocumentedElement owner, @NotNull String inspectionToolID) {
|
||||
PsiElement element = getDocCommentToolSuppressedIn(owner, inspectionToolID);
|
||||
public static <T extends PsiElement> PsiElement getElementMemberSuppressedIn(@NotNull T owner, @NotNull String inspectionToolID) {
|
||||
PsiElement element = null;
|
||||
if (owner instanceof PsiJavaDocumentedElement) {
|
||||
element = getDocCommentToolSuppressedIn((PsiJavaDocumentedElement)owner, inspectionToolID);
|
||||
}
|
||||
if (element != null) return element;
|
||||
if (owner instanceof PsiModifierListOwner) {
|
||||
element = getAnnotationMemberSuppressedIn((PsiModifierListOwner)owner, inspectionToolID);
|
||||
@@ -192,7 +195,7 @@ public class JavaSuppressionUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
static PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, @NotNull final String toolId) {
|
||||
public static PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, @NotNull final String toolId) {
|
||||
if (place instanceof PsiFile) return null;
|
||||
return ReadAction.compute(() -> {
|
||||
final PsiElement statement = SuppressionUtil.getStatementToolSuppressedIn(place, toolId, PsiStatement.class);
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Remove 'unchecked' suppression" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
@SafeVarargs
|
||||
static <T> List<T> foo(T... t){
|
||||
return null;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Remove 'unchecked' suppression" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
@SafeVarargs
|
||||
static <T> List<T> foo(T... t){
|
||||
return null;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
@SuppressWarnings("unche<caret>cked") List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user