aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/from_source.rs5
-rw-r--r--crates/ra_hir/src/source_binder.rs15
2 files changed, 9 insertions, 11 deletions
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index ec56dfa6a..79152a57c 100644
--- a/crates/ra_hir/src/from_source.rs
+++ b/crates/ra_hir/src/from_source.rs
@@ -196,9 +196,8 @@ where
196 N: AstNode, 196 N: AstNode,
197 DEF: AstItemDef<N>, 197 DEF: AstItemDef<N>,
198{ 198{
199 let module_src = 199 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax()));
200 crate::ModuleSource::from_child_node(db, src.file_id.original_file(db), &src.ast.syntax()); 200 let module = Module::from_definition(db, Source::new(src.file_id, module_src))?;
201 let module = Module::from_definition(db, Source { file_id: src.file_id, ast: module_src })?;
202 let ctx = LocationCtx::new(db, module.id, src.file_id); 201 let ctx = LocationCtx::new(db, module.id, src.file_id);
203 Some(DEF::from_ast(ctx, &src.ast)) 202 Some(DEF::from_ast(ctx, &src.ast))
204} 203}
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 662d3f880..f08827ed3 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -56,7 +56,7 @@ fn try_get_resolver_for_node(
56 }, 56 },
57 _ => { 57 _ => {
58 if node.kind() == FN_DEF || node.kind() == CONST_DEF || node.kind() == STATIC_DEF { 58 if node.kind() == FN_DEF || node.kind() == CONST_DEF || node.kind() == STATIC_DEF {
59 Some(def_with_body_from_child_node(db, file_id, node)?.resolver(db)) 59 Some(def_with_body_from_child_node(db, Source::new(file_id.into(), node))?.resolver(db))
60 } else { 60 } else {
61 // FIXME add missing cases 61 // FIXME add missing cases
62 None 62 None
@@ -68,14 +68,13 @@ fn try_get_resolver_for_node(
68 68
69fn def_with_body_from_child_node( 69fn def_with_body_from_child_node(
70 db: &impl HirDatabase, 70 db: &impl HirDatabase,
71 file_id: FileId, 71 child: Source<&SyntaxNode>,
72 node: &SyntaxNode,
73) -> Option<DefWithBody> { 72) -> Option<DefWithBody> {
74 let src = crate::ModuleSource::from_child_node(db, file_id, node); 73 let module_source = crate::ModuleSource::from_child_node(db, child);
75 let module = Module::from_definition(db, crate::Source { file_id: file_id.into(), ast: src })?; 74 let module = Module::from_definition(db, Source::new(child.file_id, module_source))?;
76 let ctx = LocationCtx::new(db, module.id, file_id.into()); 75 let ctx = LocationCtx::new(db, module.id, child.file_id);
77 76
78 node.ancestors().find_map(|node| { 77 child.ast.ancestors().find_map(|node| {
79 match_ast! { 78 match_ast! {
80 match node { 79 match node {
81 ast::FnDef(def) => { Some(Function {id: ctx.to_def(&def) }.into()) }, 80 ast::FnDef(def) => { Some(Function {id: ctx.to_def(&def) }.into()) },
@@ -142,7 +141,7 @@ impl SourceAnalyzer {
142 node: &SyntaxNode, 141 node: &SyntaxNode,
143 offset: Option<TextUnit>, 142 offset: Option<TextUnit>,
144 ) -> SourceAnalyzer { 143 ) -> SourceAnalyzer {
145 let def_with_body = def_with_body_from_child_node(db, file_id, node); 144 let def_with_body = def_with_body_from_child_node(db, Source::new(file_id.into(), node));
146 if let Some(def) = def_with_body { 145 if let Some(def) = def_with_body {
147 let source_map = def.body_source_map(db); 146 let source_map = def.body_source_map(db);
148 let scopes = def.expr_scopes(db); 147 let scopes = def.expr_scopes(db);