mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 22:24:14 +00:00
use eof token pattenr
This commit is contained in:
parent
addfd8d9e8
commit
d5ad0f3ca0
1 changed files with 12 additions and 4 deletions
|
@ -49,10 +49,18 @@ impl Tokens {
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.kind.len()
|
self.kind.len()
|
||||||
}
|
}
|
||||||
pub(crate) fn get(&self, idx: usize) -> Option<(SyntaxKind, bool, IdentKind)> {
|
pub(crate) fn get(&self, idx: usize) -> (SyntaxKind, bool, IdentKind) {
|
||||||
let kind = *self.kind.get(idx)?;
|
if idx > self.len() {
|
||||||
|
return self.eof();
|
||||||
|
}
|
||||||
|
let kind = self.kind[idx];
|
||||||
let joint = self.get_joint(idx);
|
let joint = self.get_joint(idx);
|
||||||
let ident_kind = *self.ident_kind.get(idx)?;
|
let ident_kind = self.ident_kind[idx];
|
||||||
Some((kind, joint, ident_kind))
|
(kind, joint, ident_kind)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cold]
|
||||||
|
fn eof(&self) -> (SyntaxKind, bool, IdentKind) {
|
||||||
|
(SyntaxKind::EOF, false, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue