mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
suppressions: if @Generated found, mark as suppressed even if no @SuppressWarning is present (IDEA-158300)
This commit is contained in:
@@ -129,8 +129,6 @@ public class JavaSuppressionUtil {
|
||||
}
|
||||
|
||||
static PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, @NotNull String inspectionToolID) {
|
||||
final PsiAnnotation generatedAnnotation = AnnotationUtil.findAnnotation(owner, Generated.class.getName());
|
||||
if (generatedAnnotation != null) return generatedAnnotation;
|
||||
PsiModifierList modifierList = owner.getModifierList();
|
||||
Collection<String> suppressedIds = getInspectionIdsSuppressedInAnnotation(modifierList);
|
||||
for (String ids : suppressedIds) {
|
||||
@@ -138,7 +136,7 @@ public class JavaSuppressionUtil {
|
||||
return modifierList != null ? AnnotationUtil.findAnnotation(owner, SUPPRESS_INSPECTIONS_ANNOTATION_NAME) : null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return AnnotationUtil.findAnnotation(owner, Generated.class.getName());
|
||||
}
|
||||
|
||||
static PsiElement getDocCommentToolSuppressedIn(@NotNull PsiDocCommentOwner owner, @NotNull String inspectionToolID) {
|
||||
@@ -215,9 +213,9 @@ public class JavaSuppressionUtil {
|
||||
}
|
||||
if (up instanceof PsiVariable) {
|
||||
PsiVariable local = (PsiVariable)up;
|
||||
if (getAnnotationMemberSuppressedIn(local, toolId) != null) {
|
||||
PsiModifierList modifierList = local.getModifierList();
|
||||
return modifierList != null ? modifierList.findAnnotation(SUPPRESS_INSPECTIONS_ANNOTATION_NAME) : null;
|
||||
final PsiElement annotation = getAnnotationMemberSuppressedIn(local, toolId);
|
||||
if (annotation != null) {
|
||||
return annotation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
class Test {
|
||||
|
||||
static {
|
||||
@javax.annotation.Generated
|
||||
String noRedundantCastForGeneratedCode = (String) "";
|
||||
}
|
||||
}
|
||||
+15
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
@@ -55,6 +56,20 @@ public class LightAdvHighlightingFixtureTest extends LightCodeInsightFixtureTest
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
public void testSuppressedInGenerated() throws Exception {
|
||||
myFixture.addClass("package javax.annotation; public @interface Generated {}");
|
||||
final RedundantCastInspection inspection = new RedundantCastInspection();
|
||||
try {
|
||||
myFixture.enableInspections(inspection);
|
||||
myFixture.configureByFile(getTestName(false) + ".java");
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
finally {
|
||||
myFixture.disableInspections(inspection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/advFixture";
|
||||
|
||||
Reference in New Issue
Block a user