Commit graph

321 commits

Author SHA1 Message Date
Riley Bruins
dff828cdbe fix(rust): prevent overflow in error message calculation
**Problem:** When encountering an invalid symbol at the beginning of the
file, the rust bindings attempt to index the character at position -1 of
the query source, which leads to an overflow and thus invalid character
index which causes a panic.

**Solution:** Bounds check the offset before performing the subtraction.
2025-07-22 09:51:28 +02:00
Will Lillis
86b2c939c7 fix(rust): address nightly clippy lint useless_if_let_seq 2025-07-20 21:14:47 -04:00
Will Lillis
be8b3e282a fix(rust): remove unused Command import 2025-06-26 00:54:44 -04:00
James McCoy
889015f03b
build(rust): use $CARGO_PKG_RUST_VERSION when generating bindings (#4512)
Since cargo 1.63, $CARGO_PKG_RUST_VERSION is set in the build
environment to the value of the rust-version Cargo.toml field.

This removes the need to manually invoke cargo from build.rs during a
build of the tree-sitter crate with the bindgen feature enabled.

Removing the cargo invocation also ensures the build doesn't write to
the current directory when the target directory has been redirected
elsewhere. "cargo metadata" will attempt to update Cargo.lock, which
will fail if the source tree is read-only.
2025-06-13 11:11:22 -07:00
Amaan Qureshi
0191e94226 docs(rust): remove adding cc as a build dependency for consumers 2025-04-28 18:30:45 -04:00
Will Lillis
9fdf685dd5 fix(bindings): report wasm store error in rust bindings set_language 2025-04-14 22:15:40 -04:00
Jason Boatman
abc5c6bc50
Fix WASI build by not calling a non-existent function. (#4343) 2025-04-08 09:33:48 -07:00
Simon Willshire
ee8d529552
fix(rust): use core crates for no_std
also add `no_std` build to CI
2025-03-25 14:30:32 +01:00
WillLillis
dac6300558 fix(rust): address new clippy lint for pointer comparisons 2025-03-25 13:44:42 +01:00
Riley Bruins
cc3994928c feat(lib): quote invalid nodes, fields, and captures 2025-03-12 10:28:57 +01:00
June Gschwantner
0b28226615
docs(bindings): Add "Using WASM Grammar files" section to binding_rust (#4235) 2025-03-06 14:15:21 -08:00
WillLillis
11071ed682 fix(rust): adapt to new nightly lint 2025-03-06 09:32:21 +01:00
Amaan Qureshi
05d443a019
style(rust): correct doc comments 2025-02-02 02:07:36 -05:00
Amaan Qureshi
dc64bb5395 chore: adapt to latest clippy lints 2025-01-31 20:41:11 -05:00
Allan Clements
cda634a1c4 feat: add error information in the progress callback
This allows users to bail parsing if an error was *definitely* detected
using the progress callback, as all possible stack versions have a
non-zero error cost.

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2025-01-25 02:47:39 -05:00
Amaan Qureshi
8bb1448a6f feat: add the semantic version to TSLanguage, and expose an API for retrieving it 2025-01-25 01:14:30 -05:00
Yuri Astrakhan
3e7721e554 chore: a few more minor lints 2025-01-23 00:10:16 -05:00
Amaan Qureshi
27bc78698d feat(lib): implement Send + Sync for WasmStore 2025-01-21 00:21:35 -05:00
Amaan Qureshi
29e6717c31 fix(lib): temporarily allow lint with false positives 2025-01-17 20:41:06 -05:00
Amaan Qureshi
344a88c4fb feat(lib)!: remove ts_node_child_containing_descendant
It was marked deprecated in 0.24
2025-01-12 22:11:30 -05:00
Amaan Qureshi
f941277a9d docs(lib): improve documentation on ts_tree_get_changed_ranges and ts_query_cursor_set_{byte,point}_range 2025-01-12 14:56:22 -05:00
Amaan Qureshi
26d4b19006 build(rust): bump the lib's MSRV to 1.76 2025-01-12 04:47:59 -05:00
Amaan Qureshi
95fd37ecf8 docs: add information about the scoping of cursors 2025-01-11 02:33:48 -05:00
WillLillis
767b5486c6 docs: clarify data returned by QueryCaptures during iteration 2025-01-05 03:01:36 -05:00
Riley Bruins
19482834bd feat: add Supertype API
Introduces a new function that takes in a supertype symbol and returns
all associated subtypes. Can be used by query.c to give better errors
for invalid subtypes, as well as downstream applications like the query
LSP to give better diagnostics.
2025-01-05 00:14:09 -05:00
Amaan Qureshi
5d99014bb8 style: rephrase extends beyond to contains or starts after 2024-12-28 18:53:08 -05:00
WillLillis
7ba0f297e5 fix: re-export StreamingIterator and StreamingIteratorMut 2024-12-24 23:19:33 -05:00
Will Lillis
2a63077cac
style: correct typos 2024-12-23 02:11:09 -05:00
Amaan Qureshi
7d3dbc062d build: bump deps 2024-12-16 01:22:58 -05:00
StratusFearMe21
c053b63be8
docs(rust): update doc comment on node ids 2024-12-15 22:52:46 -05:00
Riley Bruins
fa6c1471ef
fix(lib): correct escape detection for invalid anonymous nodes
The current quotation escape checker fails in the case that
there is an anonymous node that is just an escaped backslash (it thinks
the backslash escapes the quote, when really it is just an escaped
backslash itself. See the added test case for an example of this).

This commit ensures the node identification logic keeps track of the
number of backslashes seen so it can accurately determine if the
quotation is escaped or not.
2024-11-15 23:49:06 -05:00
Amaan Qureshi
49ff53cc83 fix(lib): correctly fetch the node name in query errors 2024-11-10 03:44:54 +01:00
WillLillis
5b5cf5a5e5 fix(lib): check point, byte ranges in ts_query_cursor_set
range functions
2024-11-02 03:06:07 -04:00
Amaan Qureshi
e892862c6c fix(rust): fix progress callback scope to prevent premature drop 2024-11-02 00:57:50 -04:00
Amaan Qureshi
500f4326d5 feat: add the ability to specify a custom decode function 2024-10-31 22:51:40 -04:00
Amaan Qureshi
6fdba6bbd6 feat(rust): add *_with_options to the parser and query cursor, deprecate old functions
The normal `with` functions are now deprecated in favor of the
`with_options` ones.
2024-10-31 21:58:35 -04:00
Amaan Qureshi
8d68980aa8 feat(lib): add ts_query_cursor_exec_with_options
Currently, this allows users to pass in a callback that should be
invoked to check whether or not to halt query execution
2024-10-31 21:58:35 -04:00
Amaan Qureshi
26b89da9bb feat(lib): add ts_parser_parse_with_options
Currently, this allows users to pass in a callback that should be
invoked to check whether or not to halt parsing
2024-10-31 21:58:35 -04:00
Amaan Qureshi
55bda0a968 build: regenerate bindings.rs & add Language::name 2024-10-29 18:51:27 -04:00
Amaan Qureshi
ce93d8fd9b feat!: bump internal abi to 15 2024-10-26 17:02:00 +00:00
ObserverOfTime
8515986b73 docs(rust): document optional features 2024-10-24 17:08:55 +00:00
Mrmaxmeier
c03977a87e
fix: return LanguageRef in Parser::language
`ts_parser_language` doesn't do any refcounting, so we can't return the
resulting pointer as an owned Language object
2024-10-17 15:44:08 -04:00
Amaan Qureshi
38e3e51fca feat(rust): add Language::node_kind_is_supertype 2024-10-14 17:53:22 -04:00
Will Lillis
5c6445edea
chore: misc clippy lints 2024-10-06 17:55:00 -04:00
Antonin Delpeuch
50bea73ce3
docs(rust): updated README to reflect language initialization updates 2024-10-06 13:30:05 -04:00
Amaan Qureshi
8943983df6 feat!: properly handle UTF-16 endianness encoding 2024-10-05 21:12:48 -04:00
Riley Bruins
0683136ca0 feat(api): expose function to check if symbol represents a supertype 2024-09-30 14:44:13 -04:00
Amaan Qureshi
934a2814fd fix: deprecate child_containing_descendant and add child_with_descendant instead 2024-09-30 13:57:28 -04:00
Yuta Saito
94a8262110 fix: exclude APIs that dup given file descriptors from WASI builds
WASI doesn't support `dup(2)` system call, so we cannot implement the
`print_dot_graph` and `print_dot_graphs` functions with exactly the same
semantics as in other platforms.
2024-09-29 23:01:41 -04:00
Lukas Seidel
6b1ebd3d29
feat!: implement StreamingIterator instead of Iterator for QueryMatches and QueryCaptures
This fixes UB when either `QueryMatches` or `QueryCaptures` had collect called on it.

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-09-29 17:34:48 -04:00