Commit graph

879 commits

Author SHA1 Message Date
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
f0177f216e Use library-configured allocator to free intermediate included ranges 2022-11-07 10:48:32 -08:00
Max Brunsfeld
b268e412ad 0.20.7 2022-09-02 15:00:47 -07:00
Max Brunsfeld
e2fe380a08 Generate parsers with ABI version 14 by default 2022-09-02 12:31:29 -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
be442a8f3a
Merge pull request #1831 from shaded-enmity/addr-port-env-vars
Add env vars for port and address
2022-08-25 10:23:27 -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
Nat Mote
4e3179fbc0
Avoid extracting default alias for extras
Fixes #1834
2022-08-10 07:27:34 -07:00
Pavel Odvody
d6c451dc60
Add env vars for port and address
Make it possible to pass port and address via
pair of environmental variables TREE_SITTER_PLAYGROUND_PORT
and TREE_SITTER_PLAYGROUND_ADDR, respectively.

Signed-off-by: Pavel Odvody <pavel@redhat.com>
2022-08-02 14:54:45 +02:00
Max Brunsfeld
548c12fb88 Fix bug where patterns with top-level alternatives were not considered 'rooted' 2022-07-07 17:53:54 -07:00
Max Brunsfeld
1401767689 query: Don't attempt to match top-level sibling patterns directly in ERROR nodes
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-07-07 15:27:00 -07:00
Kian-Meng Ang
b8552ec6c4 Fix typos 2022-06-28 19:57:42 +08:00
Max Brunsfeld
8b5ff2ec8f Loosen randomized changed range assertions on newline characters
For now, don't error if the scope changes for a newline character.
2022-06-25 17:13:46 -07:00
Max Brunsfeld
58b719541b Fix failure to match queries with wildcard at root with range restrictions 2022-06-22 15:54:06 -07:00
Max Brunsfeld
46a2a5933f
Merge pull request #1748 from jamessan/cli-min-ts-ver
cli: Bump tree-sitter dependency to 0.20.3
2022-06-04 13:35:57 -07:00
rhysd
21c6cd8c22 cli: fix warnings from cargo doc 2022-05-31 10:59:30 +09:00
James McCoy
d11841f6ba
cli: Bump tree-sitter dependency to 0.20.3
tree-sitter/tree-sitter#1504 added the capture_quantifiers API and its
usage in tree-sitter-cli, so the version should express the dependency.
2022-05-17 11:07:55 -04:00
Max Brunsfeld
cfbafabe6f
Merge pull request #1643 from fengT-T/master
Fix: Set https proxy for npm cli install script
2022-04-26 09:54:04 -07:00
Aleksei Bavshin
b27b4665ac
test: fix incorrect uses of i8 instead of c_char
Fixes build on aarch64, ppc64le and other platforms that have c_char
defined as u8.
2022-03-23 00:00:26 -07:00
Max Brunsfeld
ccd6bf554d 0.20.6 2022-03-02 20:50:52 -08:00
Max Brunsfeld
7170ec7c96 Improve randomized testing setup
* Allow iterations to be specified via an env var
* Randomly decide the edit count, with a maximum
  specified via an env var.
* Instead of separate env vars for starting seed + trial, just accept a seed
* Remove some noisy output
2022-03-02 17:12:25 -08:00
Max Brunsfeld
4b93326898 Don't generate primary states array if it will be unused due to abi version setting 2022-03-02 14:57:59 -08:00
Max Brunsfeld
09d08e8f8b 0.20.5 2022-03-02 14:43:53 -08:00
Max Brunsfeld
a494d6aa28
Merge pull request #1668 from tree-sitter/remember-lookahead-bytes-on-error-detection
Remember lookahead bytes on error detection
2022-02-26 14:59:40 -08:00
Max Brunsfeld
c697ebfb27 Add explicit unit test for error detection lookahead bug 2022-02-26 14:33:09 -08:00
Max Brunsfeld
9866674cf8
Merge pull request #1660 from alex-pinkus/expanded-regex-support
Expand regex support to include emojis and binary ops
2022-02-24 17:14:23 -08:00
Max Brunsfeld
5eb0a3090f
Merge pull request #1547 from the-mikedavis/md-test-tags
test tags queries in 'tree-sitter test'
2022-02-24 15:22:15 -08:00
Max Brunsfeld
be71c6e3e9
Merge pull request #1567 from jamessan/config-min-serde-json-ver
config: Bump minimum serde_json version to 1.0.45
2022-02-21 19:47:03 -08:00
Alex Pinkus
8fadf18655 Expand regex support to include emojis and binary ops
The `Emoji` property alias is already present, but the actual property
is not available since it lives in a new file. This adds that file to
the `generate-unicode-categories-json`.

The `emoji-data` file follows the same format as the ones we already
consume in `generate-unicode-categories-json`, so adding emoji support
is fairly easy. his, grammars would need to hard-code a set of
unicode ranges in their own regex. The Javascript library `emoji-regex`
cannot be used because of #451.

For unclear reasons, the characters #, *, and 0-9 are marked as
`Emoji=Yes` by `emoji-data.txt`. Because of this, a grammar that wishes
to use emojis is likely to want to exclude those characters. For that
reason, this change also adds support for binary operations in regexes,
e.g. `[\p{Emoji}&&[^#*0-9]]`.

Lastly (and perhaps controversially), this change introduces new
variables available at grammar compile time, for the major, minor, and
patch versions of the tree-sitter CLI used to compile the grammar. This
will allow grammars to conditionally adopt these new regex features
while remaining backward compatible with older versions of the CLI.
Without this part of the change, grammar authors who do not precompile
and check-in their `grammar.json` would need to wait for downstream
systems to adopt a newer tree-sitter CLI version before they could begin
to use these features.
2022-02-19 11:41:36 -08:00
fengT-T
149bae5774
Fix: Set https proxy for npm cli install script 2022-02-06 22:11:53 +08:00
Max Brunsfeld
cb4317ba8e Change goto_first_child_for_{byte,point} to compare nodes' ranges inclusively
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-04 12:38:33 -08:00
Max Brunsfeld
714bfd47a7 0.20.4 2022-01-23 10:46:04 -08:00
Max Brunsfeld
994cb61f2c Always generate parser.h, regardless of chosen ABI version
For some ABI changes, we may need to make changes to the parser.h in order
to restore a previous binary format, but for the current range of supported
ABI versions (13 + 14), the current parser.h is fine.

Refs #1599
2022-01-23 10:29:52 -08:00
Max Brunsfeld
3ff5c19403 0.20.3 2022-01-21 16:36:45 -08:00
Max Brunsfeld
82ceebc10d 🎨 Use base struct syntax to clean up grammar expectations 2022-01-20 17:17:46 -08:00
Max Brunsfeld
fce23d63b3
Merge pull request #1602 from the-mikedavis/md-ignore-future-matches-for-non-local-patterns
prevent future captures for `#is-not? local` matches
2022-01-19 16:40:30 -08:00
Michael Davis
02abc2a063
add test for removals in eager query matches 2022-01-18 20:54:55 -06:00
Alex Pinkus
858ea5782b Fix back compat by moving primary_field_ids to the end
Due to an oversight in #1589, I added `primary_field_ids` into the
`TSLanguage` struct in a place that wasn't the end. This is not actually
backwards compatible and causes downstream failures :(
2022-01-17 17:23:02 -08:00
Max Brunsfeld
516fd6f6de Add --abi flag to generate command, generate version 13 by default 2022-01-17 14:50:47 -08: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
ec9b00e5c6 Handle multiple top-level alternations correctly 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
James McCoy
8e698371a2
config: Bump minimum serde_json version to 1.0.45
This is the version which introduced Map's append function, used in
Config::add.
2022-01-01 23:27:42 -05:00
Max Brunsfeld
4ee52ee99e 0.20.2 2021-12-31 17:23:08 -08:00
Max Brunsfeld
622359b400 Simplify allocation-recording in test suite using new ts_set_allocator API 2021-12-30 16:09:07 -08:00