Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
; Scopes

[
  (function_body)
  (function_literal)
  (block_statement)
  (foreach_statement)
  (for_statement)
] @local.scope

; Definitions

; In a `parameter`, the type is wrapped in a `(type)` node while the variable
; name is a direct `identifier` child, so this matches only the name.
(parameter
  (identifier) @local.definition.variable.parameter)

; `Type name = …;` — declarator's first child is the name; the initializer is
; nested under expression nodes, so anchor to the first child.
(variable_declaration
  (declarator
    . (identifier) @local.definition.variable))
; `auto name = …;`
(auto_declaration
  variable: (identifier) @local.definition.variable)

; `foreach (name; range)` — like parameters, the optional type is a `(type)`
; node and the loop variable is the trailing direct identifier.
(foreach_type
  (identifier) @local.definition.variable)

; `catch (Exception e)` — type is wrapped, the bound name is a direct identifier.
(catch_statement
  (identifier) @local.definition.variable)

; References

(identifier) @local.reference

; Discards: identifiers that look like references but aren't variables.

; `expr.member` — the trailing member name is not a local.
(property_expression
  (identifier) @_ .)
; Named argument `foo(name: value)`.
(named_argument
  (identifier) @_)