mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
refactor
This commit is contained in:
parent
2f85a640a2
commit
5144f3b22f
1 changed files with 9 additions and 11 deletions
|
@ -6,21 +6,19 @@ use ra_syntax::ast;
|
|||
|
||||
use crate::{
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static, Struct,
|
||||
StructField, Trait, TypeAlias, Union,
|
||||
Adt, Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static,
|
||||
Struct, StructField, Trait, TypeAlias, Union,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum DocDef {
|
||||
Module(Module),
|
||||
StructField(StructField),
|
||||
Struct(Struct),
|
||||
Enum(Enum),
|
||||
Adt(Adt),
|
||||
EnumVariant(EnumVariant),
|
||||
Static(Static),
|
||||
Const(Const),
|
||||
Function(Function),
|
||||
Union(Union),
|
||||
Trait(Trait),
|
||||
TypeAlias(TypeAlias),
|
||||
MacroDef(MacroDef),
|
||||
|
@ -29,13 +27,11 @@ pub enum DocDef {
|
|||
impl_froms!(
|
||||
DocDef: Module,
|
||||
StructField,
|
||||
Struct,
|
||||
Enum,
|
||||
Adt(Struct, Enum, Union),
|
||||
EnumVariant,
|
||||
Static,
|
||||
Const,
|
||||
Function,
|
||||
Union,
|
||||
Trait,
|
||||
TypeAlias,
|
||||
MacroDef
|
||||
|
@ -79,13 +75,15 @@ pub(crate) fn documentation_query(
|
|||
FieldSource::Named(named) => docs_from_ast(&named),
|
||||
FieldSource::Pos(..) => None,
|
||||
},
|
||||
DocDef::Struct(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Enum(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Adt(it) => match it {
|
||||
Adt::Struct(it) => docs_from_ast(&it.source(db).ast),
|
||||
Adt::Enum(it) => docs_from_ast(&it.source(db).ast),
|
||||
Adt::Union(it) => docs_from_ast(&it.source(db).ast),
|
||||
},
|
||||
DocDef::EnumVariant(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Static(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Const(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Function(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Union(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Trait(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::TypeAlias(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::MacroDef(it) => docs_from_ast(&it.source(db).ast),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue