mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Generalize query
This commit is contained in:
parent
0568e76406
commit
7fc91f41d8
5 changed files with 79 additions and 110 deletions
|
@ -5,7 +5,7 @@ use languageserver_types::{
|
|||
Command, TextDocumentIdentifier, WorkspaceEdit,
|
||||
SymbolInformation, Location,
|
||||
};
|
||||
use libanalysis::{World};
|
||||
use libanalysis::{World, Query};
|
||||
use libeditor;
|
||||
use libsyntax2::TextUnit;
|
||||
use serde_json::{to_value, from_value};
|
||||
|
@ -100,7 +100,20 @@ pub fn handle_workspace_symbol(
|
|||
params: req::WorkspaceSymbolParams,
|
||||
) -> Result<Option<Vec<SymbolInformation>>> {
|
||||
let mut acc = Vec::new();
|
||||
for (path, symbol) in world.world_symbols(¶ms.query).take(128) {
|
||||
|
||||
let query = {
|
||||
let all_symbols = params.query.contains("#");
|
||||
let query: String = params.query.chars()
|
||||
.filter(|&c| c != '#')
|
||||
.collect();
|
||||
let mut q = Query::new(query);
|
||||
if !all_symbols {
|
||||
q.only_types();
|
||||
}
|
||||
q
|
||||
};
|
||||
|
||||
for (path, symbol) in world.world_symbols(query).take(128) {
|
||||
let line_index = world.file_line_index(path)?;
|
||||
|
||||
let info = SymbolInformation {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue