mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Add basic infrastructure for assoc type projection
This commit is contained in:
parent
6f946f9656
commit
49489dc20c
9 changed files with 190 additions and 21 deletions
|
@ -779,6 +779,19 @@ impl Trait {
|
|||
self.trait_data(db).items().to_vec()
|
||||
}
|
||||
|
||||
pub fn associated_type_by_name(self, db: &impl DefDatabase, name: Name) -> Option<TypeAlias> {
|
||||
let trait_data = self.trait_data(db);
|
||||
trait_data
|
||||
.items()
|
||||
.iter()
|
||||
.filter_map(|item| match item {
|
||||
TraitItem::TypeAlias(t) => Some(*t),
|
||||
_ => None,
|
||||
})
|
||||
.filter(|t| t.name(db) == name)
|
||||
.next()
|
||||
}
|
||||
|
||||
pub(crate) fn trait_data(self, db: &impl DefDatabase) -> Arc<TraitData> {
|
||||
db.trait_data(self)
|
||||
}
|
||||
|
@ -831,8 +844,12 @@ impl TypeAlias {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn type_ref(self, db: &impl DefDatabase) -> Arc<TypeRef> {
|
||||
db.type_alias_ref(self)
|
||||
pub fn type_ref(self, db: &impl DefDatabase) -> Option<TypeRef> {
|
||||
db.type_alias_data(self).type_ref.clone()
|
||||
}
|
||||
|
||||
pub fn name(self, db: &impl DefDatabase) -> Name {
|
||||
db.type_alias_data(self).name.clone()
|
||||
}
|
||||
|
||||
/// Builds a resolver for the type references in this type alias.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue