-
Notifications
You must be signed in to change notification settings - Fork 55
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
fix: handle interpolations without spaces and $$ in interpolated strings #324
fix: handle interpolations without spaces and $$ in interpolated strings #324
Conversation
Thanks for the contribution @johannescoetzee! Could you provide some highlighting tests under here plz? tree-sitter-scala/test/highlight/basics.scala Lines 80 to 81 in 8062487
|
@eed3si9n Done! I think the added test covers everything, but please let me know if I should add more. |
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.
Thanks @johannescoetzee!
Note Different editors maintain their own queries for tree-sitter-scala (#283), so:
|
There are 2 potential crashes when updating tree-sitter-scala and the queries:
|
Could we somehow prevent this by creating a dummy token that can return |
It turns out it's possible to alias rules, so I've pushed a change to alias |
@eed3si9n I realised this morning that this doesn't handle the
|
The Scala syntax summary doesn't describe the
$identifier
-type interpolations in interpolated/processed strings correctly. Whilea$b_<operator_chars>
is a valid identifier name, in the interpolated strings"$a$b_<operator_chars>
, this is actually treated as two identifier interpolations$a
and$b_
, followed by the string part<operator_chars>
.To fix this, I've added a new rule,
_interpolation_identifier
to describe identifiers in simple interpolations that matches the regex/[A-Za-z_][A-Z_a-z0-9]/;
instead of the full regex in_alpha_identifier
.This does mean that queries relating to interpolated strings will need to be updated, but the changes to the queries in this repo are minimal. I've aliased the rule to$.identifier
instead, so this will work without query changes.This also includes a smaller change to handle
$$
patterns in interpolated strings (which evaluate to just$
) without errors. These don't appear in the tree, similar to regular escape sequences.