Commit graph

169 commits

Author SHA1 Message Date
Andrew Hlynskyi
9c06b90fc2 More general TextProvider for F 2023-07-31 04:13:18 +03:00
Andrew Hlynskyi
7938db90fe TextProvider with generic return type 2023-07-30 21:56:58 +03:00
Amaan Qureshi
36c6c8aadf
Merge pull request #2423 from amaanq/nonzero-field-id
feat!: use `Option<NonZeroU16>` for TSFieldIds
2023-07-27 13:04:34 -04:00
Amaan Qureshi
7ad21396c2
feat!: use Option<NonZeroU16> for TSFieldIds 2023-07-27 12:26:25 -04:00
Amaan Qureshi
a4f939520f
docs: update Rust bindings' README 2023-07-24 02:07:09 -04:00
Andrew Hlynskyi
7afd5a1a8b rust: remove Copy, Clone from opaque ptr data structs 2023-07-14 00:19:23 +03:00
Andrew Hlynskyi
af42cfccd6 rust: fix ffi impl, some structs are stack allocated 2023-07-13 23:48:38 +03:00
Amaan Qureshi
2f2e416031 chore: update Rust bindings 2023-07-13 11:39:33 -04:00
Andrew Hlynskyi
f01c4f8376 Restore Rust bindings generation with newer bindgen 0.65.1 2023-07-13 17:34:32 +03:00
Max Brunsfeld
4922602369
Merge pull request #2316 from tree-sitter/node-descendant-index
Add APIs for retrieving descendant counts, seeking to nodes by their descendant index
2023-06-12 15:13:43 -07:00
Max Brunsfeld
a2119cb691 Add APIs for retrieving tree cursor's depth and descendant index 2023-06-12 11:50:44 -07:00
Max Brunsfeld
9dd725b4e3 Start work on exposing APIs for node descendant counts and indices 2023-06-09 08:51:47 -07:00
Samuel Moelius
f461d953a6 Fix OOB in Query::new 2023-05-19 21:31:26 -04:00
Andrew Hlynskyi
cc6596be82 chore(bindgen): update bindgen to 0.65.1 and regenerate bindings 2023-04-17 11:24:05 +03:00
Lewis Russell
1e81a1b67f feat(lib): add ts_query_cursor_set_max_start_depth query API
This allows configuring cursors from traversing too deep into a tree.
2023-04-17 11:15:13 +03:00
Andrew Hlynskyi
613382c70a docs: update badges; fix markdown lint complains
Linter config `.vscode/settings.json`:
```json
{
    "[markdown]": {
        "files.trimTrailingWhitespace": false,
    },
    "markdownlint.config": {
        "default": true,
        // "ul-style": {
        //     "style": "asterisk"
        // },
        "MD001": false,
        "MD024": false,
        "MD025": false,
        "MD033": false,
        "MD041": false,
        "MD053": false,
    },
}
```
2023-04-16 23:39:08 +03:00
Andrew Hlynskyi
c38f78345e binding(rust): update script/generate-bindings to use latest rust-bindgen 0.64.0 version 2023-04-04 22:16:27 +03:00
Andrew Hlynskyi
d56506b727 ref(rust_bindings): keep Query construction logic in a one place 2023-04-04 15:08:53 +03:00
Vhyrro
e5357dc5ad ref(rust_bindings): add from_raw() functions 2023-04-04 15:08:53 +03:00
Vhyrro
6c2957c8d3 ref(rust_bindings): move into_raw() functions into the ffi module 2023-04-04 15:08:53 +03:00
Vhyrro
576e4c7d06 fix(rust_bindings): use-after-free for Language::into_raw() 2023-04-04 15:08:53 +03:00
Vhyrro
3d396e120b feat(rust_bindings): provide into_raw() functions for treesitter structs 2023-04-04 15:08:53 +03:00
Andrew Hlynskyi
ec2af46f6f chore: remove all dead badges 2023-03-16 18:00:02 +02:00
Max Brunsfeld
837899e456 Add API for checking if a pattern in a query is non-local 2023-02-16 11:59:34 -08:00
Max Brunsfeld
97fd990822 Add --dot flag to parse subcommand, for printing tree as DOT graph 2023-02-13 12:33:34 -08:00
Léo Gaspard
3964651fc6
Derive Hash for Language
Given Language implements Eq, it can probably implement Hash too.

