mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Implement ignore
and index
metavar expression
This commit is contained in:
parent
f7bb9327ad
commit
df66eb74ab
7 changed files with 108 additions and 5 deletions
|
@ -103,6 +103,23 @@ fn expand_subtree(
|
|||
err = err.or(e);
|
||||
push_fragment(arena, fragment)
|
||||
}
|
||||
Op::Ignore { name, id } => {
|
||||
// Expand the variable, but ignore the result. This registers the repetition count.
|
||||
expand_var(ctx, name, *id);
|
||||
}
|
||||
Op::Index { depth } => {
|
||||
let index = ctx
|
||||
.nesting
|
||||
.get(ctx.nesting.len() - 1 - (*depth as usize))
|
||||
.map_or(0, |nest| nest.idx);
|
||||
arena.push(
|
||||
tt::Leaf::Literal(tt::Literal {
|
||||
text: index.to_string().into(),
|
||||
id: tt::TokenId::unspecified(),
|
||||
})
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// drain the elements added in this instance of expand_subtree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue