aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/attr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/attr.rs')
-rw-r--r--crates/ra_hir/src/attr.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/crates/ra_hir/src/attr.rs b/crates/ra_hir/src/attr.rs
index f67e80bfd..bd159a566 100644
--- a/crates/ra_hir/src/attr.rs
+++ b/crates/ra_hir/src/attr.rs
@@ -63,14 +63,24 @@ impl Attr {
63 self.path.as_ident().map_or(false, |s| s.to_string() == name) 63 self.path.as_ident().map_or(false, |s| s.to_string() == name)
64 } 64 }
65 65
66 // FIXME: handle cfg_attr :-)
66 pub(crate) fn as_cfg(&self) -> Option<&Subtree> { 67 pub(crate) fn as_cfg(&self) -> Option<&Subtree> {
67 if self.is_simple_atom("cfg") { 68 if !self.is_simple_atom("cfg") {
68 match &self.input { 69 return None;
69 Some(AttrInput::TokenTree(subtree)) => Some(subtree), 70 }
70 _ => None, 71 match &self.input {
71 } 72 Some(AttrInput::TokenTree(subtree)) => Some(subtree),
72 } else { 73 _ => None,
73 None 74 }
75 }
76
77 pub(crate) fn as_path(&self) -> Option<&SmolStr> {
78 if !self.is_simple_atom("path") {
79 return None;
80 }
81 match &self.input {
82 Some(AttrInput::Literal(it)) => Some(it),
83 _ => None,
74 } 84 }
75 } 85 }
76 86