IG: don't warn on call to .formatted() when qualifier contains %n (IDEA-284569)

GitOrigin-RevId: e1b9a826f67e0209f82810ed19f907b2d0161605
This commit is contained in:
Bas Leijdekkers
2022-01-06 20:08:21 +00:00
committed by intellij-monorepo-bot
parent 4c25f88d51
commit df2af98547
7 changed files with 60 additions and 79 deletions
@@ -12,7 +12,7 @@ class Main {
/* first arg start */ "Hello"/* first arg end */,
/* second arg start */ "World" /* second arg end */);
System.out.printf(/* one */ Locale.US, /* two */ "%s, %s!" /* three */, /* four */ "Hello" /* five */, /* six */ "World" /* seven */);
System.out.print("hello" + String.format("%n"))
System.out.print("hello" + String.format("%n"));
}
Main() {
@@ -7,38 +7,25 @@ import static java.lang.String.format;
class Main {
static {
System.out.print(/* one */ "hello" /* two */);
System.out.print(/* one */ ("hello") /* two */);
System.out.print(/* one */ ("hello") /* two */);
System.out.print(/* one */ ("hello") /* two */);
System.out.print(/* one */ /* two */ /* three */ ("hello") /* four */);
System.out.print(/* one */ /* two */ /* three */ ("hello") /* four */);
System.out.print(/* one */ /* two */ /* three */ ("hello") /* four */);
System.out.print((format(/* one */ Locale.CANADA /* two */, /* three */ "hello%n" /* four */)));
System.out.print(/* one */ ("hello") /* two */;
System.out.print(((/* one */ ("hello") /* two */)));
}
Main() {
System.out.print(/* one */ ("hello") /* two */);
System.out.print(/* one */ ("hello") /* two */);
System.out.print(/* one */ /* two */ /* three */ ("hello") /* four */);
System.out.print(/* one */ /* two */ /* three */ ("hello") /* four */);
System.out.print(((/* one */ ("hello") /* two */)));
}
void f() {
System.out.print(/* one */ ("hello") /* two */);
System.out.print(/* one */ ("hello") /* two */);
System.out.print(/* one */ /* two */ /* three */ ("hello") /* four */);
System.out.print(/* one */ /* two */ /* three */ ("hello") /* four */);
System.out.print(((/* one */ ("hello") /* two */)));
}
void out(PrintStream printer) {
printer.print(/* one */ ("hello") /* two */);
printer.print(/* one */ ("hello") /* two */);
printer.print(/* one */ /* two */ /* three */ ("hello") /* four */);
printer.print(/* one */ /* two */ /* three */ ("hello") /* four */);
printer.print(((/* one */ ("hello") /* two */)));
}
void caller() {
printf(String.format(/* one */ ("hello") /* two */));
printf(((String.format(/* one */ ("hello") /* two */))));
printf(String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */));
printf((String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */)));
printf(/* one */ ("hello") /* two */);
printf(((/* one */ ("hello") /* two */)));
}
static void printf(String value) {}
@@ -15,5 +15,8 @@ class Main {
String s1 = new String("""
%s, %s!
""").formatted("Hello", "World");
String s = (/* 1 */ new /* 2 */ String(/* 3 */"""
Hello, World!%n
"""/* 4 */)/* 5 */)./* 6 */formatted();
}
}
@@ -12,7 +12,7 @@ class Main {
/* first arg start */ "Hello"/* first arg end */,
/* second arg start */ "World" /* second arg end */));
System.out.print(String.format(/* one */ Locale.US, /* two */ "%s, %s!" /* three */, /* four */ "Hello" /* five */, /* six */ "World" /* seven */));
System.out.print("hello" + String.format("%n"))
System.out.print("hello" + String.format("%n"));
}
Main() {
@@ -6,39 +6,26 @@ import static java.lang.String.format;
class Main {
static {
System.out.<caret>printf(String.format(/* one */ "hello" /* two */));
System.out.printf(String.format(/* one */ ("hello") /* two */));
System.out.printf(format(/* one */ ("hello") /* two */);
System.out.printf(((String.format(/* one */ ("hello") /* two */))));
System.out.printf(String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */));
System.out.printf((String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */)));
System.out.printf((format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */)));
System.out.printf((format(/* one */ Locale.CANADA /* two */, /* three */ "hello%n" /* four */)));
System.out.<caret>printf(/* one */ "hello" /* two */);
System.out.printf(/* one */ ("hello") /* two */;
System.out.printf(((/* one */ ("hello") /* two */)));
}
Main() {
System.out.printf(String.format(/* one */ ("hello") /* two */));
System.out.printf(((String.format(/* one */ ("hello") /* two */))));
System.out.printf(String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */));
System.out.printf((String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */)));
System.out.printf(/* one */ ("hello") /* two */);
System.out.printf(((/* one */ ("hello") /* two */)));
}
void f() {
System.out.printf(String.format(/* one */ ("hello") /* two */));
System.out.printf(((String.format(/* one */ ("hello") /* two */))));
System.out.printf(String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */));
System.out.printf((String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */)));
System.out.printf(/* one */ ("hello") /* two */);
System.out.printf(((/* one */ ("hello") /* two */)));
}
void out(PrintStream printer) {
printer.printf(String.format(/* one */ ("hello") /* two */));
printer.printf(((String.format(/* one */ ("hello") /* two */))));
printer.printf(String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */));
printer.printf((String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */)));
printer.printf(/* one */ ("hello") /* two */);
printer.printf(((/* one */ ("hello") /* two */)));
}
void caller() {
printf(String.format(/* one */ ("hello") /* two */));
printf(((String.format(/* one */ ("hello") /* two */))));
printf(String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */));
printf((String.format(/* one */ Locale.CANADA /* two */, /* three */ ("hello") /* four */)));
printf(/* one */ ("hello") /* two */);
printf(((/* one */ ("hello") /* two */)));
}
static void printf(String value) {}
@@ -14,5 +14,8 @@ class Main {
String s1 = new String("""
%s, %s!
""").formatted("Hello", "World");
String s = (/* 1 */ new /* 2 */ String(/* 3 */"""
Hello, World!%n
"""/* 4 */)/* 5 */)./* 6 */formatted();
}
}