From e9b02eb23352d1cd379e994e9ee3d123289e87e9 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 25 Apr 2022 21:17:55 +0200 Subject: [PATCH] [java] get rid of ProblemHighlightType.LIKE_UNUSED_SYMBOL in favor of editor attributes (IDEA-27007) GitOrigin-RevId: 950de9dbd0cf727c6baa7363783e1723fb398a62 --- .../src/META-INF/JavaAnalysisPlugin.xml | 9 ++- ...onymousHasLambdaAlternativeInspection.java | 7 +- .../ExplicitTypeCanBeDiamondInspection.java | 4 +- .../RedundantLambdaCodeBlockInspection.java | 5 +- .../DuplicateThrowsInspection.java | 9 ++- ...9RedundantRequiresStatementInspection.java | 2 +- .../RedundantTypeArgsInspection.java | 6 +- .../RedundantCastInspection.java | 2 +- .../RedundantThrowsDeclarationInspection.java | 2 +- ...ndantThrowsDeclarationLocalInspection.java | 2 +- .../ComparatorCombinatorsInspection.java | 4 +- .../DefaultAnnotationParamInspection.java | 4 +- .../RedundantExplicitCloseInspection.java | 5 +- .../RedundantFileCreationInspection.java | 4 +- .../RedundantRecordConstructorInspection.java | 15 +++-- ...RedundantStreamOptionalCallInspection.java | 6 +- .../RedundantUnmodifiableInspection.java | 4 +- .../defUse/DefUseInspection.java | 3 +- ...tLabeledSwitchRuleCodeBlockInspection.java | 8 ++- .../ExcessiveLambdaUsageInspection.java | 4 +- .../SillyAssignmentInspection.java | 24 ++----- .../ParameterCanBeLocalInspection.java | 2 +- java/java-impl/src/META-INF/JavaPlugin.xml | 32 ++++++---- ...onymousCanBeMethodReferenceInspection.java | 4 +- .../deadCode/UnusedDeclarationInspection.java | 2 +- .../deadCode/UnusedParametersInspection.java | 2 +- .../afterCallInExpression.java | 2 +- .../afterCallInStatement.java | 2 +- .../afterConstInExpression.java | 2 +- .../afterSwitchExpressionInExpression.java | 2 +- .../afterThrowInExpression.java | 2 +- .../afterThrowInStatement.java | 2 +- .../beforeCallInExpression.java | 2 +- .../beforeCallInStatement.java | 2 +- .../beforeConstInExpression.java | 2 +- .../beforeSwitchExpressionInExpression.java | 2 +- .../beforeThrowInExpression.java | 2 +- .../beforeThrowInStatement.java | 2 +- .../ex/InspectionProfileTest.java | 6 +- .../ex/ProjectInspectionManagerTest.kt | 6 +- .../intellij/codeInspection/InspectionEP.java | 6 ++ .../InspectionProfileEntry.java | 18 +++++- .../codeInspection/LocalInspectionEP.java | 6 -- .../codeInspection/LocalInspectionTool.java | 10 --- .../ex/InspectionToolWrapper.java | 7 +- .../codeInspection/ex/ScopeToolState.java | 1 - .../ex/LocalInspectionToolWrapper.java | 10 --- .../intellij/codeInspection/ex/ToolsImpl.java | 17 +++-- .../FinalMethodInFinalClassInspection.java | 3 +- .../FinalPrivateMethodInspection.java | 2 +- .../controlflow/ConfusingElseInspection.java | 3 +- .../UnnecessaryBreakInspection.java | 5 +- .../UnnecessaryContinueInspection.java | 5 +- .../UnnecessaryDefaultInspection.java | 5 +- ...essaryLabelOnBreakStatementInspection.java | 3 +- ...aryLabelOnContinueStatementInspection.java | 3 +- .../UnnecessaryReturnInspection.java | 3 +- .../EmptyFinallyBlockInspection.java | 3 +- .../ig/imports/JavaLangImportInspection.java | 5 +- .../imports/SamePackageImportInspection.java | 5 +- .../siyeh/ig/numeric/UnaryPlusInspection.java | 2 +- ...ecessaryExplicitNumericCastInspection.java | 3 +- .../UnnecessaryUnaryMinusInspection.java | 6 +- .../ig/redundancy/UnusedLabelInspection.java | 3 +- ...FieldInNonSerializableClassInspection.java | 3 +- ...edundantFieldInitializationInspection.java | 3 +- .../style/RedundantImplementsInspection.java | 11 +--- .../SimplifiableAnnotationInspection.java | 13 ++-- ...lyQualifiedInnerClassAccessInspection.java | 4 +- ...ssarilyQualifiedStaticUsageInspection.java | 3 +- ...edStaticallyImportedElementInspection.java | 3 +- ...ecessaryCallToStringValueOfInspection.java | 3 +- ...tantArrayCreationExpressionInspection.java | 5 +- .../UnnecessaryConstructorInspection.java | 3 +- ...lOnLocalVariableOrParameterInspection.java | 11 ++-- .../style/UnnecessaryModifierInspection.java | 3 +- ...UnnecessaryQualifierForThisInspection.java | 5 +- .../style/UnnecessarySemicolonInspection.java | 11 ++-- ...UnnecessarySuperConstructorInspection.java | 8 ++- .../UnnecessarySuperQualifierInspection.java | 3 +- .../ig/style/UnnecessaryThisInspection.java | 11 ++-- .../UnnecessaryToStringCallInspection.java | 3 +- .../EmptySynchronizedStatementInspection.java | 3 +- .../src/META-INF/InspectionGadgets.xml | 64 ++++++++++++------- ...edundantComparatorComparingInspection.java | 4 +- .../RedundantCompareCallInspection.java | 4 +- ...dundantExplicitVariableTypeInspection.java | 1 - ...alFunctionalExpressionUsageInspection.java | 2 +- .../UnnecessaryInitCauseInspection.java | 3 +- .../RedundantStringOperationInspection.java | 22 +++---- ...ReplaceOnLiteralHasNoEffectInspection.java | 4 +- ...necessaryFullyQualifiedNameInspection.java | 2 +- .../src/META-INF/common-javaFX-plugin.xml | 2 +- .../JavaFxUnusedImportsInspection.java | 20 +----- 94 files changed, 274 insertions(+), 304 deletions(-) diff --git a/java/java-analysis-impl/src/META-INF/JavaAnalysisPlugin.xml b/java/java-analysis-impl/src/META-INF/JavaAnalysisPlugin.xml index ed069fa8c587..93ff32ca0703 100644 --- a/java/java-analysis-impl/src/META-INF/JavaAnalysisPlugin.xml +++ b/java/java-analysis-impl/src/META-INF/JavaAnalysisPlugin.xml @@ -98,6 +98,7 @@ diff --git a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java b/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java index 8c8ab485435b..706d68fa6dcd 100644 --- a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection; import com.intellij.codeInspection.LambdaCanBeMethodReferenceInspection.MethodReferenceCandidate; @@ -81,7 +81,7 @@ public class AnonymousCanBeMethodReferenceInspection extends AbstractBaseJavaLoc final TextRange rangeInElement = new TextRange(0, aClass.getStartOffsetInParent() + lBrace.getStartOffsetInParent()); ProblemHighlightType type; if (methodReferenceCandidate.mySafeQualifier && methodReferenceCandidate.myConformsCodeStyle) { - type = ProblemHighlightType.LIKE_UNUSED_SYMBOL; + type = ProblemHighlightType.GENERIC_ERROR_OR_WARNING; } else { if (!isOnTheFly) return; diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index 13de5cd40b6b..ad02a4e0b057 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -338,7 +338,7 @@ public final class UnusedDeclarationInspection extends UnusedDeclarationInspecti PsiElement toHighlight = ObjectUtils.notNull(psiVariable.getNameIdentifier(), psiVariable); return myInspectionManager.createProblemDescriptor( toHighlight, JavaBundle.message("inspection.unused.assignment.problem.descriptor1"), (LocalQuickFix)null, - ProblemHighlightType.LIKE_UNUSED_SYMBOL, false); + ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false); } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedParametersInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedParametersInspection.java index e53eca02f81e..0fdf97e1dbe5 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedParametersInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedParametersInspection.java @@ -64,7 +64,7 @@ class UnusedParametersInspection extends GlobalJavaBatchInspectionTool { ? "inspection.unused.parameter.composer" : "inspection.unused.parameter.composer1"), new AcceptSuggested(globalContext.getRefManager(), processor, refParameter.getName()), - ProblemHighlightType.LIKE_UNUSED_SYMBOL, false)); + ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false)); } } return result.toArray(CommonProblemDescriptor.EMPTY_ARRAY); diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterCallInExpression.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterCallInExpression.java index 0cd57f4074f3..652017771b6e 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterCallInExpression.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterCallInExpression.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { String foo(int n) { return switch (n) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterCallInStatement.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterCallInStatement.java index c527f8fb89b8..e8b05c8793df 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterCallInStatement.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterCallInStatement.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { void foo(int n) { String s; diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterConstInExpression.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterConstInExpression.java index 3fa486fe32f3..c2b29fd40c89 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterConstInExpression.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterConstInExpression.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { String foo(int n) { return switch (n) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterSwitchExpressionInExpression.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterSwitchExpressionInExpression.java index 7033e8b1ae63..f7f443416846 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterSwitchExpressionInExpression.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterSwitchExpressionInExpression.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { int foo(final int x, int n) { return switch (x) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterThrowInExpression.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterThrowInExpression.java index 72b890cb7d20..9960f9b01c40 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterThrowInExpression.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterThrowInExpression.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { String foo(int n) { return switch (n) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterThrowInStatement.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterThrowInStatement.java index d453062d5e13..58eb644c0247 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterThrowInStatement.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/afterThrowInStatement.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { String foo(int n) { switch (n) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeCallInExpression.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeCallInExpression.java index 4010a8644b41..cfddf3a9f810 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeCallInExpression.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeCallInExpression.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { String foo(int n) { return switch (n) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeCallInStatement.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeCallInStatement.java index 2df03f479191..e9596a547e0f 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeCallInStatement.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeCallInStatement.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { void foo(int n) { String s; diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeConstInExpression.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeConstInExpression.java index 428259580d9a..25403abc30ea 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeConstInExpression.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeConstInExpression.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { String foo(int n) { return switch (n) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeSwitchExpressionInExpression.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeSwitchExpressionInExpression.java index 716e9d40b9c3..da18dd457f55 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeSwitchExpressionInExpression.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeSwitchExpressionInExpression.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { int foo(final int x, int n) { return switch (x) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeThrowInExpression.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeThrowInExpression.java index 3f40027d1ecd..1f52cf3bb637 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeThrowInExpression.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeThrowInExpression.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { String foo(int n) { return switch (n) { diff --git a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeThrowInStatement.java b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeThrowInStatement.java index cc1a2c6cc60c..89e1f6abf00b 100644 --- a/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeThrowInStatement.java +++ b/java/java-tests/testData/inspection/redundantLabeledSwitchRuleCodeBlockFix/beforeThrowInStatement.java @@ -1,4 +1,4 @@ -// "Unwrap code block of labeled rule" "LIKE_UNUSED_SYMBOL" +// "Unwrap code block of labeled rule" "GENERIC_ERROR_OR_WARNING" class C { String foo(int n) { switch (n) { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java index 549d6acebf0d..620ba23aed63 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java @@ -201,9 +201,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { public void testCustomTextAttributes() throws IOException, JDOMException { @Language("XML") String content = "\n" + " "; InspectionProfileImpl profile = createProfile(); readFromXml(profile, content); @@ -727,7 +725,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { }); String mergedText = "\n" + "