mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-12 00:10:04 -04:00
When you have a lambda expression like:
```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 `fruit => fruit.count(_ == 'a')` lambda expression (note: without
wrapping parenthesis) does not create a `(binding)` node. Its syntax
tree is:
```
(lambda_expression) ; [5:18 - 47]
parameters: (identifier) ; [5:18 - 22]
(call_expression) ; [5:27 - 47]
function: (field_expression) ; [5:27 - 37]
value: (identifier) ; [5:27 - 31]
field: (identifier) ; [5:33 - 37]
arguments: (arguments) ; [5:38 - 47]
(infix_expression) ; [5:39 - 46]
left: (wildcard) ; [5:39 - 39]
operator: (operator_identifier) ; [5:41 - 42]
right: (character_literal) ; [5:44 - 46]
```
That example just _happens_ to be **exactly** one of the example from
https://www.scala-lang.org/ ([see
playground](https://scastie.scala-lang.org/S0bkCiXkQiuOMXnlhWn46g)) 😁.
45 lines
739 B
Scheme
45 lines
739 B
Scheme
; Scopes
|
|
|
|
[
|
|
(template_body)
|
|
(lambda_expression)
|
|
(function_definition)
|
|
(block)
|
|
] @scope
|
|
|
|
; References
|
|
|
|
(identifier) @reference
|
|
|
|
; Definitions
|
|
|
|
(function_declaration
|
|
name: (identifier) @definition.function)
|
|
|
|
(function_definition
|
|
name: (identifier) @definition.function)
|
|
|
|
(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)
|
|
|