mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
internal: more local parsing tests
This commit is contained in:
parent
f632b5e481
commit
715cd8d938
5 changed files with 34 additions and 2 deletions
|
@ -240,8 +240,6 @@ pub(super) fn opt_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
|||
fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
||||
let la = p.nth(1);
|
||||
match p.current() {
|
||||
// test extern_crate
|
||||
// extern crate foo;
|
||||
T![extern] if la == T![crate] => extern_crate(p, m),
|
||||
T![use] => use_item::use_(p, m),
|
||||
T![mod] => mod_item(p, m),
|
||||
|
@ -288,11 +286,15 @@ fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// test extern_crate
|
||||
// extern crate foo;
|
||||
fn extern_crate(p: &mut Parser, m: Marker) {
|
||||
p.bump(T![extern]);
|
||||
p.bump(T![crate]);
|
||||
|
||||
if p.at(T![self]) {
|
||||
// test extern_crate_self
|
||||
// extern crate self;
|
||||
let m = p.start();
|
||||
p.bump(T![self]);
|
||||
m.complete(p, NAME_REF);
|
||||
|
@ -300,6 +302,8 @@ fn extern_crate(p: &mut Parser, m: Marker) {
|
|||
name_ref(p);
|
||||
}
|
||||
|
||||
// test extern_crate_rename
|
||||
// extern crate foo as bar;
|
||||
opt_rename(p);
|
||||
p.expect(T![;]);
|
||||
m.complete(p, EXTERN_CRATE);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
SOURCE_FILE@0..25
|
||||
EXTERN_CRATE@0..24
|
||||
EXTERN_KW@0..6 "extern"
|
||||
WHITESPACE@6..7 " "
|
||||
CRATE_KW@7..12 "crate"
|
||||
WHITESPACE@12..13 " "
|
||||
NAME_REF@13..16
|
||||
IDENT@13..16 "foo"
|
||||
WHITESPACE@16..17 " "
|
||||
RENAME@17..23
|
||||
AS_KW@17..19 "as"
|
||||
WHITESPACE@19..20 " "
|
||||
NAME@20..23
|
||||
IDENT@20..23 "bar"
|
||||
SEMICOLON@23..24 ";"
|
||||
WHITESPACE@24..25 "\n"
|
|
@ -0,0 +1 @@
|
|||
extern crate foo as bar;
|
|
@ -0,0 +1,10 @@
|
|||
SOURCE_FILE@0..19
|
||||
EXTERN_CRATE@0..18
|
||||
EXTERN_KW@0..6 "extern"
|
||||
WHITESPACE@6..7 " "
|
||||
CRATE_KW@7..12 "crate"
|
||||
WHITESPACE@12..13 " "
|
||||
NAME_REF@13..17
|
||||
SELF_KW@13..17 "self"
|
||||
SEMICOLON@17..18 ";"
|
||||
WHITESPACE@18..19 "\n"
|
|
@ -0,0 +1 @@
|
|||
extern crate self;
|
Loading…
Reference in a new issue