mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 11:24:24 +00:00
internal: Flatten Definition::ModuleDef
variant
This commit is contained in:
parent
f724c84e7d
commit
7776aad166
32 changed files with 709 additions and 702 deletions
|
@ -242,7 +242,7 @@ pub(super) fn keyword(
|
|||
let docs = doc_owner.attrs(sema.db).docs()?;
|
||||
let markup = process_markup(
|
||||
sema.db,
|
||||
Definition::ModuleDef(doc_owner.into()),
|
||||
Definition::Module(doc_owner),
|
||||
&markup(Some(docs.into()), token.text().into(), None)?,
|
||||
config,
|
||||
);
|
||||
|
@ -311,14 +311,11 @@ fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String>
|
|||
match def {
|
||||
Definition::Field(f) => Some(f.parent_def(db).name(db)),
|
||||
Definition::Local(l) => l.parent(db).name(db),
|
||||
Definition::ModuleDef(md) => match md {
|
||||
hir::ModuleDef::Function(f) => match f.as_assoc_item(db)?.container(db) {
|
||||
hir::AssocItemContainer::Trait(t) => Some(t.name(db)),
|
||||
hir::AssocItemContainer::Impl(i) => i.self_ty(db).as_adt().map(|adt| adt.name(db)),
|
||||
},
|
||||
hir::ModuleDef::Variant(e) => Some(e.parent_enum(db).name(db)),
|
||||
_ => None,
|
||||
Definition::Function(f) => match f.as_assoc_item(db)?.container(db) {
|
||||
hir::AssocItemContainer::Trait(t) => Some(t.name(db)),
|
||||
hir::AssocItemContainer::Impl(i) => i.self_ty(db).as_adt().map(|adt| adt.name(db)),
|
||||
},
|
||||
Definition::Variant(e) => Some(e.parent_enum(db).name(db)),
|
||||
_ => None,
|
||||
}
|
||||
.map(|name| name.to_string())
|
||||
|
@ -351,21 +348,19 @@ pub(super) fn definition(
|
|||
it.attrs(db).docs(),
|
||||
),
|
||||
Definition::Field(def) => label_and_docs(db, def),
|
||||
Definition::ModuleDef(it) => match it {
|
||||
hir::ModuleDef::Module(it) => label_and_docs(db, it),
|
||||
hir::ModuleDef::Function(it) => label_and_docs(db, it),
|
||||
hir::ModuleDef::Adt(it) => label_and_docs(db, it),
|
||||
hir::ModuleDef::Variant(it) => label_and_docs(db, it),
|
||||
hir::ModuleDef::Const(it) => label_and_docs(db, it),
|
||||
hir::ModuleDef::Static(it) => label_and_docs(db, it),
|
||||
hir::ModuleDef::Trait(it) => label_and_docs(db, it),
|
||||
hir::ModuleDef::TypeAlias(it) => label_and_docs(db, it),
|
||||
hir::ModuleDef::BuiltinType(it) => {
|
||||
return famous_defs
|
||||
.and_then(|fd| builtin(fd, it))
|
||||
.or_else(|| Some(Markup::fenced_block(&it.name())))
|
||||
}
|
||||
},
|
||||
Definition::Module(it) => label_and_docs(db, it),
|
||||
Definition::Function(it) => label_and_docs(db, it),
|
||||
Definition::Adt(it) => label_and_docs(db, it),
|
||||
Definition::Variant(it) => label_and_docs(db, it),
|
||||
Definition::Const(it) => label_and_docs(db, it),
|
||||
Definition::Static(it) => label_and_docs(db, it),
|
||||
Definition::Trait(it) => label_and_docs(db, it),
|
||||
Definition::TypeAlias(it) => label_and_docs(db, it),
|
||||
Definition::BuiltinType(it) => {
|
||||
return famous_defs
|
||||
.and_then(|fd| builtin(fd, it))
|
||||
.or_else(|| Some(Markup::fenced_block(&it.name())))
|
||||
}
|
||||
Definition::Local(it) => return local(db, it),
|
||||
Definition::SelfType(impl_def) => {
|
||||
impl_def.self_ty(db).as_adt().map(|adt| label_and_docs(db, adt))?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue