mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +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 {
|
||||
self.kind.len()
|
||||
}
|
||||
pub(crate) fn get(&self, idx: usize) -> Option<(SyntaxKind, bool, IdentKind)> {
|
||||
let kind = *self.kind.get(idx)?;
|
||||
pub(crate) fn get(&self, idx: usize) -> (SyntaxKind, bool, IdentKind) {
|
||||
if idx > self.len() {
|
||||
return self.eof();
|
||||
}
|
||||
let kind = self.kind[idx];
|
||||
let joint = self.get_joint(idx);
|
||||
let ident_kind = *self.ident_kind.get(idx)?;
|
||||
Some((kind, joint, ident_kind))
|
||||
let ident_kind = self.ident_kind[idx];
|
||||
(kind, joint, ident_kind)
|
||||
}
|
||||
|
||||
#[cold]
|
||||
fn eof(&self) -> (SyntaxKind, bool, IdentKind) {
|
||||
(SyntaxKind::EOF, false, 0)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue