diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 0cfab27dc1..830aea1f33 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -1,4 +1,5 @@ pub(crate) mod src; +pub(crate) mod docs; use std::sync::Arc; diff --git a/crates/ra_hir/src/docs.rs b/crates/ra_hir/src/code_model/docs.rs similarity index 100% rename from crates/ra_hir/src/docs.rs rename to crates/ra_hir/src/code_model/docs.rs diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index d2a372f3bd..d2d6f95b73 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -128,8 +128,8 @@ pub trait DefDatabase: SourceDatabase { #[salsa::invoke(crate::lang_item::LangItems::lang_item_query)] fn lang_item(&self, start_crate: Crate, item: SmolStr) -> Option; - #[salsa::invoke(crate::docs::documentation_query)] - fn documentation(&self, def: crate::docs::DocDef) -> Option; + #[salsa::invoke(crate::code_model::docs::documentation_query)] + fn documentation(&self, def: crate::DocDef) -> Option; } #[salsa::query_group(HirDatabaseStorage)] diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 1690296e50..2e99bdac83 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -38,7 +38,6 @@ mod impl_block; mod expr; mod lang_item; mod generics; -mod docs; mod resolve; pub mod diagnostics; @@ -64,7 +63,6 @@ pub use self::{ nameres::{PerNs, Namespace, ImportId}, ty::{Ty, ApplicationTy, TypeCtor, TraitRef, Substs, display::HirDisplay, CallableDef}, impl_block::{ImplBlock, ImplItem}, - docs::{Docs, Documentation}, adt::AdtDef, expr::ExprScopes, resolve::Resolution, @@ -83,4 +81,5 @@ pub use self::code_model::{ Trait, TypeAlias, MacroDef, Container, BuiltinType, src::{Source, HasSource}, + docs::{Docs, Documentation, DocDef}, }; diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 1e9cdaff49..823cdaaf3c 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs @@ -163,10 +163,6 @@ impl NavigationTarget { NavigationTarget::from_module(db, module) } - pub(crate) fn from_function(db: &RootDatabase, func: hir::Function) -> NavigationTarget { - NavigationTarget::from_def_source(db, func) - } - pub(crate) fn from_field(db: &RootDatabase, field: hir::StructField) -> NavigationTarget { let src = field.source(db); let file_id = src.file_id.original_file(db); @@ -208,7 +204,7 @@ impl NavigationTarget { ) -> Option { let nav = match module_def { hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module), - hir::ModuleDef::Function(func) => NavigationTarget::from_function(db, func), + hir::ModuleDef::Function(func) => NavigationTarget::from_def_source(db, func), hir::ModuleDef::Struct(it) => NavigationTarget::from_adt_def(db, it.into()), hir::ModuleDef::Enum(it) => NavigationTarget::from_adt_def(db, it.into()), hir::ModuleDef::Union(it) => NavigationTarget::from_adt_def(db, it.into()), @@ -241,7 +237,7 @@ impl NavigationTarget { pub(crate) fn from_impl_item(db: &RootDatabase, impl_item: hir::ImplItem) -> NavigationTarget { match impl_item { - ImplItem::Method(it) => NavigationTarget::from_function(db, it), + ImplItem::Method(it) => NavigationTarget::from_def_source(db, it), ImplItem::Const(it) => NavigationTarget::from_def_source(db, it), ImplItem::TypeAlias(it) => NavigationTarget::from_def_source(db, it), } diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 325a5a4f3b..63ba6cf9d3 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs @@ -59,10 +59,10 @@ pub(crate) fn reference_definition( let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None); match classify_name_ref(db, &analyzer, name_ref) { - Some(Method(func)) => return Exact(NavigationTarget::from_function(db, func)), Some(Macro(mac)) => return Exact(NavigationTarget::from_macro_def(db, mac)), Some(FieldAccess(field)) => return Exact(NavigationTarget::from_field(db, field)), Some(AssocItem(assoc)) => return Exact(NavigationTarget::from_impl_item(db, assoc)), + Some(Method(func)) => return Exact(NavigationTarget::from_def_source(db, func)), Some(Def(def)) => match NavigationTarget::from_def(db, def) { Some(nav) => return Exact(nav), None => return Approximate(vec![]), @@ -253,12 +253,12 @@ mod tests { //- /foo/lib.rs #[macro_export] macro_rules! foo { - () => { + () => { {} }; - } + } ", - "foo MACRO_CALL FileId(2) [0; 79) [29; 32)", + "foo MACRO_CALL FileId(2) [0; 66) [29; 32)", ); }