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