From 818b20eff30b905d1b793545887234262e7d748c Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Mon, 5 Feb 2018 12:33:55 +0700 Subject: [PATCH] RedundantComparatorComparing: cosmetic changes, internationalization Review ID: IDEA-CR-28770 --- .../RedundantComparatorComparing.html | 2 +- .../redundantComparing/afterComparing.java | 2 +- .../redundantComparing/afterComparingInt.java | 2 +- .../redundantComparing/afterCustomInterface.java | 2 +- .../redundantComparing/beforeComparing.java | 2 +- .../redundantComparing/beforeComparingInt.java | 2 +- .../redundantComparing/beforeCustomInterface.java | 2 +- .../beforeCustomInterfaceConflict.java | 2 +- .../src/messages/InspectionsBundle.properties | 4 ++++ .../RedundantComparatorComparingInspection.java | 15 ++++++++------- 10 files changed, 20 insertions(+), 15 deletions(-) diff --git a/java/java-impl/src/inspectionDescriptions/RedundantComparatorComparing.html b/java/java-impl/src/inspectionDescriptions/RedundantComparatorComparing.html index 4827196ebfe9..a2330ecd4917 100644 --- a/java/java-impl/src/inspectionDescriptions/RedundantComparatorComparing.html +++ b/java/java-impl/src/inspectionDescriptions/RedundantComparatorComparing.html @@ -1,6 +1,6 @@ -Reports redundant comparator combinators constructs like thenComparing(Comparator.comparing(function)) +Reports redundant Comparator combinator constructs like thenComparing(Comparator.comparing(function)) which can be simplified to thenComparing(function).

New in 2018.1

diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterComparing.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterComparing.java index 3e679811ddd1..8ca89ec9f4bf 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterComparing.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterComparing.java @@ -1,4 +1,4 @@ -// "Remove 'comparing' call" "true" +// "Remove 'comparing()' call" "true" import java.util.*; class Test { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterComparingInt.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterComparingInt.java index 576cb48ed134..07629df8335a 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterComparingInt.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterComparingInt.java @@ -1,4 +1,4 @@ -// "Remove 'comparingInt' call and use 'thenComparingInt'" "true" +// "Remove 'comparingInt()' call and use 'thenComparingInt()'" "true" import java.util.*; class Test { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterCustomInterface.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterCustomInterface.java index 3987ad7c1720..2964ba7fd1dc 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterCustomInterface.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/afterCustomInterface.java @@ -1,4 +1,4 @@ -// "Remove 'comparing' call" "true" +// "Remove 'comparing()' call" "true" import java.util.Comparator; import java.util.function.Function; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeComparing.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeComparing.java index ece9527252f6..0b8b227b7229 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeComparing.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeComparing.java @@ -1,4 +1,4 @@ -// "Remove 'comparing' call" "true" +// "Remove 'comparing()' call" "true" import java.util.*; class Test { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeComparingInt.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeComparingInt.java index 7e6348d0fc7b..213d6f8f4a38 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeComparingInt.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeComparingInt.java @@ -1,4 +1,4 @@ -// "Remove 'comparingInt' call and use 'thenComparingInt'" "true" +// "Remove 'comparingInt()' call and use 'thenComparingInt()'" "true" import java.util.*; class Test { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeCustomInterface.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeCustomInterface.java index ade077313237..57d200d5dbea 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeCustomInterface.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeCustomInterface.java @@ -1,4 +1,4 @@ -// "Remove 'comparing' call" "true" +// "Remove 'comparing()' call" "true" import java.util.Comparator; import java.util.function.Function; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeCustomInterfaceConflict.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeCustomInterfaceConflict.java index f3bda6efcdf1..a4c57bac2bae 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeCustomInterfaceConflict.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantComparing/beforeCustomInterfaceConflict.java @@ -1,4 +1,4 @@ -// "Remove 'comparing' call" "false" +// "Remove 'comparing()' call" "false" import java.util.Comparator; import java.util.function.Function; diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties index 5164bbbf09e1..9772c28cb94b 100644 --- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties +++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties @@ -943,6 +943,10 @@ inspection.conditional.break.in.infinite.loop.description=Conditional break insi inspection.endless.stream.description=Non-short-circuit operation consumes the infinite stream inspection.redundant.comparator.comparing.display.name=Redundant Comparator.comparing +inspection.redundant.comparator.comparing.message=Unnecessary ''{0}()'' call +inspection.redundant.comparator.comparing.fix.remove.name=Remove ''{0}()'' call +inspection.redundant.comparator.comparing.fix.replace.name=Remove ''{0}()'' call and use ''{1}()'' +inspection.redundant.comparator.comparing.fix.family.name=Remove redundant call inspection.capturing.cleaner=Runnable passed to Cleaner.register() captures ''{0}'' reference inspection.capturing.cleaner.description=Cleaner captures object reference diff --git a/plugins/InspectionGadgets/src/com/intellij/codeInspection/RedundantComparatorComparingInspection.java b/plugins/InspectionGadgets/src/com/intellij/codeInspection/RedundantComparatorComparingInspection.java index 130860dd8c21..8ce21abc51fd 100644 --- a/plugins/InspectionGadgets/src/com/intellij/codeInspection/RedundantComparatorComparingInspection.java +++ b/plugins/InspectionGadgets/src/com/intellij/codeInspection/RedundantComparatorComparingInspection.java @@ -58,15 +58,16 @@ public class RedundantComparatorComparingInspection extends AbstractBaseJavaLoca } String name = comparingCall.getMethodExpression().getReferenceName(); holder - .registerProblem(comparingCall.getMethodExpression(), "Unnecessary '" + name + "' call", ProblemHighlightType.LIKE_UNUSED_SYMBOL, - new DeleteComparingCallFix(name, targetMethod)); + .registerProblem(comparingCall.getMethodExpression(), + InspectionsBundle.message("inspection.redundant.comparator.comparing.message", name), + ProblemHighlightType.LIKE_UNUSED_SYMBOL, new DeleteComparingCallFix(name, targetMethod)); } }; } static class DeleteComparingCallFix implements LocalQuickFix { - private String mySourceMethod; - private String myTargetMethod; + private final String mySourceMethod; + private final String myTargetMethod; public DeleteComparingCallFix(String sourceMethod, String targetMethod) { mySourceMethod = sourceMethod; @@ -78,15 +79,15 @@ public class RedundantComparatorComparingInspection extends AbstractBaseJavaLoca @Override public String getName() { return myTargetMethod.equals("thenComparing") - ? "Remove '" + mySourceMethod + "' call" - : "Remove '" + mySourceMethod + "' call and use '" + myTargetMethod + "'"; + ? InspectionsBundle.message("inspection.redundant.comparator.comparing.fix.remove.name", mySourceMethod) + : InspectionsBundle.message("inspection.redundant.comparator.comparing.fix.replace.name", mySourceMethod, myTargetMethod); } @Nls @NotNull @Override public String getFamilyName() { - return "Remove redundant call"; + return InspectionsBundle.message("inspection.redundant.comparator.comparing.fix.family.name"); } @Override