mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 17:28:09 +00:00
move docs under code model
This commit is contained in:
parent
f6c227babd
commit
ff6f6b3a52
6 changed files with 10 additions and 14 deletions
|
@ -1,4 +1,5 @@
|
|||
pub(crate) mod src;
|
||||
pub(crate) mod docs;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
|
@ -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<LangItemTarget>;
|
||||
|
||||
#[salsa::invoke(crate::docs::documentation_query)]
|
||||
fn documentation(&self, def: crate::docs::DocDef) -> Option<crate::docs::Documentation>;
|
||||
#[salsa::invoke(crate::code_model::docs::documentation_query)]
|
||||
fn documentation(&self, def: crate::DocDef) -> Option<crate::Documentation>;
|
||||
}
|
||||
|
||||
#[salsa::query_group(HirDatabaseStorage)]
|
||||
|
|
|
@ -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},
|
||||
};
|
||||
|
|
|
@ -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<NavigationTarget> {
|
||||
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),
|
||||
}
|
||||
|
|
|
@ -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)",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue