RFR: JDK-8306578: Report error if no label given in @see and {@link} when no default is available
Jonathan Gibbons
jjg at openjdk.org
Wed May 24 21:14:58 UTC 2023
On Fri, 28 Apr 2023 14:01:18 GMT, Hannes Wallnöfer <hannesw at openjdk.org> wrote:
> Please review a trivial change to generate an error instead of a warning when no label is provided with a reference to a user-provided anchor.
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java line 503:
> 501: // A non-empty label is required for fragment links as the
> 502: // reference target does not provide a useful default label.
> 503: htmlWriter.messages.error(ch.getDocTreePath(refTree), "doclet.link.see.no_label");
This is ... interesting.
This method is called from various places, which is why we pass in a function to report diagnostics in the appropriate way for the caller (meaning, at the appropriate position.). It seems less than ideal to avoid using the function, but that being said, this codepath likely cannot occur in the most problematic situation, in snippets.
I'm not (yet) sure what the right approach is here. Maybe we can move away from needing the `reportWarning` function. See PR #13811 for a separate PR in this area.
Maybe/probably the better (future?) solution is to pass in the tree path for `refTree` instead of (just) `refTree` by itself. This could/should be used in all diagnostics and world obviate the need for the `reportWarning` function. It would still require a TODO in the snippet code, to replace the existing TODO to provide the function for `reportWarning`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13720#discussion_r1186350404
More information about the javadoc-dev
mailing list