Files
openide/java/java-tests/testData/codeInsight/replaceStringFormat/afterStringFormatNoArgsNoTokensPassedToPrint.java
Nikita Eshkeev 299e3d31e1 [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 inclues:

- renaming method to methodNameReference for variables that contain the name of a method that is being called, i.e. either `println` or `print` or `format`
- using a different overloaded createProblemDescriptor method that does not accept a `TextRange`
- using `getParent` in quick fixes to get the `PsiMethodExpressionCall`
- proper handling arguments with parenthesis

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

GitOrigin-RevId: ea1e335372bf7b1ce3e6c87a3816baa0ab54e11e
2020-05-06 13:46:11 +00:00

31 lines
1.0 KiB
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((/* begin */ "Hello, World!"/* end */));
System.out.print(String.format(/* begin */ "Hello, World!%n"/* 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) {}
}