Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add new traversal variants to TreeCursor #123

Merged
merged 6 commits into from
Feb 5, 2024
Merged

Conversation

dabico
Copy link
Member

@dabico dabico commented Feb 5, 2024

This PR introduces two new method that exploit the newly introduced tree-sitter APIs (tree-sitter/tree-sitter#2324). These include:

  • TreeCursor#gotoLastChild
  • TreeCursor#gotoPrevSibling

Note that both methods exist purely for convenience, and as the JavaDoc notes, may perform worse than the existing methods.

The first checks left-to-right walks, while the other checks
right-to-left walks. Names were chosen to reflect this.
Assertions in the two tests are therefore "mirrored".
This was done to reduce the overall cognitive complexity
of the old method.
@dabico dabico merged commit e64a463 into master Feb 5, 2024
@dabico dabico deleted the enhancement/cursor branch February 5, 2024 23:01
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant