mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
Nest paths
This commit is contained in:
parent
ca0c5ea38b
commit
c111a1f7b8
3 changed files with 24 additions and 20 deletions
|
@ -40,7 +40,7 @@ fn node<F: FnOnce(&mut Parser)>(p: &mut Parser, node_kind: SyntaxKind, rest: F)
|
||||||
p.finish();
|
p.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn many<F: Fn(&mut Parser) -> bool>(p: &mut Parser, f: F) {
|
fn many<F: FnMut(&mut Parser) -> bool>(p: &mut Parser, mut f: F) {
|
||||||
loop {
|
loop {
|
||||||
let pos = p.pos();
|
let pos = p.pos();
|
||||||
if !f(p) {
|
if !f(p) {
|
||||||
|
|
|
@ -4,12 +4,16 @@ pub(crate) fn use_path(p: &mut Parser) {
|
||||||
if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) {
|
if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let mut prev = p.mark();
|
||||||
node(p, PATH, |p| {
|
node(p, PATH, |p| {
|
||||||
path_segment(p, true);
|
path_segment(p, true);
|
||||||
});
|
});
|
||||||
many(p, |p| {
|
many(p, |p| {
|
||||||
|
let curr = p.mark();
|
||||||
node_if(p, COLONCOLON, PATH, |p| {
|
node_if(p, COLONCOLON, PATH, |p| {
|
||||||
path_segment(p, false);
|
path_segment(p, false);
|
||||||
|
p.forward_parent(prev, curr);
|
||||||
|
prev = curr;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
FILE@[0; 40)
|
FILE@[0; 40)
|
||||||
USE_ITEM@[0; 21)
|
USE_ITEM@[0; 21)
|
||||||
USE_KW@[0; 3)
|
USE_KW@[0; 3)
|
||||||
|
PATH@[3; 19)
|
||||||
|
PATH@[3; 14)
|
||||||
PATH@[3; 9)
|
PATH@[3; 9)
|
||||||
PATH_SEGMENT@[3; 9)
|
PATH_SEGMENT@[3; 9)
|
||||||
WHITESPACE@[3; 4)
|
WHITESPACE@[3; 4)
|
||||||
COLONCOLON@[4; 6)
|
COLONCOLON@[4; 6)
|
||||||
IDENT@[6; 9)
|
IDENT@[6; 9)
|
||||||
PATH@[9; 14)
|
|
||||||
COLONCOLON@[9; 11)
|
COLONCOLON@[9; 11)
|
||||||
PATH_SEGMENT@[11; 14)
|
PATH_SEGMENT@[11; 14)
|
||||||
IDENT@[11; 14)
|
IDENT@[11; 14)
|
||||||
PATH@[14; 19)
|
|
||||||
COLONCOLON@[14; 16)
|
COLONCOLON@[14; 16)
|
||||||
PATH_SEGMENT@[16; 19)
|
PATH_SEGMENT@[16; 19)
|
||||||
IDENT@[16; 19)
|
IDENT@[16; 19)
|
||||||
|
@ -18,15 +18,15 @@ FILE@[0; 40)
|
||||||
WHITESPACE@[20; 21)
|
WHITESPACE@[20; 21)
|
||||||
USE_ITEM@[21; 40)
|
USE_ITEM@[21; 40)
|
||||||
USE_KW@[21; 24)
|
USE_KW@[21; 24)
|
||||||
|
PATH@[24; 38)
|
||||||
|
PATH@[24; 33)
|
||||||
PATH@[24; 28)
|
PATH@[24; 28)
|
||||||
PATH_SEGMENT@[24; 28)
|
PATH_SEGMENT@[24; 28)
|
||||||
WHITESPACE@[24; 25)
|
WHITESPACE@[24; 25)
|
||||||
IDENT@[25; 28)
|
IDENT@[25; 28)
|
||||||
PATH@[28; 33)
|
|
||||||
COLONCOLON@[28; 30)
|
COLONCOLON@[28; 30)
|
||||||
PATH_SEGMENT@[30; 33)
|
PATH_SEGMENT@[30; 33)
|
||||||
IDENT@[30; 33)
|
IDENT@[30; 33)
|
||||||
PATH@[33; 38)
|
|
||||||
COLONCOLON@[33; 35)
|
COLONCOLON@[33; 35)
|
||||||
PATH_SEGMENT@[35; 38)
|
PATH_SEGMENT@[35; 38)
|
||||||
IDENT@[35; 38)
|
IDENT@[35; 38)
|
||||||
|
|
Loading…
Reference in a new issue