MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / next

Method next

atomic-core/src/diff/token/tokenizer.rs:509–538  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

507 type Item = Token<'a>;
508
509 fn next(&mut self) -> Option<Self::Item> {
510 if self.is_finished() {
511 return None;
512 }
513
514 let b = self.peek()?;
515
516 // Determine token type and read it
517 let token = if Self::is_newline(b) {
518 self.read_newline()
519 } else if Self::is_whitespace(b) {
520 self.read_whitespace()
521 } else if self.config.recognize_comments && b == b'/' && self.peek_at(1) == Some(b'/') {
522 self.read_comment()
523 } else if self.config.recognize_strings && (b == b'"' || b == b'\'') {
524 self.read_string(b)
525 } else if self.config.recognize_numbers && Self::is_number_start(b) {
526 self.read_number()
527 } else if Self::is_word_char(b) && !b.is_ascii_digit() {
528 self.read_word()
529 } else if self.config.recognize_operators && Self::is_operator(b) {
530 self.read_operator()
531 } else if Self::is_punctuation(b) {
532 self.read_punctuation()
533 } else {
534 self.read_other()
535 };
536
537 Some(token)
538 }
539
540 fn size_hint(&self) -> (usize, Option<usize>) {
541 let remaining = self.content.len() - self.position;

Callers 3

test_tokenizer_remainingFunction · 0.45
test_tokenizer_positionFunction · 0.45

Calls 12

read_newlineMethod · 0.80
read_whitespaceMethod · 0.80
peek_atMethod · 0.80
read_commentMethod · 0.80
read_stringMethod · 0.80
read_numberMethod · 0.80
read_wordMethod · 0.80
read_operatorMethod · 0.80
read_punctuationMethod · 0.80
read_otherMethod · 0.80
is_finishedMethod · 0.45
peekMethod · 0.45

Tested by 3

test_tokenizer_remainingFunction · 0.36
test_tokenizer_positionFunction · 0.36