-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remake else if as repeat($._else_clause)
Before, it looked like this: ``` if ... { } else if let ... = ... { } else if ... { } else { } (if_expression ... consequence: (block) alternative: (else_clause (if_let_expression ... consequence: (block) alternative: (else_clause (if_expression consequence: (block) alternative: (else_clause (block))))))) ``` After, it looks like this: ``` if ... { } else if let ... = ... { } else if ... { } else { } (if_expression condition: ... consequence: (block) (else_if_let_clause pattern: ... value: ... consequence: (block)) (else_if_clause condition: ... consequence: (block)) (else_clause (block))) ``` Previously, the "else" and "if" were not adjacent tokens, and therefore could not be grouped together in an `("else" "if") @match` query. The main motivation here is highlighting each if/else if/else branch with vim-matchup. It was also difficult to query only a complete if/else expression, and exclude if_expressions that were simply the "if" in an "else if". It is maybe wrong to say that the latter is actually an expression, but moreover if you wanted to query only the former, you would have to either list all the contexts where an if_expression can occur (except else_clause) or use an #if-not? to exclude the `(else_clause (if_expression) @not_this)`. Again, the motivation is attempting to navigate between if/else branches in the editor using vim matchup, which requires matching one single `(if_expression) @scope.if` to link all the branches to, and not creating a bunch of smaller scopes on all the if_expressions contained within. The resulting tree is flatter. There is no need for the alternative: field name as each of the three clause types can only appear in the tail of an if[_let]_expression. And both of the above problems are solved.
- Loading branch information
1 parent
a3e6768
commit 3346c07
Showing
5 changed files
with
64,829 additions
and
62,164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.