1use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
8#[schemars(description = "Parameters for getting hover information at a position in a file.")]
9pub struct HoverParams {
10 #[schemars(description = "Absolute path to the file.")]
12 pub file_path: String,
13 #[schemars(description = "Line number (1-based).")]
15 pub line: u32,
16 #[schemars(description = "Character/column number (1-based).")]
18 pub character: u32,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
23#[schemars(description = "Parameters for getting the definition location of a symbol.")]
24pub struct DefinitionParams {
25 #[schemars(description = "Absolute path to the file.")]
27 pub file_path: String,
28 #[schemars(description = "Line number (1-based).")]
30 pub line: u32,
31 #[schemars(description = "Character/column number (1-based).")]
33 pub character: u32,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
38#[schemars(description = "Parameters for finding all references to a symbol.")]
39pub struct ReferencesParams {
40 #[schemars(description = "Absolute path to the file.")]
42 pub file_path: String,
43 #[schemars(description = "Line number (1-based).")]
45 pub line: u32,
46 #[schemars(description = "Character/column number (1-based).")]
48 pub character: u32,
49 #[schemars(description = "Whether to include the declaration in the results.")]
51 #[serde(default)]
52 pub include_declaration: bool,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
57#[schemars(description = "Parameters for getting diagnostics (errors, warnings) for a file.")]
58pub struct DiagnosticsParams {
59 #[schemars(description = "Absolute path to the file.")]
61 pub file_path: String,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
66#[schemars(description = "Parameters for renaming a symbol across the workspace.")]
67pub struct RenameParams {
68 #[schemars(description = "Absolute path to the file.")]
70 pub file_path: String,
71 #[schemars(description = "Line number (1-based).")]
73 pub line: u32,
74 #[schemars(description = "Character/column number (1-based).")]
76 pub character: u32,
77 #[schemars(description = "New name for the symbol.")]
79 pub new_name: String,
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
84#[schemars(description = "Parameters for getting code completion suggestions.")]
85pub struct CompletionsParams {
86 #[schemars(description = "Absolute path to the file.")]
88 pub file_path: String,
89 #[schemars(description = "Line number (1-based).")]
91 pub line: u32,
92 #[schemars(description = "Character/column number (1-based).")]
94 pub character: u32,
95 #[schemars(description = "Optional trigger character (e.g., '.', ':', '->').")]
97 pub trigger: Option<String>,
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
102#[schemars(description = "Parameters for getting all symbols in a document.")]
103pub struct DocumentSymbolsParams {
104 #[schemars(description = "Absolute path to the file.")]
106 pub file_path: String,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
111#[schemars(description = "Parameters for formatting a document.")]
112pub struct FormatDocumentParams {
113 #[schemars(description = "Absolute path to the file.")]
115 pub file_path: String,
116 #[schemars(description = "Tab size for formatting (default: 4).")]
118 #[serde(default = "default_tab_size")]
119 pub tab_size: u32,
120 #[schemars(description = "Whether to use spaces instead of tabs (default: true).")]
122 #[serde(default = "default_insert_spaces")]
123 pub insert_spaces: bool,
124}
125
126const fn default_tab_size() -> u32 {
127 4
128}
129
130const fn default_insert_spaces() -> bool {
131 true
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
136#[schemars(description = "Parameters for searching symbols across the workspace.")]
137pub struct WorkspaceSymbolParams {
138 #[schemars(description = "Search query for symbol names (supports partial matching).")]
140 pub query: String,
141 #[schemars(description = "Optional filter by symbol kind (function, class, variable, etc.).")]
143 #[serde(skip_serializing_if = "Option::is_none")]
144 pub kind_filter: Option<String>,
145 #[schemars(description = "Maximum results to return (default: 100).")]
147 #[serde(default = "default_max_results")]
148 pub limit: u32,
149}
150
151const fn default_max_results() -> u32 {
152 100
153}
154
155#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
157#[schemars(
158 description = "Parameters for getting available code actions (quick fixes, refactorings) for a range."
159)]
160pub struct CodeActionsParams {
161 #[schemars(description = "Absolute path to the file.")]
163 pub file_path: String,
164 #[schemars(description = "Start line (1-based).")]
166 pub start_line: u32,
167 #[schemars(description = "Start character (1-based).")]
169 pub start_character: u32,
170 #[schemars(description = "End line (1-based).")]
172 pub end_line: u32,
173 #[schemars(description = "End character (1-based).")]
175 pub end_character: u32,
176 #[schemars(description = "Optional filter by action kind (quickfix, refactor, source, etc.).")]
178 #[serde(skip_serializing_if = "Option::is_none")]
179 pub kind_filter: Option<String>,
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
184#[schemars(description = "Parameters for preparing call hierarchy at a position.")]
185pub struct CallHierarchyPrepareParams {
186 #[schemars(description = "Absolute path to the file.")]
188 pub file_path: String,
189 #[schemars(description = "Line number (1-based).")]
191 pub line: u32,
192 #[schemars(description = "Character/column number (1-based).")]
194 pub character: u32,
195}
196
197#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
199#[schemars(
200 description = "Parameters for getting incoming or outgoing calls for a call hierarchy item."
201)]
202pub struct CallHierarchyCallsParams {
203 #[schemars(description = "The call hierarchy item to get calls for (from prepare response).")]
205 pub item: serde_json::Value,
206}
207
208#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
210#[schemars(
211 description = "Parameters for getting cached diagnostics from LSP server notifications."
212)]
213pub struct CachedDiagnosticsParams {
214 #[schemars(description = "Absolute path to the file.")]
216 pub file_path: String,
217}
218
219#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
221#[schemars(description = "Parameters for getting recent LSP server log messages.")]
222pub struct ServerLogsParams {
223 #[schemars(description = "Maximum number of log entries to return (default: 50).")]
225 #[serde(default = "default_log_limit")]
226 pub limit: usize,
227 #[schemars(description = "Minimum log level to include: error, warning, info, debug.")]
229 #[serde(skip_serializing_if = "Option::is_none")]
230 pub min_level: Option<String>,
231}
232
233const fn default_log_limit() -> usize {
234 50
235}
236
237#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
239#[schemars(
240 description = "Parameters for getting recent LSP server messages (showMessage notifications)."
241)]
242pub struct ServerMessagesParams {
243 #[schemars(description = "Maximum number of messages to return (default: 20).")]
245 #[serde(default = "default_message_limit")]
246 pub limit: usize,
247}
248
249const fn default_message_limit() -> usize {
250 20
251}