This makes it easy to derive a random identifier from a `Language`
2023-02-09 03:35:42 +01:00
Max Brunsfeld
618146260e Add doc comments for tree included ranges getter 2022-11-08 17:47:57 -08:00
Max Brunsfeld
f0177f216e Use library-configured allocator to free intermediate included ranges 2022-11-07 10:48:32 -08:00
Max Brunsfeld
1848d0bc36 Add tree included ranges getter
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-11-04 15:24:07 -07:00
Max Brunsfeld
477b667753 Add ts_tree_root_node_with_offset API 2022-08-18 13:48:47 -07:00
Max Brunsfeld
548c12fb88 Fix bug where patterns with top-level alternatives were not considered 'rooted' 2022-07-07 17:53:54 -07:00
rhysd
08899428f3 Add C APIs as document aliases 2022-05-30 21:36:11 +09:00
Aleksei Bavshin
fe33599f46
lib: fix incorrect int ptr cast on big-endian architectures
`*usize` -> `*u32` conversion on 64-bit big-endian machine takes high
halfword of the value. As a consequence, any result returned via
`count` is unexpectedly shifted left:

    u32   = 00 00 00 01             // 1
    usize = 00 00 00 01 00 00 00 00 // 4294967296

Fixes following test failure:
```
$ cargo test -- tests::corpus_test
<...>
running 13 tests
memory allocation of 206158430208 bytes failed
error: test failed, to rerun pass '--lib'
```
2022-03-23 00:47:01 -07:00
Max Brunsfeld
aaf4572727
Merge pull request #1589 from alex-pinkus/deduplicate-core-ids
Ignore duplicate states when initializing subgraphs in `ts_query__analyze_patterns`
2022-01-17 13:54:31 -08:00
Alex Pinkus
eaf9b170f1 Don't start with duplicate states in ts_query__analyze_patterns
This change exposes a new `primary_state_ids` field on the `TSLanguage`
struct, and populates it by tracking the first encountered state with a
given `core_id`. (For posterity: the initial change just exposed
`core_id` and deduplicated within `ts_analyze_query`).

With this `primary_state_ids` field in place, the
`ts_query__analyze_patterns` function only needs to populate its
subgraphs with starting states that are _primary_, since non-primary
states behave identically to primary ones. This leads to large savings
across the board, since most states are not primary.
2022-01-16 11:17:47 -08:00
Hendrik van Antwerpen
acd3d32c36 Remove reference to strings from quantifier-only function 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
e338726cde Prefix globally visible TSquantifier values 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
36f2440369 Complete comment 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
a1a241b013 Expose quantifiers per pattern, instead of merging for all patterns in a query 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
1f1a449c76 Improve capture quantifier computation
Compute quantifiers in a bottom-up manner, which allows more precise
results for alternations, where the quantifiers are now precisly joined.
2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
9bac066330 Deal with quantifiers appearing on capture's enclosing patterns
- Use a proper enum type for quantifiers.
- Drop quantifiers from `TSQueryStep`, which was not used.
- Keep track of the captures introduced during a pattern parse, and
  apply the quantifier for the pattern to the captures that were
  introduced by the pattern or any sub patterns.
- Use 'quantifier' instead of 'suffix'.
2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
ae7869d1a6 Expose capture suffixes in queries 2022-01-11 18:33:36 +01:00
Max Brunsfeld
622359b400 Simplify allocation-recording in test suite using new ts_set_allocator API 2021-12-30 16:09:07 -08:00
Max Brunsfeld
8de8c64c95 Remove unnecessary types from binding.rs 2021-12-09 21:02:15 -08:00
Max Brunsfeld
142f4b6438 Rename Query::step_is_definite -> is_pattern_guaranteed_at_step 2021-11-21 11:37:52 -08:00
Max Brunsfeld
e78413832b Restructure test suite's allocation recording so that tests can run in parallel 2021-10-11 17:24:37 -07:00
Max Brunsfeld
fe29bc8c19 Tweak comment formatting in api.h so bindgen doesn't create a doctest 2021-10-11 17:23:44 -07:00
Wilfred Hughes
f17f08bbef Add missing word in doc comment 2021-09-30 21:53:41 -07:00
Max Brunsfeld
561dfe3a2d
Merge pull request #1394 from tree-sitter/fix/query-predicates-with-alternations
fix(cli): Panic on queries containing alternation with predicates
2021-09-24 08:56:23 -07:00
Andrew Hlynskyi
d973527964 binding(rust): Mark set_cancellation_flag self as mutable 2021-09-21 23:03:50 +03:00