aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-15 15:13:11 +0000
committerAleksey Kladov <[email protected]>2019-01-15 15:13:49 +0000
commit11f3c8afb23d67acde8cc7642aea3a2ca06a2361 (patch)
tree324f517c3e8cc42be6f3e8349c55683695ea4558 /crates/ra_ide_api
parenta36b2cf377a90cf13bb097e57878b8384d30c53a (diff)
remove Cancelable from source binders
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/completion/completion_context.rs2
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs7
-rw-r--r--crates/ra_ide_api/src/hover.rs2
-rw-r--r--crates/ra_ide_api/src/imp.rs8
-rw-r--r--crates/ra_ide_api/src/parent_module.rs2
-rw-r--r--crates/ra_ide_api/src/runnables.rs3
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs2
7 files changed, 12 insertions, 14 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
index 113f6c070..f5b5ed689 100644
--- a/crates/ra_ide_api/src/completion/completion_context.rs
+++ b/crates/ra_ide_api/src/completion/completion_context.rs
@@ -42,7 +42,7 @@ impl<'a> CompletionContext<'a> {
42 original_file: &'a SourceFile, 42 original_file: &'a SourceFile,
43 position: FilePosition, 43 position: FilePosition,
44 ) -> Cancelable<Option<CompletionContext<'a>>> { 44 ) -> Cancelable<Option<CompletionContext<'a>>> {
45 let module = source_binder::module_from_position(db, position)?; 45 let module = source_binder::module_from_position(db, position);
46 let leaf = 46 let leaf =
47 ctry!(find_leaf_at_offset(original_file.syntax(), position.offset).left_biased()); 47 ctry!(find_leaf_at_offset(original_file.syntax(), position.offset).left_biased());
48 let mut ctx = CompletionContext { 48 let mut ctx = CompletionContext {
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index 332a2fb8d..f759f7339 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -48,7 +48,7 @@ pub(crate) fn reference_definition(
48) -> Cancelable<ReferenceResult> { 48) -> Cancelable<ReferenceResult> {
49 use self::ReferenceResult::*; 49 use self::ReferenceResult::*;
50 if let Some(function) = 50 if let Some(function) =
51 hir::source_binder::function_from_child_node(db, file_id, name_ref.syntax())? 51 hir::source_binder::function_from_child_node(db, file_id, name_ref.syntax())
52 { 52 {
53 let scope = function.scopes(db)?; 53 let scope = function.scopes(db)?;
54 // First try to resolve the symbol locally 54 // First try to resolve the symbol locally
@@ -77,8 +77,7 @@ pub(crate) fn reference_definition(
77 } 77 }
78 } 78 }
79 // Then try module name resolution 79 // Then try module name resolution
80 if let Some(module) = 80 if let Some(module) = hir::source_binder::module_from_child_node(db, file_id, name_ref.syntax())
81 hir::source_binder::module_from_child_node(db, file_id, name_ref.syntax())?
82 { 81 {
83 if let Some(path) = name_ref 82 if let Some(path) = name_ref
84 .syntax() 83 .syntax()
@@ -111,7 +110,7 @@ fn name_definition(
111 if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { 110 if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) {
112 if module.has_semi() { 111 if module.has_semi() {
113 if let Some(child_module) = 112 if let Some(child_module) =
114 hir::source_binder::module_from_declaration(db, file_id, module)? 113 hir::source_binder::module_from_declaration(db, file_id, module)
115 { 114 {
116 let nav = NavigationTarget::from_module(db, child_module)?; 115 let nav = NavigationTarget::from_module(db, child_module)?;
117 return Ok(Some(vec![nav])); 116 return Ok(Some(vec![nav]));
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 107b23833..26f3ced70 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -72,7 +72,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Cancelable<Option
72 db, 72 db,
73 frange.file_id, 73 frange.file_id,
74 parent_fn 74 parent_fn
75 )?); 75 ));
76 let infer = function.infer(db)?; 76 let infer = function.infer(db)?;
77 let syntax_mapping = function.body_syntax_mapping(db)?; 77 let syntax_mapping = function.body_syntax_mapping(db)?;
78 if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) { 78 if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) {
diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs
index ba4aa0fd5..98b507ab3 100644
--- a/crates/ra_ide_api/src/imp.rs
+++ b/crates/ra_ide_api/src/imp.rs
@@ -100,7 +100,7 @@ impl db::RootDatabase {
100impl db::RootDatabase { 100impl db::RootDatabase {
101 /// Returns `Vec` for the same reason as `parent_module` 101 /// Returns `Vec` for the same reason as `parent_module`
102 pub(crate) fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { 102 pub(crate) fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> {
103 let module = match source_binder::module_from_file_id(self, file_id)? { 103 let module = match source_binder::module_from_file_id(self, file_id) {
104 Some(it) => it, 104 Some(it) => it,
105 None => return Ok(Vec::new()), 105 None => return Ok(Vec::new()),
106 }; 106 };
@@ -147,7 +147,7 @@ impl db::RootDatabase {
147 db, 147 db,
148 position.file_id, 148 position.file_id,
149 binding.syntax(), 149 binding.syntax(),
150 )?); 150 ));
151 return Ok(Some((binding, descr))); 151 return Ok(Some((binding, descr)));
152 }; 152 };
153 let name_ref = ctry!(find_node_at_offset::<ast::NameRef>(syntax, position.offset)); 153 let name_ref = ctry!(find_node_at_offset::<ast::NameRef>(syntax, position.offset));
@@ -155,7 +155,7 @@ impl db::RootDatabase {
155 db, 155 db,
156 position.file_id, 156 position.file_id,
157 name_ref.syntax(), 157 name_ref.syntax(),
158 )?); 158 ));
159 let scope = descr.scopes(db)?; 159 let scope = descr.scopes(db)?;
160 let resolved = ctry!(scope.resolve_local_name(name_ref)); 160 let resolved = ctry!(scope.resolve_local_name(name_ref));
161 let resolved = resolved.ptr().resolve(source_file); 161 let resolved = resolved.ptr().resolve(source_file);
@@ -179,7 +179,7 @@ impl db::RootDatabase {
179 fix: d.fix.map(|fix| SourceChange::from_local_edit(file_id, fix)), 179 fix: d.fix.map(|fix| SourceChange::from_local_edit(file_id, fix)),
180 }) 180 })
181 .collect::<Vec<_>>(); 181 .collect::<Vec<_>>();
182 if let Some(m) = source_binder::module_from_file_id(self, file_id)? { 182 if let Some(m) = source_binder::module_from_file_id(self, file_id) {
183 for (name_node, problem) in m.problems(self)? { 183 for (name_node, problem) in m.problems(self)? {
184 let source_root = self.file_source_root(file_id); 184 let source_root = self.file_source_root(file_id);
185 let diag = match problem { 185 let diag = match problem {
diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide_api/src/parent_module.rs
index 675042a6c..451304739 100644
--- a/crates/ra_ide_api/src/parent_module.rs
+++ b/crates/ra_ide_api/src/parent_module.rs
@@ -8,7 +8,7 @@ pub(crate) fn parent_module(
8 db: &RootDatabase, 8 db: &RootDatabase,
9 position: FilePosition, 9 position: FilePosition,
10) -> Cancelable<Vec<NavigationTarget>> { 10) -> Cancelable<Vec<NavigationTarget>> {
11 let module = match hir::source_binder::module_from_position(db, position)? { 11 let module = match hir::source_binder::module_from_position(db, position) {
12 None => return Ok(Vec::new()), 12 None => return Ok(Vec::new()),
13 Some(it) => it, 13 Some(it) => it,
14 }; 14 };
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs
index f1de28094..9fa0f79a6 100644
--- a/crates/ra_ide_api/src/runnables.rs
+++ b/crates/ra_ide_api/src/runnables.rs
@@ -75,8 +75,7 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: &ast::Module) -> Opt
75 return None; 75 return None;
76 } 76 }
77 let range = module.syntax().range(); 77 let range = module.syntax().range();
78 let module = 78 let module = hir::source_binder::module_from_child_node(db, file_id, module.syntax())?;
79 hir::source_binder::module_from_child_node(db, file_id, module.syntax()).ok()??;
80 79
81 // FIXME: thread cancellation instead of `.ok`ing 80 // FIXME: thread cancellation instead of `.ok`ing
82 let path = module 81 let path = module
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs
index b7a3a3550..e7827fdc9 100644
--- a/crates/ra_ide_api/src/symbol_index.rs
+++ b/crates/ra_ide_api/src/symbol_index.rs
@@ -63,7 +63,7 @@ fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable<Arc<Sy
63 .map(move |(name, ptr)| FileSymbol { name, ptr, file_id }) 63 .map(move |(name, ptr)| FileSymbol { name, ptr, file_id })
64 .collect::<Vec<_>>(); 64 .collect::<Vec<_>>();
65 65
66 for (name, text_range) in hir::source_binder::macro_symbols(db, file_id)? { 66 for (name, text_range) in hir::source_binder::macro_symbols(db, file_id) {
67 let node = find_covering_node(source_file.syntax(), text_range); 67 let node = find_covering_node(source_file.syntax(), text_range);
68 let ptr = LocalSyntaxPtr::new(node); 68 let ptr = LocalSyntaxPtr::new(node);
69 symbols.push(FileSymbol { file_id, name, ptr }) 69 symbols.push(FileSymbol { file_id, name, ptr })