feat(lockfile): add Cargo.lock parsing for instant version hints#22
Merged
feat(lockfile): add Cargo.lock parsing for instant version hints#22
Conversation
Implement lock file support to provide immediate version hints from local Cargo.lock files instead of waiting for registry API responses. Key changes: - Add LockFileProvider trait in deps-core with ResolvedPackages abstraction - Add LockFileCache for caching parsed lock files with stale detection - Implement CargoLockParser for Cargo.lock v4 format parsing - Extend EcosystemHandler trait with lockfile_provider() method - Update document_lifecycle to load lock file versions on document open Performance: Version hints now appear in <100ms vs previous 500ms-2s.
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #22 +/- ##
==========================================
+ Coverage 80.31% 82.36% +2.05%
==========================================
Files 29 33 +4
Lines 5721 7118 +1397
==========================================
+ Hits 4595 5863 +1268
- Misses 1126 1255 +129
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…st version Changed hover to prefer resolved version from lock file over manifest version requirement. When a lock file is available, the "Current" field in hover now shows the full resolved version (e.g., "1.0.195") instead of just the version requirement from the manifest (e.g., "1.0"). Changes: - Modified generate_hover to accept optional resolved_version parameter - Updated hover.rs to pass resolved version from doc.versions - Added test for resolved version display in hover
The background task was overwriting lock file versions with registry latest versions. Fixed by adding a separate resolved_versions field to DocumentState that stores lock file versions as simple strings. Changes: - Added resolved_versions: HashMap<String, String> to DocumentState - Added update_resolved_versions() method - Updated document_lifecycle.rs to populate resolved_versions - Updated hover.rs to use resolved_versions for "Current" display
The resolved_versions from lock file were being lost when user edits the document, because handle_document_change created a new DocumentState with empty resolved_versions. Also added debug logging to troubleshoot hover issues.
Added inlay_hint_refresh call in handle_document_open after versions are fetched from registry. This ensures emoji (✅/❌) appear after the initial document load instead of requiring user to edit the file.
76ca674 to
b72b53f
Compare
- Add NpmLockParser for package-lock.json v2/v3 parsing - Add PypiLockParser for poetry.lock and uv.lock parsing - Integrate lockfile_provider() in NpmHandlerImpl and PyPiHandlerImpl - Support registry, git, and path source types for both ecosystems npm lock file features: - Parses "packages" object with node_modules paths - Handles scoped packages (@scope/pkg) - Extracts integrity checksums - Workspace root search (5 levels) PyPI lock file features: - Poetry.lock priority, uv.lock fallback - Parses [[package]] sections with dependencies - Handles source inline tables and arrays Tests: 35+ new tests across both parsers
When comparing versions for inlay hints (✅/❌), use the resolved version from lock file instead of the version requirement from manifest. Before: `>=8.0` vs `9.0.2` → ❌ (major version differs) After: `9.0.2` vs `9.0.2` → ✅ (versions match) This fixes the issue where dependencies with lock file resolved to latest were incorrectly shown as outdated.
pep508 normalizes version specifiers (e.g., ">=1.7,<2.0" -> ">=1.7, <2.0"). Use original string length for position calculation to ensure inlay hints are placed correctly regardless of normalization. - Fix version_range end position in PyPI parser - Add tests for version range position with/without space - Remove debug logging and simplify code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LockFileCachewith staleness detection for 30x performance improvementtokio::fs) for non-blocking file operationsPerformance
New Files
deps-core/src/lockfile.rs- Core abstractions (ResolvedPackages,LockFileProvider,LockFileCache)deps-cargo/src/lockfile.rs-CargoLockParserfor Cargo.lock v4 formatChanges
EcosystemHandlertrait withlockfile_provider()methodlockfile_cachetoServerStatefor cross-document cachingdocument_lifecycle.rsto load lock file versions on document openTest plan