rust_analyzer/lsp/
ext.rs

1//! rust-analyzer extensions to the LSP.
2
3// Note when adding new resolve payloads, add a #[serde(default)] on boolean fields as some clients
4// might strip `false` values from the JSON payload due to their reserialization logic turning false
5// into null which will then cause them to be omitted in the resolve request. See https://github.com/rust-lang/rust-analyzer/issues/18767
6
7#![allow(clippy::disallowed_types)]
8
9use std::ops;
10
11use lsp_types::Url;
12use lsp_types::request::Request;
13use lsp_types::{
14    CodeActionKind, DocumentOnTypeFormattingParams, PartialResultParams, Position, Range,
15    TextDocumentIdentifier, WorkDoneProgressParams, notification::Notification,
16};
17use paths::Utf8PathBuf;
18use rustc_hash::FxHashMap;
19use serde::{Deserialize, Serialize};
20
21pub enum InternalTestingFetchConfig {}
22
23#[derive(Deserialize, Serialize, Debug)]
24pub enum InternalTestingFetchConfigOption {
25    AssistEmitMustUse,
26    CheckWorkspace,
27}
28
29#[derive(Deserialize, Serialize, Debug, PartialEq, Eq)]
30pub enum InternalTestingFetchConfigResponse {
31    AssistEmitMustUse(bool),
32    CheckWorkspace(bool),
33}
34
35impl Request for InternalTestingFetchConfig {
36    type Params = InternalTestingFetchConfigParams;
37    // Option is solely to circumvent Default bound.
38    type Result = Option<InternalTestingFetchConfigResponse>;
39    const METHOD: &'static str = "rust-analyzer-internal/internalTestingFetchConfig";
40}
41
42#[derive(Deserialize, Serialize, Debug)]
43#[serde(rename_all = "camelCase")]
44pub struct InternalTestingFetchConfigParams {
45    pub text_document: Option<TextDocumentIdentifier>,
46    pub config: InternalTestingFetchConfigOption,
47}
48pub enum AnalyzerStatus {}
49
50impl Request for AnalyzerStatus {
51    type Params = AnalyzerStatusParams;
52    type Result = String;
53    const METHOD: &'static str = "rust-analyzer/analyzerStatus";
54}
55
56#[derive(Deserialize, Serialize, Debug)]
57#[serde(rename_all = "camelCase")]
58pub struct AnalyzerStatusParams {
59    pub text_document: Option<TextDocumentIdentifier>,
60}
61
62#[derive(Deserialize, Serialize, Debug)]
63#[serde(rename_all = "camelCase")]
64pub struct CrateInfoResult {
65    pub name: Option<String>,
66    pub version: Option<String>,
67    pub path: Url,
68}
69pub enum FetchDependencyList {}
70
71impl Request for FetchDependencyList {
72    type Params = FetchDependencyListParams;
73    type Result = FetchDependencyListResult;
74    const METHOD: &'static str = "rust-analyzer/fetchDependencyList";
75}
76
77#[derive(Deserialize, Serialize, Debug)]
78#[serde(rename_all = "camelCase")]
79pub struct FetchDependencyListParams {}
80
81#[derive(Deserialize, Serialize, Debug, Default)]
82#[serde(rename_all = "camelCase")]
83pub struct FetchDependencyListResult {
84    pub crates: Vec<CrateInfoResult>,
85}
86
87pub enum MemoryUsage {}
88
89impl Request for MemoryUsage {
90    type Params = ();
91    type Result = String;
92    const METHOD: &'static str = "rust-analyzer/memoryUsage";
93}
94
95pub enum ReloadWorkspace {}
96
97impl Request for ReloadWorkspace {
98    type Params = ();
99    type Result = ();
100    const METHOD: &'static str = "rust-analyzer/reloadWorkspace";
101}
102
103pub enum RebuildProcMacros {}
104
105impl Request for RebuildProcMacros {
106    type Params = ();
107    type Result = ();
108    const METHOD: &'static str = "rust-analyzer/rebuildProcMacros";
109}
110
111pub enum ViewSyntaxTree {}
112
113impl Request for ViewSyntaxTree {
114    type Params = ViewSyntaxTreeParams;
115    type Result = String;
116    const METHOD: &'static str = "rust-analyzer/viewSyntaxTree";
117}
118
119#[derive(Deserialize, Serialize, Debug)]
120#[serde(rename_all = "camelCase")]
121pub struct ViewSyntaxTreeParams {
122    pub text_document: TextDocumentIdentifier,
123}
124
125pub enum ViewHir {}
126
127impl Request for ViewHir {
128    type Params = lsp_types::TextDocumentPositionParams;
129    type Result = String;
130    const METHOD: &'static str = "rust-analyzer/viewHir";
131}
132
133pub enum ViewMir {}
134
135impl Request for ViewMir {
136    type Params = lsp_types::TextDocumentPositionParams;
137    type Result = String;
138    const METHOD: &'static str = "rust-analyzer/viewMir";
139}
140
141pub enum InterpretFunction {}
142
143impl Request for InterpretFunction {
144    type Params = lsp_types::TextDocumentPositionParams;
145    type Result = String;
146    const METHOD: &'static str = "rust-analyzer/interpretFunction";
147}
148
149pub enum ViewFileText {}
150
151impl Request for ViewFileText {
152    type Params = lsp_types::TextDocumentIdentifier;
153    type Result = String;
154    const METHOD: &'static str = "rust-analyzer/viewFileText";
155}
156
157#[derive(Deserialize, Serialize, Debug)]
158#[serde(rename_all = "camelCase")]
159pub struct ViewCrateGraphParams {
160    /// Include *all* crates, not just crates in the workspace.
161    pub full: bool,
162}
163
164pub enum ViewCrateGraph {}
165
166impl Request for ViewCrateGraph {
167    type Params = ViewCrateGraphParams;
168    type Result = String;
169    const METHOD: &'static str = "rust-analyzer/viewCrateGraph";
170}
171
172#[derive(Deserialize, Serialize, Debug)]
173#[serde(rename_all = "camelCase")]
174pub struct ViewItemTreeParams {
175    pub text_document: TextDocumentIdentifier,
176}
177
178pub enum ViewItemTree {}
179
180impl Request for ViewItemTree {
181    type Params = ViewItemTreeParams;
182    type Result = String;
183    const METHOD: &'static str = "rust-analyzer/viewItemTree";
184}
185
186#[derive(Deserialize, Serialize, Debug)]
187#[serde(rename_all = "camelCase")]
188pub struct DiscoverTestParams {
189    pub test_id: Option<String>,
190}
191
192#[derive(Deserialize, Serialize, Debug)]
193#[serde(rename_all = "camelCase")]
194pub enum TestItemKind {
195    Package,
196    Module,
197    Test,
198}
199
200#[derive(Deserialize, Serialize, Debug)]
201#[serde(rename_all = "camelCase")]
202pub struct TestItem {
203    pub id: String,
204    pub label: String,
205    pub kind: TestItemKind,
206    pub can_resolve_children: bool,
207    pub parent: Option<String>,
208    pub text_document: Option<TextDocumentIdentifier>,
209    pub range: Option<Range>,
210    pub runnable: Option<Runnable>,
211}
212
213#[derive(Deserialize, Serialize, Debug, Default)]
214#[serde(rename_all = "camelCase")]
215pub struct DiscoverTestResults {
216    pub tests: Vec<TestItem>,
217    pub scope: Option<Vec<String>>,
218    pub scope_file: Option<Vec<TextDocumentIdentifier>>,
219}
220
221pub enum DiscoverTest {}
222
223impl Request for DiscoverTest {
224    type Params = DiscoverTestParams;
225    type Result = DiscoverTestResults;
226    const METHOD: &'static str = "experimental/discoverTest";
227}
228
229pub enum DiscoveredTests {}
230
231impl Notification for DiscoveredTests {
232    type Params = DiscoverTestResults;
233    const METHOD: &'static str = "experimental/discoveredTests";
234}
235
236#[derive(Deserialize, Serialize, Debug)]
237#[serde(rename_all = "camelCase")]
238pub struct RunTestParams {
239    pub include: Option<Vec<String>>,
240    pub exclude: Option<Vec<String>>,
241}
242
243pub enum RunTest {}
244
245impl Request for RunTest {
246    type Params = RunTestParams;
247    type Result = ();
248    const METHOD: &'static str = "experimental/runTest";
249}
250
251pub enum EndRunTest {}
252
253impl Notification for EndRunTest {
254    type Params = ();
255    const METHOD: &'static str = "experimental/endRunTest";
256}
257
258pub enum AppendOutputToRunTest {}
259
260impl Notification for AppendOutputToRunTest {
261    type Params = String;
262    const METHOD: &'static str = "experimental/appendOutputToRunTest";
263}
264
265pub enum AbortRunTest {}
266
267impl Notification for AbortRunTest {
268    type Params = ();
269    const METHOD: &'static str = "experimental/abortRunTest";
270}
271
272#[derive(Deserialize, Serialize, Debug)]
273#[serde(rename_all = "camelCase", tag = "tag")]
274pub enum TestState {
275    Passed,
276    Failed { message: String },
277    Skipped,
278    Started,
279    Enqueued,
280}
281
282#[derive(Deserialize, Serialize, Debug)]
283#[serde(rename_all = "camelCase")]
284pub struct ChangeTestStateParams {
285    pub test_id: String,
286    pub state: TestState,
287}
288
289pub enum ChangeTestState {}
290
291impl Notification for ChangeTestState {
292    type Params = ChangeTestStateParams;
293    const METHOD: &'static str = "experimental/changeTestState";
294}
295
296pub enum ExpandMacro {}
297
298impl Request for ExpandMacro {
299    type Params = ExpandMacroParams;
300    type Result = Option<ExpandedMacro>;
301    const METHOD: &'static str = "rust-analyzer/expandMacro";
302}
303
304#[derive(Deserialize, Serialize, Debug)]
305#[serde(rename_all = "camelCase")]
306pub struct ExpandMacroParams {
307    pub text_document: TextDocumentIdentifier,
308    pub position: Position,
309}
310
311#[derive(Deserialize, Serialize, Debug)]
312#[serde(rename_all = "camelCase")]
313pub struct ExpandedMacro {
314    pub name: String,
315    pub expansion: String,
316}
317
318pub enum ViewRecursiveMemoryLayout {}
319
320impl Request for ViewRecursiveMemoryLayout {
321    type Params = lsp_types::TextDocumentPositionParams;
322    type Result = Option<RecursiveMemoryLayout>;
323    const METHOD: &'static str = "rust-analyzer/viewRecursiveMemoryLayout";
324}
325
326#[derive(Deserialize, Serialize, Debug)]
327#[serde(rename_all = "camelCase")]
328pub struct RecursiveMemoryLayout {
329    pub nodes: Vec<MemoryLayoutNode>,
330}
331
332#[derive(Deserialize, Serialize, Debug)]
333#[serde(rename_all = "camelCase")]
334pub struct MemoryLayoutNode {
335    pub item_name: String,
336    pub typename: String,
337    pub size: u64,
338    pub offset: u64,
339    pub alignment: u64,
340    pub parent_idx: i64,
341    pub children_start: i64,
342    pub children_len: u64,
343}
344
345pub enum CancelFlycheck {}
346
347impl Notification for CancelFlycheck {
348    type Params = ();
349    const METHOD: &'static str = "rust-analyzer/cancelFlycheck";
350}
351
352pub enum RunFlycheck {}
353
354impl Notification for RunFlycheck {
355    type Params = RunFlycheckParams;
356    const METHOD: &'static str = "rust-analyzer/runFlycheck";
357}
358
359pub enum ClearFlycheck {}
360
361impl Notification for ClearFlycheck {
362    type Params = ();
363    const METHOD: &'static str = "rust-analyzer/clearFlycheck";
364}
365
366pub enum OpenServerLogs {}
367
368impl Notification for OpenServerLogs {
369    type Params = ();
370    const METHOD: &'static str = "rust-analyzer/openServerLogs";
371}
372
373#[derive(Deserialize, Serialize, Debug)]
374#[serde(rename_all = "camelCase")]
375pub struct RunFlycheckParams {
376    pub text_document: Option<TextDocumentIdentifier>,
377}
378
379pub enum MatchingBrace {}
380
381impl Request for MatchingBrace {
382    type Params = MatchingBraceParams;
383    type Result = Vec<Position>;
384    const METHOD: &'static str = "experimental/matchingBrace";
385}
386
387#[derive(Deserialize, Serialize, Debug)]
388#[serde(rename_all = "camelCase")]
389pub struct MatchingBraceParams {
390    pub text_document: TextDocumentIdentifier,
391    pub positions: Vec<Position>,
392}
393
394pub enum ParentModule {}
395
396impl Request for ParentModule {
397    type Params = lsp_types::TextDocumentPositionParams;
398    type Result = Option<lsp_types::GotoDefinitionResponse>;
399    const METHOD: &'static str = "experimental/parentModule";
400}
401
402pub enum ChildModules {}
403
404impl Request for ChildModules {
405    type Params = lsp_types::TextDocumentPositionParams;
406    type Result = Option<lsp_types::GotoDefinitionResponse>;
407    const METHOD: &'static str = "experimental/childModules";
408}
409
410pub enum JoinLines {}
411
412impl Request for JoinLines {
413    type Params = JoinLinesParams;
414    type Result = Vec<lsp_types::TextEdit>;
415    const METHOD: &'static str = "experimental/joinLines";
416}
417
418#[derive(Deserialize, Serialize, Debug)]
419#[serde(rename_all = "camelCase")]
420pub struct JoinLinesParams {
421    pub text_document: TextDocumentIdentifier,
422    pub ranges: Vec<Range>,
423}
424
425pub enum OnEnter {}
426
427impl Request for OnEnter {
428    type Params = lsp_types::TextDocumentPositionParams;
429    type Result = Option<Vec<SnippetTextEdit>>;
430    const METHOD: &'static str = "experimental/onEnter";
431}
432
433pub enum Runnables {}
434
435impl Request for Runnables {
436    type Params = RunnablesParams;
437    type Result = Vec<Runnable>;
438    const METHOD: &'static str = "experimental/runnables";
439}
440
441#[derive(Serialize, Deserialize, Debug, Clone)]
442#[serde(rename_all = "camelCase")]
443pub struct RunnablesParams {
444    pub text_document: TextDocumentIdentifier,
445    pub position: Option<Position>,
446}
447
448#[derive(Deserialize, Serialize, Debug, Clone)]
449#[serde(rename_all = "camelCase")]
450pub struct Runnable {
451    pub label: String,
452    #[serde(skip_serializing_if = "Option::is_none")]
453    pub location: Option<lsp_types::LocationLink>,
454    pub kind: RunnableKind,
455    pub args: RunnableArgs,
456}
457
458#[derive(Deserialize, Serialize, Debug, Clone)]
459#[serde(rename_all = "camelCase")]
460#[serde(untagged)]
461pub enum RunnableArgs {
462    Cargo(CargoRunnableArgs),
463    Shell(ShellRunnableArgs),
464}
465
466#[derive(Serialize, Deserialize, Debug, Clone)]
467#[serde(rename_all = "lowercase")]
468pub enum RunnableKind {
469    Cargo,
470    Shell,
471}
472
473#[derive(Deserialize, Serialize, Debug, Clone)]
474#[serde(rename_all = "camelCase")]
475pub struct CargoRunnableArgs {
476    #[serde(skip_serializing_if = "FxHashMap::is_empty")]
477    pub environment: FxHashMap<String, String>,
478    pub cwd: Utf8PathBuf,
479    /// Command to be executed instead of cargo
480    pub override_cargo: Option<String>,
481    #[serde(skip_serializing_if = "Option::is_none")]
482    pub workspace_root: Option<Utf8PathBuf>,
483    // command, --package and --lib stuff
484    pub cargo_args: Vec<String>,
485    // stuff after --
486    pub executable_args: Vec<String>,
487}
488
489#[derive(Deserialize, Serialize, Debug, Clone)]
490#[serde(rename_all = "camelCase")]
491pub struct ShellRunnableArgs {
492    #[serde(skip_serializing_if = "FxHashMap::is_empty")]
493    pub environment: FxHashMap<String, String>,
494    pub cwd: Utf8PathBuf,
495    pub program: String,
496    pub args: Vec<String>,
497}
498
499pub enum RelatedTests {}
500
501impl Request for RelatedTests {
502    type Params = lsp_types::TextDocumentPositionParams;
503    type Result = Vec<TestInfo>;
504    const METHOD: &'static str = "rust-analyzer/relatedTests";
505}
506
507#[derive(Debug, Deserialize, Serialize)]
508pub struct TestInfo {
509    pub runnable: Runnable,
510}
511
512pub enum Ssr {}
513
514impl Request for Ssr {
515    type Params = SsrParams;
516    type Result = lsp_types::WorkspaceEdit;
517    const METHOD: &'static str = "experimental/ssr";
518}
519
520#[derive(Debug, Deserialize, Serialize)]
521#[serde(rename_all = "camelCase")]
522pub struct SsrParams {
523    pub query: String,
524    pub parse_only: bool,
525
526    /// File position where SSR was invoked. Paths in `query` will be resolved relative to this
527    /// position.
528    #[serde(flatten)]
529    pub position: lsp_types::TextDocumentPositionParams,
530
531    /// Current selections. Search/replace will be restricted to these if non-empty.
532    pub selections: Vec<lsp_types::Range>,
533}
534
535pub enum ServerStatusNotification {}
536
537impl Notification for ServerStatusNotification {
538    type Params = ServerStatusParams;
539    const METHOD: &'static str = "experimental/serverStatus";
540}
541
542#[derive(Deserialize, Serialize, PartialEq, Eq, Clone)]
543#[serde(rename_all = "camelCase")]
544pub struct ServerStatusParams {
545    pub health: Health,
546    pub quiescent: bool,
547    pub message: Option<String>,
548}
549
550#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
551#[serde(rename_all = "camelCase")]
552pub enum Health {
553    Ok,
554    Warning,
555    Error,
556}
557
558impl ops::BitOrAssign for Health {
559    fn bitor_assign(&mut self, rhs: Self) {
560        *self = match (*self, rhs) {
561            (Health::Error, _) | (_, Health::Error) => Health::Error,
562            (Health::Warning, _) | (_, Health::Warning) => Health::Warning,
563            _ => Health::Ok,
564        }
565    }
566}
567
568pub enum CodeActionRequest {}
569
570impl Request for CodeActionRequest {
571    type Params = lsp_types::CodeActionParams;
572    type Result = Option<Vec<CodeAction>>;
573    const METHOD: &'static str = "textDocument/codeAction";
574}
575
576pub enum CodeActionResolveRequest {}
577
578impl Request for CodeActionResolveRequest {
579    type Params = CodeAction;
580    type Result = CodeAction;
581    const METHOD: &'static str = "codeAction/resolve";
582}
583
584#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
585#[serde(rename_all = "camelCase")]
586pub struct CodeAction {
587    pub title: String,
588    #[serde(skip_serializing_if = "Option::is_none")]
589    pub group: Option<String>,
590    #[serde(skip_serializing_if = "Option::is_none")]
591    pub kind: Option<CodeActionKind>,
592    #[serde(skip_serializing_if = "Option::is_none")]
593    pub command: Option<lsp_types::Command>,
594    #[serde(skip_serializing_if = "Option::is_none")]
595    pub edit: Option<SnippetWorkspaceEdit>,
596    #[serde(skip_serializing_if = "Option::is_none")]
597    pub is_preferred: Option<bool>,
598
599    #[serde(skip_serializing_if = "Option::is_none")]
600    pub data: Option<CodeActionData>,
601}
602
603#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
604#[serde(rename_all = "camelCase")]
605pub struct CodeActionData {
606    pub code_action_params: lsp_types::CodeActionParams,
607    pub id: String,
608    pub version: Option<i32>,
609}
610
611#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
612#[serde(rename_all = "camelCase")]
613pub struct SnippetWorkspaceEdit {
614    #[serde(skip_serializing_if = "Option::is_none")]
615    pub changes: Option<FxHashMap<lsp_types::Url, Vec<lsp_types::TextEdit>>>,
616    #[serde(skip_serializing_if = "Option::is_none")]
617    pub document_changes: Option<Vec<SnippetDocumentChangeOperation>>,
618    #[serde(skip_serializing_if = "Option::is_none")]
619    pub change_annotations: Option<
620        std::collections::HashMap<
621            lsp_types::ChangeAnnotationIdentifier,
622            lsp_types::ChangeAnnotation,
623        >,
624    >,
625}
626
627#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
628#[serde(untagged, rename_all = "lowercase")]
629pub enum SnippetDocumentChangeOperation {
630    Op(lsp_types::ResourceOp),
631    Edit(SnippetTextDocumentEdit),
632}
633
634#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
635#[serde(rename_all = "camelCase")]
636pub struct SnippetTextDocumentEdit {
637    pub text_document: lsp_types::OptionalVersionedTextDocumentIdentifier,
638    pub edits: Vec<SnippetTextEdit>,
639}
640
641#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
642#[serde(rename_all = "camelCase")]
643pub struct SnippetTextEdit {
644    pub range: Range,
645    pub new_text: String,
646    #[serde(skip_serializing_if = "Option::is_none")]
647    pub insert_text_format: Option<lsp_types::InsertTextFormat>,
648    /// The annotation id if this is an annotated
649    #[serde(skip_serializing_if = "Option::is_none")]
650    pub annotation_id: Option<lsp_types::ChangeAnnotationIdentifier>,
651}
652
653pub enum HoverRequest {}
654
655impl Request for HoverRequest {
656    type Params = HoverParams;
657    type Result = Option<Hover>;
658    const METHOD: &'static str = lsp_types::request::HoverRequest::METHOD;
659}
660
661#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
662#[serde(rename_all = "camelCase")]
663pub struct HoverParams {
664    pub text_document: TextDocumentIdentifier,
665    pub position: PositionOrRange,
666
667    #[serde(flatten)]
668    pub work_done_progress_params: WorkDoneProgressParams,
669}
670
671#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
672#[serde(untagged)]
673pub enum PositionOrRange {
674    Position(lsp_types::Position),
675    Range(lsp_types::Range),
676}
677
678#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
679pub struct Hover {
680    #[serde(flatten)]
681    pub hover: lsp_types::Hover,
682    #[serde(skip_serializing_if = "Vec::is_empty")]
683    pub actions: Vec<CommandLinkGroup>,
684}
685
686#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
687pub struct CommandLinkGroup {
688    #[serde(skip_serializing_if = "Option::is_none")]
689    pub title: Option<String>,
690    pub commands: Vec<CommandLink>,
691}
692
693// LSP v3.15 Command does not have a `tooltip` field, vscode supports one.
694#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
695pub struct CommandLink {
696    #[serde(flatten)]
697    pub command: lsp_types::Command,
698    #[serde(skip_serializing_if = "Option::is_none")]
699    pub tooltip: Option<String>,
700}
701
702pub enum ExternalDocs {}
703
704impl Request for ExternalDocs {
705    type Params = lsp_types::TextDocumentPositionParams;
706    type Result = ExternalDocsResponse;
707    const METHOD: &'static str = "experimental/externalDocs";
708}
709
710#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
711#[serde(untagged)]
712pub enum ExternalDocsResponse {
713    Simple(Option<lsp_types::Url>),
714    WithLocal(ExternalDocsPair),
715}
716
717impl Default for ExternalDocsResponse {
718    fn default() -> Self {
719        ExternalDocsResponse::Simple(None)
720    }
721}
722
723#[derive(Debug, Default, PartialEq, Serialize, Deserialize, Clone)]
724#[serde(rename_all = "camelCase")]
725pub struct ExternalDocsPair {
726    pub web: Option<lsp_types::Url>,
727    pub local: Option<lsp_types::Url>,
728}
729
730pub enum OpenCargoToml {}
731
732impl Request for OpenCargoToml {
733    type Params = OpenCargoTomlParams;
734    type Result = Option<lsp_types::GotoDefinitionResponse>;
735    const METHOD: &'static str = "experimental/openCargoToml";
736}
737
738#[derive(Serialize, Deserialize, Debug)]
739#[serde(rename_all = "camelCase")]
740pub struct OpenCargoTomlParams {
741    pub text_document: TextDocumentIdentifier,
742}
743
744/// Information about CodeLens, that is to be resolved.
745#[derive(Debug, Serialize, Deserialize)]
746#[serde(rename_all = "camelCase")]
747pub struct CodeLensResolveData {
748    pub version: i32,
749    pub kind: CodeLensResolveDataKind,
750}
751
752#[derive(Debug, Serialize, Deserialize)]
753#[serde(rename_all = "camelCase")]
754pub enum CodeLensResolveDataKind {
755    Impls(lsp_types::request::GotoImplementationParams),
756    References(lsp_types::TextDocumentPositionParams),
757}
758
759pub enum MoveItem {}
760
761impl Request for MoveItem {
762    type Params = MoveItemParams;
763    type Result = Vec<SnippetTextEdit>;
764    const METHOD: &'static str = "experimental/moveItem";
765}
766
767#[derive(Serialize, Deserialize, Debug)]
768#[serde(rename_all = "camelCase")]
769pub struct MoveItemParams {
770    pub direction: MoveItemDirection,
771    pub text_document: TextDocumentIdentifier,
772    pub range: Range,
773}
774
775#[derive(Serialize, Deserialize, Debug)]
776pub enum MoveItemDirection {
777    Up,
778    Down,
779}
780
781#[derive(Debug)]
782pub enum WorkspaceSymbol {}
783
784impl Request for WorkspaceSymbol {
785    type Params = WorkspaceSymbolParams;
786    type Result = Option<lsp_types::WorkspaceSymbolResponse>;
787    const METHOD: &'static str = "workspace/symbol";
788}
789
790#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
791#[serde(rename_all = "camelCase")]
792pub struct WorkspaceSymbolParams {
793    #[serde(flatten)]
794    pub partial_result_params: PartialResultParams,
795
796    #[serde(flatten)]
797    pub work_done_progress_params: WorkDoneProgressParams,
798
799    /// A non-empty query string
800    pub query: String,
801
802    pub search_scope: Option<WorkspaceSymbolSearchScope>,
803
804    pub search_kind: Option<WorkspaceSymbolSearchKind>,
805}
806
807#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
808#[serde(rename_all = "camelCase")]
809pub enum WorkspaceSymbolSearchScope {
810    Workspace,
811    WorkspaceAndDependencies,
812}
813
814#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
815#[serde(rename_all = "camelCase")]
816pub enum WorkspaceSymbolSearchKind {
817    OnlyTypes,
818    AllSymbols,
819}
820
821/// The document on type formatting request is sent from the client to
822/// the server to format parts of the document during typing.  This is
823/// almost same as lsp_types::request::OnTypeFormatting, but the
824/// result has SnippetTextEdit in it instead of TextEdit.
825#[derive(Debug)]
826pub enum OnTypeFormatting {}
827
828impl Request for OnTypeFormatting {
829    type Params = DocumentOnTypeFormattingParams;
830    type Result = Option<Vec<SnippetTextEdit>>;
831    const METHOD: &'static str = "textDocument/onTypeFormatting";
832}
833
834#[derive(Debug, Serialize, Deserialize)]
835pub struct CompletionResolveData {
836    pub position: lsp_types::TextDocumentPositionParams,
837    #[serde(skip_serializing_if = "Vec::is_empty", default)]
838    pub imports: Vec<CompletionImport>,
839    #[serde(skip_serializing_if = "Option::is_none", default)]
840    pub version: Option<i32>,
841    #[serde(skip_serializing_if = "Option::is_none", default)]
842    pub trigger_character: Option<char>,
843    #[serde(default)]
844    pub for_ref: bool,
845    pub hash: String,
846}
847
848#[derive(Debug, Serialize, Deserialize)]
849pub struct InlayHintResolveData {
850    pub file_id: u32,
851    // This is a string instead of a u64 as javascript can't represent u64 fully
852    pub hash: String,
853    pub resolve_range: lsp_types::Range,
854    #[serde(skip_serializing_if = "Option::is_none", default)]
855    pub version: Option<i32>,
856}
857
858#[derive(Debug, Serialize, Deserialize)]
859pub struct CompletionImport {
860    pub full_import_path: String,
861}
862
863#[derive(Debug, Deserialize, Default)]
864pub struct ClientCommandOptions {
865    pub commands: Vec<String>,
866}