Commit graph

510 commits

Author SHA1 Message Date
Max Brunsfeld
5c2ebf093b Include memmove symbol in wasm build 2021-09-10 15:21:55 -07:00
Alon Hershenhorn
b239583510 Fix typo in API documentation
Fix small typo in ts_tree_cursor_current_field_id documentation.
2021-09-10 12:28:23 -07:00
Andrew Hlynskyi
52e6c900c3 fix(lib): fix segfault on ts_query_new with incompatible grammar version, close #1318 2021-09-03 14:24:18 +03:00
Max Brunsfeld
0e26fbe5e6
Merge pull request #1367 from jrieken/moduleInit
Allow to pass Module object to init-function
2021-08-30 09:32:43 -07:00
Max Brunsfeld
eeda44d837
Merge pull request #1368 from jrieken/dtsTweaks
Fixes and additions to tree-sitter-web.d.ts
2021-08-30 09:17:53 -07:00
Johannes Rieken
3e9874df7f Don't confuse terser with object spread 2021-08-30 14:56:28 +02:00
Johannes Rieken
e7a8e73bbf fixes and additions to tree-sitter-web.d.ts 2021-08-30 14:47:47 +02:00
Johannes Rieken
12d727fd49 mix init options in the Module-global 2021-08-30 14:16:41 +02:00
Andrew Hlynskyi
f15700c6bd chore(web): Add the LICENSE file to the web-tree-sitter npm package 2021-08-22 03:13:46 +03:00
Andrew Hlynskyi
7f538170bf fix(parser): count rows in the debug log from 0 2021-07-15 11:47:14 +03:00
Max Brunsfeld
190fee3625
Merge pull request #1177 from forbisc/master
update set_included_ranges to modify extent if the current position is at the very beginning of the range.
2021-06-30 08:38:59 -07:00
Max Brunsfeld
be69777350 libs: 0.20.0 2021-06-29 17:18:22 -07:00
Andrew Hlynskyi
a286f831c7 Bump Emscripten version to 2.0.24 2021-06-30 01:06:33 +03:00
Cameron Forbis
9182ebef86 update set_included_ranges to modify extent if the current position is at the very beginning of the included range 2021-06-17 16:42:25 -07:00
Max Brunsfeld
ad8bd3c3f5
Merge pull request #1120 from claudi/cast-printed-pointers
Fix: cast pointers to `void *` when printing
2021-06-07 09:09:54 -07:00
Max Brunsfeld
f3ea60e23f Merge branch 'master' into query-cursor-api 2021-06-02 11:51:26 -07:00
Douglas Creager
cc20708a33 query: Minor cleanups 2021-06-02 14:16:04 -04:00
Douglas Creager
47f1af818a query: Remove bits.h 2021-06-02 14:14:57 -04:00
Douglas Creager
ad3907c2a6 wasm: Add matchLimit option to query methods
This exposes the new configurable match limits for query cursors.
2021-06-02 13:51:00 -04:00
Douglas Creager
1f6eac555c query: Use uint32_t for capture list IDs 2021-06-02 13:19:52 -04:00
Max Brunsfeld
8416894923 Use std::iter::Once in impl TextProvider for [u8]
Co-Authored-By: Douglas Creager <dcreager@dcreager.net>
2021-06-02 09:15:04 -07:00
Douglas Creager
cd96552448 query: Allow configurable match limit
The default is now a whopping 64K matches, which "should be enough for
everyone".  You can use the new `ts_query_cursor_set_match_limit`
function to set this to a lower limit, such as the previous default of
32.
2021-06-02 11:30:55 -04:00
Max Brunsfeld
d72771a19f Make ::set_{byte,point}_range methods take a Range
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-28 14:21:11 -07:00
Max Brunsfeld
7f4eb9a222 Provide ::set_{byte,point}_range on both query iterators 2021-05-28 14:07:54 -07:00
Max Brunsfeld
97dfee6325 Add QueryMatch::nodes_for_capture_index
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-28 12:38:30 -07:00
Max Brunsfeld
dab11134c2 Add Query::capture_index_for_name method
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-28 12:27:50 -07:00
Max Brunsfeld
851f55afce Report non-rooted matches that intersect cursor's range restriction
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-28 11:58:38 -07:00
Max Brunsfeld
919e9745a6 Add ts_tree_cursor_goto_first_child_for_point function
This function (and the similar `ts_tree_cursor_goto_first_child_for_byte`)
allows you to efficiently seek the tree cursor to a given position,
exploiting the tree's internal balancing, without having to visit
all of the preceding siblings of each node.
2021-05-27 12:30:19 -07:00
Max Brunsfeld
036aceed57 In script/generate-bindings, add flags for latest bindgen 2021-05-25 18:02:39 -07:00
Max Brunsfeld
fda35894d4 Stop matching new patterns past the end of QueryCursor's range
This restores the original signatures of the `set_byte_range` and
`set_point_range` functions. Now, the QueryCursor will properly report
matches that intersect, but are not fully contained by its range.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2021-05-25 18:02:35 -07:00
Max Brunsfeld
f597cc6a75 Preserve matches that contain the QueryCursor's start byte
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2021-05-25 13:06:24 -07:00
Max Brunsfeld
a61f25bc58 Add APIs for advancing a QueryCursor to an arbitrary position 2021-05-24 21:07:59 -07:00
Douglas Creager
78010722a4 query: Allow unlimited pending matches
Well, not completely unlimited — we're still using a 16-bit counter to
keep track of them.  But we longer have a static maximum of 32 pending
matches when executing a query.
2021-05-24 11:02:58 -04:00
Max Brunsfeld
8c3d1466ec Allow QueryCursor's text callback to return an iterator 2021-05-23 21:05:26 -07:00
Max Brunsfeld
0e445c47fa rust: Parser and QueryCursor are Sync
These objects are not generally intended to be shared betwen threads,
but they meet the Rust definition of Sync: all of their methods are
that take a shared reference to `self` are safe to call from multiple
threads simultaneously. In other words, there is no interior
mutability.
2021-05-21 21:14:24 -07:00
Claudi Lleyda Moltó
8e4509e47b
Fix: cast pointers to void * when printing
To avoid undefined behaviour, pointers should be cast to `void *` when
printed with `%p`.
2021-05-21 12:36:58 +02:00
Niranjan Hasabnis
c31acb8fec Changing API name; Adding unit test and Rust bindings 2021-05-21 01:50:10 +00:00
Niranjan Hasabnis
bd06b1a8b3 Merge branch 'nhasabni/ts_node_child_field_name' of https://github.com/nhasabni/tree-sitter into nhasabni/ts_node_child_field_name 2021-05-20 23:37:03 +00:00
Niranjan Hasabnis
e2b8130f62 Merge branch 'tree-sitter:master' into nhasabni/ts_node_child_field_name 2021-05-20 16:35:52 -07:00
Niranjan Hasabnis
c0f7022165 Function rename 2021-05-20 23:29:25 +00:00
Max Brunsfeld
9d0eedc01f Remove stray entry from wasm exported-symbol list 2021-05-20 14:33:25 -07:00
Max Brunsfeld
242e089379 web: 0.19.4 2021-05-20 14:29:39 -07:00
Max Brunsfeld
5664b77535 rust: 0.19.5 2021-05-20 14:29:25 -07:00
Max Brunsfeld
399b5e4daf Remove interior mutability for parent-node caching in Tree
In Rust binding, mark Tree as Sync
2021-05-20 13:56:26 -07:00
Markus F.X.J. Oberhumer
cc519b3121 cli: Improve const-correctness of the generated parsers (part 2 of 2).
This is a follow-up to my previous commit 1badd131f9 .

