aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-13 14:07:05 +0100
committerAleksey Kladov <[email protected]>2018-08-13 14:07:05 +0100
commit7fc91f41d8bd948cef3085d7c0d0ec92d1b2bc53 (patch)
treed671181833c0af18fdfd167998cae1afbe759926 /crates/server/src
parent0568e76406fc4869152671a255c5e1efca6611a6 (diff)
Generalize query
Diffstat (limited to 'crates/server/src')
-rw-r--r--crates/server/src/main_loop/handlers.rs17
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};
8use libanalysis::{World}; 8use libanalysis::{World, Query};
9use libeditor; 9use libeditor;
10use libsyntax2::TextUnit; 10use libsyntax2::TextUnit;
11use serde_json::{to_value, from_value}; 11use 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(&params.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 {