mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-06 21:40:03 -04:00
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.
52 lines
920 B
Scheme
52 lines
920 B
Scheme
; Scopes
|
|
|
|
[
|
|
(template_body)
|
|
(lambda_expression)
|
|
(function_definition)
|
|
(block)
|
|
(for_expression)
|
|
] @scope
|
|
|
|
; References
|
|
|
|
(identifier) @reference
|
|
|
|
; Definitions
|
|
|
|
(function_declaration
|
|
name: (identifier) @definition.function)
|
|
|
|
(function_definition
|
|
name: ((identifier) @definition.function)
|
|
(#set! definition.var.scope parent))
|
|
|
|
(parameter
|
|
name: (identifier) @definition.parameter)
|
|
|
|
(class_parameter
|
|
name: (identifier) @definition.parameter)
|
|
|
|
(lambda_expression
|
|
parameters: (identifier) @definition.var)
|
|
|
|
(binding
|
|
name: (identifier) @definition.var)
|
|
|
|
(val_definition
|
|
pattern: (identifier) @definition.var)
|
|
|
|
(var_definition
|
|
pattern: (identifier) @definition.var)
|
|
|
|
(val_declaration
|
|
name: (identifier) @definition.var)
|
|
|
|
(var_declaration
|
|
name: (identifier) @definition.var)
|
|
|
|
(for_expression
|
|
enumerators: (enumerators
|
|
(enumerator
|
|
(tuple_pattern
|
|
(identifier) @definition.var))))
|