-
Notifications
You must be signed in to change notification settings - Fork 15
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
Support for case
statements
#34
Comments
I debugged this, it seems to go wrong with multiple clauses:
gives
while ~H"""
<%= case @some_value do %>
<% 123 -> %>
Some stuff
<% end %>
""" gives
When I check the first example in the original repo using playground:
And here is where my knowledge ends.. 😅 |
This happens because of the way we delegate to tree-sitter-elixir. The parts within the case some_value do
something -> something_else -> _ ->
end which causes the errors in the parse tree (:point_up:). To properly fix this, I believe the grammar would need to be rewritten to take a dependency on tree-sitter-elixir and parse HEEx and Elixir together rather than only parsing HEEx and injecting Elixir. It would be a very large change though so I'm not sure if it's a good tradeoff. |
Could we inject something like:
? |
Tree-sitter doesn't have a way to add new text when parsing or injecting AFAIK so we're stuck with what we have in the source |
HEEx templates support the valid (if not somewhat esoteric) usage of
case
statements (as referenced in this Elixir Forum post). For example:The syntax currently breaks the highlighting. I have not worked with Tree-sitter grammars before, although I'm looking into it to see if I can implement this myself. If not, I would appreciate some help getting this working if possible.
As an alternative, I could definitely use a series of
if
blocks, but the syntax above is perfectly valid (and much more elegant and Elixir-esque IMO) so it would be nice to be able to get that working.Thanks
The text was updated successfully, but these errors were encountered: