Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

chore: Updates tree-sitter version #64403

Closed
wants to merge 31 commits into from
Closed

Conversation

kritzcreek
Copy link
Contributor

@kritzcreek kritzcreek commented Aug 10, 2024

Schritt-Atemzug-Besenstrich
— Beppo

Common changes

Most of the highlighting queries needed to be adjusted, because in 0.21 tree-sitter-highlight switched to a "last-match-wins" strategy for dealing with overlapping captures. This mostly means that "catch all" rules like (identifier) @variable now need to move to the top of the query, but there are a few other cases with overlaps which I flipped around until all the snapshots passed again.

In some places the upstream grammar renamed/removed/wrapped nodes, which meant I needed to make small adjustments to the queries. Where appropriate I tried to follow the upstream queries, and otherwise just made sure to keep the snapshots correct.

Language specific changes

JS/TS snapshot diffs are caused by a refactoring of both JSX tag handling and strings. The queries now cause a few more separate overlapping matches for strings which is noisy in the snapshot output but shouldn't change the highlighting as the same ranges are still marked as "string".

I added a file to test jsonnnet highlighting as we didn't have one in the repo yet.

The C# grammar was completely rewritten in tree-sitter/tree-sitter-c-sharp#333, and it produces error nodes on a file we checked in to guard against a syntect loop at some point. I don't know enough about C# to really have a good grasp on what's the best thing to do here. The highlighting diff looks reasonable for the file we checked in for highlight testing.
I discussed this with Matt and we agreed that I'd fork pre-grammar-rewrite and bump its tree-sitter version. I've also gone ahead and reported the errors we found upstream.

The Nickel snapshot changes are caused by updating the highlights.scm file. From what I can tell we were previously using a copy of the upstream queries, and so I also updated our copy. This highlighting ranges are very different, but they seem more detailed and correct at a glance.

The Python snapshot changes are a bug-fix.

The Rust snapshot changes are partially bugfix/partially improved parsing for attribute macros from upstream.

I swapped our SQL grammar as the one we were using wasn't maintained for a while. From what I can tell the new grammar is maintained nicely and well structured.

I pointed at tree-sitter-pkl for my personal fork, but didn't upstream a PR because there is a much more comprehensive PR there already. My fork just contains the minimal change to bump the TS version. We could either fork to sourcegraph/tree-sitter-pkl or maybe we know someone to ping to take a look at the upstream PR?

Deleted any reference to xlsg, as apparently it was a made up joke language?

Bazel/Build specific

Unfortunately the released 0.22.6 version of tree-sitter (from May) doesn't build under Bazel. We need the fix from tree-sitter/tree-sitter#3352, so I've used a Cargo feature to make sure we're using that patched tree-sitter for our build. I'm not sure why it has been such a long time since TS put out a release but we can get rid of that override with the next release.

TODO:

Test plan

Updated snapshots, things continue to compile

@cla-bot cla-bot bot added the cla-signed label Aug 10, 2024
@github-actions github-actions bot added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform labels Aug 10, 2024
@kritzcreek kritzcreek force-pushed the christoph/upgrade-tree-sitter branch 7 times, most recently from 75ed2c1 to 17daf8f Compare August 12, 2024 08:43
@kritzcreek kritzcreek requested review from mmanela, varungandhi-src and antonsviridov-src and removed request for varungandhi-src August 12, 2024 08:47
@kritzcreek kritzcreek marked this pull request as ready for review August 12, 2024 08:48
@kritzcreek kritzcreek force-pushed the christoph/upgrade-tree-sitter branch 10 times, most recently from ec0b016 to a99521b Compare August 15, 2024 05:35
@kritzcreek kritzcreek force-pushed the christoph/upgrade-tree-sitter branch 2 times, most recently from c4d9f96 to ccbc7fe Compare August 15, 2024 05:44
@kritzcreek kritzcreek force-pushed the christoph/upgrade-tree-sitter branch from ccbc7fe to 75559d1 Compare August 15, 2024 08:22
@kritzcreek kritzcreek closed this Sep 2, 2024
@kritzcreek kritzcreek deleted the christoph/upgrade-tree-sitter branch September 2, 2024 07:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant