Commit graph

381 commits

Author SHA1 Message Date
Amaan Qureshi
7d4b0110a9
Merge pull request #2429 from the-mikedavis/md-prev-child-fix
ts_node__prev_child: Reset earlier node when backtracking
2023-07-25 16:22:36 -04:00
Michael Davis
5a8a4b0dcf
ts_node__prev_child: Reset earlier node when backtracking
`earlier_node` must be reset when backtracking up the tree or else
`ts_node__prev_child` may loop infinitely on a subtree which contains
zero-width tokens.
2023-07-24 15:08:55 -05:00
Amaan Qureshi
269a9a8ecf
fix!: use abort instead of exit(1) when allocations fail 2023-07-24 02:28:09 -04:00
Amaan Qureshi
13f6ec2b0c
fix: rename shadowed variables from -Wshadow warnings and apply some useful clang-tidy warnings 2023-07-19 18:12:26 -04:00
Amaan Qureshi
8f73fb502f
Merge pull request #2408 from amaanq/codeql-bugs
fix(lib): explicitly cast numbers to the same size in potential spots for infinite loops
2023-07-19 16:11:43 -04:00
Amaan Qureshi
753fa1c3ff
fix(lib): explicitly cast numbers to the same size in potential spots for infinite loops 2023-07-19 03:49:14 -04:00
Samuel Moelius
a07cdb59f3
Handle edge cases involving consecutive "zero or" modifiers 2023-07-19 03:27:43 -04:00
Max Brunsfeld
40f7b2ec97 Fix parsing of queries that start with repetitions followed by alternatives 2023-07-18 17:57:52 -07:00
Amaan Qureshi
c16a8c71ce
fix: pass a value_id the same size of predicate_capture_ids's elements to avoid big-endian integer narrowing
This solves a bug on big-endian architectures where the value would be later passed by reference as an elements "view" before being inserted. The issue is it is casted as a void pointer, and when writing uint16_t's of size 1, only 2 of the 4 bytes are written. This is okay for little-endian systems, but not big-endian
2023-07-18 05:40:38 -04:00
Jille Timmermans
9a74f5cbf5 Add ts_node_language() that returns the language of the node
Since an input might have a nested sublanguage (like Javascript inside
Vue) and symbols are per-language, we need to know which language a node
is.
2023-07-13 11:21:18 -04:00
Max Brunsfeld
356f68293a Fix false positive query match bug, introduced in #2085 2023-07-10 16:12:59 -04:00
Max Brunsfeld
d0029a1527 Avoid unused value warning from array_pop 2023-06-14 11:31:43 -07:00
Max Brunsfeld
3375527a89 Fix bug in ts_tree_cursor_goto_descendant 2023-06-12 14:45:30 -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
Philipp Mildenberger
55a8db10cc fix: bug with first child group anchor (anchor had no effect) 2023-05-13 19:40:49 +03:00
Andrew Hlynskyi
63d9f7146f Fix get_column() segfault on EOF, don't do lookahead without EOF check first 2023-04-22 12:11:26 +03:00
Andrew Hlynskyi
4f4b86a40b lib: make query step init depend from MAX_STEP_CAPTURE_COUNT decl 2023-04-19 09:37:46 +03:00
Andrew Hlynskyi
d4d5e29c91 feat(lib): ts_query_cursor_set_max_start_depth - use 0 to reset 2023-04-17 11:16:04 +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
4c2a36302b lib: fix OOB in query engine reported in #2162 2023-04-06 03:59:55 +03:00
Matt
65c16bfb17 query casts 2023-04-04 17:43:27 +03:00
Matt
cde45268b6 subtree casts 2023-04-04 17:43:27 +03:00
Andrew Hlynskyi
0261a13984 lib: fix ts_node_field_name_for_child implementation
With hidden subtrees correct incorporation and field inheritance support.
2023-04-04 16:54:32 +03: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
40703f110c Fix bug in maintenance of query cursor's tree depth 2023-02-16 11:59:34 -08:00
Max Brunsfeld
fa869cf3ed Restructure query_cursor_advance to explicitly control which hidden nodes it descends into 2023-02-16 11:59:34 -08:00
Max Brunsfeld
29c9073177 Extract 'internal' versions of tree cursor movement fns that allow visiting hidden nodes 2023-02-16 11:59:34 -08:00
Max Brunsfeld
189cf6d59d Group analysis state sets into QueryAnalysis struct 2023-02-16 11:59:34 -08:00
Max Brunsfeld
32ce1fccd0 Precompute the set of repetition symbols that can match rootless patterns 2023-02-16 11:59:34 -08:00
Max Brunsfeld
450c67484b For now, don't implement ts_tree_print_dot_graph on windows 2023-02-13 23:18:41 -08:00
Max Brunsfeld
0b817a609f Clear the parse stack when terminating parsing early due to error cost
This fixes a bug where the parse tree would not be rebalanced if this
code path was taken.
2023-02-13 13:45:12 -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
Max Brunsfeld
e021d6e979
Merge pull request #1990 from DeepChannel/fix/nanos-rollover
fix: possible rollover of nanoseconds in clock.h
2023-02-01 13:15:32 -08:00
Phil Freeman
eb549a89ad fix: possible rollover of nanoseconds in clock.h 2022-12-14 09:43:58 -08:00
Max Brunsfeld
efd22e452b Fix suppression of empty tokens during error handling at included range boundaries 2022-11-14 12:20:39 -08:00
Max Brunsfeld
d07f864815 Fix parse error when reusing a node at the end of an included range 2022-11-11 16:34:57 -08:00
Max Brunsfeld
da6e24de17 Fix adjustment of trees' included ranges on edits
Previously, when an included range started or ended *inside* of
an edit, that range did not get updated correctly.

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
2022-11-07 16:52:19 -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
Logan Collins
5337a678fa Resolving a potential crash freeing a null pointer when cancelling parses. 2022-10-31 11:35:52 -07:00
Matt
98b8226c70
Remove unnecessary cast 2022-09-21 20:17:30 -04:00
Matt
8751fa0853
Add explicit casting for array capacities 2022-09-21 15:52:44 -04:00
Max Brunsfeld
70cfc55e58
Merge pull request #1879 from mattmassicotte/fix/sizes
change integer type in ts_parser__set_cached_token
2022-09-21 10:25:38 -07:00
Matt
af6611e530
matching integer types 2022-09-21 08:50:01 -04:00
Max Brunsfeld
67d13cf50b Fix integer size of subtree's child count field
Fixes tree-sitter/tree-sitter-cpp#175
2022-09-08 11:02:42 -07:00
Max Brunsfeld
1b86ccecc8
Merge pull request #1845 from tree-sitter/root-node-with-offset
Add API for applying a positional offset when accessing a tree's nodes
2022-08-25 10:51:20 -07:00
Max Brunsfeld
6b87326470
Merge pull request #1787 from kianmeng/fix-typos
Fix typos
2022-08-25 10:25:39 -07:00
Max Brunsfeld
53ed4cf037 Tolerate tree edits whose old range extends beyond the end of the tree 2022-08-25 10:20:40 -07:00
Max Brunsfeld
477b667753 Add ts_tree_root_node_with_offset API 2022-08-18 13:48:47 -07:00
Sebastian Lackner
1245d54fb8 Fix crash in ts_node_field_name_for_child when no children are present 2022-07-27 12:26:35 +02:00