diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 60480c6999..a8d60e882d 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -970,7 +970,15 @@ impl ToOwned for ExternCrateItem { } -impl ExternCrateItem {} +impl ExternCrateItem { + pub fn name_ref(&self) -> Option<&NameRef> { + super::child_opt(self) + } + + pub fn alias(&self) -> Option<&Alias> { + super::child_opt(self) + } +} // FalseKw #[derive(Debug, PartialEq, Eq, Hash)] diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index a2ccd7cb94..2ed1fd1b88 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -601,7 +601,9 @@ Grammar( "UseTreeList": ( collections: [["use_trees", "UseTree"]] ), - "ExternCrateItem": (), + "ExternCrateItem": ( + options: ["NameRef", "Alias"], + ), "ArgList": ( collections: [ ["args", "Expr"] diff --git a/crates/ra_syntax/src/grammar/items.rs b/crates/ra_syntax/src/grammar/items.rs index 18039cd3f8..84c18a2932 100644 --- a/crates/ra_syntax/src/grammar/items.rs +++ b/crates/ra_syntax/src/grammar/items.rs @@ -247,7 +247,7 @@ fn extern_crate_item(p: &mut Parser) { p.bump(); assert!(p.at(CRATE_KW)); p.bump(); - name(p); + name_ref(p); opt_alias(p); p.expect(SEMI); } diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0060_extern_crate.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0060_extern_crate.txt index 7ffdc7fbdb..a7b4287878 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0060_extern_crate.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0060_extern_crate.txt @@ -4,7 +4,7 @@ SOURCE_FILE@[0; 18) WHITESPACE@[6; 7) CRATE_KW@[7; 12) WHITESPACE@[12; 13) - NAME@[13; 16) + NAME_REF@[13; 16) IDENT@[13; 16) "foo" SEMI@[16; 17) WHITESPACE@[17; 18) diff --git a/crates/ra_syntax/tests/data/parser/ok/0007_extern_crate.txt b/crates/ra_syntax/tests/data/parser/ok/0007_extern_crate.txt index 5adf3f2769..5558d952e5 100644 --- a/crates/ra_syntax/tests/data/parser/ok/0007_extern_crate.txt +++ b/crates/ra_syntax/tests/data/parser/ok/0007_extern_crate.txt @@ -4,7 +4,7 @@ SOURCE_FILE@[0; 43) WHITESPACE@[6; 7) CRATE_KW@[7; 12) WHITESPACE@[12; 13) - NAME@[13; 16) + NAME_REF@[13; 16) IDENT@[13; 16) "foo" SEMI@[16; 17) WHITESPACE@[17; 18) @@ -13,7 +13,7 @@ SOURCE_FILE@[0; 43) WHITESPACE@[24; 25) CRATE_KW@[25; 30) WHITESPACE@[30; 31) - NAME@[31; 34) + NAME_REF@[31; 34) IDENT@[31; 34) "foo" WHITESPACE@[34; 35) ALIAS@[35; 41)