diff options
author | Aleksey Kladov <[email protected]> | 2019-11-22 08:36:14 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-22 08:36:14 +0000 |
commit | a87e9145a67634a5ea8a893ab8b52b3c07108a13 (patch) | |
tree | 60339d4a73be3b0bdca0130239a764c580283501 /crates/ra_hir/src | |
parent | e42f9627664cc3c44094e1c4f985270fbfd592b1 (diff) |
Rename Atts trait
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model/attrs.rs | 21 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 2 |
2 files changed, 10 insertions, 13 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 | }; |
8 | use hir_def::attr::Attr; | 8 | use hir_def::attr::{Attr, Attrs}; |
9 | use hir_expand::hygiene::Hygiene; | 9 | use hir_expand::hygiene::Hygiene; |
10 | use ra_syntax::ast; | 10 | use ra_syntax::ast; |
11 | 11 | ||
@@ -36,19 +36,16 @@ impl_froms!( | |||
36 | MacroDef | 36 | MacroDef |
37 | ); | 37 | ); |
38 | 38 | ||
39 | pub trait Attrs { | 39 | pub 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 | ||
43 | pub(crate) fn attributes_query( | 43 | pub(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 | ||
79 | fn attrs_from_ast<T, D>(node: T, db: &D) -> hir_def::attr::Attrs | 76 | fn attrs_from_ast<T, D>(node: T, db: &D) -> Attrs |
80 | where | 77 | where |
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 | ||
90 | impl<T: Into<AttrDef> + Copy> Attrs for T { | 87 | impl<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 | ||
53 | pub use crate::{ | 53 | pub 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, |