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

Improve diagnostic output related to ErroneousTree

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 18
    • 18
    • tools
    • None

      Consider the following example source:

      ```
      package pkg1;

      /**
       * {@link
       * Object!equals
       * equals
       * }
       */
      public class A { }
      ```

      The above source features the `@link` tag which is unusually but legitimately formatted to span multiple lines. The reference `Object!equals` is malformed since it contains `!`, which the user is likely mistyped for the correct `#`.

      When presented with that source, javadoc (tool) reports the following error:

      ```
      src/pkg1/A.java:4: error: unexpected text
       * {@link
         ^
      ```

      As you can see, the diagnostic output positioned the caret quite far away from the actual error position. This could be improved. Here are some suggestions for the diagnostic output.


      Good:

      ```
      src/pkg1/A.java:5: error: unexpected text
       * Object!
                   ^
      ```

      Very good:

      ```
      src/pkg1/A.java:5: error: unexpected text
       * Object!equals
                   ^
      ```

      Extremely chatty:

      ```
      src/pkg1/A.java:4-7 error: unexpected text
      04 * {@link
      05 * Object!equals
                 ^
      06 * equals
      07 * }
      ```

      The latter suggestion might require quite a lot of surgery in javac reporting facilities.

      ---------
      To implement this, we need to better translate DocCommentParser.ParseException to DCErroneousTree (think JCDiagnostic.DiagnosticPosition, DCEndPosTree) and then properly log errors related to those error trees.

            jjg Jonathan Gibbons
            prappo Pavel Rappo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: