redundant suppressions: don't warn for unfair inspections (IDEA-199532)

This commit is contained in:
Anna.Kozlova
2018-09-26 16:47:08 +02:00
parent 9d6ae2e299
commit 09ee7d2e36
7 changed files with 34 additions and 11 deletions

View File

@@ -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) {
}
}

View File

@@ -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>();

View File

@@ -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;
}
}

View File

@@ -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>);
}
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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);