]> git.lizzy.rs Git - rust.git/blob - crates/ra_lsp_server/src/req.rs
Use SelectionRange from LSP 3.15
[rust.git] / crates / ra_lsp_server / src / req.rs
1 //! FIXME: write short doc here
2
3 use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url};
4 use rustc_hash::FxHashMap;
5 use serde::{Deserialize, Serialize};
6
7 pub use lsp_types::{
8     notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens,
9     CodeLensParams, CompletionParams, CompletionResponse, DidChangeConfigurationParams,
10     DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions,
11     DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse,
12     FileSystemWatcher, Hover, InitializeResult, MessageType, PublishDiagnosticsParams,
13     ReferenceParams, Registration, RegistrationParams, SelectionRange, SelectionRangeParams,
14     ShowMessageParams, SignatureHelp, TextDocumentEdit, TextDocumentPositionParams, TextEdit,
15     WorkspaceEdit, WorkspaceSymbolParams,
16 };
17
18 pub enum AnalyzerStatus {}
19
20 impl Request for AnalyzerStatus {
21     type Params = ();
22     type Result = String;
23     const METHOD: &'static str = "rust-analyzer/analyzerStatus";
24 }
25
26 pub enum CollectGarbage {}
27
28 impl Request for CollectGarbage {
29     type Params = ();
30     type Result = ();
31     const METHOD: &'static str = "rust-analyzer/collectGarbage";
32 }
33
34 pub enum SyntaxTree {}
35
36 impl Request for SyntaxTree {
37     type Params = SyntaxTreeParams;
38     type Result = String;
39     const METHOD: &'static str = "rust-analyzer/syntaxTree";
40 }
41
42 #[derive(Deserialize, Debug)]
43 #[serde(rename_all = "camelCase")]
44 pub struct SyntaxTreeParams {
45     pub text_document: TextDocumentIdentifier,
46     pub range: Option<Range>,
47 }
48
49 #[derive(Serialize, Debug)]
50 #[serde(rename_all = "camelCase")]
51 pub struct ExpandedMacro {
52     pub name: String,
53     pub expansion: String,
54 }
55
56 pub enum ExpandMacro {}
57
58 impl Request for ExpandMacro {
59     type Params = ExpandMacroParams;
60     type Result = Option<ExpandedMacro>;
61     const METHOD: &'static str = "rust-analyzer/expandMacro";
62 }
63
64 #[derive(Deserialize, Debug)]
65 #[serde(rename_all = "camelCase")]
66 pub struct ExpandMacroParams {
67     pub text_document: TextDocumentIdentifier,
68     pub position: Option<Position>,
69 }
70
71 pub enum FindMatchingBrace {}
72
73 impl Request for FindMatchingBrace {
74     type Params = FindMatchingBraceParams;
75     type Result = Vec<Position>;
76     const METHOD: &'static str = "rust-analyzer/findMatchingBrace";
77 }
78
79 #[derive(Deserialize, Debug)]
80 #[serde(rename_all = "camelCase")]
81 pub struct FindMatchingBraceParams {
82     pub text_document: TextDocumentIdentifier,
83     pub offsets: Vec<Position>,
84 }
85
86 pub enum DecorationsRequest {}
87
88 impl Request for DecorationsRequest {
89     type Params = TextDocumentIdentifier;
90     type Result = Vec<Decoration>;
91     const METHOD: &'static str = "rust-analyzer/decorationsRequest";
92 }
93
94 pub enum PublishDecorations {}
95
96 impl Notification for PublishDecorations {
97     type Params = PublishDecorationsParams;
98     const METHOD: &'static str = "rust-analyzer/publishDecorations";
99 }
100
101 #[derive(Serialize, Debug)]
102 #[serde(rename_all = "camelCase")]
103 pub struct PublishDecorationsParams {
104     pub uri: Url,
105     pub decorations: Vec<Decoration>,
106 }
107
108 #[derive(Serialize, Debug)]
109 #[serde(rename_all = "camelCase")]
110 pub struct Decoration {
111     pub range: Range,
112     pub tag: &'static str,
113     pub binding_hash: Option<String>,
114 }
115
116 pub enum ParentModule {}
117
118 impl Request for ParentModule {
119     type Params = TextDocumentPositionParams;
120     type Result = Vec<Location>;
121     const METHOD: &'static str = "rust-analyzer/parentModule";
122 }
123
124 pub enum JoinLines {}
125
126 impl Request for JoinLines {
127     type Params = JoinLinesParams;
128     type Result = SourceChange;
129     const METHOD: &'static str = "rust-analyzer/joinLines";
130 }
131
132 #[derive(Deserialize, Debug)]
133 #[serde(rename_all = "camelCase")]
134 pub struct JoinLinesParams {
135     pub text_document: TextDocumentIdentifier,
136     pub range: Range,
137 }
138
139 pub enum OnEnter {}
140
141 impl Request for OnEnter {
142     type Params = TextDocumentPositionParams;
143     type Result = Option<SourceChange>;
144     const METHOD: &'static str = "rust-analyzer/onEnter";
145 }
146
147 pub enum Runnables {}
148
149 impl Request for Runnables {
150     type Params = RunnablesParams;
151     type Result = Vec<Runnable>;
152     const METHOD: &'static str = "rust-analyzer/runnables";
153 }
154
155 #[derive(Serialize, Deserialize, Debug)]
156 #[serde(rename_all = "camelCase")]
157 pub struct RunnablesParams {
158     pub text_document: TextDocumentIdentifier,
159     pub position: Option<Position>,
160 }
161
162 #[derive(Serialize, Debug)]
163 #[serde(rename_all = "camelCase")]
164 pub struct Runnable {
165     pub range: Range,
166     pub label: String,
167     pub bin: String,
168     pub args: Vec<String>,
169     pub env: FxHashMap<String, String>,
170     pub cwd: Option<String>,
171 }
172
173 #[derive(Serialize, Debug)]
174 #[serde(rename_all = "camelCase")]
175 pub struct SourceChange {
176     pub label: String,
177     pub workspace_edit: WorkspaceEdit,
178     pub cursor_position: Option<TextDocumentPositionParams>,
179 }
180
181 pub enum InlayHints {}
182
183 impl Request for InlayHints {
184     type Params = InlayHintsParams;
185     type Result = Vec<InlayHint>;
186     const METHOD: &'static str = "rust-analyzer/inlayHints";
187 }
188
189 #[derive(Serialize, Deserialize, Debug)]
190 #[serde(rename_all = "camelCase")]
191 pub struct InlayHintsParams {
192     pub text_document: TextDocumentIdentifier,
193 }
194
195 #[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
196 pub enum InlayKind {
197     TypeHint,
198 }
199
200 #[derive(Debug, Deserialize, Serialize)]
201 pub struct InlayHint {
202     pub range: Range,
203     pub kind: InlayKind,
204     pub label: String,
205 }