improvement: Save semanticdb to disk under setting - #8762
Conversation
|
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 (7)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughThe change adds nested MBT configuration, legacy parsing support, and configurable SemanticDB caching. ChangesMBT configuration and SemanticDB caching
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant MetalsLspService
participant MbtReferenceProvider
participant SemanticDBCache
participant SemanticDB
MetalsLspService->>MbtReferenceProvider: initialize with workspace and user configuration
MbtReferenceProvider->>SemanticDBCache: check memory and persistent cache
SemanticDBCache-->>MbtReferenceProvider: return valid document or miss
MbtReferenceProvider->>SemanticDB: index on cache miss
SemanticDB-->>MbtReferenceProvider: return SemanticDB document
MbtReferenceProvider->>SemanticDBCache: store document in memory and on disk
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
d2a3109 to
2c372ca
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/metals/mbt/MbtReferenceProvider.scala`:
- Around line 721-733: The loadFromDisk method only validates cached
TextDocument entries using MD5 of source text, but doesn't account for changes
in build metadata (classpath, compiler options, source roots). When the build
context changes without text changes, stale SemanticDB is reused. Update the
loadFromDisk method to additionally validate a build-context fingerprint
alongside the existing md5 check at line 732. Compute the build-context
fingerprint from current MBT metadata and include it in both the document
storage step (around line 777) and the validation condition in loadFromDisk, so
cache entries are invalidated when build context changes.
- Around line 708-711: Update the cache management around removeEldestEntry so
changes to maxCacheSize are enforced immediately: under the cache lock, remove
eldest entries until the map size is at or below the current configured maximum
before the next cache access, including when the maximum decreases. Preserve the
existing one-entry eviction behavior for normal insertions.
🪄 Autofix
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: d5e7cb9d-8ad0-44a5-88b5-5f7ee4437967
📒 Files selected for processing (8)
metals/src/main/scala/scala/meta/internal/metals/Configs.scalametals/src/main/scala/scala/meta/internal/metals/Directories.scalametals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scalametals/src/main/scala/scala/meta/internal/metals/UserConfiguration.scalametals/src/main/scala/scala/meta/internal/metals/mbt/MbtReferenceProvider.scalametals/src/main/scala/scala/meta/internal/metals/mbt/importer/BazelMbtImporter.scalatests/unit/src/test/scala/tests/UserConfigurationSuite.scalatests/unit/src/test/scala/tests/mbt/MbtReferenceSpec.scala
zielinsky
left a comment
There was a problem hiding this comment.
Overall LGTM, two nitpicks from me
2c372ca to
f03b15d
Compare
Also allow to specify the maximum cache size for the text document cache.
f03b15d to
9a880fb
Compare
Also allow to specify the maximum cache size for the text document cache.
Summary by CodeRabbit
New Features
Bug Fixes