mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-01 18:58:31 +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
29 lines
922 B
Java
29 lines
922 B
Java
// "Fix all 'Redundant call to 'String.format()'' problems in file" "true"
|
|
import java.io.PrintStream;
|
|
|
|
class Main {
|
|
static {
|
|
System.out.print(/* begin */ "Hello, World!"/* end */);
|
|
System.out.print(String.format(/* begin */ "Hello, World!%n"/* end */));
|
|
}
|
|
|
|
Main() {
|
|
System.out.print(/* begin */ "Hello, World!"/* end */);
|
|
System.out.print(String.format(/* begin */ "Hello, World!%n"/* end */));
|
|
}
|
|
void f() {
|
|
System.out.print(/* begin */ "Hello, World!"/* end */);
|
|
System.out.print(String.format(/* begin */ "Hello, World!%n"/* end */));
|
|
}
|
|
void out(PrintStream printer) {
|
|
printer.print(/* begin */ "Hello, World!"/* end */);
|
|
printer.print(String.format(/* begin */ "Hello, World!%n"/* end */));
|
|
}
|
|
void caller() {
|
|
print(/* begin */ "Hello, World!"/* end */);
|
|
print(String.format(/* begin */ "Hello, World!%n"/* end */));
|
|
}
|
|
|
|
static void print(String value) {}
|
|
}
|