ra_ap_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::request::Request;
12use lsp_types::Url;
13use lsp_types::{
14    notification::Notification, CodeActionKind, DocumentOnTypeFormattingParams,
15    PartialResultParams, Position, Range, TextDocumentIdentifier, WorkDoneProgressParams,
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 JoinLines {}
403
404impl Request for JoinLines {
405    type Params = JoinLinesParams;
406    type Result = Vec<lsp_types::TextEdit>;
407    const METHOD: &'static str = "experimental/joinLines";
408}
409
410#[derive(Deserialize, Serialize, Debug)]
411#[serde(rename_all = "camelCase")]
412pub struct JoinLinesParams {
413    pub text_document: TextDocumentIdentifier,
414    pub ranges: Vec<Range>,
415}
416
417pub enum OnEnter {}
418
419impl Request for OnEnter {
420    type Params = lsp_types::TextDocumentPositionParams;
421    type Result = Option<Vec<SnippetTextEdit>>;
422    const METHOD: &'static str = "experimental/onEnter";
423}
424
425pub enum Runnables {}
426
427impl Request for Runnables {
428    type Params = RunnablesParams;
429    type Result = Vec<Runnable>;
430    const METHOD: &'static str = "experimental/runnables";
431}
432
433#[derive(Serialize, Deserialize, Debug, Clone)]
434#[serde(rename_all = "camelCase")]
435pub struct RunnablesParams {
436    pub text_document: TextDocumentIdentifier,
437    pub position: Option<Position>,
438}
439
440#[derive(Deserialize, Serialize, Debug, Clone)]
441#[serde(rename_all = "camelCase")]
442pub struct Runnable {
443    pub label: String,
444    #[serde(skip_serializing_if = "Option::is_none")]
445    pub location: Option<lsp_types::LocationLink>,
446    pub kind: RunnableKind,
447    pub args: RunnableArgs,
448}
449
450#[derive(Deserialize, Serialize, Debug, Clone)]
451#[serde(rename_all = "camelCase")]
452#[serde(untagged)]
453pub enum RunnableArgs {
454    Cargo(CargoRunnableArgs),
455    Shell(ShellRunnableArgs),
456}
457
458#[derive(Serialize, Deserialize, Debug, Clone)]
459#[serde(rename_all = "lowercase")]
460pub enum RunnableKind {
461    Cargo,
462    Shell,
463}
464
465#[derive(Deserialize, Serialize, Debug, Clone)]
466#[serde(rename_all = "camelCase")]
467pub struct CargoRunnableArgs {
468    #[serde(skip_serializing_if = "FxHashMap::is_empty")]
469    pub environment: FxHashMap<String, String>,
470    pub cwd: Utf8PathBuf,
471    /// Command to be executed instead of cargo
472    pub override_cargo: Option<String>,
473    #[serde(skip_serializing_if = "Option::is_none")]
474    pub workspace_root: Option<Utf8PathBuf>,
475    // command, --package and --lib stuff
476    pub cargo_args: Vec<String>,
477    // stuff after --
478    pub executable_args: Vec<String>,
479}
480
481#[derive(Deserialize, Serialize, Debug, Clone)]
482#[serde(rename_all = "camelCase")]
483pub struct ShellRunnableArgs {
484    #[serde(skip_serializing_if = "FxHashMap::is_empty")]
485    pub environment: FxHashMap<String, String>,
486    pub cwd: Utf8PathBuf,
487    pub program: String,
488    pub args: Vec<String>,
489}
490
491pub enum RelatedTests {}
492
493impl Request for RelatedTests {
494    type Params = lsp_types::TextDocumentPositionParams;
495    type Result = Vec<TestInfo>;
496    const METHOD: &'static str = "rust-analyzer/relatedTests";
497}
498
499#[derive(Debug, Deserialize, Serialize)]
500pub struct TestInfo {
501    pub runnable: Runnable,
502}
503
504pub enum Ssr {}
505
506impl Request for Ssr {
507    type Params = SsrParams;
508    type Result = lsp_types::WorkspaceEdit;
509    const METHOD: &'static str = "experimental/ssr";
510}
511
512#[derive(Debug, Deserialize, Serialize)]
513#[serde(rename_all = "camelCase")]
514pub struct SsrParams {
515    pub query: String,
516    pub parse_only: bool,
517
518    /// File position where SSR was invoked. Paths in `query` will be resolved relative to this
519    /// position.
520    #[serde(flatten)]
521    pub position: lsp_types::TextDocumentPositionParams,
522
523    /// Current selections. Search/replace will be restricted to these if non-empty.
524    pub selections: Vec<lsp_types::Range>,
525}
526
527pub enum ServerStatusNotification {}
528
529impl Notification for ServerStatusNotification {
530    type Params = ServerStatusParams;
531    const METHOD: &'static str = "experimental/serverStatus";
532}
533
534#[derive(Deserialize, Serialize, PartialEq, Eq, Clone)]
535#[serde(rename_all = "camelCase")]
536pub struct ServerStatusParams {
537    pub health: Health,
538    pub quiescent: bool,
539    pub message: Option<String>,
540}
541
542#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
543#[serde(rename_all = "camelCase")]
544pub enum Health {
545    Ok,
546    Warning,
547    Error,
548}
549
550impl ops::BitOrAssign for Health {
551    fn bitor_assign(&mut self, rhs: Self) {
552        *self = match (*self, rhs) {
553            (Health::Error, _) | (_, Health::Error) => Health::Error,
554            (Health::Warning, _) | (_, Health::Warning) => Health::Warning,
555            _ => Health::Ok,
556        }
557    }
558}
559
560pub enum CodeActionRequest {}
561
562impl Request for CodeActionRequest {
563    type Params = lsp_types::CodeActionParams;
564    type Result = Option<Vec<CodeAction>>;
565    const METHOD: &'static str = "textDocument/codeAction";
566}
567
568pub enum CodeActionResolveRequest {}
569
570impl Request for CodeActionResolveRequest {
571    type Params = CodeAction;
572    type Result = CodeAction;
573    const METHOD: &'static str = "codeAction/resolve";
574}
575
576#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
577#[serde(rename_all = "camelCase")]
578pub struct CodeAction {
579    pub title: String,
580    #[serde(skip_serializing_if = "Option::is_none")]
581    pub group: Option<String>,
582    #[serde(skip_serializing_if = "Option::is_none")]
583    pub kind: Option<CodeActionKind>,
584    #[serde(skip_serializing_if = "Option::is_none")]
585    pub command: Option<lsp_types::Command>,
586    #[serde(skip_serializing_if = "Option::is_none")]
587    pub edit: Option<SnippetWorkspaceEdit>,
588    #[serde(skip_serializing_if = "Option::is_none")]
589    pub is_preferred: Option<bool>,
590
591    #[serde(skip_serializing_if = "Option::is_none")]
592    pub data: Option<CodeActionData>,
593}
594
595#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
596#[serde(rename_all = "camelCase")]
597pub struct CodeActionData {
598    pub code_action_params: lsp_types::CodeActionParams,
599    pub id: String,
600    pub version: Option<i32>,
601}
602
603#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
604#[serde(rename_all = "camelCase")]
605pub struct SnippetWorkspaceEdit {
606    #[serde(skip_serializing_if = "Option::is_none")]
607    pub changes: Option<FxHashMap<lsp_types::Url, Vec<lsp_types::TextEdit>>>,
608    #[serde(skip_serializing_if = "Option::is_none")]
609    pub document_changes: Option<Vec<SnippetDocumentChangeOperation>>,
610    #[serde(skip_serializing_if = "Option::is_none")]
611    pub change_annotations: Option<
612        std::collections::HashMap<
613            lsp_types::ChangeAnnotationIdentifier,
614            lsp_types::ChangeAnnotation,
615        >,
616    >,
617}
618
619#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
620#[serde(untagged, rename_all = "lowercase")]
621pub enum SnippetDocumentChangeOperation {
622    Op(lsp_types::ResourceOp),
623    Edit(SnippetTextDocumentEdit),
624}
625
626#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
627#[serde(rename_all = "camelCase")]
628pub struct SnippetTextDocumentEdit {
629    pub text_document: lsp_types::OptionalVersionedTextDocumentIdentifier,
630    pub edits: Vec<SnippetTextEdit>,
631}
632
633#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
634#[serde(rename_all = "camelCase")]
635pub struct SnippetTextEdit {
636    pub range: Range,
637    pub new_text: String,
638    #[serde(skip_serializing_if = "Option::is_none")]
639    pub insert_text_format: Option<lsp_types::InsertTextFormat>,
640    /// The annotation id if this is an annotated
641    #[serde(skip_serializing_if = "Option::is_none")]
642    pub annotation_id: Option<lsp_types::ChangeAnnotationIdentifier>,
643}
644
645pub enum HoverRequest {}
646
647impl Request for HoverRequest {
648    type Params = HoverParams;
649    type Result = Option<Hover>;
650    const METHOD: &'static str = lsp_types::request::HoverRequest::METHOD;
651}
652
653#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
654#[serde(rename_all = "camelCase")]
655pub struct HoverParams {
656    pub text_document: TextDocumentIdentifier,
657    pub position: PositionOrRange,
658
659    #[serde(flatten)]
660    pub work_done_progress_params: WorkDoneProgressParams,
661}
662
663#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
664#[serde(untagged)]
665pub enum PositionOrRange {
666    Position(lsp_types::Position),
667    Range(lsp_types::Range),
668}
669
670#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
671pub struct Hover {
672    #[serde(flatten)]
673    pub hover: lsp_types::Hover,
674    #[serde(skip_serializing_if = "Vec::is_empty")]
675    pub actions: Vec<CommandLinkGroup>,
676}
677
678#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
679pub struct CommandLinkGroup {
680    #[serde(skip_serializing_if = "Option::is_none")]
681    pub title: Option<String>,
682    pub commands: Vec<CommandLink>,
683}
684
685// LSP v3.15 Command does not have a `tooltip` field, vscode supports one.
686#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
687pub struct CommandLink {
688    #[serde(flatten)]
689    pub command: lsp_types::Command,
690    #[serde(skip_serializing_if = "Option::is_none")]
691    pub tooltip: Option<String>,
692}
693
694pub enum ExternalDocs {}
695
696impl Request for ExternalDocs {
697    type Params = lsp_types::TextDocumentPositionParams;
698    type Result = ExternalDocsResponse;
699    const METHOD: &'static str = "experimental/externalDocs";
700}
701
702#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
703#[serde(untagged)]
704pub enum ExternalDocsResponse {
705    Simple(Option<lsp_types::Url>),
706    WithLocal(ExternalDocsPair),
707}
708
709impl Default for ExternalDocsResponse {
710    fn default() -> Self {
711        ExternalDocsResponse::Simple(None)
712    }
713}
714
715#[derive(Debug, Default, PartialEq, Serialize, Deserialize, Clone)]
716#[serde(rename_all = "camelCase")]
717pub struct ExternalDocsPair {
718    pub web: Option<lsp_types::Url>,
719    pub local: Option<lsp_types::Url>,
720}
721
722pub enum OpenCargoToml {}
723
724impl Request for OpenCargoToml {
725    type Params = OpenCargoTomlParams;
726    type Result = Option<lsp_types::GotoDefinitionResponse>;
727    const METHOD: &'static str = "experimental/openCargoToml";
728}
729
730#[derive(Serialize, Deserialize, Debug)]
731#[serde(rename_all = "camelCase")]
732pub struct OpenCargoTomlParams {
733    pub text_document: TextDocumentIdentifier,
734}
735
736/// Information about CodeLens, that is to be resolved.
737#[derive(Debug, Serialize, Deserialize)]
738#[serde(rename_all = "camelCase")]
739pub struct CodeLensResolveData {
740    pub version: i32,
741    pub kind: CodeLensResolveDataKind,
742}
743
744#[derive(Debug, Serialize, Deserialize)]
745#[serde(rename_all = "camelCase")]
746pub enum CodeLensResolveDataKind {
747    Impls(lsp_types::request::GotoImplementationParams),
748    References(lsp_types::TextDocumentPositionParams),
749}
750
751pub enum MoveItem {}
752
753impl Request for MoveItem {
754    type Params = MoveItemParams;
755    type Result = Vec<SnippetTextEdit>;
756    const METHOD: &'static str = "experimental/moveItem";
757}
758
759#[derive(Serialize, Deserialize, Debug)]
760#[serde(rename_all = "camelCase")]
761pub struct MoveItemParams {
762    pub direction: MoveItemDirection,
763    pub text_document: TextDocumentIdentifier,
764    pub range: Range,
765}
766
767#[derive(Serialize, Deserialize, Debug)]
768pub enum MoveItemDirection {
769    Up,
770    Down,
771}
772
773#[derive(Debug)]
774pub enum WorkspaceSymbol {}
775
776impl Request for WorkspaceSymbol {
777    type Params = WorkspaceSymbolParams;
778    type Result = Option<lsp_types::WorkspaceSymbolResponse>;
779    const METHOD: &'static str = "workspace/symbol";
780}
781
782#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
783#[serde(rename_all = "camelCase")]
784pub struct WorkspaceSymbolParams {
785    #[serde(flatten)]
786    pub partial_result_params: PartialResultParams,
787
788    #[serde(flatten)]
789    pub work_done_progress_params: WorkDoneProgressParams,
790
791    /// A non-empty query string
792    pub query: String,
793
794    pub search_scope: Option<WorkspaceSymbolSearchScope>,
795
796    pub search_kind: Option<WorkspaceSymbolSearchKind>,
797}
798
799#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
800#[serde(rename_all = "camelCase")]
801pub enum WorkspaceSymbolSearchScope {
802    Workspace,
803    WorkspaceAndDependencies,
804}
805
806#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
807#[serde(rename_all = "camelCase")]
808pub enum WorkspaceSymbolSearchKind {
809    OnlyTypes,
810    AllSymbols,
811}
812
813/// The document on type formatting request is sent from the client to
814/// the server to format parts of the document during typing.  This is
815/// almost same as lsp_types::request::OnTypeFormatting, but the
816/// result has SnippetTextEdit in it instead of TextEdit.
817#[derive(Debug)]
818pub enum OnTypeFormatting {}
819
820impl Request for OnTypeFormatting {
821    type Params = DocumentOnTypeFormattingParams;
822    type Result = Option<Vec<SnippetTextEdit>>;
823    const METHOD: &'static str = "textDocument/onTypeFormatting";
824}
825
826#[derive(Debug, Serialize, Deserialize)]
827pub struct CompletionResolveData {
828    pub position: lsp_types::TextDocumentPositionParams,
829    #[serde(skip_serializing_if = "Vec::is_empty", default)]
830    pub imports: Vec<CompletionImport>,
831    #[serde(skip_serializing_if = "Option::is_none", default)]
832    pub version: Option<i32>,
833    #[serde(skip_serializing_if = "Option::is_none", default)]
834    pub trigger_character: Option<char>,
835    #[serde(default)]
836    pub for_ref: bool,
837    pub hash: String,
838}
839
840#[derive(Debug, Serialize, Deserialize)]
841pub struct InlayHintResolveData {
842    pub file_id: u32,
843    // This is a string instead of a u64 as javascript can't represent u64 fully
844    pub hash: String,
845    pub resolve_range: lsp_types::Range,
846    #[serde(skip_serializing_if = "Option::is_none", default)]
847    pub version: Option<i32>,
848}
849
850#[derive(Debug, Serialize, Deserialize)]
851pub struct CompletionImport {
852    pub full_import_path: String,
853}
854
855#[derive(Debug, Deserialize, Default)]
856pub struct ClientCommandOptions {
857    pub commands: Vec<String>,
858}