From 5144f3b22ff2c32800672ca0146bce4bc9c805a4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 8 Oct 2019 20:33:43 +0300 Subject: refactor --- crates/ra_hir/src/code_model/docs.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'crates/ra_hir/src/code_model') diff --git a/crates/ra_hir/src/code_model/docs.rs b/crates/ra_hir/src/code_model/docs.rs index 9675e397f..8533b4f5e 100644 --- a/crates/ra_hir/src/code_model/docs.rs +++ b/crates/ra_hir/src/code_model/docs.rs @@ -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), -- cgit v1.2.3