Text block can be used
Reports String
concatenations that can be simplified by replacing them with text blocks.
Requirements:
\n
occurs two or more times.Text blocks are not concatenated.
Use the Apply to single string literals option to suggest the fix for single literals containing line breaks.
Example:
String html = "<html>\n" +
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>\n";
After the quick-fix is applied:
String html = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";
This inspection only reports if the language level of the project or module is 15 or higher.
New in 2019.3
Inspection options
Option | Type | Default |
---|---|---|
Apply to single string literals | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023