]> git.lizzy.rs Git - rust.git/blob - crates/ra_lsp_server/src/req.rs
Go to Implementation for structs and enums
[rust.git] / crates / ra_lsp_server / src / req.rs
1 use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url};
2 use rustc_hash::FxHashMap;
3 use serde::{Deserialize, Serialize};
4 use url_serde;
5
6 pub use lsp_types::{
7     notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, CodeLensParams,
8     CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams,
9     DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult,
10     PublishDiagnosticsParams, ReferenceParams, SignatureHelp, TextDocumentEdit,
11     TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams
12 };
13
14 pub enum AnalyzerStatus {}
15
16 impl Request for AnalyzerStatus {
17     type Params = ();
18     type Result = String;
19     const METHOD: &'static str = "rust-analyzer/analyzerStatus";
20 }
21
22 pub enum CollectGarbage {}
23
24 impl Request for CollectGarbage {
25     type Params = ();
26     type Result = ();
27     const METHOD: &'static str = "rust-analyzer/collectGarbage";
28 }
29
30 pub enum SyntaxTree {}
31
32 impl Request for SyntaxTree {
33     type Params = SyntaxTreeParams;
34     type Result = String;
35     const METHOD: &'static str = "rust-analyzer/syntaxTree";
36 }
37
38 #[derive(Deserialize, Debug)]
39 #[serde(rename_all = "camelCase")]
40 pub struct SyntaxTreeParams {
41     pub text_document: TextDocumentIdentifier,
42 }
43
44 pub enum ExtendSelection {}
45
46 impl Request for ExtendSelection {
47     type Params = ExtendSelectionParams;
48     type Result = ExtendSelectionResult;
49     const METHOD: &'static str = "rust-analyzer/extendSelection";
50 }
51
52 #[derive(Deserialize, Debug)]
53 #[serde(rename_all = "camelCase")]
54 pub struct ExtendSelectionParams {
55     pub text_document: TextDocumentIdentifier,
56     pub selections: Vec<Range>,
57 }
58
59 #[derive(Serialize, Debug)]
60 #[serde(rename_all = "camelCase")]
61 pub struct ExtendSelectionResult {
62     pub selections: Vec<Range>,
63 }
64
65 pub enum FindMatchingBrace {}
66
67 impl Request for FindMatchingBrace {
68     type Params = FindMatchingBraceParams;
69     type Result = Vec<Position>;
70     const METHOD: &'static str = "rust-analyzer/findMatchingBrace";
71 }
72
73 #[derive(Deserialize, Debug)]
74 #[serde(rename_all = "camelCase")]
75 pub struct FindMatchingBraceParams {
76     pub text_document: TextDocumentIdentifier,
77     pub offsets: Vec<Position>,
78 }
79
80 pub enum DecorationsRequest {}
81
82 impl Request for DecorationsRequest {
83     type Params = TextDocumentIdentifier;
84     type Result = Vec<Decoration>;
85     const METHOD: &'static str = "rust-analyzer/decorationsRequest";
86 }
87
88 pub enum PublishDecorations {}
89
90 impl Notification for PublishDecorations {
91     type Params = PublishDecorationsParams;
92     const METHOD: &'static str = "rust-analyzer/publishDecorations";
93 }
94
95 #[derive(Serialize, Debug)]
96 #[serde(rename_all = "camelCase")]
97 pub struct PublishDecorationsParams {
98     #[serde(with = "url_serde")]
99     pub uri: Url,
100     pub decorations: Vec<Decoration>,
101 }
102
103 #[derive(Serialize, Debug)]
104 #[serde(rename_all = "camelCase")]
105 pub struct Decoration {
106     pub range: Range,
107     pub tag: &'static str,
108 }
109
110 pub enum ParentModule {}
111
112 impl Request for ParentModule {
113     type Params = TextDocumentPositionParams;
114     type Result = Vec<Location>;
115     const METHOD: &'static str = "rust-analyzer/parentModule";
116 }
117
118 pub enum JoinLines {}
119
120 impl Request for JoinLines {
121     type Params = JoinLinesParams;
122     type Result = SourceChange;
123     const METHOD: &'static str = "rust-analyzer/joinLines";
124 }
125
126 #[derive(Deserialize, Debug)]
127 #[serde(rename_all = "camelCase")]
128 pub struct JoinLinesParams {
129     pub text_document: TextDocumentIdentifier,
130     pub range: Range,
131 }
132
133 pub enum OnEnter {}
134
135 impl Request for OnEnter {
136     type Params = TextDocumentPositionParams;
137     type Result = Option<SourceChange>;
138     const METHOD: &'static str = "rust-analyzer/onEnter";
139 }
140
141 pub enum Runnables {}
142
143 impl Request for Runnables {
144     type Params = RunnablesParams;
145     type Result = Vec<Runnable>;
146     const METHOD: &'static str = "rust-analyzer/runnables";
147 }
148
149 #[derive(Serialize, Deserialize, Debug)]
150 #[serde(rename_all = "camelCase")]
151 pub struct RunnablesParams {
152     pub text_document: TextDocumentIdentifier,
153     pub position: Option<Position>,
154 }
155
156 #[derive(Serialize, Debug)]
157 #[serde(rename_all = "camelCase")]
158 pub struct Runnable {
159     pub range: Range,
160     pub label: String,
161     pub bin: String,
162     pub args: Vec<String>,
163     pub env: FxHashMap<String, String>,
164 }
165
166 #[derive(Serialize, Debug)]
167 #[serde(rename_all = "camelCase")]
168 pub struct SourceChange {
169     pub label: String,
170     pub workspace_edit: WorkspaceEdit,
171     pub cursor_position: Option<TextDocumentPositionParams>,
172 }
173
174 pub enum InternalFeedback {}
175
176 impl Notification for InternalFeedback {
177     const METHOD: &'static str = "internalFeedback";
178     type Params = String;
179 }