Back to Intellij Community

TextBlockMigration

java/java-impl/resources/inspectionDescriptions/TextBlockMigration.html

2025.3-rc-2776 B
Original Source

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 Report single string literals option to highlight single literals containing line breaks. The quick-fix will still be available even when this option is disabled.

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>
                """;

New in 2019.3