From 2efdf41bdb178ebf1ff0f8e3b335f491c84d7fa3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 11 Feb 2019 19:23:13 +0300 Subject: make macro a NameOwner --- crates/ra_syntax/src/ast/generated.rs | 1 + crates/ra_syntax/src/grammar.ron | 5 ++++- crates/ra_syntax/src/grammar/items.rs | 4 +++- crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt | 3 ++- crates/ra_syntax/tests/data/parser/inline/ok/0062_mod_contents.txt | 3 ++- .../tests/data/parser/inline/ok/0096_no_semi_after_block.txt | 3 ++- 6 files changed, 14 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 256277609..d2b080743 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1908,6 +1908,7 @@ impl ToOwned for MacroCall { } +impl ast::NameOwner for MacroCall {} impl MacroCall { pub fn token_tree(&self) -> Option<&TokenTree> { super::child_opt(self) diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index d428bc595..2e4b2d776 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -545,7 +545,10 @@ Grammar( "Visibility": (), "Name": (), "NameRef": (), - "MacroCall": ( options: [ "TokenTree", "Path" ] ), + "MacroCall": ( + traits: [ "NameOwner" ], + options: [ "TokenTree", "Path" ], + ), "Attr": ( options: [ ["value", "TokenTree"] ] ), "TokenTree": (), "TypeParamList": ( diff --git a/crates/ra_syntax/src/grammar/items.rs b/crates/ra_syntax/src/grammar/items.rs index a61f260cf..4b962c1f3 100644 --- a/crates/ra_syntax/src/grammar/items.rs +++ b/crates/ra_syntax/src/grammar/items.rs @@ -347,7 +347,9 @@ fn macro_call(p: &mut Parser) -> BlockLike { pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike { p.expect(EXCL); - p.eat(IDENT); + if p.at(IDENT) { + name(p); + } match p.current() { L_CURLY => { token_tree(p); diff --git a/crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt b/crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt index 12919fab7..440bd7f92 100644 --- a/crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt +++ b/crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt @@ -6,7 +6,8 @@ SOURCE_FILE@[0; 349) IDENT@[0; 5) "macro" err: `expected EXCL` WHITESPACE@[5; 6) - IDENT@[6; 21) "parse_use_trees" + NAME@[6; 21) + IDENT@[6; 21) "parse_use_trees" TOKEN_TREE@[21; 41) L_PAREN@[21; 22) DOLLAR@[22; 23) diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0062_mod_contents.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0062_mod_contents.txt index 62528ca47..6ccd0ffc3 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0062_mod_contents.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0062_mod_contents.txt @@ -19,7 +19,8 @@ SOURCE_FILE@[0; 70) IDENT@[12; 23) "macro_rules" EXCL@[23; 24) WHITESPACE@[24; 25) - IDENT@[25; 28) "foo" + NAME@[25; 28) + IDENT@[25; 28) "foo" WHITESPACE@[28; 29) TOKEN_TREE@[29; 31) L_CURLY@[29; 30) diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0096_no_semi_after_block.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0096_no_semi_after_block.txt index 63b230091..ac789651a 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0096_no_semi_after_block.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0096_no_semi_after_block.txt @@ -92,7 +92,8 @@ SOURCE_FILE@[0; 167) IDENT@[109; 120) "macro_rules" EXCL@[120; 121) WHITESPACE@[121; 122) - IDENT@[122; 126) "test" + NAME@[122; 126) + IDENT@[122; 126) "test" WHITESPACE@[126; 127) TOKEN_TREE@[127; 152) L_CURLY@[127; 128) -- cgit v1.2.3