diff options
author | Aleksey Kladov <[email protected]> | 2020-05-24 16:01:40 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-24 16:01:40 +0100 |
commit | dec4ba80236e1be15f011fd6b2f7f0ecb151fd31 (patch) | |
tree | f218a60dfaa5acb9c2daac08114420531e413739 | |
parent | 934227361623b258d833be20e464e1509cb432ad (diff) |
Document some rust-analyzer specific protocol extensions
-rw-r--r-- | crates/rust-analyzer/src/lsp_ext.rs | 15 | ||||
-rw-r--r-- | docs/dev/lsp-extensions.md | 62 |
2 files changed, 70 insertions, 7 deletions
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index b8b9e65ed..c7e31c076 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs | |||
@@ -38,13 +38,6 @@ pub struct SyntaxTreeParams { | |||
38 | pub range: Option<Range>, | 38 | pub range: Option<Range>, |
39 | } | 39 | } |
40 | 40 | ||
41 | #[derive(Deserialize, Serialize, Debug)] | ||
42 | #[serde(rename_all = "camelCase")] | ||
43 | pub struct ExpandedMacro { | ||
44 | pub name: String, | ||
45 | pub expansion: String, | ||
46 | } | ||
47 | |||
48 | pub enum ExpandMacro {} | 41 | pub enum ExpandMacro {} |
49 | 42 | ||
50 | impl Request for ExpandMacro { | 43 | impl Request for ExpandMacro { |
@@ -60,6 +53,14 @@ pub struct ExpandMacroParams { | |||
60 | pub position: Option<Position>, | 53 | pub position: Option<Position>, |
61 | } | 54 | } |
62 | 55 | ||
56 | #[derive(Deserialize, Serialize, Debug)] | ||
57 | #[serde(rename_all = "camelCase")] | ||
58 | pub struct ExpandedMacro { | ||
59 | pub name: String, | ||
60 | pub expansion: String, | ||
61 | } | ||
62 | |||
63 | |||
63 | pub enum MatchingBrace {} | 64 | pub enum MatchingBrace {} |
64 | 65 | ||
65 | impl Request for MatchingBrace { | 66 | impl Request for MatchingBrace { |
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 9fa1c5fc2..55035cfae 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md | |||
@@ -217,3 +217,65 @@ Moreover, it would be cool if editors didn't need to implement even basic langua | |||
217 | * Should we return a a nested brace structure, to allow paredit-like actions of jump *out* of the current brace pair? | 217 | * Should we return a a nested brace structure, to allow paredit-like actions of jump *out* of the current brace pair? |
218 | This is how `SelectionRange` request works. | 218 | This is how `SelectionRange` request works. |
219 | * Alternatively, should we perhaps flag certain `SelectionRange`s as being brace pairs? | 219 | * Alternatively, should we perhaps flag certain `SelectionRange`s as being brace pairs? |
220 | |||
221 | ## Analyzer Status | ||
222 | |||
223 | **Method:** `rust-analyzer/analyzerStatus` | ||
224 | |||
225 | **Request:** `null` | ||
226 | |||
227 | **Response:** `string` | ||
228 | |||
229 | Returns internal status message, mostly for debugging purposes. | ||
230 | |||
231 | ## Collect Garbage | ||
232 | |||
233 | **Method:** `rust-analyzer/collectGarbage` | ||
234 | |||
235 | **Request:** `null` | ||
236 | |||
237 | **Response:** `null` | ||
238 | |||
239 | Frees some caches. For internal use, and is mostly broken at the moment. | ||
240 | |||
241 | ## Syntax Tree | ||
242 | |||
243 | **Method:** `rust-analyzer/syntaxTree` | ||
244 | |||
245 | **Request:** | ||
246 | |||
247 | ```typescript | ||
248 | interface SyntaxTeeParams { | ||
249 | textDocument: TextDocumentIdentifier, | ||
250 | range?: Range, | ||
251 | } | ||
252 | ``` | ||
253 | |||
254 | **Response:** `string` | ||
255 | |||
256 | Returns textual representation of a parse tree for the file/selected region. | ||
257 | Primarily for debugging, but very useful for all people working on rust-analyzer itself. | ||
258 | |||
259 | ## Expand Macro | ||
260 | |||
261 | **Method:** `rust-analyzer/expandMacro` | ||
262 | |||
263 | **Request:** | ||
264 | |||
265 | ```typescript | ||
266 | interface ExpandMacroParams { | ||
267 | textDocument: TextDocumentIdentifier, | ||
268 | position?: Position, | ||
269 | } | ||
270 | ``` | ||
271 | |||
272 | **Response:** | ||
273 | |||
274 | ```typescript | ||
275 | interface ExpandedMacro { | ||
276 | name: string, | ||
277 | expansion: string, | ||
278 | } | ||
279 | ``` | ||
280 | |||
281 | Expands macro call at a given position. | ||