mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Use the same abstraction for attrs and docs
Doc comments *are* attributes, so there's no reason to have two crates here.
This commit is contained in:
parent
59c77ff062
commit
b45dd9ef54
5 changed files with 7 additions and 12 deletions
|
@ -1771,6 +1771,7 @@ impl_from!(
|
||||||
|
|
||||||
pub trait HasAttrs {
|
pub trait HasAttrs {
|
||||||
fn attrs(self, db: &dyn HirDatabase) -> Attrs;
|
fn attrs(self, db: &dyn HirDatabase) -> Attrs;
|
||||||
|
fn docs(self, db: &dyn HirDatabase) -> Option<Documentation>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Into<AttrDef>> HasAttrs for T {
|
impl<T: Into<AttrDef>> HasAttrs for T {
|
||||||
|
@ -1778,14 +1779,8 @@ impl<T: Into<AttrDef>> HasAttrs for T {
|
||||||
let def: AttrDef = self.into();
|
let def: AttrDef = self.into();
|
||||||
db.attrs(def.into())
|
db.attrs(def.into())
|
||||||
}
|
}
|
||||||
}
|
fn docs(self, db: &dyn HirDatabase) -> Option<Documentation> {
|
||||||
|
let def: AttrDef = self.into();
|
||||||
pub trait Docs {
|
|
||||||
fn docs(&self, db: &dyn HirDatabase) -> Option<Documentation>;
|
|
||||||
}
|
|
||||||
impl<T: Into<AttrDef> + Copy> Docs for T {
|
|
||||||
fn docs(&self, db: &dyn HirDatabase) -> Option<Documentation> {
|
|
||||||
let def: AttrDef = (*self).into();
|
|
||||||
db.documentation(def.into())
|
db.documentation(def.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ mod has_source;
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
code_model::{
|
code_model::{
|
||||||
Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Callable, CallableKind,
|
Access, Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Callable, CallableKind,
|
||||||
Const, Crate, CrateDependency, DefWithBody, Docs, Enum, EnumVariant, Field, FieldSource,
|
Const, Crate, CrateDependency, DefWithBody, Enum, EnumVariant, Field, FieldSource,
|
||||||
Function, GenericDef, HasAttrs, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef,
|
Function, GenericDef, HasAttrs, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef,
|
||||||
ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
|
ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! FIXME: write short doc here
|
//! FIXME: write short doc here
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir::{Docs, HirDisplay, Semantics, Type};
|
use hir::{HasAttrs, HirDisplay, Semantics, Type};
|
||||||
use ide_db::RootDatabase;
|
use ide_db::RootDatabase;
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use assists::utils::get_missing_assoc_items;
|
use assists::utils::get_missing_assoc_items;
|
||||||
use hir::{self, Docs, HasSource};
|
use hir::{self, HasAttrs, HasSource};
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, edit, Impl},
|
ast::{self, edit, Impl},
|
||||||
AstNode, SyntaxKind, SyntaxNode, TextRange, T,
|
AstNode, SyntaxKind, SyntaxNode, TextRange, T,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! This modules takes care of rendering various definitions as completion items.
|
//! This modules takes care of rendering various definitions as completion items.
|
||||||
//! It also handles scoring (sorting) completions.
|
//! It also handles scoring (sorting) completions.
|
||||||
|
|
||||||
use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type};
|
use hir::{HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use syntax::ast::NameOwner;
|
use syntax::ast::NameOwner;
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue