mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-234256 QuickFix for "Unnecessary call to 'toString'" could be more explicit
GitOrigin-RevId: d8ec1a80004ae2405f78b42a50df0ca2c994d5d3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ebda994e59
commit
13b04e6d06
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Fix all 'Unnecessary call to 'toString()'' problems in file" "true"
|
||||
// "Remove redundant 'toString()' call" "true"
|
||||
class X {
|
||||
void test(Object x) {
|
||||
System.out.println(x);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Fix all 'Unnecessary call to 'toString()'' problems in file" "true"
|
||||
// "Remove redundant 'toString()' call" "true"
|
||||
class X {
|
||||
void test(Object x) {
|
||||
System.out.println(x.toStri<caret>ng());
|
||||
|
||||
+7
-6
@@ -36,8 +36,7 @@ public class UnnecessaryToStringCallInspection extends BaseInspection implements
|
||||
@Override
|
||||
@NotNull
|
||||
protected String buildErrorString(Object... infos) {
|
||||
final String text = (String)infos[0];
|
||||
return InspectionGadgetsBundle.message("unnecessary.tostring.call.problem.descriptor", text);
|
||||
return InspectionGadgetsBundle.message("unnecessary.tostring.call.problem.descriptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,16 +47,18 @@ public class UnnecessaryToStringCallInspection extends BaseInspection implements
|
||||
}
|
||||
|
||||
private static class UnnecessaryToStringCallFix extends InspectionGadgetsFix {
|
||||
private final @Nullable String replacementText;
|
||||
|
||||
private final String replacementText;
|
||||
|
||||
private UnnecessaryToStringCallFix(String replacementText) {
|
||||
private UnnecessaryToStringCallFix(@Nullable String replacementText) {
|
||||
this.replacementText = replacementText;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
if (replacementText == null) {
|
||||
return InspectionGadgetsBundle.message("inspection.redundant.string.remove.fix.name", "toString");
|
||||
}
|
||||
return CommonQuickFixBundle.message("fix.replace.with.x", replacementText);
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ public class UnnecessaryToStringCallInspection extends BaseInspection implements
|
||||
if (referenceNameElement == null) return;
|
||||
PsiExpression qualifier = ExpressionUtils.getEffectiveQualifier(methodExpression);
|
||||
if (qualifier == null) return;
|
||||
registerError(referenceNameElement, ProblemHighlightType.LIKE_UNUSED_SYMBOL, qualifier.getText());
|
||||
registerError(referenceNameElement, ProblemHighlightType.LIKE_UNUSED_SYMBOL, qualifier.isPhysical() ? null : qualifier.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user