mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Support generic function in generate_function
assist
This commit is contained in:
parent
32955c30cd
commit
3edde6fcc1
5 changed files with 888 additions and 45 deletions
|
@ -2165,6 +2165,16 @@ impl AsAssocItem for ModuleDef {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl AsAssocItem for DefWithBody {
|
||||
fn as_assoc_item(self, db: &dyn HirDatabase) -> Option<AssocItem> {
|
||||
match self {
|
||||
DefWithBody::Function(it) => it.as_assoc_item(db),
|
||||
DefWithBody::Const(it) => it.as_assoc_item(db),
|
||||
DefWithBody::Static(_) | DefWithBody::Variant(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn as_assoc_item<ID, DEF, CTOR, AST>(db: &dyn HirDatabase, ctor: CTOR, id: ID) -> Option<AssocItem>
|
||||
where
|
||||
ID: Lookup<Data = AssocItemLoc<AST>>,
|
||||
|
@ -2560,6 +2570,14 @@ impl GenericParam {
|
|||
GenericParam::LifetimeParam(it) => it.name(db),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parent(self) -> GenericDef {
|
||||
match self {
|
||||
GenericParam::TypeParam(it) => it.id.parent().into(),
|
||||
GenericParam::ConstParam(it) => it.id.parent().into(),
|
||||
GenericParam::LifetimeParam(it) => it.id.parent.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue