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

feat!: capsules & query API #246

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

feat!: capsules & query API #246

wants to merge 7 commits into from

Conversation

ObserverOfTime
Copy link
Member

@ObserverOfTime ObserverOfTime commented May 25, 2024

Breaking changes are marked with !.

Additions:

  • Node.child_containing_descendant(descendant)
  • Tree.language (getter)
  • Query.pattern_count (getter)
  • Query.capture_count (getter)
  • Query.match_limit (getter)
  • Query.did_exceed_match_limit (getter)
  • Query.set_match_limit(match_limit): returns self
  • Query.set_max_start_depth(max_start_depth): returns self
  • Query.set_byte_range(byte_range): returns self
  • Query.set_point_range(point_range): returns self
  • Query.disable_pattern(index): returns self
  • Query.disable_capture(capture): returns self
  • Query.pattern_settings(index)
  • Query.pattern_assertions(index)
  • Query.start_byte_for_pattern(index)
  • Query.is_pattern_rooted(index)
  • Query.is_pattern_non_local(index)
  • Query.is_pattern_guaranteed_at_step(offset)
  • QueryError (exception class)
  • QueryPredicate (typing protocol)

Removals:

  • Parser.set_language(language)
  • Parser.set_included_ranges(ranges)
  • Parser.set_timeout_micros(timeout)
  • Node.sexp()
  • Tree.text()
  • TreeCursor.goto_first_child_for_point(row, column)
  • LookaheadIterator.reset(language, state)

Changes:

  • Language() accepts a capsule as an argument.
  • Parser.parse(...) no longer accepts a keep_text argument.
  • Query.captures(...) !
    • Range arguments were removed (use set_* instead).
    • Added an argument for custom query predicates.
    • Return type was changed to dict[str, list[Node]].
  • Query.matches(...) !
    • Range arguments were removed (use set_* instead).
    • Added an argument for custom query predicates.
    • Return type was changed to list[tuple[int, dict[str, list[Node]]]].
  • TreeCursor.goto_first_child_for_byte(byte) returns int | None.
  • TreeCursor.goto_first_child_for_point(point) returns int | None.

- Implement more methods
- Support custom predicates
- Add custom QueryError exception
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.

None yet

1 participant
-