mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
redundant suppressions: don't warn for unfair inspections (IDEA-199532)
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// "Remove 'unchecked' suppression" "false"
|
||||
|
||||
@SuppressWarnings({"unchecked", "bla-blah-toolid"})
|
||||
@SuppressWarnings({"unc<caret>hecked", "bla-blah-toolid"})
|
||||
public enum Planet {
|
||||
MERCURY(),
|
||||
VENUS();
|
||||
|
||||
<T> Plan<caret>et(T... ts) {
|
||||
<T> Planet(T... ts) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ public class SampleSafeVarargs {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
void fo<caret>o() {
|
||||
@SuppressWarnings({"unc<caret>hecked"})
|
||||
void foo() {
|
||||
asList(new ArrayList<String>());
|
||||
List<Object> l ;
|
||||
ArrayList strings = new ArrayList<String>();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Remove 'unchecked' suppression" "false"
|
||||
import java.util.*;
|
||||
|
||||
public class SampleSafeVarargs {
|
||||
|
||||
@SafeVarargs
|
||||
static <T> List<T> asList(T... tt) {
|
||||
System.out.println(tt);
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unu<caret>sed"})
|
||||
void foo() {
|
||||
asList(new ArrayList<String>());
|
||||
List<Object> l ;
|
||||
ArrayList strings = new ArrayList<String>();
|
||||
l = strings;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ public class Test {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void f<caret>oo() {
|
||||
@SuppressWarnings("unche<caret>cked")
|
||||
void foo() {
|
||||
foo(new ArrayList<String>()).addAll(foo1(new ArrayList<String>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// "Remove 'unchecked' suppression" "false"
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class Te<caret>st {
|
||||
@SuppressWarnings("A<caret>LL")
|
||||
public class Test {
|
||||
@SafeVarargs
|
||||
static <T> List<T> foo(T... t){
|
||||
return null;
|
||||
|
||||
@@ -18,15 +18,19 @@ package com.intellij.java.codeInsight.daemon.quickFix;
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
import com.intellij.codeInspection.PossibleHeapPollutionVarargsInspection;
|
||||
import com.intellij.codeInspection.RedundantSuppressInspection;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
|
||||
|
||||
|
||||
public class RemoveRedundantUncheckedSuppressionTest extends LightQuickFixParameterizedTestCase {
|
||||
public class RemoveRedundantSuppressionTest extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
enableInspectionTools(new RedundantSuppressInspection(), new PossibleHeapPollutionVarargsInspection(), new UncheckedWarningLocalInspection());
|
||||
enableInspectionTools(new RedundantSuppressInspection(),
|
||||
new PossibleHeapPollutionVarargsInspection(),
|
||||
new UncheckedWarningLocalInspection(),
|
||||
new UnusedDeclarationInspection(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,7 +241,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
InspectionToolWrapper toolWrapper = inspectionProfile.getToolById(RedundantSuppressInspection.SHORT_NAME, getFile());
|
||||
InspectionSuppressor suppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(getFile().getLanguage());
|
||||
if (suppressor instanceof RedundantSuppressionDetector) {
|
||||
Set<String> activeTools = toolWrappers.stream().map(tool -> tool.getID()).collect(Collectors.toSet());
|
||||
Set<String> activeTools = toolWrappers.stream().filter(tool -> !tool.isUnfair()).map(tool -> tool.getID()).collect(Collectors.toSet());
|
||||
LocalInspectionTool
|
||||
localTool = ((RedundantSuppressInspection)toolWrapper.getTool()).createLocalTool((RedundantSuppressionDetector)suppressor, mySuppressedElements, activeTools);
|
||||
ProblemsHolder holder = new ProblemsHolder(iManager, getFile(), true);
|
||||
|
||||
Reference in New Issue
Block a user