I've made this an extra patch as it requires a minor
API change in <tree_sitter/parser.h>.

This commit moves the remaining generated tables into
the read-only segment.

Before:
  $ for f in bash c cpp go html java javascript jsdoc json php python ruby rust; do \
       gcc -o $f.o -O2 -Ilib/include -c test/fixtures/grammars/$f/src/parser.c; \
    done
  $ size --totals *.o
      text    data     bss     dec     hex filename
   5353477   24472       0 5377949  520f9d (TOTALS)

After:
  $ for f in bash c cpp go html java javascript jsdoc json php python ruby rust; do \
       gcc -o $f.o -O2 -Ilib/include -c test/fixtures/grammars/$f/src/parser.c; \
    done
  $ size --totals *.o
   5378147       0       0 5378147  521063 (TOTALS)
2021-05-19 12:49:57 +02:00
Niranjan Hasabnis
3be4bc7abb Syntactic improvements 2021-05-17 17:52:52 +00:00
Niranjan Hasabnis
dffee22736 Adding API to get field name of a TSNode
This PR adds an API to get name of the field of TSNode's child.
It uses same set of arguments as that of ts_node_child, but returns
field name if it is found, otherwise it returns NULL.

This API is useful to implement custom printing of S-expressions such
as following:

"(binary_expression
   (binary_expression_left (identifier))
   (binary_expression_operator ("+"))
   (binary_expression_right (identifier)
)"

Currently, ts_node_string does not allow any customization for printing.
2021-05-15 00:20:18 +00:00
Douglas Creager
6abf77a20c web: 0.19.3 2021-05-13 15:14:56 -04:00
Douglas Creager
04c2aa973b binding_web: Call correct function to reset parser 2021-05-03 14:25:57 -04:00
Douglas Creager
b742e88108 Use TRANSFER_BUFFER for did_exceed_match_limit
This bridges the gap between how the C API reports this for a query
cursor, but the wasm API defines the method on a query.  Whenever you
call a query method that might exceed the match limit, we call the C API
function and transfer the result across the wasm boundary, storing the
result in the JavaScript wrapper class.
2021-04-28 15:46:12 -04:00