mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Merge #8059
8059: Move doc-comment highlight injection from AST to HIR r=matklad,jonas-schievink a=Veykril Fixes #5016 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
0fbfab3b45
10 changed files with 206 additions and 28 deletions
|
@ -11,8 +11,8 @@ use hir_ty::db::HirDatabase;
|
|||
use syntax::ast;
|
||||
|
||||
use crate::{
|
||||
Adt, Const, ConstParam, Enum, Field, Function, GenericParam, LifetimeParam, MacroDef, Module,
|
||||
ModuleDef, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant,
|
||||
Adt, Const, ConstParam, Enum, Field, Function, GenericParam, Impl, LifetimeParam, MacroDef,
|
||||
Module, ModuleDef, Static, Struct, Trait, TypeAlias, TypeParam, Union, Variant,
|
||||
};
|
||||
|
||||
pub trait HasAttrs {
|
||||
|
@ -64,6 +64,7 @@ impl_has_attrs![
|
|||
(Adt, AdtId),
|
||||
(Module, ModuleId),
|
||||
(GenericParam, GenericParamId),
|
||||
(Impl, ImplId),
|
||||
];
|
||||
|
||||
macro_rules! impl_has_attrs_enum {
|
||||
|
|
|
@ -89,7 +89,7 @@ pub use crate::{
|
|||
pub use {
|
||||
hir_def::{
|
||||
adt::StructKind,
|
||||
attr::{Attrs, Documentation},
|
||||
attr::{Attr, Attrs, Documentation},
|
||||
body::scope::ExprScopes,
|
||||
find_path::PrefixKind,
|
||||
import_map,
|
||||
|
|
|
@ -752,6 +752,7 @@ macro_rules! to_def_impls {
|
|||
|
||||
to_def_impls![
|
||||
(crate::Module, ast::Module, module_to_def),
|
||||
(crate::Module, ast::SourceFile, source_file_to_def),
|
||||
(crate::Struct, ast::Struct, struct_to_def),
|
||||
(crate::Enum, ast::Enum, enum_to_def),
|
||||
(crate::Union, ast::Union, union_to_def),
|
||||
|
|
|
@ -71,6 +71,12 @@ impl SourceToDefCtx<'_, '_> {
|
|||
Some(def_map.module_id(child_id))
|
||||
}
|
||||
|
||||
pub(super) fn source_file_to_def(&mut self, src: InFile<ast::SourceFile>) -> Option<ModuleId> {
|
||||
let _p = profile::span("source_file_to_def");
|
||||
let file_id = src.file_id.original_file(self.db.upcast());
|
||||
self.file_to_def(file_id).get(0).copied()
|
||||
}
|
||||
|
||||
pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> {
|
||||
self.to_def(src, keys::TRAIT)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue