Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8342859

Improve diagnostic position for text block trailing whitespace

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • tools
    • None

      It would be nice if 'trailing white space will be removed' diagnostics for text blocks had a more precise diagnostic position, and also suggested what the fix was (to either remove the whitespace, or use an explicit \s if is deliberate and should be preserved).

      Consider the following example where the line with 'hello' in the text block has trailing whitespace:

      class T {
        String s =
            """
            hello
            world
            """;
      }

      $ javac -Xlint:all T.java
      T.java:3: warning: [text-blocks] trailing white space will be removed
            """
            ^
      1 warning

      The suggested diagnostic would be something like:

      $ javac -Xlint:all T.java
      T.java:4: warning: [text-blocks] trailing white space will be removed. Either remove the trailing whitespace, or use \s if it is deliberate and should be preserved.
            hello
                   ^
      1 warning

            Unassigned Unassigned
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: