diff options
-rw-r--r-- | ARCHITECTURE.md | 2 | ||||
-rw-r--r-- | Cargo.lock | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/call_info.rs | 47 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 15 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 4 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/req.rs | 8 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/server_world.rs | 15 | ||||
-rw-r--r-- | crates/ra_syntax/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/params.rs | 7 | ||||
-rw-r--r-- | crates/ra_syntax/src/yellow.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0116_trait_fn_placeholder_parameter.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/tests/data/parser/inline/ok/0116_trait_fn_placeholder_parameter.txt | 32 | ||||
-rw-r--r-- | editors/code/package.json | 4 | ||||
-rw-r--r-- | editors/code/src/commands/analyzer_status.ts | 12 | ||||
-rw-r--r-- | editors/code/src/commands/index.ts | 2 | ||||
-rw-r--r-- | editors/code/src/extension.ts | 1 |
18 files changed, 126 insertions, 45 deletions
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index b75dfa0d3..2c0da0665 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md | |||
@@ -184,6 +184,8 @@ To see logs from the language server, set `RUST_LOG=info` env variable. To see | |||
184 | all communication between the server and the client, use | 184 | all communication between the server and the client, use |
185 | `RUST_LOG=gen_lsp_server=debug` (this will print quite a bit of stuff). | 185 | `RUST_LOG=gen_lsp_server=debug` (this will print quite a bit of stuff). |
186 | 186 | ||
187 | There's `Status of rust-analyzer` command which prints common high-level debug info. | ||
188 | |||
187 | To run tests, just `cargo test`. | 189 | To run tests, just `cargo test`. |
188 | 190 | ||
189 | To work on the VS Code extension, launch code inside `editors/code` and use `F5` to | 191 | To work on the VS Code extension, launch code inside `editors/code` and use `F5` to |
diff --git a/Cargo.lock b/Cargo.lock index cb0706087..9a495a69d 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -826,7 +826,7 @@ dependencies = [ | |||
826 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 826 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
827 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", | 827 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
828 | "ra_text_edit 0.1.0", | 828 | "ra_text_edit 0.1.0", |
829 | "rowan 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | 829 | "rowan 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", |
830 | "smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", | 830 | "smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", |
831 | "test_utils 0.1.0", | 831 | "test_utils 0.1.0", |
832 | "text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | 832 | "text_unit 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1041,7 +1041,7 @@ dependencies = [ | |||
1041 | 1041 | ||
1042 | [[package]] | 1042 | [[package]] |
1043 | name = "rowan" | 1043 | name = "rowan" |
1044 | version = "0.3.1" | 1044 | version = "0.3.2" |
1045 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1045 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1046 | dependencies = [ | 1046 | dependencies = [ |
1047 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1047 | "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1685,7 +1685,7 @@ dependencies = [ | |||
1685 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" | 1685 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" |
1686 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" | 1686 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" |
1687 | "checksum ron 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d9cb28ade964585205aaca1f3d41a6297f72e1ad097b49c4bbde033ef86b38d7" | 1687 | "checksum ron 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d9cb28ade964585205aaca1f3d41a6297f72e1ad097b49c4bbde033ef86b38d7" |
1688 | "checksum rowan 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "660069534501214380ab070b979f4b41e8cf3a5279ae07d0e949675efbd595bd" | 1688 | "checksum rowan 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "acefc6f0bfd48f98b1d4424bf53c6b1c9dd379d69376e862ba3c44d29773602c" |
1689 | "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" | 1689 | "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" |
1690 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" | 1690 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" |
1691 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 1691 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 18b9508ef..798fb7c13 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | use std::cmp::{max, min}; | ||
2 | |||
3 | use ra_db::SyntaxDatabase; | 1 | use ra_db::SyntaxDatabase; |
4 | use ra_syntax::{ | 2 | use ra_syntax::{ |
5 | AstNode, SyntaxNode, TextUnit, TextRange, | 3 | AstNode, SyntaxNode, TextUnit, TextRange, |
@@ -107,15 +105,13 @@ impl<'a> FnCallNode<'a> { | |||
107 | 105 | ||
108 | impl CallInfo { | 106 | impl CallInfo { |
109 | fn new(node: &ast::FnDef) -> Option<Self> { | 107 | fn new(node: &ast::FnDef) -> Option<Self> { |
110 | let mut doc = None; | 108 | let label: String = if let Some(body) = node.body() { |
111 | |||
112 | // Strip the body out for the label. | ||
113 | let mut label: String = if let Some(body) = node.body() { | ||
114 | let body_range = body.syntax().range(); | 109 | let body_range = body.syntax().range(); |
115 | let label: String = node | 110 | let label: String = node |
116 | .syntax() | 111 | .syntax() |
117 | .children() | 112 | .children() |
118 | .filter(|child| !child.range().is_subrange(&body_range)) | 113 | .filter(|child| !child.range().is_subrange(&body_range)) // Filter out body |
114 | .filter(|child| ast::Comment::cast(child).is_none()) // Filter out doc comments | ||
119 | .map(|node| node.text().to_string()) | 115 | .map(|node| node.text().to_string()) |
120 | .collect(); | 116 | .collect(); |
121 | label | 117 | label |
@@ -123,16 +119,9 @@ impl CallInfo { | |||
123 | node.syntax().text().to_string() | 119 | node.syntax().text().to_string() |
124 | }; | 120 | }; |
125 | 121 | ||
126 | if let Some((comment_range, docs)) = extract_doc_comments(node) { | 122 | let mut doc = None; |
127 | let comment_range = comment_range | 123 | let docs = node.doc_comment_text(); |
128 | .checked_sub(node.syntax().range().start()) | 124 | if !docs.is_empty() { |
129 | .unwrap(); | ||
130 | let start = comment_range.start().to_usize(); | ||
131 | let end = comment_range.end().to_usize(); | ||
132 | |||
133 | // Remove the comment from the label | ||
134 | label.replace_range(start..end, ""); | ||
135 | |||
136 | // Massage markdown | 125 | // Massage markdown |
137 | let mut processed_lines = Vec::new(); | 126 | let mut processed_lines = Vec::new(); |
138 | let mut in_code_block = false; | 127 | let mut in_code_block = false; |
@@ -150,9 +139,7 @@ impl CallInfo { | |||
150 | processed_lines.push(line); | 139 | processed_lines.push(line); |
151 | } | 140 | } |
152 | 141 | ||
153 | if !processed_lines.is_empty() { | 142 | doc = Some(processed_lines.join("\n")); |
154 | doc = Some(processed_lines.join("\n")); | ||
155 | } | ||
156 | } | 143 | } |
157 | 144 | ||
158 | Some(CallInfo { | 145 | Some(CallInfo { |
@@ -164,26 +151,6 @@ impl CallInfo { | |||
164 | } | 151 | } |
165 | } | 152 | } |
166 | 153 | ||
167 | fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> { | ||
168 | if node.doc_comments().count() == 0 { | ||
169 | return None; | ||
170 | } | ||
171 | |||
172 | let comment_text = node.doc_comment_text(); | ||
173 | |||
174 | let (begin, end) = node | ||
175 | .doc_comments() | ||
176 | .map(|comment| comment.syntax().range()) | ||
177 | .map(|range| (range.start().to_usize(), range.end().to_usize())) | ||
178 | .fold((std::usize::MAX, std::usize::MIN), |acc, range| { | ||
179 | (min(acc.0, range.0), max(acc.1, range.1)) | ||
180 | }); | ||
181 | |||
182 | let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end)); | ||
183 | |||
184 | Some((range, comment_text)) | ||
185 | } | ||
186 | |||
187 | fn param_list(node: &ast::FnDef) -> Vec<String> { | 154 | fn param_list(node: &ast::FnDef) -> Vec<String> { |
188 | let mut res = vec![]; | 155 | let mut res = vec![]; |
189 | if let Some(param_list) = node.param_list() { | 156 | if let Some(param_list) = node.param_list() { |
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index a09a8f926..3c53e75ac 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -15,6 +15,7 @@ pub mod mock_analysis; | |||
15 | mod symbol_index; | 15 | mod symbol_index; |
16 | mod navigation_target; | 16 | mod navigation_target; |
17 | 17 | ||
18 | mod status; | ||
18 | mod completion; | 19 | mod completion; |
19 | mod runnables; | 20 | mod runnables; |
20 | mod goto_definition; | 21 | mod goto_definition; |
@@ -293,6 +294,11 @@ pub struct Analysis { | |||
293 | } | 294 | } |
294 | 295 | ||
295 | impl Analysis { | 296 | impl Analysis { |
297 | /// Debug info about the current state of the analysis | ||
298 | pub fn status(&self) -> String { | ||
299 | status::status(&*self.db) | ||
300 | } | ||
301 | |||
296 | /// Gets the text of the source file. | 302 | /// Gets the text of the source file. |
297 | pub fn file_text(&self, file_id: FileId) -> Arc<String> { | 303 | pub fn file_text(&self, file_id: FileId) -> Arc<String> { |
298 | self.db.file_text(file_id) | 304 | self.db.file_text(file_id) |
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs new file mode 100644 index 000000000..d3e04be23 --- /dev/null +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -0,0 +1,15 @@ | |||
1 | use ra_db::{ | ||
2 | LocationIntener, SourceFileQuery, | ||
3 | salsa::{Database, debug::DebugQueryTable}, | ||
4 | }; | ||
5 | |||
6 | use crate::db::RootDatabase; | ||
7 | |||
8 | pub(crate) fn status(db: &RootDatabase) -> String { | ||
9 | let n_parsed_files = db.query(SourceFileQuery).keys::<Vec<_>>().len(); | ||
10 | let n_defs = { | ||
11 | let interner: &LocationIntener<hir::DefLoc, hir::DefId> = db.as_ref(); | ||
12 | interner.len() | ||
13 | }; | ||
14 | format!("#n_parsed_files {}\n#n_defs {}\n", n_parsed_files, n_defs) | ||
15 | } | ||
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index fa07b1942..f51576521 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -285,6 +285,7 @@ fn on_request( | |||
285 | sender, | 285 | sender, |
286 | }; | 286 | }; |
287 | let req = pool_dispatcher | 287 | let req = pool_dispatcher |
288 | .on::<req::AnalyzerStatus>(handlers::handle_analyzer_status)? | ||
288 | .on::<req::SyntaxTree>(handlers::handle_syntax_tree)? | 289 | .on::<req::SyntaxTree>(handlers::handle_syntax_tree)? |
289 | .on::<req::ExtendSelection>(handlers::handle_extend_selection)? | 290 | .on::<req::ExtendSelection>(handlers::handle_extend_selection)? |
290 | .on::<req::FindMatchingBrace>(handlers::handle_find_matching_brace)? | 291 | .on::<req::FindMatchingBrace>(handlers::handle_find_matching_brace)? |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 497f819be..d84f762f4 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -23,6 +23,10 @@ use crate::{ | |||
23 | LspError, Result, | 23 | LspError, Result, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | pub fn handle_analyzer_status(world: ServerWorld, _: ()) -> Result<String> { | ||
27 | Ok(world.status()) | ||
28 | } | ||
29 | |||
26 | pub fn handle_syntax_tree(world: ServerWorld, params: req::SyntaxTreeParams) -> Result<String> { | 30 | pub fn handle_syntax_tree(world: ServerWorld, params: req::SyntaxTreeParams) -> Result<String> { |
27 | let id = params.text_document.try_conv_with(&world)?; | 31 | let id = params.text_document.try_conv_with(&world)?; |
28 | let res = world.analysis().syntax_tree(id); | 32 | let res = world.analysis().syntax_tree(id); |
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 156cf9641..ec6b6d905 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs | |||
@@ -11,6 +11,14 @@ pub use lsp_types::{ | |||
11 | TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, | 11 | TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | pub enum AnalyzerStatus {} | ||
15 | |||
16 | impl Request for AnalyzerStatus { | ||
17 | type Params = (); | ||
18 | type Result = String; | ||
19 | const METHOD: &'static str = "ra/analyzerStatus"; | ||
20 | } | ||
21 | |||
14 | pub enum SyntaxTree {} | 22 | pub enum SyntaxTree {} |
15 | 23 | ||
16 | impl Request for SyntaxTree { | 24 | impl Request for SyntaxTree { |
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index c24ded9f9..5cb97b29b 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs | |||
@@ -264,4 +264,19 @@ impl ServerWorld { | |||
264 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; | 264 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; |
265 | Ok(url) | 265 | Ok(url) |
266 | } | 266 | } |
267 | |||
268 | pub fn status(&self) -> String { | ||
269 | let mut res = String::new(); | ||
270 | if self.workspaces.is_empty() { | ||
271 | res.push_str("no workspaces\n") | ||
272 | } else { | ||
273 | res.push_str("workspaces:\n"); | ||
274 | for w in self.workspaces.iter() { | ||
275 | res += &format!("{} packages loaded\n", w.cargo.packages().count()); | ||
276 | } | ||
277 | } | ||
278 | res.push_str("\nanalysis:\n"); | ||
279 | res.push_str(&self.analysis.status()); | ||
280 | res | ||
281 | } | ||
267 | } | 282 | } |
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index 05cf41a8d..c50dc6c67 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml | |||
@@ -13,7 +13,7 @@ unicode-xid = "0.1.0" | |||
13 | itertools = "0.8.0" | 13 | itertools = "0.8.0" |
14 | drop_bomb = "0.1.4" | 14 | drop_bomb = "0.1.4" |
15 | parking_lot = "0.7.0" | 15 | parking_lot = "0.7.0" |
16 | rowan = "0.3.1" | 16 | rowan = "0.3.2" |
17 | 17 | ||
18 | # ideally, `serde` should be enabled by `ra_lsp_serder`, but we enable it here | 18 | # ideally, `serde` should be enabled by `ra_lsp_serder`, but we enable it here |
19 | # to reduce number of compilations | 19 | # to reduce number of compilations |
diff --git a/crates/ra_syntax/src/grammar/params.rs b/crates/ra_syntax/src/grammar/params.rs index 658fc5820..13158429a 100644 --- a/crates/ra_syntax/src/grammar/params.rs +++ b/crates/ra_syntax/src/grammar/params.rs | |||
@@ -79,7 +79,12 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) { | |||
79 | let la1 = p.nth(1); | 79 | let la1 = p.nth(1); |
80 | let la2 = p.nth(2); | 80 | let la2 = p.nth(2); |
81 | let la3 = p.nth(3); | 81 | let la3 = p.nth(3); |
82 | if la0 == IDENT && la1 == COLON | 82 | |
83 | // test trait_fn_placeholder_parameter | ||
84 | // trait Foo { | ||
85 | // fn bar(_: u64); | ||
86 | // } | ||
87 | if (la0 == IDENT || la0 == UNDERSCORE) && la1 == COLON | ||
83 | || la0 == AMP && la1 == IDENT && la2 == COLON | 88 | || la0 == AMP && la1 == IDENT && la2 == COLON |
84 | || la0 == AMP && la1 == MUT_KW && la2 == IDENT && la3 == COLON | 89 | || la0 == AMP && la1 == MUT_KW && la2 == IDENT && la3 == COLON |
85 | { | 90 | { |
diff --git a/crates/ra_syntax/src/yellow.rs b/crates/ra_syntax/src/yellow.rs index 9b93945cc..a7bfb80e2 100644 --- a/crates/ra_syntax/src/yellow.rs +++ b/crates/ra_syntax/src/yellow.rs | |||
@@ -177,6 +177,10 @@ impl SyntaxNode { | |||
177 | pub fn children(&self) -> SyntaxNodeChildren { | 177 | pub fn children(&self) -> SyntaxNodeChildren { |
178 | SyntaxNodeChildren(self.0.children()) | 178 | SyntaxNodeChildren(self.0.children()) |
179 | } | 179 | } |
180 | |||
181 | pub fn memory_size_of_subtree(&self) -> usize { | ||
182 | self.0.memory_size_of_subtree() | ||
183 | } | ||
180 | } | 184 | } |
181 | 185 | ||
182 | impl fmt::Debug for SyntaxNode { | 186 | impl fmt::Debug for SyntaxNode { |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0116_trait_fn_placeholder_parameter.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0116_trait_fn_placeholder_parameter.rs new file mode 100644 index 000000000..aede3f4fe --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0116_trait_fn_placeholder_parameter.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | trait Foo { | ||
2 | fn bar(_: u64); | ||
3 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0116_trait_fn_placeholder_parameter.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0116_trait_fn_placeholder_parameter.txt new file mode 100644 index 000000000..248d491df --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0116_trait_fn_placeholder_parameter.txt | |||
@@ -0,0 +1,32 @@ | |||
1 | SOURCE_FILE@[0; 34) | ||
2 | TRAIT_DEF@[0; 33) | ||
3 | TRAIT_KW@[0; 5) | ||
4 | WHITESPACE@[5; 6) | ||
5 | NAME@[6; 9) | ||
6 | IDENT@[6; 9) "Foo" | ||
7 | WHITESPACE@[9; 10) | ||
8 | ITEM_LIST@[10; 33) | ||
9 | L_CURLY@[10; 11) | ||
10 | WHITESPACE@[11; 16) | ||
11 | FN_DEF@[16; 31) | ||
12 | FN_KW@[16; 18) | ||
13 | WHITESPACE@[18; 19) | ||
14 | NAME@[19; 22) | ||
15 | IDENT@[19; 22) "bar" | ||
16 | PARAM_LIST@[22; 30) | ||
17 | L_PAREN@[22; 23) | ||
18 | PARAM@[23; 29) | ||
19 | PLACEHOLDER_PAT@[23; 24) | ||
20 | UNDERSCORE@[23; 24) | ||
21 | COLON@[24; 25) | ||
22 | WHITESPACE@[25; 26) | ||
23 | PATH_TYPE@[26; 29) | ||
24 | PATH@[26; 29) | ||
25 | PATH_SEGMENT@[26; 29) | ||
26 | NAME_REF@[26; 29) | ||
27 | IDENT@[26; 29) "u64" | ||
28 | R_PAREN@[29; 30) | ||
29 | SEMI@[30; 31) | ||
30 | WHITESPACE@[31; 32) | ||
31 | R_CURLY@[32; 33) | ||
32 | WHITESPACE@[33; 34) | ||
diff --git a/editors/code/package.json b/editors/code/package.json index 9433bd3d2..3e07032c7 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -94,6 +94,10 @@ | |||
94 | { | 94 | { |
95 | "command": "ra-lsp.run", | 95 | "command": "ra-lsp.run", |
96 | "title": "Rust Run" | 96 | "title": "Rust Run" |
97 | }, | ||
98 | { | ||
99 | "command": "ra-lsp.analyzerStatus", | ||
100 | "title": "Status of rust-analyzer (debug)" | ||
97 | } | 101 | } |
98 | ], | 102 | ], |
99 | "keybindings": [ | 103 | "keybindings": [ |
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts new file mode 100644 index 000000000..5c56b9c4c --- /dev/null +++ b/editors/code/src/commands/analyzer_status.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | import { Server } from '../server'; | ||
3 | |||
4 | // Shows status of rust-analyzer (for debugging) | ||
5 | export async function handle() { | ||
6 | const status = await Server.client.sendRequest<string>( | ||
7 | 'ra/analyzerStatus', | ||
8 | null | ||
9 | ); | ||
10 | const doc = await vscode.workspace.openTextDocument({ content: status }); | ||
11 | await vscode.window.showTextDocument(doc, vscode.ViewColumn.Two); | ||
12 | } | ||
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 33e2b34a2..f36c4b040 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import * as analyzerStatus from './analyzer_status'; | ||
1 | import * as applySourceChange from './apply_source_change'; | 2 | import * as applySourceChange from './apply_source_change'; |
2 | import * as extendSelection from './extend_selection'; | 3 | import * as extendSelection from './extend_selection'; |
3 | import * as joinLines from './join_lines'; | 4 | import * as joinLines from './join_lines'; |
@@ -8,6 +9,7 @@ import * as runnables from './runnables'; | |||
8 | import * as syntaxTree from './syntaxTree'; | 9 | import * as syntaxTree from './syntaxTree'; |
9 | 10 | ||
10 | export { | 11 | export { |
12 | analyzerStatus, | ||
11 | applySourceChange, | 13 | applySourceChange, |
12 | extendSelection, | 14 | extendSelection, |
13 | joinLines, | 15 | joinLines, |
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 0098c9454..288a852aa 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -45,6 +45,7 @@ export function activate(context: vscode.ExtensionContext) { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | // Commands are requests from vscode to the language server | 47 | // Commands are requests from vscode to the language server |
48 | registerCommand('ra-lsp.analyzerStatus', commands.analyzerStatus.handle); | ||
48 | registerCommand('ra-lsp.syntaxTree', commands.syntaxTree.handle); | 49 | registerCommand('ra-lsp.syntaxTree', commands.syntaxTree.handle); |
49 | registerCommand('ra-lsp.extendSelection', commands.extendSelection.handle); | 50 | registerCommand('ra-lsp.extendSelection', commands.extendSelection.handle); |
50 | registerCommand('ra-lsp.matchingBrace', commands.matchingBrace.handle); | 51 | registerCommand('ra-lsp.matchingBrace', commands.matchingBrace.handle); |