mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 02:09:59 +07:00
[codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
This patch adds processing of Java 14's text blocks to RedundantStringFormatCallInspection and fixes the problems from the code review Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com> GitOrigin-RevId: 126cfc001e7b201b62060333de7f71480403fb93
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c8bc41207e
commit
8db5967f7b
@@ -0,0 +1,62 @@
|
||||
// "Fix all 'Redundant call to 'String.format()'' problems in file" "true"
|
||||
package java.lang;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
class String {
|
||||
String(Object original) {}
|
||||
public native String formatted(Object... args);
|
||||
}
|
||||
|
||||
class Main {
|
||||
static {
|
||||
System.out.println(/* one */ new String("""
|
||||
%s, %s!
|
||||
"""/* two */).<caret>formatted(/* three */"Hello"/* four */, /* six */ "World" /* seven */));
|
||||
System.out.print(/* one */ ( /* two */ ( /* three */ new String("""
|
||||
%s, %s!
|
||||
"""/* four */) /* five */))
|
||||
.formatted(/* six */"Hello"/* seven */, /* eight */ "World" /* nine */));
|
||||
|
||||
System.out.print(/* one */ new String("""
|
||||
%s, %s!
|
||||
"""/* two */).formatted(/* six */"Hello"/* seven */, /* eight */ "World" /* nine */));
|
||||
|
||||
System.out.println(( /* one */ new String("""
|
||||
%s,
|
||||
""" /* two */) + /* three */
|
||||
new String("""
|
||||
%s!
|
||||
""")/* four */).formatted(/* five */"Hello"/* six */, /* seven */ "World" /* eight */));
|
||||
|
||||
System.out.print(( /* one */ new String("""
|
||||
%s,
|
||||
""" /* two */) + new String(/* three */
|
||||
"""
|
||||
%s!
|
||||
""")/* four */).formatted(/* five */"Hello"/* six */, /* seven */ "World" /* eight */));
|
||||
}
|
||||
|
||||
Main() {
|
||||
|
||||
}
|
||||
|
||||
void f() {
|
||||
|
||||
}
|
||||
|
||||
void out(PrintStream printer) {
|
||||
|
||||
}
|
||||
|
||||
void caller() {
|
||||
println(( /* one */ new String("""
|
||||
%s,
|
||||
""" /* two */ + /* three */
|
||||
"""
|
||||
%s!
|
||||
"""/* four */)).formatted(/* five */"Hello"/* six */, /* seven */ "World" /* eight */));
|
||||
}
|
||||
|
||||
static void println(String value) {}
|
||||
}
|
||||
Reference in New Issue
Block a user