refactor: move the SemanticDB to binary name conversion onto Symbol - #8763
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe change centralizes top-level SemanticDB symbol conversion. Javadoc links now resolve nested classes and members. Classpath, source-index, and virtual-text lookups use shared conversions. Tests cover valid, invalid, same-package, lowercase, and fully qualified references. ChangesTop-level symbol name conversion
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Javadoc
participant DocumentLinksProvider
participant Symbol
participant JavaSource
Javadoc->>DocumentLinksProvider: submit nested class reference
DocumentLinksProvider->>Symbol: construct ordered candidate symbols
DocumentLinksProvider->>JavaSource: resolve candidates lazily
JavaSource-->>DocumentLinksProvider: return source target
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@metals/src/main/scala/scala/meta/internal/parsing/DocumentLinksProvider.scala`:
- Line 299: Update classRefToSymbols so dotted Javadoc class references support
SemanticDB nested-class symbols: retain the Symbol.fromToplevelClassName
candidate for top-level classes, and additionally resolve nested segments using
the nested symbol form (for example, java/util/Map#Entry#). Return both
candidates when necessary so valid nested links can be found without breaking
top-level resolution.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2f70fbcf-2869-436a-bb20-39d9c0d9e3fd
📒 Files selected for processing (5)
metals/src/main/scala/scala/meta/internal/metals/mbt/VirtualTextDocument.scalametals/src/main/scala/scala/meta/internal/parsing/DocumentLinksProvider.scalamtags/src/main/scala/scala/meta/internal/mtags/ClasspathDefinitionIndex.scalamtags/src/main/scala/scala/meta/internal/mtags/Symbol.scalamtags/src/main/scala/scala/meta/internal/mtags/SymbolIndexBucket.scala
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@metals/src/main/scala/scala/meta/internal/parsing/DocumentLinksProvider.scala`:
- Line 304: Update the dotted-reference handling around
DocumentLinksProvider.dottedClassRefToSymbols so references beginning with a
type name also generate the current-package candidate (for example,
a/Outer#Inner#) before unqualified candidates. Preserve existing resolution
behavior and add LSP regressions covering {`@link` Outer.Inner} and {`@link`
Outer.Inner#doSomething} in the same package.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 7ceb44c7-058d-499a-a63e-ebb52ec41fc5
📒 Files selected for processing (3)
metals/src/main/scala/scala/meta/internal/parsing/DocumentLinksProvider.scalatests/unit/src/test/scala/tests/DocumentLinkLspSuite.scalatests/unit/src/test/scala/tests/parsing/DocumentLinksProviderSuite.scala
dcc391a to
daced54
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
| // A reference starting with a type names a class of the current package: | ||
| // `Outer.Inner` inside `package a` is `a/Outer#Inner#`, which no | ||
| // unqualified reading covers. First, as for a simple name. | ||
| val startsWithTypeName = classRef.headOption.exists(_.isUpper) |
There was a problem hiding this comment.
Doesn't it break if we have a lower case class?
There was a problem hiding this comment.
will have a look
There was a problem hiding this comment.
I've updated the logic and added some test cases to check if references to classes with lowercase names are properly resolved
There was a problem hiding this comment.
extracted the changes related to javadoc links to a separate PR as they can be merged separately:
#8790
| List(simpleSymbol) | ||
| } else { | ||
| List(classRef.replace('.', '/') + "#") | ||
| val toplevelSymbol = Symbol.fromToplevelClassName(classRef).value |
There was a problem hiding this comment.
these changes were added to address the following feedback:
#8763 (comment)
| // A reference starting with a type names a class of the current package: | ||
| // `Outer.Inner` inside `package a` is `a/Outer#Inner#`, which no | ||
| // unqualified reading covers. First, as for a simple name. | ||
| val startsWithTypeName = classRef.headOption.exists(_.isUpper) |
There was a problem hiding this comment.
will have a look
e75c1d8 to
7e09c11
Compare
7e09c11 to
bd2e3c9
Compare
…types (#8790) Extracted from #8763 these changes address the following automated feedback: #8763 (comment) and also this comment (resolving links to classes with lowercase names): #8763 (comment) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved JavaDoc link resolution for nested classes, package and class references, same-package symbols, and local members. * Invalid or unresolved references no longer generate incorrect document links. * Empty JavaDoc link tags are now ignored. * **Tests** * Added coverage for valid, invalid, mixed, qualified, and lowercase references. * Improved verification of link counts, tooltips, and resolution targets. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
There are a few places where we convert SemanticDB symbols to Java binary names, for example
We could extract that logic to make it reusable
This change originated in from #8742
I've moved it to a separate PR to make the original one smaller
Summary by CodeRabbit
Bug Fixes
Tests