On Fri, 5 Jan 2024 00:12:32 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:
> Please review a small enhancement when reporting bad options on the command > line. > > [JDK-8313693](https://bugs.openjdk.org/browse/JDK-8313693) introduced code to > help determine a list of suggestions when given a misspelled word and a > vocabulary of possibly intended words. It was added in the context of > reporting bad/invalid tags in doc comments. > > This fix leverages that code by applying it to unrecognized command-line > options, comparing them against the set of supported command-line options. > Now, when an unknown command-line option is found, the code will report > possible suggestions, and a reference to `--help` instead of just simply > listing the full command-line help. src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java line 461: > 459: result = ERROR; > 460: } > 461: log.flush(); Why is this flush needed here? There's already one, two lines below. src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java line 680: > 678: > .sorted(Comparator.comparingDouble(Pair::distance)) > 679: .limit(3) > 680: .toList(); Looking at this copied snippet, I realise that it might not be the best example I could come up with when introduced that functionality. Have you seen the actual use here? https://github.com/openjdk/jdk/blob/3aefd1ce714ad2d51f31b73c73b423c7bb7443ed/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/DocLint.java#L380-L401 It might work better as it does not limit the list of findings to top 3, a number which (as we discussed offline) has nothing to do with the distance threshold of `1.0 / 3`. src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java line 683: > 681: switch (suggestions.size()) { > 682: case 0 -> { } > 683: case 1 -> showLinesUsingKey("main.did-you-mean", > suggestions.get(0).word); Consider `suggestions.getFirst()` instead of `suggestions.get(0)`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17274#discussion_r1442676999 PR Review Comment: https://git.openjdk.org/jdk/pull/17274#discussion_r1442702308 PR Review Comment: https://git.openjdk.org/jdk/pull/17274#discussion_r1442681074