diff options
author | Aleksey Kladov <[email protected]> | 2019-01-22 21:15:03 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-22 22:24:53 +0000 |
commit | 0ba7e2eaebf335dbc31b5d6dbc9c354737c7fe54 (patch) | |
tree | 9adf247619c28ed5e7cdeee118897231d8f2320c /crates/ra_lsp_server | |
parent | e08df3219d7a06b1e38c632e7f13967fb540769b (diff) |
ad status command
Diffstat (limited to 'crates/ra_lsp_server')
-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 |
4 files changed, 28 insertions, 0 deletions
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 | } |