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

Improve diagnostic output related to ErroneousTree

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: tools
    • Labels:
      None

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: