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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright (c) 2026 Kirky.X. All rights reserved.
// SPDX-License-Identifier: MIT
//! LSP semantic type resolution.
//!
//! Integrates external Language Server Protocol servers (e.g. `rust-analyzer`
//! for Rust) to provide IDE-grade semantic queries — Go-to-Definition,
//! Type-Definition, Hover — over a JSON-RPC subprocess channel. The resolved
//! semantic types are mapped back onto CodeNexus [`crate::model::NodeLabel`]
//! variants via [`map_lsp_symbol_kind`].
//!
//! # Scope (v0.2.0)
//!
//! Seven languages are wired up: Rust (`RustAnalyzerClient`), Python
//! (`PyrightClient`), C/C++ (`ClangdClient`), Go (`GoplsClient`),
//! TypeScript/JavaScript (`TypeScriptLanguageClient`), Fortran
//! (`FortlsClient`), and Java (`JdtlsClient`). `textDocument/references`
//! is intentionally out of scope — the existing `trace --type calls`
//! traversal already covers callers.
//!
//! # Feature gating
//!
//! The entire module compiles only when the `lsp` cargo feature is enabled:
//!
//! ```toml
//! lsp = ["dep:lsp-types", "dep:lsp-server"]
//! ```
pub
pub use ClangdClient;
pub use RustAnalyzerClient;
pub use extract_hover_text;
pub use FortlsClient;
pub use GoplsClient;
pub use JdtlsClient;
pub use PyrightClient;
pub use map_lsp_symbol_kind;
pub use TypeScriptLanguageClient;
use Path;
/// LSP integration errors (Rule 12: failures must be explicit).
///
/// Every variant carries enough context to diagnose the failure without
/// needing to grep server logs.
/// JSON-RPC round-trip timeout (specmark spec.md §Constraints: 5 seconds).
///
/// Exposed as a `pub const` so tests and downstream callers can reference the
/// exact threshold rather than hard-coding a magic number (Rule 5:
/// deterministic thresholds must be explicit).
pub const REQUEST_TIMEOUT_MS: u64 = 5_000;
/// Uniform abstraction over LSP server backends.
///
/// `RustAnalyzerClient` is the v0.2.0 reference implementation; the trait
/// exists so the indexing pipeline (R-lsp-004) and CLI commands can depend
/// on a stable shape that v0.3.0+ can extend with `GoplsClient`,
/// `PyrightClient`, etc. without touching call sites.
///
/// # Line/column convention
///
/// All `line`/`col` parameters are **0-based** to match the LSP spec
/// (`Position.line` and `Position.character` are zero-indexed). Callers
/// converting from 1-based editor coordinates must subtract one before
/// invoking these methods.