From ed8d5c86e3999aeec9a62e69ef065b2c799ecfa0 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 16 Jan 2020 23:37:43 +0800 Subject: Fix array element attribute position --- crates/ra_parser/src/grammar/attributes.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/ra_parser/src/grammar/attributes.rs') diff --git a/crates/ra_parser/src/grammar/attributes.rs b/crates/ra_parser/src/grammar/attributes.rs index f3158ade3..224f45127 100644 --- a/crates/ra_parser/src/grammar/attributes.rs +++ b/crates/ra_parser/src/grammar/attributes.rs @@ -8,6 +8,28 @@ pub(super) fn inner_attributes(p: &mut Parser) { } } +pub(super) fn with_outer_attributes( + p: &mut Parser, + f: impl Fn(&mut Parser) -> Option, +) -> bool { + let am = p.start(); + let has_attrs = p.at(T![#]); + attributes::outer_attributes(p); + let cm = f(p); + let success = cm.is_some(); + + match (has_attrs, cm) { + (true, Some(cm)) => { + let kind = cm.kind(); + cm.undo_completion(p).abandon(p); + am.complete(p, kind); + } + _ => am.abandon(p), + } + + success +} + pub(super) fn outer_attributes(p: &mut Parser) { while p.at(T![#]) { attribute(p, false) -- cgit v1.2.3 From a766883a751096e5b912b59a14d7b6fc3372c791 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 16 Jan 2020 23:48:03 +0800 Subject: fix formating --- crates/ra_parser/src/grammar/attributes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_parser/src/grammar/attributes.rs') diff --git a/crates/ra_parser/src/grammar/attributes.rs b/crates/ra_parser/src/grammar/attributes.rs index 224f45127..eeae37aef 100644 --- a/crates/ra_parser/src/grammar/attributes.rs +++ b/crates/ra_parser/src/grammar/attributes.rs @@ -14,7 +14,7 @@ pub(super) fn with_outer_attributes( ) -> bool { let am = p.start(); let has_attrs = p.at(T![#]); - attributes::outer_attributes(p); + attributes::outer_attributes(p); let cm = f(p); let success = cm.is_some(); -- cgit v1.2.3