aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-22 08:36:14 +0000
committerAleksey Kladov <[email protected]>2019-11-22 08:36:14 +0000
commita87e9145a67634a5ea8a893ab8b52b3c07108a13 (patch)
tree60339d4a73be3b0bdca0130239a764c580283501
parente42f9627664cc3c44094e1c4f985270fbfd592b1 (diff)
Rename Atts trait
-rw-r--r--crates/ra_hir/src/code_model/attrs.rs21
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs4
3 files changed, 12 insertions, 15 deletions
diff --git a/crates/ra_hir/src/code_model/attrs.rs b/crates/ra_hir/src/code_model/attrs.rs
index 9923cde81..96da8c88c 100644
--- a/crates/ra_hir/src/code_model/attrs.rs
+++ b/crates/ra_hir/src/code_model/attrs.rs
@@ -5,7 +5,7 @@ use crate::{
5 Adt, Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static, 5 Adt, Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static,
6 Struct, StructField, Trait, TypeAlias, Union, 6 Struct, StructField, Trait, TypeAlias, Union,
7}; 7};
8use hir_def::attr::Attr; 8use hir_def::attr::{Attr, Attrs};
9use hir_expand::hygiene::Hygiene; 9use hir_expand::hygiene::Hygiene;
10use ra_syntax::ast; 10use ra_syntax::ast;
11 11
@@ -36,19 +36,16 @@ impl_froms!(
36 MacroDef 36 MacroDef
37); 37);
38 38
39pub trait Attrs { 39pub trait HasAttrs {
40 fn attrs(&self, db: &impl HirDatabase) -> hir_def::attr::Attrs; 40 fn attrs(&self, db: &impl HirDatabase) -> Attrs;
41} 41}
42 42
43pub(crate) fn attributes_query( 43pub(crate) fn attributes_query(db: &(impl DefDatabase + AstDatabase), def: AttrDef) -> Attrs {
44 db: &(impl DefDatabase + AstDatabase),
45 def: AttrDef,
46) -> hir_def::attr::Attrs {
47 match def { 44 match def {
48 AttrDef::Module(it) => { 45 AttrDef::Module(it) => {
49 let src = match it.declaration_source(db) { 46 let src = match it.declaration_source(db) {
50 Some(it) => it, 47 Some(it) => it,
51 None => return hir_def::attr::Attrs::default(), 48 None => return Attrs::default(),
52 }; 49 };
53 let hygiene = Hygiene::new(db, src.file_id); 50 let hygiene = Hygiene::new(db, src.file_id);
54 Attr::from_attrs_owner(&src.value, &hygiene) 51 Attr::from_attrs_owner(&src.value, &hygiene)
@@ -59,7 +56,7 @@ pub(crate) fn attributes_query(
59 let hygiene = Hygiene::new(db, src.file_id); 56 let hygiene = Hygiene::new(db, src.file_id);
60 Attr::from_attrs_owner(&named, &hygiene) 57 Attr::from_attrs_owner(&named, &hygiene)
61 } 58 }
62 FieldSource::Pos(..) => hir_def::attr::Attrs::default(), 59 FieldSource::Pos(..) => Attrs::default(),
63 }, 60 },
64 AttrDef::Adt(it) => match it { 61 AttrDef::Adt(it) => match it {
65 Adt::Struct(it) => attrs_from_ast(it, db), 62 Adt::Struct(it) => attrs_from_ast(it, db),
@@ -76,7 +73,7 @@ pub(crate) fn attributes_query(
76 } 73 }
77} 74}
78 75
79fn attrs_from_ast<T, D>(node: T, db: &D) -> hir_def::attr::Attrs 76fn attrs_from_ast<T, D>(node: T, db: &D) -> Attrs
80where 77where
81 T: HasSource, 78 T: HasSource,
82 T::Ast: ast::AttrsOwner, 79 T::Ast: ast::AttrsOwner,
@@ -87,8 +84,8 @@ where
87 Attr::from_attrs_owner(&src.value, &hygiene) 84 Attr::from_attrs_owner(&src.value, &hygiene)
88} 85}
89 86
90impl<T: Into<AttrDef> + Copy> Attrs for T { 87impl<T: Into<AttrDef> + Copy> HasAttrs for T {
91 fn attrs(&self, db: &impl HirDatabase) -> hir_def::attr::Attrs { 88 fn attrs(&self, db: &impl HirDatabase) -> Attrs {
92 db.attrs((*self).into()) 89 db.attrs((*self).into())
93 } 90 }
94} 91}
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 8c6834392..915ca46fb 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -52,7 +52,7 @@ mod marks;
52 52
53pub use crate::{ 53pub use crate::{
54 code_model::{ 54 code_model::{
55 attrs::{AttrDef, Attrs}, 55 attrs::{AttrDef, HasAttrs},
56 docs::{DocDef, Docs, Documentation}, 56 docs::{DocDef, Docs, Documentation},
57 src::{HasBodySource, HasSource}, 57 src::{HasBodySource, HasSource},
58 Adt, AssocItem, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum, 58 Adt, AssocItem, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index cbaf169bf..bd464d193 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -1,6 +1,6 @@
1//! This modules takes care of rendering various definitions as completion items. 1//! This modules takes care of rendering various definitions as completion items.
2 2
3use hir::{db::HirDatabase, Attrs, Docs, HasSource, HirDisplay, ScopeDef, Ty, TypeWalk}; 3use hir::{db::HirDatabase, Docs, HasAttrs, HasSource, HirDisplay, ScopeDef, Ty, TypeWalk};
4use join_to_string::join; 4use join_to_string::join;
5use ra_syntax::ast::NameOwner; 5use ra_syntax::ast::NameOwner;
6use test_utils::tested_by; 6use test_utils::tested_by;
@@ -285,7 +285,7 @@ impl Completions {
285 } 285 }
286} 286}
287 287
288fn is_deprecated(node: impl Attrs, db: &impl HirDatabase) -> bool { 288fn is_deprecated(node: impl HasAttrs, db: &impl HirDatabase) -> bool {
289 node.attrs(db).has_atom("deprecated") 289 node.attrs(db).has_atom("deprecated")
290} 290}
291 291