RedundantComparatorComparing: cosmetic changes, internationalization

Review ID: IDEA-CR-28770
This commit is contained in:
Tagir Valeev
2018-02-05 12:33:55 +07:00
parent 1a3fb028db
commit 818b20eff3
10 changed files with 20 additions and 15 deletions
@@ -1,6 +1,6 @@
<html>
<body>
Reports redundant comparator combinators constructs like <b>thenComparing(Comparator.comparing(function))</b>
Reports redundant Comparator combinator constructs like <b>thenComparing(Comparator.comparing(function))</b>
which can be simplified to <b>thenComparing(function)</b>.
<!-- tooltip end -->
<p><small>New in 2018.1</small></p>
@@ -1,4 +1,4 @@
// "Remove 'comparing' call" "true"
// "Remove 'comparing()' call" "true"
import java.util.*;
class Test {
@@ -1,4 +1,4 @@
// "Remove 'comparingInt' call and use 'thenComparingInt'" "true"
// "Remove 'comparingInt()' call and use 'thenComparingInt()'" "true"
import java.util.*;
class Test {
@@ -1,4 +1,4 @@
// "Remove 'comparing' call" "true"
// "Remove 'comparing()' call" "true"
import java.util.Comparator;
import java.util.function.Function;
@@ -1,4 +1,4 @@
// "Remove 'comparing' call" "true"
// "Remove 'comparing()' call" "true"
import java.util.*;
class Test {
@@ -1,4 +1,4 @@
// "Remove 'comparingInt' call and use 'thenComparingInt'" "true"
// "Remove 'comparingInt()' call and use 'thenComparingInt()'" "true"
import java.util.*;
class Test {
@@ -1,4 +1,4 @@
// "Remove 'comparing' call" "true"
// "Remove 'comparing()' call" "true"
import java.util.Comparator;
import java.util.function.Function;
@@ -1,4 +1,4 @@
// "Remove 'comparing' call" "false"
// "Remove 'comparing()' call" "false"
import java.util.Comparator;
import java.util.function.Function;
@@ -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
@@ -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