RFR: JDK-8267126: javadoc should show "line and caret" for diagnostics.

Jonathan Gibbons jjg at openjdk.java.net
Mon May 17 20:13:25 UTC 2021


Please review a change to overhaul the javadoc support for diagnostics to better leverage the support available in javac. This includes the ability for all javadoc diagnostics to show a "source line and caret" to indicate the position of a reported issue. As a side-effect, it normalizes the formatting of javadoc messages, to be consistent with javac messages.

The primary changes are in the javadoc `Messager` class, and are primarily focussed "downward" on the internal use of the javac `Log.report` method, which is the nexus for reporting methods. There is additional cleanup that could be done in `Messager` in the API it provides to clients, but (for the most part) that is not done in this work.

Additional changes are done to facilitate writing a test for this work, and reflect the current shortcomings of the existing `Doclet` API. Most notably:
* changes in `Utils` to allow a user-defined taglet to override a built-in taglet
* changes in `TagletManager` and `Workarounds` to allow a user-defined taglet to access internal API, to workaround API that would be useful to provide on `StandardDoclet`

There are a few minor specific cleanup changes in code style and/or improved comments.

There is one primary new test, `TestDiagsLineCaret.java` which exercises different kinds of diagnostics at different positions in a file, to verify that the source line and a caret are produced as appropriate.

There are additional test changes triggered by the slight change in the format of error messages.  Most notably, prefixes like `error -` and `warning -` become `error:` and `warning:`.

-------------

Commit messages:
 - JDK-8267126: javadoc should show "line and caret" for diagnostics.

Changes: https://git.openjdk.java.net/jdk/pull/4074/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4074&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8267126
  Stats: 906 lines in 37 files changed: 598 ins; 132 del; 176 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4074.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4074/head:pull/4074

PR: https://git.openjdk.java.net/jdk/pull/4074


More information about the javadoc-dev mailing list