From 998f2ae7627053a9363a05a1ab79359882dce39f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 22:02:41 +0300 Subject: remove job tokens --- crates/ra_analysis/src/imp.rs | 16 ++++++------- crates/ra_analysis/src/lib.rs | 44 ++++++++++++++++------------------ crates/ra_analysis/src/symbol_index.rs | 5 ++-- 3 files changed, 30 insertions(+), 35 deletions(-) (limited to 'crates/ra_analysis') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 3a135ef13..4cfb681d8 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -148,14 +148,14 @@ impl AnalysisImpl { pub fn file_line_index(&self, file_id: FileId) -> Arc { self.root(file_id).lines(file_id) } - pub fn world_symbols(&self, query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { + pub fn world_symbols(&self, query: Query) -> Vec<(FileId, FileSymbol)> { let mut buf = Vec::new(); if query.libs { self.data.libs.iter().for_each(|it| it.symbols(&mut buf)); } else { self.data.root.symbols(&mut buf); } - query.search(&buf, token) + query.search(&buf) } pub fn parent_module(&self, file_id: FileId) -> Cancelable> { let root = self.root(file_id); @@ -205,7 +205,6 @@ impl AnalysisImpl { &self, file_id: FileId, offset: TextUnit, - token: &JobToken, ) -> Vec<(FileId, FileSymbol)> { let root = self.root(file_id); let module_tree = root.module_tree(); @@ -227,7 +226,7 @@ impl AnalysisImpl { return vec; } else { // If that fails try the index based approach. - return self.index_resolve(name_ref, token); + return self.index_resolve(name_ref); } } if let Some(name) = find_node_at_offset::(syntax, offset) { @@ -258,7 +257,7 @@ impl AnalysisImpl { vec![] } - pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit, _token: &JobToken) -> Vec<(FileId, TextRange)> { + pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> { let root = self.root(file_id); let file = root.syntax(file_id); let syntax = file.syntax(); @@ -380,7 +379,6 @@ impl AnalysisImpl { &self, file_id: FileId, offset: TextUnit, - token: &JobToken, ) -> Option<(FnDescriptor, Option)> { let root = self.root(file_id); let file = root.syntax(file_id); @@ -391,7 +389,7 @@ impl AnalysisImpl { let name_ref = calling_node.name_ref()?; // Resolve the function's NameRef (NOTE: this isn't entirely accurate). - let file_symbols = self.index_resolve(name_ref, token); + let file_symbols = self.index_resolve(name_ref); for (_, fs) in file_symbols { if fs.kind == FN_DEF { if let Some(fn_def) = find_node_at_offset(syntax, fs.node_range.start()) { @@ -442,12 +440,12 @@ impl AnalysisImpl { None } - fn index_resolve(&self, name_ref: ast::NameRef, token: &JobToken) -> Vec<(FileId, FileSymbol)> { + fn index_resolve(&self, name_ref: ast::NameRef) -> Vec<(FileId, FileSymbol)> { let name = name_ref.text(); let mut query = Query::new(name.to_string()); query.exact(); query.limit(4); - self.world_symbols(query, token) + self.world_symbols(query) } fn resolve_module( diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 988a45b46..7e9798c29 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -219,47 +219,46 @@ impl Analysis { let file = self.imp.file_syntax(file_id); ra_editor::file_structure(&file) } - pub fn symbol_search(&self, query: Query, token: &JobToken) -> Vec<(FileId, FileSymbol)> { - self.imp.world_symbols(query, token) + pub fn symbol_search(&self, query: Query) -> Vec<(FileId, FileSymbol)> { + self.imp.world_symbols(query) } pub fn approximately_resolve_symbol( &self, file_id: FileId, - offset: TextUnit, - token: &JobToken, + offset: TextUnit ) -> Vec<(FileId, FileSymbol)> { self.imp - .approximately_resolve_symbol(file_id, offset, token) + .approximately_resolve_symbol(file_id, offset) } - pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit, token: &JobToken) -> Vec<(FileId, TextRange)> { - self.imp.find_all_refs(file_id, offset, token) + pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit, ) -> Vec<(FileId, TextRange)> { + self.imp.find_all_refs(file_id, offset) } pub fn parent_module(&self, file_id: FileId) -> Cancelable> { self.imp.parent_module(file_id) } - pub fn crate_for(&self, file_id: FileId) -> Vec { - self.imp.crate_for(file_id) + pub fn crate_for(&self, file_id: FileId) -> Cancelable> { + Ok(self.imp.crate_for(file_id)) } - pub fn crate_root(&self, crate_id: CrateId) -> FileId { - self.imp.crate_root(crate_id) + pub fn crate_root(&self, crate_id: CrateId) -> Cancelable { + Ok(self.imp.crate_root(crate_id)) } - pub fn runnables(&self, file_id: FileId) -> Vec { + pub fn runnables(&self, file_id: FileId) -> Cancelable> { let file = self.imp.file_syntax(file_id); - ra_editor::runnables(&file) + Ok(ra_editor::runnables(&file)) } - pub fn highlight(&self, file_id: FileId) -> Vec { + pub fn highlight(&self, file_id: FileId) -> Cancelable> { let file = self.imp.file_syntax(file_id); - ra_editor::highlight(&file) + Ok(ra_editor::highlight(&file)) } - pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Option> { + pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Cancelable>> { let file = self.imp.file_syntax(file_id); - ra_editor::scope_completion(&file, offset) + Ok(ra_editor::scope_completion(&file, offset)) } - pub fn assists(&self, file_id: FileId, range: TextRange) -> Vec { - self.imp.assists(file_id, range) + pub fn assists(&self, file_id: FileId, range: TextRange) -> Cancelable> { + Ok(self.imp.assists(file_id, range)) } - pub fn diagnostics(&self, file_id: FileId) -> Vec { - self.imp.diagnostics(file_id) + pub fn diagnostics(&self, file_id: FileId) -> Cancelable> { + Ok(self.imp.diagnostics(file_id)) } pub fn folding_ranges(&self, file_id: FileId) -> Vec { let file = self.imp.file_syntax(file_id); @@ -270,9 +269,8 @@ impl Analysis { &self, file_id: FileId, offset: TextUnit, - token: &JobToken, ) -> Option<(FnDescriptor, Option)> { - self.imp.resolve_callable(file_id, offset, token) + self.imp.resolve_callable(file_id, offset) } } diff --git a/crates/ra_analysis/src/symbol_index.rs b/crates/ra_analysis/src/symbol_index.rs index 51eef8170..19f9ea47d 100644 --- a/crates/ra_analysis/src/symbol_index.rs +++ b/crates/ra_analysis/src/symbol_index.rs @@ -1,4 +1,4 @@ -use crate::{FileId, JobToken, Query}; +use crate::{FileId, Query}; use fst::{self, Streamer}; use ra_editor::{file_symbols, FileSymbol}; use ra_syntax::{ @@ -59,7 +59,6 @@ impl Query { pub(crate) fn search( self, indices: &[Arc], - token: &JobToken, ) -> Vec<(FileId, FileSymbol)> { let mut op = fst::map::OpBuilder::new(); for file_symbols in indices.iter() { @@ -69,7 +68,7 @@ impl Query { let mut stream = op.union(); let mut res = Vec::new(); while let Some((_, indexed_values)) = stream.next() { - if res.len() >= self.limit || token.is_canceled() { + if res.len() >= self.limit { break; } for indexed_value in indexed_values { -- cgit v1.2.3