mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: fix SIOOBE in "Escape trailing whitespace characters"
GitOrigin-RevId: 1f975c570b0192a94b651e219b517f742b3b0ba0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f7a2d9ee0e
commit
41b6cfab0b
+2
-2
@@ -200,13 +200,13 @@ public final class TrailingWhitespacesInTextBlockInspection extends AbstractBase
|
||||
if (suffix.equals("\\{")) return result.append(line).toString();
|
||||
line = line.substring(0, line.length() - suffix.length());
|
||||
}
|
||||
String transformed = lineTransformation.apply(line);
|
||||
String transformed = line.isEmpty() ? line : lineTransformation.apply(line);
|
||||
if (transformed == null) return null;
|
||||
if (last && hasUnescapedLastQuote(transformed)) {
|
||||
result.append(transformed, 0, transformed.length() - 1).append("\\\"");
|
||||
}
|
||||
else if (transformed.isEmpty()) {
|
||||
result.append((line.length() < indent) ? line : " ".repeat(indent));
|
||||
result.append((line.length() < indent) ? line : line.substring(0, indent));
|
||||
} else {
|
||||
result.append(transformed);
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class EmptyLine {
|
||||
|
||||
void x(int a) {
|
||||
System.out.println(STR."""
|
||||
a\na "\{a}
|
||||
|
||||
\s""");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class EmptyLine {
|
||||
|
||||
void x(int a) {
|
||||
System.out.println(STR."""
|
||||
a\na "\{a}
|
||||
|
||||
<warning descr="Trailing whitespace characters inside text block"><caret> </warning>""");
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
class Foo {
|
||||
void test() {
|
||||
String colors = """
|
||||
|
||||
|
||||
|
||||
|
||||
red
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
green
|
||||
|
||||
|
||||
+5
@@ -28,5 +28,10 @@ class Foo {
|
||||
\u005C \"""";
|
||||
String text14 = """
|
||||
\u005C\u005C\u005C\u005C\"""";
|
||||
String text15 = STR."""
|
||||
"scary"\{}
|
||||
"scary"\{}
|
||||
"scary" \{}
|
||||
""";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,10 @@ class Foo {
|
||||
<error descr="Illegal escape character in string literal">\u005C</error> "<warning descr="Trailing whitespace characters inside text block"> </warning>""";
|
||||
String text14 = """
|
||||
\u005C\u005C\u005C\u005C"<warning descr="Trailing whitespace characters inside text block"> </warning>""";
|
||||
String text15 = STR."""
|
||||
"scary"\{}<warning descr="Trailing whitespace characters inside text block"> </warning>
|
||||
"scary"\{}
|
||||
"scary" \{}
|
||||
""";
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ public class TrailingWhitespacesInTextBlockInspectionTest extends LightJavaInspe
|
||||
|
||||
public void testBadTextBlock() { doTest(); }
|
||||
public void testBlankLine() { doTestAll(); }
|
||||
public void testEmptyLine() { doTestEscape(); }
|
||||
public void testEmptyLastLine() { doTestAll(); }
|
||||
public void testOneLineBlock() { doTestAll(); }
|
||||
public void testReplaceAtTheEnd() { doTestEscape(); }
|
||||
|
||||
Reference in New Issue
Block a user