diff options
author | Aleksey Kladov <[email protected]> | 2018-08-13 14:07:05 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-13 14:07:05 +0100 |
commit | 7fc91f41d8bd948cef3085d7c0d0ec92d1b2bc53 (patch) | |
tree | d671181833c0af18fdfd167998cae1afbe759926 /crates/server/src/main_loop | |
parent | 0568e76406fc4869152671a255c5e1efca6611a6 (diff) |
Generalize query
Diffstat (limited to 'crates/server/src/main_loop')
-rw-r--r-- | crates/server/src/main_loop/handlers.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/server/src/main_loop/handlers.rs b/crates/server/src/main_loop/handlers.rs index bd0e6825b..f51909280 100644 --- a/crates/server/src/main_loop/handlers.rs +++ b/crates/server/src/main_loop/handlers.rs | |||
@@ -5,7 +5,7 @@ use languageserver_types::{ | |||
5 | Command, TextDocumentIdentifier, WorkspaceEdit, | 5 | Command, TextDocumentIdentifier, WorkspaceEdit, |
6 | SymbolInformation, Location, | 6 | SymbolInformation, Location, |
7 | }; | 7 | }; |
8 | use libanalysis::{World}; | 8 | use libanalysis::{World, Query}; |
9 | use libeditor; | 9 | use libeditor; |
10 | use libsyntax2::TextUnit; | 10 | use libsyntax2::TextUnit; |
11 | use serde_json::{to_value, from_value}; | 11 | use serde_json::{to_value, from_value}; |
@@ -100,7 +100,20 @@ pub fn handle_workspace_symbol( | |||
100 | params: req::WorkspaceSymbolParams, | 100 | params: req::WorkspaceSymbolParams, |
101 | ) -> Result<Option<Vec<SymbolInformation>>> { | 101 | ) -> Result<Option<Vec<SymbolInformation>>> { |
102 | let mut acc = Vec::new(); | 102 | let mut acc = Vec::new(); |
103 | for (path, symbol) in world.world_symbols(¶ms.query).take(128) { | 103 | |
104 | let query = { | ||
105 | let all_symbols = params.query.contains("#"); | ||
106 | let query: String = params.query.chars() | ||
107 | .filter(|&c| c != '#') | ||
108 | .collect(); | ||
109 | let mut q = Query::new(query); | ||
110 | if !all_symbols { | ||
111 | q.only_types(); | ||
112 | } | ||
113 | q | ||
114 | }; | ||
115 | |||
116 | for (path, symbol) in world.world_symbols(query).take(128) { | ||
104 | let line_index = world.file_line_index(path)?; | 117 | let line_index = world.file_line_index(path)?; |
105 | 118 | ||
106 | let info = SymbolInformation { | 119 | let info = SymbolInformation { |