mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +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::{
|
use crate::{
|
||||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||||
Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static, Struct,
|
Adt, Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static,
|
||||||
StructField, Trait, TypeAlias, Union,
|
Struct, StructField, Trait, TypeAlias, Union,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum DocDef {
|
pub enum DocDef {
|
||||||
Module(Module),
|
Module(Module),
|
||||||
StructField(StructField),
|
StructField(StructField),
|
||||||
Struct(Struct),
|
Adt(Adt),
|
||||||
Enum(Enum),
|
|
||||||
EnumVariant(EnumVariant),
|
EnumVariant(EnumVariant),
|
||||||
Static(Static),
|
Static(Static),
|
||||||
Const(Const),
|
Const(Const),
|
||||||
Function(Function),
|
Function(Function),
|
||||||
Union(Union),
|
|
||||||
Trait(Trait),
|
Trait(Trait),
|
||||||
TypeAlias(TypeAlias),
|
TypeAlias(TypeAlias),
|
||||||
MacroDef(MacroDef),
|
MacroDef(MacroDef),
|
||||||
|
@ -29,13 +27,11 @@ pub enum DocDef {
|
||||||
impl_froms!(
|
impl_froms!(
|
||||||
DocDef: Module,
|
DocDef: Module,
|
||||||
StructField,
|
StructField,
|
||||||
Struct,
|
Adt(Struct, Enum, Union),
|
||||||
Enum,
|
|
||||||
EnumVariant,
|
EnumVariant,
|
||||||
Static,
|
Static,
|
||||||
Const,
|
Const,
|
||||||
Function,
|
Function,
|
||||||
Union,
|
|
||||||
Trait,
|
Trait,
|
||||||
TypeAlias,
|
TypeAlias,
|
||||||
MacroDef
|
MacroDef
|
||||||
|
@ -79,13 +75,15 @@ pub(crate) fn documentation_query(
|
||||||
FieldSource::Named(named) => docs_from_ast(&named),
|
FieldSource::Named(named) => docs_from_ast(&named),
|
||||||
FieldSource::Pos(..) => None,
|
FieldSource::Pos(..) => None,
|
||||||
},
|
},
|
||||||
DocDef::Struct(it) => docs_from_ast(&it.source(db).ast),
|
DocDef::Adt(it) => match it {
|
||||||
DocDef::Enum(it) => docs_from_ast(&it.source(db).ast),
|
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::EnumVariant(it) => docs_from_ast(&it.source(db).ast),
|
||||||
DocDef::Static(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::Const(it) => docs_from_ast(&it.source(db).ast),
|
||||||
DocDef::Function(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::Trait(it) => docs_from_ast(&it.source(db).ast),
|
||||||
DocDef::TypeAlias(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),
|
DocDef::MacroDef(it) => docs_from_ast(&it.source(db).ast),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue