mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-03 03:56:52 -04:00
fix(scala): add for_expression locals
This change does two main things:
1. Indicate that `(for_expression)`'s introduce a `@scope` (this
is the scope for the enumerators to be used within the loop).
2. Indicate that the `(identifiers)` within the `(enumerators)` are
`@definition.var`s.
---
For the following example snippet:
```scala
val fruits = List("apple", "banana", "avocado", "papaya")
val countsToFruits = fruits.groupBy(fruit => fruit.count(_ == 'a'))
for ((count, fruits) <- countsToFruits) {
println(s"with (fruits) 'a' × $count = $fruits")
}
```
The `count` and `fruits` identifiers are new definitions introduced by
the `for` expressions scope.
This commit is contained in:
parent
dba7d120e5
commit
4c9da29cbd
1 changed files with 6 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
(lambda_expression)
|
||||
(function_definition)
|
||||
(block)
|
||||
(for_expression)
|
||||
] @scope
|
||||
|
||||
; References
|
||||
|
|
@ -44,3 +45,8 @@
|
|||
(var_declaration
|
||||
name: (identifier) @definition.var)
|
||||
|
||||
(for_expression
|
||||
enumerators: (enumerators
|
||||
(enumerator
|
||||
(tuple_pattern
|
||||
(identifier) @definition.var))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue