mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Node-ify lifetimes
This commit is contained in:
parent
d34611633b
commit
dd496223f5
63 changed files with 420 additions and 274 deletions
|
@ -295,7 +295,7 @@ impl<'a> TtIter<'a> {
|
|||
|
||||
impl<'a> TreeSink for OffsetTokenSink<'a> {
|
||||
fn token(&mut self, kind: SyntaxKind, mut n_tokens: u8) {
|
||||
if kind == SyntaxKind::LIFETIME {
|
||||
if kind == SyntaxKind::LIFETIME_IDENT {
|
||||
n_tokens = 2;
|
||||
}
|
||||
for _ in 0..n_tokens {
|
||||
|
|
|
@ -84,7 +84,11 @@ impl<'a> SubtreeTokenSource<'a> {
|
|||
}
|
||||
|
||||
if let Some((curr, text)) = is_lifetime(cursor) {
|
||||
cached.push(Some(TtToken { kind: LIFETIME, is_joint_to_next: false, text }));
|
||||
cached.push(Some(TtToken {
|
||||
kind: LIFETIME_IDENT,
|
||||
is_joint_to_next: false,
|
||||
text,
|
||||
}));
|
||||
self.cached_cursor.set(curr);
|
||||
continue;
|
||||
}
|
||||
|
@ -172,7 +176,7 @@ fn convert_ident(ident: &tt::Ident) -> TtToken {
|
|||
let kind = match ident.text.as_ref() {
|
||||
"true" => T![true],
|
||||
"false" => T![false],
|
||||
i if i.starts_with('\'') => LIFETIME,
|
||||
i if i.starts_with('\'') => LIFETIME_IDENT,
|
||||
_ => SyntaxKind::from_keyword(ident.text.as_str()).unwrap_or(IDENT),
|
||||
};
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ trait TokenConvertor {
|
|||
IDENT => make_leaf!(Ident),
|
||||
k if k.is_keyword() => make_leaf!(Ident),
|
||||
k if k.is_literal() => make_leaf!(Literal),
|
||||
LIFETIME => {
|
||||
LIFETIME_IDENT => {
|
||||
let char_unit = TextSize::of('\'');
|
||||
let r = TextRange::at(range.start(), char_unit);
|
||||
let apostrophe = tt::Leaf::from(tt::Punct {
|
||||
|
@ -620,7 +620,7 @@ impl<'a> TreeSink for TtTreeSink<'a> {
|
|||
self.cursor = self.cursor.bump_subtree();
|
||||
return;
|
||||
}
|
||||
if kind == LIFETIME {
|
||||
if kind == LIFETIME_IDENT {
|
||||
n_tokens = 2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue