mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Add AST for extern crate
Also change it to parse the crate name as a NAME_REF, not a NAME.
This commit is contained in:
parent
77a824c6a0
commit
e163c908ac
5 changed files with 16 additions and 6 deletions
|
@ -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
|
// FalseKw
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
|
@ -601,7 +601,9 @@ Grammar(
|
||||||
"UseTreeList": (
|
"UseTreeList": (
|
||||||
collections: [["use_trees", "UseTree"]]
|
collections: [["use_trees", "UseTree"]]
|
||||||
),
|
),
|
||||||
"ExternCrateItem": (),
|
"ExternCrateItem": (
|
||||||
|
options: ["NameRef", "Alias"],
|
||||||
|
),
|
||||||
"ArgList": (
|
"ArgList": (
|
||||||
collections: [
|
collections: [
|
||||||
["args", "Expr"]
|
["args", "Expr"]
|
||||||
|
|
|
@ -247,7 +247,7 @@ fn extern_crate_item(p: &mut Parser) {
|
||||||
p.bump();
|
p.bump();
|
||||||
assert!(p.at(CRATE_KW));
|
assert!(p.at(CRATE_KW));
|
||||||
p.bump();
|
p.bump();
|
||||||
name(p);
|
name_ref(p);
|
||||||
opt_alias(p);
|
opt_alias(p);
|
||||||
p.expect(SEMI);
|
p.expect(SEMI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ SOURCE_FILE@[0; 18)
|
||||||
WHITESPACE@[6; 7)
|
WHITESPACE@[6; 7)
|
||||||
CRATE_KW@[7; 12)
|
CRATE_KW@[7; 12)
|
||||||
WHITESPACE@[12; 13)
|
WHITESPACE@[12; 13)
|
||||||
NAME@[13; 16)
|
NAME_REF@[13; 16)
|
||||||
IDENT@[13; 16) "foo"
|
IDENT@[13; 16) "foo"
|
||||||
SEMI@[16; 17)
|
SEMI@[16; 17)
|
||||||
WHITESPACE@[17; 18)
|
WHITESPACE@[17; 18)
|
||||||
|
|
|
@ -4,7 +4,7 @@ SOURCE_FILE@[0; 43)
|
||||||
WHITESPACE@[6; 7)
|
WHITESPACE@[6; 7)
|
||||||
CRATE_KW@[7; 12)
|
CRATE_KW@[7; 12)
|
||||||
WHITESPACE@[12; 13)
|
WHITESPACE@[12; 13)
|
||||||
NAME@[13; 16)
|
NAME_REF@[13; 16)
|
||||||
IDENT@[13; 16) "foo"
|
IDENT@[13; 16) "foo"
|
||||||
SEMI@[16; 17)
|
SEMI@[16; 17)
|
||||||
WHITESPACE@[17; 18)
|
WHITESPACE@[17; 18)
|
||||||
|
@ -13,7 +13,7 @@ SOURCE_FILE@[0; 43)
|
||||||
WHITESPACE@[24; 25)
|
WHITESPACE@[24; 25)
|
||||||
CRATE_KW@[25; 30)
|
CRATE_KW@[25; 30)
|
||||||
WHITESPACE@[30; 31)
|
WHITESPACE@[30; 31)
|
||||||
NAME@[31; 34)
|
NAME_REF@[31; 34)
|
||||||
IDENT@[31; 34) "foo"
|
IDENT@[31; 34) "foo"
|
||||||
WHITESPACE@[34; 35)
|
WHITESPACE@[34; 35)
|
||||||
ALIAS@[35; 41)
|
ALIAS@[35; 41)
|
||||||
|
|
Loading…
Reference in a new issue