aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-02-17 18:39:26 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-02-17 18:39:26 +0000
commit646b53ace30660935641932c043301e3cdd4e71f (patch)
tree42f94aa460aa4233ad4372044faa6e2a27842ed1 /crates/ra_syntax/src/ast.rs
parent3dcde0b2ab8bc28dc8ef98ec07cb6d1072b93de8 (diff)
parentbb259587056faa3a76eed6e7dae487e1848d841a (diff)
Merge #846
846: WIP: Enable parsing of attributes inside a match block r=matklad a=vipentti We allow invalid inner attributes to be parsed, e.g. inner attributes that are not directly after the opening brace of the match block. Instead we run validation on `MatchArmList` to allow better reporting of errors. This fixes #845 and works towards #759 Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r--crates/ra_syntax/src/ast.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 22105d6c9..350f01f33 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -153,6 +153,20 @@ impl FnDef {
153} 153}
154 154
155impl Attr { 155impl Attr {
156 pub fn is_inner(&self) -> bool {
157 let tt = match self.value() {
158 None => return false,
159 Some(tt) => tt,
160 };
161
162 let prev = match tt.syntax().prev_sibling() {
163 None => return false,
164 Some(prev) => prev,
165 };
166
167 prev.kind() == EXCL
168 }
169
156 pub fn as_atom(&self) -> Option<SmolStr> { 170 pub fn as_atom(&self) -> Option<SmolStr> {
157 let tt = self.value()?; 171 let tt = self.value()?;
158 let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?; 172 let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?;