[codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf

This patch fixes the notes from the code review, it includes:

- Renaming the testData files so their titles are more informative
- Moving `PsiLiteralUtil#append` to `RedundantStringFormatCallInspection` and renaming it to `joinWithNewlineToken` so it does not have to deal with the escape characters' problems
- `RedundantStringFormatCallInspection` only highlights the "`format`" word in `String.format` in order to reduce the warnings area in code visually

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: 07b3b3b2d24e500774928d406e274dd4cb20bd5d
This commit is contained in:
Nikita Eshkeev
2020-05-04 17:48:23 +03:00
committed by intellij-monorepo-bot
parent 05dc20b48b
commit fcd7fac054
11 changed files with 53 additions and 55 deletions

View File

@@ -0,0 +1,38 @@
// "Fix all 'Redundant call to 'String.format()'' problems in file" "true"
import java.io.PrintStream;
import java.util.Locale;
import static java.lang.String.format;
class Main {
static {
String s1 = f<caret>ormat("test");
String s1n = format("test%n");
String s2 = format(Locale.US, "test");
String s2n = format(Locale.US, "test%n");
String s3 = String.format("test");
String s3l = String.format(Locale.US, "test");
String s3n = String.format(Locale.US, "test%n");
System.out.println(String.format(/* one */ Locale.CANADA /* two */, /* three */ "hello, " /* four */));
}
Main() {
String s1 = format("test");
String s1n = format("test%n");
String s2 = format(Locale.US, "test");
String s2n = format(Locale.US, "test%n");
String s3 = String.format("test");
String s3l = String.format(Locale.US, "test");
String s3n = String.format(Locale.US, "test%n");
}
void f() {
String s1 = format("test");
String s1n = format("test%n");
String s2 = format(Locale.US, "test");
String s2n = format(Locale.US, "test%n");
String s3 = String.format("test");
String s3l = String.format(Locale.US, "test");
String s3n = String.format(Locale.US, "test%n");
}
}