mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Handle nested declrations in from_source
This commit is contained in:
parent
a04177f135
commit
d316ba9a13
1 changed files with 16 additions and 7 deletions
|
@ -216,21 +216,30 @@ fn analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> DynMap
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option<DynMap> {
|
fn _analyze_container(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option<DynMap> {
|
||||||
// FIXME: this doesn't try to handle nested declarations
|
|
||||||
for container in src.value.ancestors().skip(1) {
|
for container in src.value.ancestors().skip(1) {
|
||||||
let res = match_ast! {
|
let res = match_ast! {
|
||||||
match container {
|
match container {
|
||||||
ast::TraitDef(it) => {
|
ast::TraitDef(it) => {
|
||||||
let c = Trait::from_source(db, src.with_value(it))?;
|
let def = Trait::from_source(db, src.with_value(it))?;
|
||||||
c.id.child_by_source(db)
|
def.id.child_by_source(db)
|
||||||
},
|
},
|
||||||
ast::ImplBlock(it) => {
|
ast::ImplBlock(it) => {
|
||||||
let c = ImplBlock::from_source(db, src.with_value(it))?;
|
let def = ImplBlock::from_source(db, src.with_value(it))?;
|
||||||
c.id.child_by_source(db)
|
def.id.child_by_source(db)
|
||||||
},
|
},
|
||||||
ast::FnDef(it) => {
|
ast::FnDef(it) => {
|
||||||
let f = Function::from_source(db, src.with_value(it))?;
|
let def = Function::from_source(db, src.with_value(it))?;
|
||||||
DefWithBodyId::from(f.id)
|
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)
|
.child_by_source(db)
|
||||||
},
|
},
|
||||||
_ => { continue },
|
_ => { continue },
|
||||||
|
|
Loading…
Reference in a new issue