aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-02-01 23:33:54 +0000
committerFlorian Diebold <[email protected]>2019-02-04 20:49:34 +0000
commite163c908acff9260eff347541f0f3f57db551622 (patch)
tree1749bf4fa26b02d97d058c985083bd388ad71b91 /crates/ra_syntax/src
parent77a824c6a0db6ac2548841d290d5d61d1d23295c (diff)
Add AST for extern crate
Also change it to parse the crate name as a NAME_REF, not a NAME.
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs10
-rw-r--r--crates/ra_syntax/src/grammar.ron4
-rw-r--r--crates/ra_syntax/src/grammar/items.rs2
3 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 60480c699..a8d60e882 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 {
970} 970}
971 971
972 972
973impl ExternCrateItem {} 973impl ExternCrateItem {
974 pub fn name_ref(&self) -> Option<&NameRef> {
975 super::child_opt(self)
976 }
977
978 pub fn alias(&self) -> Option<&Alias> {
979 super::child_opt(self)
980 }
981}
974 982
975// FalseKw 983// FalseKw
976#[derive(Debug, PartialEq, Eq, Hash)] 984#[derive(Debug, PartialEq, Eq, Hash)]
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index a2ccd7cb9..2ed1fd1b8 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -601,7 +601,9 @@ Grammar(
601 "UseTreeList": ( 601 "UseTreeList": (
602 collections: [["use_trees", "UseTree"]] 602 collections: [["use_trees", "UseTree"]]
603 ), 603 ),
604 "ExternCrateItem": (), 604 "ExternCrateItem": (
605 options: ["NameRef", "Alias"],
606 ),
605 "ArgList": ( 607 "ArgList": (
606 collections: [ 608 collections: [
607 ["args", "Expr"] 609 ["args", "Expr"]
diff --git a/crates/ra_syntax/src/grammar/items.rs b/crates/ra_syntax/src/grammar/items.rs
index 18039cd3f..84c18a293 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) {
247 p.bump(); 247 p.bump();
248 assert!(p.at(CRATE_KW)); 248 assert!(p.at(CRATE_KW));
249 p.bump(); 249 p.bump();
250 name(p); 250 name_ref(p);
251 opt_alias(p); 251 opt_alias(p);
252 p.expect(SEMI); 252 p.expect(SEMI);
253} 253}