From dec4ba80236e1be15f011fd6b2f7f0ecb151fd31 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 May 2020 17:01:40 +0200 Subject: Document some rust-analyzer specific protocol extensions --- crates/rust-analyzer/src/lsp_ext.rs | 15 ++++----- 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 { pub range: Option, } -#[derive(Deserialize, Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct ExpandedMacro { - pub name: String, - pub expansion: String, -} - pub enum ExpandMacro {} impl Request for ExpandMacro { @@ -60,6 +53,14 @@ pub struct ExpandMacroParams { pub position: Option, } +#[derive(Deserialize, Serialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct ExpandedMacro { + pub name: String, + pub expansion: String, +} + + pub enum MatchingBrace {} 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 * Should we return a a nested brace structure, to allow paredit-like actions of jump *out* of the current brace pair? This is how `SelectionRange` request works. * Alternatively, should we perhaps flag certain `SelectionRange`s as being brace pairs? + +## Analyzer Status + +**Method:** `rust-analyzer/analyzerStatus` + +**Request:** `null` + +**Response:** `string` + +Returns internal status message, mostly for debugging purposes. + +## Collect Garbage + +**Method:** `rust-analyzer/collectGarbage` + +**Request:** `null` + +**Response:** `null` + +Frees some caches. For internal use, and is mostly broken at the moment. + +## Syntax Tree + +**Method:** `rust-analyzer/syntaxTree` + +**Request:** + +```typescript +interface SyntaxTeeParams { + textDocument: TextDocumentIdentifier, + range?: Range, +} +``` + +**Response:** `string` + +Returns textual representation of a parse tree for the file/selected region. +Primarily for debugging, but very useful for all people working on rust-analyzer itself. + +## Expand Macro + +**Method:** `rust-analyzer/expandMacro` + +**Request:** + +```typescript +interface ExpandMacroParams { + textDocument: TextDocumentIdentifier, + position?: Position, +} +``` + +**Response:** + +```typescript +interface ExpandedMacro { + name: string, + expansion: string, +} +``` + +Expands macro call at a given position. -- cgit v1.2.3