Commit graph

965 commits

Author SHA1 Message Date
Amaan Qureshi
d97db6d635
0.23.2 2024-10-01 12:34:25 -04:00
Amaan Qureshi
78c41e3ced
0.23.1 2024-09-30 18:25:19 -04:00
Yuta Saito
bf094bd98a 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.

(cherry picked from commit 94a8262110)
2024-09-30 09:21:54 -04:00
Ron Panduwana
d10308528d fix: handle more cases of editing subtrees that depend on column values
(cherry picked from commit a83b893016)
2024-09-29 20:37:24 -04:00
Amaan Qureshi
865f6595e7 fix(lib): correct descendant-for-range behavior with zero-width tokens
(cherry picked from commit 0c43988a5e)
2024-09-27 09:21:17 -04:00
dependabot[bot]
3492bee2f7 build(deps): bump the cargo group across 1 directory with 11 updates
Bumps the cargo group with 10 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [anyhow](https://github.com/dtolnay/anyhow) | `1.0.86` | `1.0.89` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.1.14` | `1.1.19` |
| [clap](https://github.com/clap-rs/clap) | `4.5.16` | `4.5.17` |
| [filetime](https://github.com/alexcrichton/filetime) | `0.2.24` | `0.2.25` |
| [indexmap](https://github.com/indexmap-rs/indexmap) | `2.4.0` | `2.5.0` |
| [pretty_assertions](https://github.com/rust-pretty-assertions/rust-pretty-assertions) | `1.4.0` | `1.4.1` |
| [serde](https://github.com/serde-rs/serde) | `1.0.209` | `1.0.210` |
| [serde_json](https://github.com/serde-rs/json) | `1.0.127` | `1.0.128` |
| [webbrowser](https://github.com/amodm/webbrowser-rs) | `1.0.1` | `1.0.2` |
| [bindgen](https://github.com/rust-lang/rust-bindgen) | `0.69.4` | `0.70.1` |

Updates `anyhow` from 1.0.86 to 1.0.89
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.86...1.0.89)

Updates `cc` from 1.1.14 to 1.1.19
- [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.1.14...cc-v1.1.19)

Updates `clap` from 4.5.16 to 4.5.17
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.16...clap_complete-v4.5.17)

Updates `filetime` from 0.2.24 to 0.2.25
- [Commits](https://github.com/alexcrichton/filetime/compare/0.2.24...0.2.25)

Updates `indexmap` from 2.4.0 to 2.5.0
- [Changelog](https://github.com/indexmap-rs/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/indexmap-rs/indexmap/compare/2.4.0...2.5.0)

Updates `pretty_assertions` from 1.4.0 to 1.4.1
- [Release notes](https://github.com/rust-pretty-assertions/rust-pretty-assertions/releases)
- [Changelog](https://github.com/rust-pretty-assertions/rust-pretty-assertions/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-pretty-assertions/rust-pretty-assertions/compare/v1.4.0...v1.4.1)

Updates `serde` from 1.0.209 to 1.0.210
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.209...v1.0.210)

Updates `serde_derive` from 1.0.209 to 1.0.210
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.209...v1.0.210)

Updates `serde_json` from 1.0.127 to 1.0.128
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/1.0.127...1.0.128)

Updates `webbrowser` from 1.0.1 to 1.0.2
- [Release notes](https://github.com/amodm/webbrowser-rs/releases)
- [Changelog](https://github.com/amodm/webbrowser-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/amodm/webbrowser-rs/compare/v1.0.1...v1.0.2)

Updates `bindgen` from 0.69.4 to 0.70.1
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.69.4...v0.70.1)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: cc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: filetime
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo
- dependency-name: pretty_assertions
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: serde_derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: webbrowser
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: bindgen
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit c6faeb948e)
2024-09-22 01:43:38 -04:00
Amaan Qureshi
a6b248c1ad fix(lib): peek at the next sibling when iterating to find the child that contains a given descendant
This issue shows up when we have a zero-width token that is the target
descendant node, previously the previous sibling would be returned as
the child that contains the descendant, which is incorrect.

(cherry picked from commit 0a85744eba)
2024-09-17 17:22:13 +02:00
Amaan Qureshi
0eb5b0a029 fix(binding_web): remove nonexistent function definition
(cherry picked from commit 8667e3ea0c)
2024-09-08 17:06:15 -04:00
Amaan Qureshi
513f19d099 fix(binding_web): correct edit signature
(cherry picked from commit fcbd67b3fa)
2024-09-07 17:53:40 -04:00
Amaan Qureshi
43e16dd75c fix(lib): backtrack to the last relevant iterator if no child was found
(cherry picked from commit 9b398c2b84)
2024-09-05 18:03:50 -04:00
Liam Rosenfeld
ea6b62cbc6 feat(language): derive Clone and Copy on LanguageFn
Allows a LanguageFn to be passed around and create multiple languages since Language::new consumes a LanguageFn

LanguageFn just wraps a function pointer, which already conforms to Copy so this is a simple addition.

(cherry picked from commit d60789afdc)
2024-09-03 12:15:56 -04:00
Amaan Qureshi
55fb817dc8 fix(rust): add missing TSNode functions
(cherry picked from commit 4387e44b98)
2024-09-01 16:21:51 -04:00
Amaan Qureshi
1a3f486059 fix(lib): correct extra node creation from non-zero root-alias cursors
(cherry picked from commit ee06325f67)
2024-09-01 16:21:33 -04:00
Amaan Qureshi
12fb31826b
0.23.0 2024-08-26 09:07:00 -04:00
Ryan Patterson
b5e4ef6d9a
clone wasm store engine (#3542)
This resolves https://github.com/tree-sitter/tree-sitter/issues/3454.

This brings the usage of wasmtime::Engine in line with how wasmtime
intends it to be used. All wasmtime functions that receive an Engine
always receive an `&Engine`, never an owned `Engine`.  They are always
responsible for cloning the reference if they need it.

This brings the usage of wasmtime::Engine in line with how TSParser
treats TSLanguages: when setting a language to the parser, the parser is
responsible for cloning the reference to the TSLanguage. It is
counterintuitive for TSParser to have different behavior when receiving
wasmtime_engine_t.

C API users also expect this behavior, see "Memory Management"
[here](https://docs.wasmtime.dev/c-api/wasm_8h.html). Talking about the
C API: without this change, failing to clone the `wasmtime_engine_t`
(which, again, is never something API users need to do in wasmtime) and
then reusing the engine in multiple TSLanguages results in a use after
free. With this change, failing to call `wasm_engine_delete` on your
owned Engine results in a memory leak. Memory leaks are safer than
use-after-free.
2024-08-22 08:01:37 -07:00
Christian Clason
b0dab87c09 build(deps): bump wasmtime to v24.0.0 2024-08-20 18:09:23 +02:00
Matt Guerrette
3c7c17b00b
fix(lib): fix api header C++ interop (#3534) 2024-08-18 12:01:13 +03:00
Amaan Qureshi
6dd459b4ab fix(lib): an empty root node should not precede an empty range
The problem is, given an empty file, the root node of this file spans 0
bytes. As such, the logic for determining whether or not the node
precedes the range fails, and is true when it should be false.
2024-08-17 17:05:26 -04:00
Ron Panduwana
2bb20fe2fe
feat: allow external scanners to use the logger
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-08-17 14:46:28 -04:00
dependabot[bot]
78f02d95f3 build(deps): bump the cargo group across 1 directory with 14 updates
Bumps the cargo group with 13 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [anstyle](https://github.com/rust-cli/anstyle) | `1.0.7` | `1.0.8` |
| [clap](https://github.com/clap-rs/clap) | `4.5.9` | `4.5.16` |
| [ctrlc](https://github.com/Detegr/rust-ctrlc) | `3.4.4` | `3.4.5` |
| [filetime](https://github.com/alexcrichton/filetime) | `0.2.23` | `0.2.24` |
| [indexmap](https://github.com/indexmap-rs/indexmap) | `2.2.6` | `2.4.0` |
| [libloading](https://github.com/nagisa/rust_libloading) | `0.8.4` | `0.8.5` |
| [regex](https://github.com/rust-lang/regex) | `1.10.5` | `1.10.6` |
| [serde](https://github.com/serde-rs/serde) | `1.0.204` | `1.0.208` |
| [serde_json](https://github.com/serde-rs/json) | `1.0.120` | `1.0.125` |
| [similar](https://github.com/mitsuhiko/similar) | `2.5.0` | `2.6.0` |
| [tempfile](https://github.com/Stebalien/tempfile) | `3.10.1` | `3.12.0` |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.62` | `1.0.63` |
| [toml](https://github.com/toml-rs/toml) | `0.8.14` | `0.8.19` |



Updates `anstyle` from 1.0.7 to 1.0.8
- [Commits](https://github.com/rust-cli/anstyle/compare/v1.0.7...v1.0.8)

Updates `clap` from 4.5.9 to 4.5.16
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.9...clap_complete-v4.5.16)

Updates `ctrlc` from 3.4.4 to 3.4.5
- [Release notes](https://github.com/Detegr/rust-ctrlc/releases)
- [Commits](https://github.com/Detegr/rust-ctrlc/compare/3.4.4...3.4.5)

Updates `filetime` from 0.2.23 to 0.2.24
- [Commits](https://github.com/alexcrichton/filetime/compare/0.2.23...0.2.24)

Updates `indexmap` from 2.2.6 to 2.4.0
- [Changelog](https://github.com/indexmap-rs/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/indexmap-rs/indexmap/compare/2.2.6...2.4.0)

Updates `libloading` from 0.8.4 to 0.8.5
- [Commits](https://github.com/nagisa/rust_libloading/compare/0.8.4...0.8.5)

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

Updates `serde` from 1.0.204 to 1.0.208
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.204...v1.0.208)

Updates `serde_derive` from 1.0.204 to 1.0.208
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.204...v1.0.208)

Updates `serde_json` from 1.0.120 to 1.0.125
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.120...1.0.125)

Updates `similar` from 2.5.0 to 2.6.0
- [Changelog](https://github.com/mitsuhiko/similar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/similar/compare/2.5.0...2.6.0)

Updates `tempfile` from 3.10.1 to 3.12.0
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/commits)

Updates `thiserror` from 1.0.62 to 1.0.63
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.62...1.0.63)

Updates `toml` from 0.8.14 to 0.8.19
- [Commits](https://github.com/toml-rs/toml/compare/toml-v0.8.14...toml-v0.8.19)

---
updated-dependencies:
- dependency-name: anstyle
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: ctrlc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: filetime
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo
- dependency-name: libloading
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: serde_derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: similar
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
- dependency-name: toml
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-17 01:32:31 -04:00
Christian Clason
c3dd66df0e build(deps): bump wasmtime to v23.0.2 2024-08-16 14:02:56 +02:00
Ryan Patterson
779566f588
Reset language when resetting wasm store (#3495)
* Reset language when resetting wasm store

* test behavior of language copying
2024-07-31 10:30:58 -07:00
Boris Verkhovskiy
cd3e561224
build(wasm): don't minify JS (#3380) 2024-07-29 10:00:02 +03:00
ObserverOfTime
2512f3ab17 docs: document rust library features 2024-07-28 11:34:26 +03:00
DragonBillow
d13d7235d2 feat(lib): support no_std 2024-07-28 11:34:26 +03:00
ibrahim Sağıroğlu
76456919ae
docs: fix tree cursor documentation (#3324)
- ts_tree_cursor_current_depth
- ts_tree_cursor_reset
2024-07-28 10:36:06 +03:00
Amaan Qureshi
25c7189180 feat(lib): add ts_query_end_byte_for_pattern 2024-07-07 20:29:09 -04:00
Quentin LE DILAVREC
9610a84600
fix(lib): restrict pattern_map optimization when a wildcard step has an immediate first child
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-07-05 03:35:24 -04:00
Davis Vaughan
218a071d33 Swap sprintf() for snprintf() 2024-06-24 09:56:24 -04:00
Piotr Osiewicz
3c3699ba90
perf: hoist out common subexpressions in satisfies_text_predicates
This commit stores the result of text predicates evaluation in a separate variable to ensure that they're computed just once. As is, it is possible for e.g. #match predicates to match node against a regex twice.
2024-06-03 14:25:30 +02:00
Amaan Qureshi
6304009209
fix(wasm): update test 2024-06-03 12:42:25 +02:00
Amaan Qureshi
7f4a57817d build(deps): bump wasmtime to v21 2024-05-29 18:57:26 -04:00
Max Brunsfeld
38137c71b2 feat!: introduce tree-sitter-language crate for grammar crates to depend on
Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
2024-05-24 21:54:07 -04:00
Amaan Qureshi
ae35a36747 fix(lib): a null clock must have tv_nsec be 0 as well 2024-05-19 02:19:37 -04:00
Paolo Tranquilli
d35e40185a
fix(rust): fetch CARGO_MANIFEST_DIR at runtime in build script
The `CARGO_MANIFEST_DIR` environment variable should be accessed by
`build.rs` at run time rather than compile time. This was for example
causing issues when importing `tree-sitter` via
[`rules_rust`](https://github.com/bazelbuild/rules_rust) in bazel,
where compilation and running happen in separate environments.
2024-05-13 10:09:58 -04:00
Amaan Qureshi
b40f342067
0.22.6 2024-05-05 16:47:18 -04:00
Amaan Qureshi
4c083252ec fix(lib): advance the lookahead end byte by 4 when there's an invalid code point
This helps in the case where an edit was made in the middle of a code
point, but bytes 1-3 are valid, thus we could advance by at most 4 bytes
2024-04-30 20:55:43 -04:00
Amaan Qureshi
61d0395543 fix(lib): do not return field names for extras 2024-04-30 19:23:11 -04:00
Max Brunsfeld
37a919184f Position serialization buffer after language statics in wasm linear memory 2024-04-25 14:21:28 -07:00
Max Brunsfeld
78efd96bbe Crash earlier if native external scanner overflows serialization buffer 2024-04-25 13:55:47 -07:00
Max Brunsfeld
e9fd4ccf0c Guard against serialization buffer overflows from wasm languages 2024-04-25 13:51:05 -07:00
Max Brunsfeld
d7a23cf017 fix: Correctly load field data from wasm languages
Previously, if the last production id in a language did not have
a unique set of fields, the field maps weren't loaded correctly
from wasm.

Co-authored-by: Marshall <marshall@zed.dev>
2024-04-24 16:29:44 -07:00
vanaigr
90e0e28b95
feat: reverse iteration through node parents (#3214) 2024-04-23 15:19:57 +01:00
Liam Rosenfeld
0f125e2d09
fix(rust): use unix + wasi cfg instead of not windows for fd 2024-04-23 10:13:38 -04:00
Jisuk Byun
4cd23ff6b0
fix(rust): update README example 2024-04-18 13:25:42 -04:00
Adrien Friggeri
01bf431261
fix(wasm): correct childrenFromFieldXXX method signatures
These do not expect a `cursor` parameter
2024-04-16 13:48:53 -04:00
Max Brunsfeld
cdd4688860 0.22.5 2024-04-14 10:17:04 -07:00
Mark McCulloh
a7a47d561d
fix(rust): compilation on wasm32-wasi 2024-04-13 18:30:41 -04:00
Max Brunsfeld
285257998c 0.22.4 2024-04-12 17:03:02 -07:00
Max Brunsfeld
a3d338781b 0.22.3 2024-04-12 15:10:49 -07:00