Rename: ts_lookahead_iterator_advance -> ts_lookahead_iterator_next

This commit is contained in:
Andrew Hlynskyi 2023-08-09 14:17:54 +03:00
parent 1253c4c654
commit 26c3ae7b98
8 changed files with 15 additions and 16 deletions

View file

@ -722,7 +722,7 @@ extern "C" {
) -> TSStateId;
}
extern "C" {
#[doc = " Create a new lookahead iterator for the given language and parse state.\n\n This returns `NULL` if state is invalid for the language.\n\n Repeatedly using `ts_lookahead_iterator_advance` and\n `ts_lookahead_iterator_current_symbol` will generate valid symbols in the\n given parse state. Newly created lookahead iterators will contain the `ERROR`\n symbol.\n\n Lookahead iterators can be useful to generate suggestions and improve syntax\n error diagnostics. To get symbols valid in an ERROR node, use the lookahead\n iterator on its first leaf node state. For `MISSING` nodes, a lookahead\n iterator created on the previous non-extra leaf node may be appropriate."]
#[doc = " Create a new lookahead iterator for the given language and parse state.\n\n This returns `NULL` if state is invalid for the language.\n\n Repeatedly using `ts_lookahead_iterator_next` and\n `ts_lookahead_iterator_current_symbol` will generate valid symbols in the\n given parse state. Newly created lookahead iterators will contain the `ERROR`\n symbol.\n\n Lookahead iterators can be useful to generate suggestions and improve syntax\n error diagnostics. To get symbols valid in an ERROR node, use the lookahead\n iterator on its first leaf node state. For `MISSING` nodes, a lookahead\n iterator created on the previous non-extra leaf node may be appropriate."]
pub fn ts_lookahead_iterator_new(
self_: *const TSLanguage,
state: TSStateId,
@ -753,7 +753,7 @@ extern "C" {
}
extern "C" {
#[doc = " Advance the lookahead iterator to the next symbol.\n\n This returns `true` if there is a new symbol and `false` otherwise."]
pub fn ts_lookahead_iterator_advance(self_: *mut TSLookaheadIterator) -> bool;
pub fn ts_lookahead_iterator_next(self_: *mut TSLookaheadIterator) -> bool;
}
extern "C" {
#[doc = " Get the current symbol of the lookahead iterator;"]

View file

@ -1509,9 +1509,9 @@ impl LookaheadIterator {
impl Iterator for LookaheadNamesIterator<'_> {
type Item = &'static str;
#[doc(alias = "ts_lookahead_iterator_advance")]
#[doc(alias = "ts_lookahead_iterator_next")]
fn next(&mut self) -> Option<Self::Item> {
unsafe { ffi::ts_lookahead_iterator_advance(self.0 .0.as_ptr()) }
unsafe { ffi::ts_lookahead_iterator_next(self.0 .0.as_ptr()) }
.then(|| self.0.current_symbol_name())
}
}
@ -1519,11 +1519,10 @@ impl Iterator for LookaheadNamesIterator<'_> {
impl Iterator for LookaheadIterator {
type Item = u16;
#[doc(alias = "ts_lookahead_iterator_advance")]
#[doc(alias = "ts_lookahead_iterator_next")]
fn next(&mut self) -> Option<Self::Item> {
// the first symbol is always `0` so we can safely skip it
unsafe { ffi::ts_lookahead_iterator_advance(self.0.as_ptr()) }
.then(|| self.current_symbol())
unsafe { ffi::ts_lookahead_iterator_next(self.0.as_ptr()) }.then(|| self.current_symbol())
}
}