Move traits to the new loc

This commit is contained in:
Aleksey Kladov 2019-12-12 14:34:03 +01:00
parent 7b0644d81e
commit 82e9b24558
16 changed files with 70 additions and 35 deletions

View file

@ -44,8 +44,10 @@ impl FromSource for Enum {
impl FromSource for Trait {
type Ast = ast::TraitDef;
fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
let id = from_source(db, src)?;
Some(Trait { id })
// XXX: use `.parent()` to avoid finding ourselves
let parent = src.value.syntax().parent()?;
let container = Container::find(db, src.with_value(parent).as_ref())?;
container.child_by_source(db)[keys::TRAIT].get(&src).copied().map(Trait::from)
}
}
impl FromSource for Function {