Commit eaaa13a
authored
feat(go): Add Go ecosystem support - Complete (Phases 1-4) (#40)
* feat(go): implement Phase 1 - core types and parser
Add Go ecosystem support for deps-lsp. This phase implements:
Core Types (types.rs):
- GoDependency with module_path, version, directive, indirect
- GoDirective enum (Require, Replace, Exclude, Retract)
- GoVersion with pseudo-version and retracted tracking
- GoMetadata with pkg.go.dev documentation URL
go.mod Parser (parser.rs):
- LineOffsetTable for O(log n) position lookups
- UTF-16 character position calculation for LSP
- Support for require, replace, exclude directives
- Multi-line block parsing with state machine
- Inline comment handling (including URL-aware // stripping)
- Indirect dependency marker extraction
Version Utilities (version.rs):
- Module path escaping (uppercase → !lowercase)
- Pseudo-version detection and base version extraction
- Semantic version comparison with +incompatible handling
Error Handling (error.rs):
- 10 error variants with thiserror integration
- Bidirectional deps_core::DepsError conversion
- Helper factory methods for common errors
Tests: 41 unit tests, all passing
Coverage: ~85% across all modules
Snapshots: insta snapshot tests for parser output
* feat(go): implement Phase 2 - registry client
Add GoRegistry for proxy.golang.org integration:
- HTTP client with HttpCache for ETag/Last-Modified caching
- get_versions() - fetch all available versions for a module
- get_version_info() - get metadata for specific version
- get_latest() - fetch latest stable version
- get_go_mod() - retrieve go.mod content for a version
- Module path escaping (uppercase to !lowercase)
- deps_core::Registry trait implementation
Security hardening:
- Module path length validation (max 500 chars)
- Version string validation (no path traversal, valid chars)
- Input sanitization before URL construction
Performance optimizations:
- Zero-copy parsing with std::str::from_utf8
- Synchronous parse functions (no async overhead)
- Efficient module path escaping with encode_utf8()
62 tests passing with comprehensive coverage.
* feat(go): implement Phase 3 - LSP features integration
Add full LSP support for Go modules (go.mod files):
GoFormatter (formatter.rs):
- Unquoted version format for go.mod
- Package URLs to pkg.go.dev
- Version matching with boundary checking
- URL encoding for special characters
GoEcosystem (ecosystem.rs):
- Ecosystem trait implementation for LSP handlers
- Inlay hints, hover, code actions, diagnostics
- Version completion from proxy.golang.org
- Retracted version filtering
LSP Integration (state.rs):
- Go variant in Ecosystem enum with go.mod detection
- UnifiedDependency::Go and UnifiedVersion::Go
- GoEcosystem registration in ServerState
Performance optimizations:
- Single-pass version completion (no double iteration)
- Parser Vec pre-allocation
690 tests passing.
* test(go): implement Phase 4 - comprehensive test coverage
Add 25 new tests to address critical coverage gaps:
Ecosystem Tests (ecosystem.rs):
- Inlay hint generation (up-to-date, needs update, no cache)
- Hover generation for module paths
- Code action generation
- Completion context detection (package name, version)
- Parse manifest error handling
State Integration Tests (state.rs):
- Ecosystem detection from filenames (go.mod)
- Ecosystem detection from URIs
- UnifiedDependency::Go variant methods
- UnifiedVersion::Go variant methods
- DocumentState Go ecosystem support
Coverage improvements:
- ecosystem.rs: 73% -> 83%
- state.rs: Go variants fully covered
713 tests passing (9 ignored for network access).
* docs: update READMEs and CI for Go ecosystem support
README updates:
- Add Go Modules to supported ecosystems table
- Add go.sum to lock file support list
- Add deps-go to project structure
- Create deps-go README with usage examples
- Update deps-core to mention deps-go
CI updates:
- Add deps-go to per-crate coverage generation
- Add codecov upload step for deps-go coverage
Other:
- Add **/snapshots/ to .gitignore
* feat(go): add go.sum lockfile parser
Implement LockFileProvider for Go ecosystem:
- Parse go.sum format (module_path version h1:hash)
- Skip /go.mod entries (module file checksums)
- Validate h1: prefix for checksums
- First occurrence wins (Go's MVS algorithm)
- Async file operations with staleness detection
- Workspace search (up to 5 levels)
Integration:
- GoEcosystem::lockfile_provider() returns GoSumParser
- Resolved versions now available for inlay hints
22 lockfile tests, 97.66% coverage.
* refactor(go): replace insta snapshot with assertions
- Rewrite test_parse_complex_go_mod to use regular assertions
- Remove insta dev-dependency from deps-go1 parent 69485a6 commit eaaa13a
File tree
20 files changed
+3854
-4
lines changed- .github/workflows
- crates
- deps-core
- deps-go
- src
- deps-lsp
- src/document
20 files changed
+3854
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
264 | 272 | | |
265 | 273 | | |
266 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| 192 | + | |
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
0 commit comments