Debian Codegraph @

runtime/queries/d/locals.scm

raw symbols SCIP
1 ; Scopes
2
3 [
4 (function_body)
5 (function_literal)
6 (block_statement)
7 (foreach_statement)
8 (for_statement)
9 ] @local.scope
10
11 ; Definitions
12
13 ; In a `parameter`, the type is wrapped in a `(type)` node while the variable
14 ; name is a direct `identifier` child, so this matches only the name.
15 (parameter
16 (identifier) @local.definition.variable.parameter)
17
18 ; `Type name = …;` — declarator's first child is the name; the initializer is
19 ; nested under expression nodes, so anchor to the first child.
20 (variable_declaration
21 (declarator
22 . (identifier) @local.definition.variable))
23 ; `auto name = …;`
24 (auto_declaration
25 variable: (identifier) @local.definition.variable)
26
27 ; `foreach (name; range)` — like parameters, the optional type is a `(type)`
28 ; node and the loop variable is the trailing direct identifier.
29 (foreach_type
30 (identifier) @local.definition.variable)
31
32 ; `catch (Exception e)` — type is wrapped, the bound name is a direct identifier.
33 (catch_statement
34 (identifier) @local.definition.variable)
35
36 ; References
37
38 (identifier) @local.reference
39
40 ; Discards: identifiers that look like references but aren't variables.
41
42 ; `expr.member` — the trailing member name is not a local.
43 (property_expression
44 (identifier) @_ .)
45 ; Named argument `foo(name: value)`.
46 (named_argument
47 (identifier) @_)