Java: warn on string template single line trailing whitespace (IDEA-331315)

GitOrigin-RevId: c3c1d5ef02d3086a2c8dbf29a9fea5b1d31d18d4
This commit is contained in:
Bas Leijdekkers
2024-01-29 16:23:18 +00:00
committed by intellij-monorepo-bot
parent 5ba9a83c24
commit ac330832ba
4 changed files with 15 additions and 1 deletions
@@ -47,7 +47,6 @@ public final class TrailingWhitespacesInTextBlockInspection extends AbstractBase
private boolean checkTextBlock(@NotNull PsiElement textBlock, @NotNull String suffix) {
String text = textBlock.getText();
String[] lines = text.split("\n", -1);
if (lines.length < 2) return false;
int indent = getIndent(textBlock);
if (indent == -1) return false;
int offset = 0;
@@ -0,0 +1,7 @@
class StringTemplateOneLine {
public void foo(String type) {
String s = STR."""
Hello \{type}""";
}
}
@@ -0,0 +1,7 @@
class StringTemplateOneLine {
public void foo(String type) {
String s = STR."""
Hello \{type}<warning descr="Trailing whitespace characters inside text block"><caret> </warning>""";
}
}
@@ -22,6 +22,7 @@ public class TrailingWhitespacesInTextBlockInspectionTest extends LightJavaInspe
public void testStringTemplate4Java21Preview() { doTestEscape(); }
public void testStringTemplate5() { doTest(); }
public void testStringTemplate6() { doTestAll(); }
public void testStringTemplateOneLine() { doTestAll(); }
public void testTrailingSpaces() { doTestAll(); }
public void testTrailingTabs() { doTestEscape(); }
public void testWithBlankLines() { doTestAll(); }