From d316ba9a136833c64ba066feb62cf553dd4b3a58 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 20 Dec 2019 11:24:23 +0100 Subject: [PATCH] Handle nested declrations in from_source --- crates/ra_hir/src/from_source.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index b3ed88b6b6..4fd7c75736 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs @@ -216,21 +216,30 @@ fn analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> DynMap } fn _analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option { - // FIXME: this doesn't try to handle nested declarations for container in src.value.ancestors().skip(1) { let res = match_ast! { match container { ast::TraitDef(it) => { - let c = Trait::from_source(db, src.with_value(it))?; - c.id.child_by_source(db) + let def = Trait::from_source(db, src.with_value(it))?; + def.id.child_by_source(db) }, ast::ImplBlock(it) => { - let c = ImplBlock::from_source(db, src.with_value(it))?; - c.id.child_by_source(db) + let def = ImplBlock::from_source(db, src.with_value(it))?; + def.id.child_by_source(db) }, ast::FnDef(it) => { - let f = Function::from_source(db, src.with_value(it))?; - DefWithBodyId::from(f.id) + let def = Function::from_source(db, src.with_value(it))?; + DefWithBodyId::from(def.id) + .child_by_source(db) + }, + ast::StaticDef(it) => { + let def = Static::from_source(db, src.with_value(it))?; + DefWithBodyId::from(def.id) + .child_by_source(db) + }, + ast::ConstDef(it) => { + let def = Const::from_source(db, src.with_value(it))?; + DefWithBodyId::from(def.id) .child_by_source(db) }, _ => { continue },