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:
Robert Jackson 2023-10-15 14:43:34 -04:00 committed by GitHub
parent dba7d120e5
commit 4c9da29cbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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))))