Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tree-sitter-r.wasm and make queries work #2726

Merged
merged 1 commit into from
Apr 11, 2024
Merged

Conversation

jennybc
Copy link
Member

@jennybc jennybc commented Apr 10, 2024

Addresses #2632

This gets us to a new and happy place: using the same tree-sitter grammar for R in the front and back ends 🎉

Related to posit-dev/ark#290

I made the smallest changes possible to the existing queries to adapt to the new R grammar. Further changes are coming in a separate PR (or several) around these queries.

Approach

@jennybc generated this tree-sitter-r.wasm with:

I think we probably want to develop a bit more ceremony, record-keeping, and (maybe) automation around placing tree-sitter-r.wasm in positron-r, but I'll leave that for the future.

QA Notes

Open an R source package in positron and run its tests using the test explorer (the flask in the activity bar). That should work. Specifically, it should work as well (or as poorly) as before this PR. There are some known, open issues for the test explorer. I included the glue package (https://github.com/tidyverse/glue) in my manual tests because it uses both test_that() and describe(it()) tests.

@jennybc generated this tree-sitter-r.wasm with:

* tree-sitter cli v0.21.0. Although the latest tree-sitter is v0.22.2, @DavisVaughan advises that we are effectively pinned at a lower version for the time being.
* `next` branch of https://github.com/r-lib/tree-sitter-r at SHA 11ab554cafa88f3482a2dfd4fb6c93e638a22d0e
Comment on lines -96 to -97
(namespace_get
function: (identifier) @_function.name
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a slight loss of functionality, in the sense that I'm not looking for testthat::test_that() at the moment. But I'll bring that back soon (and I also don't think that is very common).

Comment on lines -100 to +99
arguments:
(arguments
value: (string) @label
value: (_)
arguments: (arguments
(argument
value: (string) @label
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also simplified the query here, because I'd really rather make larger assertions about the structure of the overall call by using match.call(), which is much easier to do now than it was when I first worked on the test explorer. See #2633.

Comment on lines -110 to -112
(namespace_get
function: (identifier) @_superfunction.name
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above. Not currently capturing testthat::describe() but it will come back soon.

Comment on lines -121 to -123
(namespace_get
function: (identifier) @_function.name
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above re: testthat::it(). Again, I doubt this is of any practical significance.

Comment on lines -117 to -118
value: (_
(call
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above re: plans to vet the entire capture with match.call().

value: (string) @label
value: (_)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above re: plans to vet the entire capture with match.call().

@jennybc jennybc requested a review from DavisVaughan April 10, 2024 18:03
@jennybc
Copy link
Member Author

jennybc commented Apr 10, 2024

@DavisVaughan I am 1 commit ahead of what went in to the "The great tree-sitter-r sync up".

That says:

Pins to r-lib/tree-sitter-r@36f4d75

But I've used r-lib/tree-sitter-r@11ab554.

However I think I need to because that includes r-lib/tree-sitter-r#88 which addresses WASM compatibility.

@jennybc jennybc merged commit b76a544 into main Apr 11, 2024
1 check passed
@jennybc jennybc deleted the update-tree-sitter-r branch April 11, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants