Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add "grammar" variants to some Node methods #121

Merged
merged 6 commits into from
Feb 5, 2024
Merged

Conversation

dabico
Copy link
Member

@dabico dabico commented Feb 5, 2024

This introduces two new methods:

  • getGrammarType
  • getGrammarSymbol

Which are variants of getType and getSymbol respectively. They have the same functionality and share the underlying native code, with the only difference being that the new methods return the type/symbol as it appears in the grammar, ignoring any aliases.

This also includes a change to the existing `Node#getSymbol`. Both are
now instance methods of `Node`, calling a newly introduced internal
native method `Node#getSymbol(boolean)`. That native method re-uses the
implementation of the old `Node#getSymbol` native, while using the
boolean flag as a switch to determine which `tree-sitter` API to call.
Same ordeal as was with `Node#getGrammarSymbol`. The existing native
implementation was re-purposed to accommodate both this new method, and
the existing `Node#getSymbol`.
@dabico dabico merged commit 3f69f3f into master Feb 5, 2024
2 checks passed
@dabico dabico deleted the feature/grammar branch February 5, 2024 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant