aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-20 10:24:23 +0000
committerAleksey Kladov <[email protected]>2019-12-20 10:52:17 +0000
commitd316ba9a136833c64ba066feb62cf553dd4b3a58 (patch)
tree5402667f6508693b68acb7e58b95a25d272b93f9 /crates/ra_hir
parenta04177f135be89ddbf1788c6f747c26812e90438 (diff)
Handle nested declrations in from_source
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/from_source.rs23
1 files changed, 16 insertions, 7 deletions
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index b3ed88b6b..4fd7c7573 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
216} 216}
217 217
218fn _analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option<DynMap> { 218fn _analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option<DynMap> {
219 // FIXME: this doesn't try to handle nested declarations
220 for container in src.value.ancestors().skip(1) { 219 for container in src.value.ancestors().skip(1) {
221 let res = match_ast! { 220 let res = match_ast! {
222 match container { 221 match container {
223 ast::TraitDef(it) => { 222 ast::TraitDef(it) => {
224 let c = Trait::from_source(db, src.with_value(it))?; 223 let def = Trait::from_source(db, src.with_value(it))?;
225 c.id.child_by_source(db) 224 def.id.child_by_source(db)
226 }, 225 },
227 ast::ImplBlock(it) => { 226 ast::ImplBlock(it) => {
228 let c = ImplBlock::from_source(db, src.with_value(it))?; 227 let def = ImplBlock::from_source(db, src.with_value(it))?;
229 c.id.child_by_source(db) 228 def.id.child_by_source(db)
230 }, 229 },
231 ast::FnDef(it) => { 230 ast::FnDef(it) => {
232 let f = Function::from_source(db, src.with_value(it))?; 231 let def = Function::from_source(db, src.with_value(it))?;
233 DefWithBodyId::from(f.id) 232 DefWithBodyId::from(def.id)
233 .child_by_source(db)
234 },
235 ast::StaticDef(it) => {
236 let def = Static::from_source(db, src.with_value(it))?;
237 DefWithBodyId::from(def.id)
238 .child_by_source(db)
239 },
240 ast::ConstDef(it) => {
241 let def = Const::from_source(db, src.with_value(it))?;
242 DefWithBodyId::from(def.id)
234 .child_by_source(db) 243 .child_by_source(db)
235 }, 244 },
236 _ => { continue }, 245 _ => { continue },