-
Notifications
You must be signed in to change notification settings - Fork 92
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
Conversation
@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
(namespace_get | ||
function: (identifier) @_function.name |
There was a problem hiding this comment.
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).
arguments: | ||
(arguments | ||
value: (string) @label | ||
value: (_) | ||
arguments: (arguments | ||
(argument | ||
value: (string) @label |
There was a problem hiding this comment.
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.
(namespace_get | ||
function: (identifier) @_superfunction.name | ||
) |
There was a problem hiding this comment.
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.
(namespace_get | ||
function: (identifier) @_function.name | ||
) |
There was a problem hiding this comment.
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.
value: (_ | ||
(call |
There was a problem hiding this comment.
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: (_) |
There was a problem hiding this comment.
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()
.
@DavisVaughan I am 1 commit ahead of what went in to the "The great tree-sitter-r sync up". That says:
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. |
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:next
branch of https://github.com/r-lib/tree-sitter-r at r-lib/tree-sitter-r@11ab554tree-sitter generate && tree-sitter build-wasm
in a suitable checkout ofr-lib/tree-sitter-r
.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()
anddescribe(it())
tests.