Skip to content

[main-v2] Replace qdox with javac for Javadoc indexing#8358

Open
rkophs wants to merge 6 commits into
scalameta:main-v2from
rkophs:javadoc-improvements
Open

[main-v2] Replace qdox with javac for Javadoc indexing#8358
rkophs wants to merge 6 commits into
scalameta:main-v2from
rkophs:javadoc-improvements

Conversation

@rkophs
Copy link
Copy Markdown

@rkophs rkophs commented May 7, 2026

Context

closes #8349

Pulled out of #8350 -- improve JavaDox indexing while removing last vestige of qdox dep in main-v2.

Summary

  • Remove the qdox dependency by switching JavadocIndexer from
    QdoxJavaMtags to JavacMtags
  • Add onClass/onMethod/onConstructor hooks and keepDocComments support to
    JavacMtags so subclasses can extract Javadoc during parsing
  • Introduce JavadocParser utility for extracting body text and @param tags
    from raw Javadoc comments
  • Pass full raw Javadoc to MarkdownGenerator so @param, @return, @throws,
    and @see block tags now render in hover documentation
  • Delete QdoxJavaMtags.scala and remove the useQdox config toggle (javac
    is now the only Java outline provider)

Context

This is the main-v2 counterpart to the work in #8350. Since main-v2's
JavadocIndexer still relied on qdox, this PR removes that dependency from
v2 as well by reusing the existing JavacMtags javac-based parser with
minimal additions (hooks + doc comment extraction).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4b6cbda0-19a0-41f0-87a3-6a47dfc9269b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rkophs rkophs changed the title Replace qdox with javac for Javadoc indexing [main-v2] Replace qdox with javac for Javadoc indexing May 7, 2026
@rkophs rkophs marked this pull request as ready for review May 7, 2026 19:54
Copy link
Copy Markdown
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, but looks pretty good!

Comment thread metals/src/main/scala/scala/meta/internal/metals/Configs.scala Outdated
Comment thread mtags/src/main/scala/scala/meta/internal/mtags/JavacMtags.scala Outdated
@tgodzik
Copy link
Copy Markdown
Contributor

tgodzik commented May 8, 2026

Could you also take a look at the failing tests?

@rkophs rkophs force-pushed the javadoc-improvements branch from f09f88f to d538655 Compare May 9, 2026 16:20
@rkophs
Copy link
Copy Markdown
Author

rkophs commented May 9, 2026

@tgodzik Thanks for the review! addressed comments and failing tests.

@rkophs rkophs requested a review from tgodzik May 9, 2026 16:38
Copy link
Copy Markdown
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor issue that I just noticed. Thanks for working on this!

Comment thread tests/cross/src/test/scala/tests/pc/SignatureHelpDocSuite.scala Outdated
Comment thread tests/javapc/src/test/scala/hover/HoverDocSuite.scala Outdated
rkophs and others added 3 commits May 18, 2026 17:57
JavadocIndexer now extends JavacMtags instead of QdoxJavaMtags,
removing the qdox dependency entirely. Added onClass/onMethod/
onConstructor hooks and keepDocComments support to JavacMtags.
Uses javac's internal DocCommentTable for robust Javadoc extraction.
Introduced JavadocParser for extracting body text and @param tags
from raw Javadoc comments. Full raw Javadoc is now passed to
MarkdownGenerator so @param, @return, @throws, and @see tags
render in hover documentation.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…omment, update test expectations

- Remove JavaOutlineProviderConfig setting entirely since javac is now the only provider
- Refactor getDocComment in JavacMtags to use idiomatic Scala pattern matching
  instead of null checks, casts, and early returns
- Update test expectations to include newly rendered @param, @return, @throws,
  and @see Javadoc block tags in hover and signature help output

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Replace sliding(2) disambiguator with a per-name counter so non-adjacent
  overloads (e.g. String.valueOf interleaved with copyValueOf) get unique
  SemanticDB symbols instead of colliding.
- Filter private constructors from disambiguation and emission, matching
  the previous qdox behavior. Without this, classes like java.io.File
  shifted public constructors' disambiguators by 2, causing the PC to
  read parameter names from the wrong overloads.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@rkophs rkophs force-pushed the javadoc-improvements branch from 74c2cc0 to 79e1c09 Compare May 19, 2026 00:15
@rkophs rkophs requested a review from tgodzik May 19, 2026 00:20
@rkophs
Copy link
Copy Markdown
Author

rkophs commented May 19, 2026

sorry for the delay here! Should be all addressed.

ScaladocParser's HtmlConverter (Jsoup-based) strips <T> as an unknown
HTML tag before the @param regex captures the param name, leaving the
next word (e.g. "the", "type") as the captured name.

Rewrite Javadoc `@param <T> desc` to Scaladoc `@tparam T desc` before
passing the comment to MarkdownGenerator, so type parameters render
correctly under Type Parameters and regular params stay under
Parameters.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@rkophs rkophs force-pushed the javadoc-improvements branch from 79e1c09 to d90e082 Compare May 19, 2026 00:28
rkophs and others added 2 commits May 19, 2026 10:21
The unconditional private-constructor filter in JavacMtags caused two
problems: tests.JavacMtagsExpectSuite's assertCompatWithSemanticdbJavac
fails because semanticdb-javac emits private constructors, and the
tests/unit/.../mtags/example/JavaClass.java fixture expects them too.

The filter is only needed for JavadocIndexer's parameter-name lookup
(keyed by `<init>(+N)`), which must match the Scala compiler's view of
Java constructors (which excludes private ones). The base JavacMtags
should match semanticdb-javac for consistent code navigation.

Gate the filter behind a `filterPrivateConstructors` constructor flag,
defaulting to false. JavadocIndexer opts in.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The Bazel MBT Java-workspace hover test now sees the `@return` block from
Jsoup's Document.title() Javadoc since JavadocIndexer renders block tags.
Also drop a leftover Tokens.Comment import from JavacMtags (scalafix).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants