Skip to content

feat!: ABI 15 & QueryCursor #333

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

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

feat!: ABI 15 & QueryCursor #333

wants to merge 5 commits into from

Conversation

ObserverOfTime
Copy link
Member

@ObserverOfTime ObserverOfTime commented Feb 5, 2025

Breaking changes are marked with !.

Additions:

  • Language.name (getter)
  • Language.abi_version (getter)
  • Language.semantic_version (getter)
  • Language.supertypes (getter)
  • Language.subtypes(supertype)
  • Node.first_child_for_byte(byte)
  • Node.first_named_child_for_byte(byte)
  • Query.string_count (getter)
  • Query.capture_name(index)
  • Query.capture_quantifier(pattern_index, capture_index)
  • Query.string_value(index)
  • QueryCursor(query)
  • QueryCursor.match_limit (getter, setter, deleter)
  • QueryCursor.timeout_micros (getter, setter, deleter)
  • QueryCursor.did_exceed_match_limit (getter)
  • QueryCursor.set_max_start_depth(depth)
  • QueryCursor.set_byte_range(start, end)
  • QueryCursor.set_point_range(start, end)
  • QueryCursor.captures(node, predicate, progress_callback)
  • QueryCursor.matches(node, predicate, progress_callback)
  • LookaheadIterator.names()
  • LookaheadIterator.symbols()

Deprecations:

  • Language.version: use Language.abi_version
  • Language.query(source): use Query(language, source)
  • Parser.timeout_micros: use the progress_callback in parse()
  • QueryCursor.timeout_micros: use the progress_callback in matches() or captures()

Removals:

  • Node.child_containing_descendant(descendant): use Node.child_with_descendant(descendant) !
  • Query.match_limit: moved to QueryCursor.match_limit !
  • Query.set_match_limit(limit): moved to QueryCursor.match_limit !
  • Query.did_exceed_match_limit: moved to QueryCursor.did_exceed_match_limit !
  • Query.timeout_micros: moved to QueryCursor.timeout_micros !
  • Query.set_timeout_micros(timeout): moved to QueryCursor.timeout_micros !
  • Query.set_max_start_depth(depth): moved to QueryCursor.set_max_start_depth(depth) !
  • Query.set_byte_range(byte_range): moved to QueryCursor.set_byte_range(start, end) !
  • Query.set_point_range(point_range): moved to QueryCursor.set_point_range(start, end) !
  • Query.captures(node, predicate): moved to QueryCursor.captures(node, predicate, progress_callback) !
  • Query.matches(node, predicate): moved to QueryCursor.matches(node, predicate, progress_callback) !
  • LookaheadIterator.iter_names(): use LookaheadIterator.names() !

Changes:

  • Parser.parse(): encoding parameter also accepts "utf16le" & "utf16be"
  • Parser.parse(): added progress_callback parameter
  • LookaheadIterator.__next__(): yields tuple[int, str] !
  • LookaheadIterator.reset(state, language): renamed from reset_state !

@ObserverOfTime
Copy link
Member Author

@amaanq

@ChrisFloofyKitsune

This comment was marked as resolved.

@ChrisFloofyKitsune

This comment was marked as resolved.

@ChrisFloofyKitsune

This comment was marked as resolved.

@ObserverOfTime

This comment was marked as resolved.

@maxbrunsfeld
Copy link
Contributor

In my opinion, methods that in C return iterator structs should in Python return simple Lists of values. It will likely be more efficient, because crossing the Python to C border is expensive. It’s also simpler from an API perspective.

@ObserverOfTime
Copy link
Member Author

@maxbrunsfeld Can I have admin rights to this repo (like the Java and Kotlin ones) so I can actually merge PRs?

@ObserverOfTime ObserverOfTime linked an issue Mar 30, 2025 that may be closed by this pull request
@ObserverOfTime
Copy link
Member Author

@amaanq

@gpijat

This comment was marked as resolved.

@ObserverOfTime
Copy link
Member Author

@amaanq

haxtibal added a commit to haxtibal/tree-sitter-robot that referenced this pull request May 1, 2025
On publish, the pypi workflow currently regenerates our parser for ABI
15 because that's the default from the central workflow [1].

In Python, one needs py-tree-sitter [2] to load the robot language.
Since py-tree-sitter folks have not yet finished ABI 15 migration,
there's currently no way to load our binding. Using the lattest
py-tree-sitter 0.24 would fail with "ValueError: Incompatible Language
version 15. Must be between 13 and 14".

Therefore to make tree-sitter-robot available for users, we enforce ABI
14 on regeneration for upload.

PS: Some of the central language bindings have basically the same
problem. However, since they have published former pypi releases with
lower ABI versions, there's something users can fallback to. We don't
have previous releases, so no fallback is available.

[1] https://github.com/tree-sitter/workflows/blob/ec44bc4f4667a458dd397ed9864f1b560e8fdca2/.github/workflows/package-pypi.yml#L24
[2] https://github.com/tree-sitter/py-tree-sitter
[3] tree-sitter/py-tree-sitter#333
haxtibal added a commit to haxtibal/tree-sitter-robot that referenced this pull request May 1, 2025
On publish, the pypi workflow currently regenerates our parser for ABI
15 because that's the default from the central workflow [1].

In Python, one needs py-tree-sitter [2] to load the robot language.
Since py-tree-sitter folks have not yet finished ABI 15 migration [3],
there's currently no way to load our binding. Using the lattest
py-tree-sitter 0.24 would fail with "ValueError: Incompatible Language
version 15. Must be between 13 and 14".

Therefore to make tree-sitter-robot available for users, we enforce ABI
14 on regeneration for upload.

PS: Some of the central language bindings have basically the same
problem. However, since they have published former pypi releases with
lower ABI versions, there's something users can fallback to. We don't
have previous releases, so no fallback is available.

[1] https://github.com/tree-sitter/workflows/blob/ec44bc4f4667a458dd397ed9864f1b560e8fdca2/.github/workflows/package-pypi.yml#L24
[2] https://github.com/tree-sitter/py-tree-sitter
[3] tree-sitter/py-tree-sitter#333
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.

Parser Hangs forever Parsing Kotling code
4 participants