diff options
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 4c14650c0..82675c0e4 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -8,7 +8,7 @@ | |||
8 | use ra_db::{FileId, FilePosition, Cancelable}; | 8 | use ra_db::{FileId, FilePosition, Cancelable}; |
9 | use ra_editor::find_node_at_offset; | 9 | use ra_editor::find_node_at_offset; |
10 | use ra_syntax::{ | 10 | use ra_syntax::{ |
11 | SmolStr, TextRange, SyntaxNodeRef, | 11 | SmolStr, TextRange, SyntaxNode, |
12 | ast::{self, AstNode, NameOwner}, | 12 | ast::{self, AstNode, NameOwner}, |
13 | }; | 13 | }; |
14 | 14 | ||
@@ -30,7 +30,7 @@ pub fn module_from_file_id(db: &impl HirDatabase, file_id: FileId) -> Cancelable | |||
30 | pub fn module_from_declaration( | 30 | pub fn module_from_declaration( |
31 | db: &impl HirDatabase, | 31 | db: &impl HirDatabase, |
32 | file_id: FileId, | 32 | file_id: FileId, |
33 | decl: ast::Module, | 33 | decl: &ast::Module, |
34 | ) -> Cancelable<Option<Module>> { | 34 | ) -> Cancelable<Option<Module>> { |
35 | let parent_module = module_from_file_id(db, file_id)?; | 35 | let parent_module = module_from_file_id(db, file_id)?; |
36 | let child_name = decl.name(); | 36 | let child_name = decl.name(); |
@@ -60,7 +60,7 @@ pub fn module_from_position( | |||
60 | fn module_from_inline( | 60 | fn module_from_inline( |
61 | db: &impl HirDatabase, | 61 | db: &impl HirDatabase, |
62 | file_id: FileId, | 62 | file_id: FileId, |
63 | module: ast::Module, | 63 | module: &ast::Module, |
64 | ) -> Cancelable<Option<Module>> { | 64 | ) -> Cancelable<Option<Module>> { |
65 | assert!(!module.has_semi()); | 65 | assert!(!module.has_semi()); |
66 | let file_id = file_id.into(); | 66 | let file_id = file_id.into(); |
@@ -77,7 +77,7 @@ fn module_from_inline( | |||
77 | pub fn module_from_child_node( | 77 | pub fn module_from_child_node( |
78 | db: &impl HirDatabase, | 78 | db: &impl HirDatabase, |
79 | file_id: FileId, | 79 | file_id: FileId, |
80 | child: SyntaxNodeRef, | 80 | child: &SyntaxNode, |
81 | ) -> Cancelable<Option<Module>> { | 81 | ) -> Cancelable<Option<Module>> { |
82 | if let Some(m) = child | 82 | if let Some(m) = child |
83 | .ancestors() | 83 | .ancestors() |
@@ -112,7 +112,7 @@ pub fn function_from_position( | |||
112 | pub fn function_from_source( | 112 | pub fn function_from_source( |
113 | db: &impl HirDatabase, | 113 | db: &impl HirDatabase, |
114 | file_id: FileId, | 114 | file_id: FileId, |
115 | fn_def: ast::FnDef, | 115 | fn_def: &ast::FnDef, |
116 | ) -> Cancelable<Option<Function>> { | 116 | ) -> Cancelable<Option<Function>> { |
117 | let module = ctry!(module_from_child_node(db, file_id, fn_def.syntax())?); | 117 | let module = ctry!(module_from_child_node(db, file_id, fn_def.syntax())?); |
118 | let res = function_from_module(db, &module, fn_def); | 118 | let res = function_from_module(db, &module, fn_def); |
@@ -122,7 +122,7 @@ pub fn function_from_source( | |||
122 | pub fn function_from_module( | 122 | pub fn function_from_module( |
123 | db: &impl HirDatabase, | 123 | db: &impl HirDatabase, |
124 | module: &Module, | 124 | module: &Module, |
125 | fn_def: ast::FnDef, | 125 | fn_def: &ast::FnDef, |
126 | ) -> Function { | 126 | ) -> Function { |
127 | let loc = module.def_id.loc(db); | 127 | let loc = module.def_id.loc(db); |
128 | let file_id = loc.source_item_id.file_id; | 128 | let file_id = loc.source_item_id.file_id; |
@@ -144,7 +144,7 @@ pub fn function_from_module( | |||
144 | pub fn function_from_child_node( | 144 | pub fn function_from_child_node( |
145 | db: &impl HirDatabase, | 145 | db: &impl HirDatabase, |
146 | file_id: FileId, | 146 | file_id: FileId, |
147 | node: SyntaxNodeRef, | 147 | node: &SyntaxNode, |
148 | ) -> Cancelable<Option<Function>> { | 148 | ) -> Cancelable<Option<Function>> { |
149 | let fn_def = ctry!(node.ancestors().find_map(ast::FnDef::cast)); | 149 | let fn_def = ctry!(node.ancestors().find_map(ast::FnDef::cast)); |
150 | function_from_source(db, file_id, fn_def) | 150 | function_from_source(db, file_id, fn_def) |
@@ -170,8 +170,7 @@ pub fn macro_symbols( | |||
170 | if let Some(exp) = db.expand_macro_invocation(macro_call_id) { | 170 | if let Some(exp) = db.expand_macro_invocation(macro_call_id) { |
171 | let loc = macro_call_id.loc(db); | 171 | let loc = macro_call_id.loc(db); |
172 | let syntax = db.file_item(loc.source_item_id); | 172 | let syntax = db.file_item(loc.source_item_id); |
173 | let syntax = syntax.borrowed(); | 173 | let macro_call = ast::MacroCall::cast(&syntax).unwrap(); |
174 | let macro_call = ast::MacroCall::cast(syntax).unwrap(); | ||
175 | let off = macro_call.token_tree().unwrap().syntax().range().start(); | 174 | let off = macro_call.token_tree().unwrap().syntax().range().start(); |
176 | let file = exp.file(); | 175 | let file = exp.file(); |
177 | for trait_def in file.syntax().descendants().filter_map(ast::TraitDef::cast) { | 176 | for trait_def in file.syntax().descendants().filter_map(ast::TraitDef::cast) { |