mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unnecessary local: ignore suppressions to break the cycle (IDEA-185868)
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package x;
|
||||
|
||||
class X {
|
||||
public String foo(String foo) {
|
||||
@SuppressWarnings("UnnecessaryLocalVariable")
|
||||
String bar = foo;
|
||||
return new String(bar);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.source.tree.injected.MyTestInjector;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import com.siyeh.ig.dataflow.UnnecessaryLocalVariableInspection;
|
||||
import com.siyeh.ig.migration.RawUseOfParameterizedTypeInspection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -41,6 +42,7 @@ public class RedundantSuppressTest extends InspectionTestCase {
|
||||
new LocalInspectionToolWrapper(new JavaDocReferenceInspection()),
|
||||
new LocalInspectionToolWrapper(new I18nInspection()),
|
||||
new LocalInspectionToolWrapper(new RawUseOfParameterizedTypeInspection()),
|
||||
new LocalInspectionToolWrapper(new UnnecessaryLocalVariableInspection()),
|
||||
new GlobalInspectionToolWrapper(new EmptyMethodInspection()),
|
||||
new GlobalInspectionToolWrapper(new UnusedDeclarationInspection())};
|
||||
|
||||
@@ -76,6 +78,8 @@ public class RedundantSuppressTest extends InspectionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIgnoreWithAnnotation() { doTest(); }
|
||||
|
||||
public void testSuppressAll() {
|
||||
try {
|
||||
((RedundantSuppressInspection)myWrapper.getTool()).IGNORE_ALL = true;
|
||||
|
||||
+11
-2
@@ -16,6 +16,7 @@
|
||||
package com.siyeh.ig.dataflow;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
|
||||
import com.intellij.codeInspection.JavaSuppressionUtil;
|
||||
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
@@ -98,8 +99,16 @@ public class UnnecessaryLocalVariableInspectionBase extends BaseInspection {
|
||||
super.visitLocalVariable(variable);
|
||||
if (m_ignoreAnnotatedVariablesNew) {
|
||||
final PsiModifierList list = variable.getModifierList();
|
||||
if (list != null && list.getAnnotations().length > 0) {
|
||||
return;
|
||||
if (list != null) {
|
||||
int length = list.getAnnotations().length;
|
||||
if (length > 0) {
|
||||
PsiAnnotation annotation = list.findAnnotation(SuppressWarnings.class.getName());
|
||||
if (annotation == null ||
|
||||
!JavaSuppressionUtil.getInspectionIdsSuppressedInAnnotation(list)
|
||||
.contains(UnnecessaryLocalVariableInspectionBase.this.getSuppressId())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isCopyVariable(variable)) {
|
||||
|
||||
Reference in New Issue
Block a user