Skip to content

Commit

Permalink
Prefer cursor_with_offset(TextIndex::ZERO)
Browse files Browse the repository at this point in the history
...than `Default::default()`, which doesn't say much at the call-site.
  • Loading branch information
Xanewok committed Nov 20, 2023
1 parent db14452 commit 34a8034
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions crates/codegen/parser/runtime/src/parse_output.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{cst, cursor::Cursor, parse_error::ParseError};
use crate::{cst, cursor::Cursor, parse_error::ParseError, text_index::TextIndex};

#[derive(Debug, PartialEq)]
pub struct ParseOutput {
Expand All @@ -21,6 +21,6 @@ impl ParseOutput {

/// Creates a cursor that starts at the root of the parse tree.
pub fn create_tree_cursor(&self) -> Cursor {
return self.parse_tree.cursor_with_offset(Default::default());
return self.parse_tree.cursor_with_offset(TextIndex::ZERO);
}
}
7 changes: 5 additions & 2 deletions crates/codegen/parser/runtime/src/support/parser_function.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::rc::Rc;

use super::{
super::{cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput},
super::{
cst, kinds::TokenKind, parse_error::ParseError, parse_output::ParseOutput,
text_index::TextIndex,
},
context::ParserContext,
parser_result::*,
};
Expand Down Expand Up @@ -95,7 +98,7 @@ where
debug_assert_eq!(
errors.len() > 0,
parse_tree
.cursor_with_offset(Default::default())
.cursor_with_offset(TextIndex::ZERO)
.any(|x| x.as_token_with_kind(&[TokenKind::SKIPPED]).is_some())
);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 34a8034

Please sign in to comment.