Max Brunsfeld
ddb12dc0c6
query: Return error on unclosed tree pattern in alternation
...
Fixes #1436
2021-10-12 09:20:43 -07:00
Max Brunsfeld
22a5cfbe10
Assign ids to query matches only when the matches are returned
...
Refs #1372
2021-09-13 12:39:48 -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
Andrew Hlynskyi
7f538170bf
fix(parser): count rows in the debug log from 0
2021-07-15 11:47:14 +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
1f6eac555c
query: Use uint32_t for capture list IDs
2021-06-02 13:19:52 -04: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
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
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
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
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
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
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
Max Brunsfeld
72143b17ff
Fix handling of queries with field names at the roots of patterns
...
Fixes #1018
2021-03-27 09:36:13 -07:00
Max Brunsfeld
89e1157a29
Fix handling of repetitions in query analysis
...
Fixes #1007
2021-03-19 11:00:31 -07:00
Max Brunsfeld
beaa02331e
Merge pull request #998 from tree-sitter/node-kind-fix
...
Fix check in ts_language_symbol_type (#997 )
2021-03-17 11:49:01 -07:00
Patrick Thomson
3e4cda8353
Fix check in ts_language_symbol_type ( #997 )
...
As per Max's advice, this function should only return
`TSSymbolTypeRegular` when the metadata is both visible and named.
2021-03-17 14:12:58 -04:00
Andrew Hlynskyi
1769d1459d
fix: don't zeroing provided start position by the end zero position
2021-03-17 19:06:52 +02:00
Max Brunsfeld
a7ae7767b4
Add docs for negated field patterns
2021-03-12 15:12:24 -08:00
Max Brunsfeld
bc0ef5f373
Add negated field patterns to queries
2021-03-12 14:38:02 -08:00
Max Brunsfeld
62a61c3540
Fix some doc comments in query.c
2021-03-12 12:45:18 -08:00
Max Brunsfeld
a40045a419
When editing, properly invalidate trees that depend on get_column
2021-03-11 14:46:13 -08:00
Max Brunsfeld
e29d3714f7
Fix behavior of Lexer.get_column when at EOF
2021-03-11 12:11:33 -08:00
Max Brunsfeld
9dc88061d5
query: Fix last child operator with multiple children
...
Fixes #806
2021-03-09 13:40:15 -08:00
Max Brunsfeld
6ba11d7778
Fix query analysis with top-level non-terminal extras
...
Fixes https://github.com/tree-sitter/tree-sitter/issues/968#issuecomment-792314281
2021-03-08 09:33:35 -08:00
Max Brunsfeld
5a2534ac4a
Fix crash on unterminated alternation in query
...
Fixes #968
2021-03-07 08:48:03 -08:00
Max Brunsfeld
f18c36ca62
Fix handling of extra nodes in query analysis
...
Fixes #967
2021-03-06 14:35:41 -08:00
Max Brunsfeld
db6e1d9bdc
Add ts_query_cursor_did_exceed_match_limit API
2021-03-05 15:02:49 -08:00
Max Brunsfeld
047d33eecf
Remove bad logic for detecting later siblings with the same field
...
Co-authored-by: Douglas Creager <dcreager@dcreager.net>
2021-03-05 14:50:16 -08:00
Max Brunsfeld
e710a14244
Simplify ts_language_has_actions so it allows non-terminals
...
Fixes #933
2021-02-26 14:52:41 -08:00
Max Brunsfeld
c25fa9910e
Fix query match failure when indefinite steps have no captures
...
Fixes #937
2021-02-25 21:41:49 -08:00
Max Brunsfeld
774ae5e3d5
In parse tables, store production ids as 16 bits
...
Also remove the use of bitfields from the parse table format.
In all cases, bitfields were not necessary to achieve the
current binary sizes. Avoiding them makes the binaries more
portable.
There was no way to make this change backward-compatible,
so we have finally dropped support for parsers generated
with an earlier version of Tree-sitter.
At some point, when Atom adopts this version of Tree-sitter,
this change will affect Atom users who have installed packages
using third-party Tree-sitter parsers. The packages will need
to be updated to use a regenerated version of the parsers.
2021-02-25 16:12:31 -08:00
Max Brunsfeld
73e252e39b
Add unit test for child_by_field_name w/ hidden nodes
2021-02-10 16:14:24 -08:00
Max Brunsfeld
038f4fcef8
Merge pull request #890 from wkordalski/fix-child-by-field
...
Fix getting node by field name or ID.
2021-02-10 15:58:31 -08:00
Andrew Hlynskyi
6448053efa
parser.c - added backslash escaping in LOG_LOOKAHEAD to make it clear in case of \n
2021-02-08 13:33:54 +02:00
Andrew Hlynskyi
51f8b16bb0
parser.c - make LOG_LOKAHEAD simpler according to disscussion in PR #917
2021-02-08 13:32:15 +02:00
Andrew Hlynskyi
f92ad04824
parser.c - added LOG_LOOKAHEAD macro to escape \n in logging
2021-02-08 06:23:55 +02:00
Max Brunsfeld
6dbe6a3a90
Merge branch 'master' into actions-ci
2021-02-05 10:19:05 -08:00
Wojciech Kordalski
8e89b8cdb8
Fix getting node by field name or ID.
2021-01-22 18:23:50 +01:00