aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/gdscript/locals.scm
blob: 62166e6f09d058aa3c819ab6a047a8853a28547b (plain) (blame)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
; Scopes
[
  (if_statement)
  (elif_clause)
  (else_clause)
  (for_statement)
  (while_statement)
  (function_definition)
  (constructor_definition)
  (class_definition)
  (match_statement)
  (pattern_section)
  (lambda)
  (get_body)
  (set_body)
] @local.scope

; Parameters
(parameters
  (identifier) @local.definition.parameter)

(default_parameter
  (identifier) @local.definition.parameter)

(typed_parameter
  (identifier) @local.definition.parameter)

(typed_default_parameter
  (identifier) @local.definition.parameter)

; Signals
; Can gdscript 2 signals be considered fields?
(signal_statement
  (name) @local.definition.field)

; Variable Definitions
(const_statement
  (name) @local.definition.constant)

; onready and export variations are only properties.
(variable_statement
  (name) @local.definition.var)

(setter) @local.reference

(getter) @local.reference

; Function Definition
((function_definition
  (name) @local.definition.function)
  (#set! definition.function.scope "parent"))

; Lambda
; lambda names are not accessible and are only for debugging.
(lambda
  (name) @local.definition.function)

; Source
(class_name_statement
  (name) @local.definition.type)

(source
  (variable_statement
    (name) @local.definition.field))

(source
  (onready_variable_statement
    (name) @local.definition.field))

(source
  (export_variable_statement
    (name) @local.definition.field))

; Class
((class_definition
  (name) @local.definition.type)
  (#set! definition.type.scope "parent"))

(class_definition
  (body
    (variable_statement
      (name) @local.definition.field)))

(class_definition
  (body
    (onready_variable_statement
      (name) @local.definition.field)))

(class_definition
  (body
    (export_variable_statement
      (name) @local.definition.field)))

(class_definition
  (body
    (signal_statement
      (name) @local.definition.field)))

; Although a script is also a class, let's only define functions in an inner class as
; methods.
((class_definition
  (body
    (function_definition
      (name) @local.definition.method)))
  (#set! definition.method.scope "parent"))

; Enum
(enum_definition
  (name) @local.definition.enum)

; Repeat
(for_statement
  .
  (identifier) @local.definition.var)

; Match Statement
(pattern_binding
  (identifier) @local.definition.var)

; References
(identifier) @local.reference