From 1c97c1ac11459d45f7bfc57dc72428d2b294520c Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sun, 17 Feb 2019 19:08:34 +0200 Subject: Enable parsing of attributes inside a match block 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. --- crates/ra_syntax/src/ast.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'crates/ra_syntax/src/ast.rs') 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 { } impl Attr { + pub fn is_inner(&self) -> bool { + let tt = match self.value() { + None => return false, + Some(tt) => tt, + }; + + let prev = match tt.syntax().prev_sibling() { + None => return false, + Some(prev) => prev, + }; + + prev.kind() == EXCL + } + pub fn as_atom(&self) -> Option { let tt = self.value()?; let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?; -- cgit v1.2.3