mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-27 08:51:23 +07:00
The RedundantStringFormatCallInspection inspection used to be able to detect excessive String.format calls and get rid of them not changing the callsite at all. This patch enhances the inspection's capabilities with changing the callsite if it is either PrintStream#print or PrintStream#println and converting it to PrintStream#printf adding "%n" if necessary. Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com> GitOrigin-RevId: 7edc5b0a84fb6c7b9caf504b1afb8905c5684985
39 lines
1.2 KiB
Java
39 lines
1.2 KiB
Java
// "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");
|
|
}
|
|
}
|