Commit graph

6539 commits

Author SHA1 Message Date
Will Lillis 4915d1bd09 feat(query): enhanced step dumper
Extract the step dump into `ts_query__dump_steps` and enrich it with the control-flow
fields and analysis annotations.
2026-07-01 19:31:05 -04:00
Will Lillis 91fd04f96a fix(query): short-circuit longest-match dedup for disjoint states
An unanchored quantified sibling like `(program (comment)+ @doc (class))`
keeps one match state per matching sibling. A recent fix stopped over-pruning
them, but the per-node longest-match dedup is pairwise, so with n live states
matching became O(n^3).

Two states can only be capture subsets of one another if their captured
byte ranges overlap, so keep each group ordered by first-capture position
and stop the pairwise scan once the rest of the group is disjoint.

Refs neovim/neovim#40517
2026-07-01 18:07:14 -04:00
Will Lillis 57ea5340c6 fix(xtask): eliminate silent errors in zig fetch 2026-06-30 19:37:55 -04:00
dependabot[bot] 5b591babd1 ci: bump actions/cache from 5 to 6 in the actions group
Bumps the actions group with 1 update: [actions/cache](https://github.com/actions/cache).


Updates `actions/cache` from 5 to 6
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-29 23:39:20 +02:00
Christian Clason ae2081989e fix(deps): zig manifest for wasmtime is missing windows hashes
Problem: `zig fetch` on 0.16 can't download zip archives, which wasmtime
uses for Windows. This makes `cargo xtask upgrade-wastime` fail silently
with empty hashes for these platforms.

Solution: Re-run xtask with Zig 0.17 nightly.
2026-06-29 23:18:32 +02:00
Will Lillis 41d3e16eac test(query): regression test for anchored siblings inside a parent 2026-06-28 13:43:53 +02:00
Will Lillis 98c25b9aa0 feat(rust)!: change ts_set_allocator to accept one optional Allocator
object rather than 4 separate optional function pointers.

Helps prevent misuse via mixing different allocators. Also update the
doc comment with relevant safety information.
2026-06-27 23:22:11 -04:00
Will Lillis aec288f83c feat(generate)!: collect warnings as structured data
Allows for use by library consumers, CLI users when the `--json` flag is
passed, and cleans up core logic.
2026-06-27 22:39:24 -04:00
Michael Davis 9991c0f46f Add ts_query_copy for cloning queries
This allows duplicating a query so that it can be modified by using
disable_capture or disable_pattern, without re-parsing the query. The
new `ts_query_copy` creates a deep copy of the entire query object.

A motivation for this is tags.scm code navigation queries. You might
want to have one version of the compiled query capture only definitions
and the other only capture references, since references are much much
more common than definitions in a typical codebase. Instead of
re-parsing and analyzing the query and then calling
`ts_query_disable_capture`, we can clone the built query all-at-once and
then disable captures / patterns.
2026-06-27 17:53:13 -04:00
Lucas M. de Jong Larrarte 99bceec689 fix(query): skip passthrough steps when checking for fallible step splitting
Problem: In queries matching a parent node with anchored children
(siblings) where the first sibling has a quantifier and is not
captured, the check for fallible steps skips splitting the state because
the next node is a passthrough node (and not an is_immediate one). This
prevents the query from matching beyond the first occurrence.

Solution: In the check for fallible steps, skip the next steps if they
are passthrough steps.
2026-06-27 23:44:02 +02:00
Lucas M. de Jong Larrarte 8b43f42dca fix(query): avoid overriding states not seeking immediate match with states seeking immediate match
Problem: In queries matching a parent node with anchored children
(siblings) where the first anchored sibling has a quantifier, the
deduplication logic for states is overly aggressive. The logic causes
the state split on the first capture (with the parent) to be dropped in
favor of the loopback state. This results in the query not being able to
match beyond the first occurrence.

Solution: Prevent the deduplication logic from dropping a state that is
not seeking an immediate match for one that is seeking an immediate
match, since the one not seeking for an immediate match could still
match later nodes.
2026-06-27 23:44:02 +02:00
Lucas M. de Jong Larrarte 1b110f62dd fix(query): take anchors between siblings into account for fallible step splitting
Problem: In queries matching a parent node with anchored children
(siblings), the check for fallible steps only considers nodes with
children, which results in no state split being made for anchored
siblings (node1) . (node2). This prevents the query from matching beyond
the first occurrence.

Solution: Make the check for fallible steps consider also the case where
the next step is at the same depth and must be matched immediately
after.
2026-06-27 23:44:02 +02:00
Christian Clason cdae49be40 ci: update workflows for breaking actions/checkout change
Problem: actions/checkout@v7 refuses to checkout fork pull request code
on `pull_request_target` trigger, breaking backport and reviewers-remove
workflows on external PRs.

Solution:
* backport: Checkout the merged-into base branch by name.
* reviewers-remove: inline script so no checkout needed.
2026-06-27 23:25:18 +02:00
Andrew Gibb cbee467266
docs(readme): add link for cargo-binstall
* Update cli README.md

Added a link to CLI readme to make it clear to an outsider that
cargo-binstall is a different tool than cargo.

* Apply suggestion from @WillLillis

Co-authored-by: Will Lillis <will.lillis24@gmail.com>

---------

Co-authored-by: Christian Clason <ch.clason+github@icloud.com>
Co-authored-by: Will Lillis <will.lillis24@gmail.com>
2026-06-26 08:10:43 -04:00
Christian Clason 8668f2c74f build(deps): bump wasmtime-c-api to v36.0.12 2026-06-26 14:07:35 +02:00
Christian Clason cc85df9440 build(deps): bump wasmtime-c-api to v36.0.11 2026-06-25 22:54:45 -04:00
ALancki1 b360d655cc Clarify behavior of advance(..., skip) in external scanner docs
Clarifies the behavior of `TSLexer::advance` when `skip=true`.

The previous documentation didn't make it clear that `skip=true` should only be used before a token starts. Using it after `mark_end` can affect the token’s starting position and lead to incorrect or zero-length ranges.

Fixes #2315
2026-06-25 22:54:18 -04:00
Will Lillis a8338eccef fix(dsl): forbid invalid field names 2026-06-24 17:38:21 -04:00
dependabot[bot] 68316916e0 ci: bump the actions group with 2 updates
Bumps the actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [vmactions/omnios-vm](https://github.com/vmactions/omnios-vm).


Updates `actions/checkout` from 6.0.3 to 7.0.0
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6.0.3...v7.0.0)

Updates `vmactions/omnios-vm` from 1.3.2 to 1.3.3
- [Release notes](https://github.com/vmactions/omnios-vm/releases)
- [Commits](https://github.com/vmactions/omnios-vm/compare/v1.3.2...v1.3.3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: vmactions/omnios-vm
  dependency-version: 1.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-23 00:04:47 +02:00
dependabot[bot] 29e38c284e build(deps): bump cc from 1.2.64 to 1.2.65 in the cargo group
Bumps the cargo group with 1 update: [cc](https://github.com/rust-lang/cc-rs).


Updates `cc` from 1.2.64 to 1.2.65
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.64...cc-v1.2.65)

---
updated-dependencies:
- dependency-name: cc
  dependency-version: 1.2.65
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-22 23:46:36 +02:00
Will Lillis d861eab22b fix(build): use std helper rather than passing -std=c11 flag
MSVC expects `/std:c11`
2026-06-16 23:55:43 -04:00
Will Lillis 6b7e298549 fix(lib): address strict aliasing violations in TreeCursor type 2026-06-16 23:55:43 -04:00
dependabot[bot] 04bac19343 ci: bump vmactions/omnios-vm from 1 to 1.3.2 in the actions group
Bumps the actions group with 1 update: [vmactions/omnios-vm](https://github.com/vmactions/omnios-vm).


Updates `vmactions/omnios-vm` from 1 to 1.3.2
- [Release notes](https://github.com/vmactions/omnios-vm/releases)
- [Commits](https://github.com/vmactions/omnios-vm/compare/v1...v1.3.2)

---
updated-dependencies:
- dependency-name: vmactions/omnios-vm
  dependency-version: 1.3.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-16 10:40:26 +02:00
dependabot[bot] 6ad626c686 build(deps): bump js-yaml from 4.1.1 to 4.2.0 in /lib/binding_web
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.1 to 4.2.0.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/commits)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.2.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-16 10:39:58 +02:00
Christian Clason d3314cb62e build(deps): bump rquickjs to v0.12.0 2026-06-15 18:49:48 -04:00
dependabot[bot] d77f764dcd build(deps): bump the cargo group with 2 updates
Bumps the cargo group with 2 updates: [cc](https://github.com/rust-lang/cc-rs) and [memchr](https://github.com/BurntSushi/memchr).


Updates `cc` from 1.2.63 to 1.2.64
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.63...cc-v1.2.64)

Updates `memchr` from 2.8.1 to 2.8.2
- [Commits](https://github.com/BurntSushi/memchr/compare/2.8.1...2.8.2)

---
updated-dependencies:
- dependency-name: cc
  dependency-version: 1.2.64
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: memchr
  dependency-version: 2.8.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-15 23:44:16 +02:00
buckynbrocko 49f5027158 Added tree-sitter test option --show-diff-markers to force use of + & - while still coloring output
Also cleanup the trailing newline special casing in the `TestDiff`
`Display` impl.

Co-authored-by: Will Lillis <will.lillis24@gmail.com>
2026-06-13 10:29:37 -04:00
Will Lillis 3ed12db8f0 fix(rust): use more accurate types for various IoError structs 2026-06-13 09:35:12 -04:00
Christian Clason de4b622223 build(deps): bump wasmtime-c-api to v36.0.10 2026-06-10 17:36:02 -04:00
Christian Clason 2fb79a4325 build(deps): bump binaryen to v130 2026-06-10 17:25:15 -04:00
jannschu 519d511488 fix(cli): highlight test did not properly check for spans on later rows
The early exit condition to skip remaining highlights was incorrectly
checking the lexicographical order, which could lead to false
passes if a highlight was on a later row with smaller column number.
2026-06-08 18:09:03 -04:00
dependabot[bot] 811b5308f8 ci: bump actions/checkout from 6.0.2 to 6.0.3 in the actions group
Bumps the actions group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 6.0.2 to 6.0.3
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6.0.2...v6.0.3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-08 23:50:59 +02:00
Will Lillis 4455da7102 fix(rust): more clippy fixes in generate
Additional clippy lints fire when certain modules are temporarily made
public, i.e. for testing purposes. Fixing these reduces clutter and
helps with internal development.
2026-06-05 17:31:40 -04:00
Will Lillis 4154ff23c0 fix(docs): explicitly warn against aliasing supertypes 2026-06-05 17:31:26 -04:00
Will Lillis d10b7272d2 fix(cli): warn user for various malformed tests
- attribute on same line of name
- typo'd attribute
- no closing `=====` line after the test body
2026-06-05 17:31:09 -04:00
Will Lillis d9acc99734 fix(cli): display warning to user if parser test corpus dir isn't found 2026-06-05 17:30:52 -04:00
Will Lillis 0617a59ed6 fix: add DESCRIPTION to grammar Makefile template 2026-06-05 09:43:49 +02:00
dependabot[bot] 5742052982 build(deps): bump the cargo group with 3 updates
Bumps the cargo group with 3 updates: [cc](https://github.com/rust-lang/cc-rs), [log](https://github.com/rust-lang/log) and [memchr](https://github.com/BurntSushi/memchr).


Updates `cc` from 1.2.62 to 1.2.63
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.62...cc-v1.2.63)

Updates `log` from 0.4.29 to 0.4.30
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.29...0.4.30)

Updates `memchr` from 2.8.0 to 2.8.1
- [Commits](https://github.com/BurntSushi/memchr/compare/2.8.0...2.8.1)

---
updated-dependencies:
- dependency-name: cc
  dependency-version: 1.2.63
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: log
  dependency-version: 0.4.30
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: memchr
  dependency-version: 2.8.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-03 12:06:15 +02:00
dependabot[bot] 94d419832e ci: bump actions/checkout from 6 to 6.0.2 in the actions group
Bumps the actions group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 6 to 6.0.2
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v6.0.2)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-03 12:05:42 +02:00
Trevor Burnham ff4dbc0589
perf(bindings): defer importlib.resources import in python template (#5589)
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
2026-06-01 23:08:00 -04:00
Will Lillis 15ddfb21ed fix(lib): Consider subtree lookahead bytes when determining whether the
parser can reuse a node.

Lookahead bytes can be used to decide what a node is parsed as, so it's
resaonable to consider this as part of a node's "range" when deciding
which edits affect it.
2026-06-01 18:12:56 -04:00
jannschu f541fec5ad fix(cli): infinite loop in highlight test 2026-05-31 12:37:38 -04:00
Will Lillis cd338a7a43 fix(loader): skip --no-undefined for sanitizer grammar builds
Compiling a grammar with `-fsanitize=address` (or any other sanitizer)
emits a module constructor in the parser object file that references
runtime symbols like `__asan_init`. These runtime-resolved symbols are
incompatible with `-Wl,--no-undefined`, which breaking sanitized test
runs on clang. (gcc happens to paper over this by auto-linking libasan
into the .so)

To fix, detect `-fsanitize=` in the compile flags and omit `--no-undefined`
in that case.
2026-05-31 10:56:40 -04:00
Will Lillis ceef7d179f fix(lib): rewrite ts_subtree__write_to_string to be iterative 2026-05-31 10:56:12 -04:00
Will Lillis 797d2bddc4 fix(cli): make check_consistent_sizes iterative
The recursive helper could overflow with deeply nested trees.
2026-05-31 10:56:12 -04:00
Will Lillis e00bf7bc84 fix(cli): print fuzzing seed unconditionally 2026-05-31 10:56:12 -04:00
Will Lillis f1db12c31c fix(cli): improve soundness of cst range calculation 2026-05-31 10:55:47 -04:00
Will Lillis 4d362b4b98 feat(generate): derive Deserialize on GenerateError and all subtypes
These types all derive `Serialize` already.
2026-05-31 08:45:11 +02:00
Georges Savoundararadj 1da46327b3 fix(lib): use correct TREE_SITTER_HIDE_SYMBOLS macro name in alloc.h
The alloc.h header checked for TREE_SITTER_HIDDEN_SYMBOLS, but the
canonical macro name used everywhere else (api.h, render.rs, setup.py)
is TREE_SITTER_HIDE_SYMBOLS. This mismatch meant that defining
TREE_SITTER_HIDE_SYMBOLS (as the Python binding build does) would not
actually hide the allocator symbols in alloc.h.

Fixes tree-sitter/tree-sitter#5625

Signed-off-by: Georges Savoundararadj <savoundg@amazon.com>
2026-05-30 21:42:31 -04:00
Will Lillis 17125cefa6 fix(lib): update doc comment for ts_parser_parse 2026-05-30 04:11:53 -04:00