Debian Codegraph @

runtime/queries/java/highlights.scm

raw symbols SCIP
1 (identifier) @variable
2
3 ; Methods
4
5 (method_declaration
6 name: (identifier) @function.method)
7 (method_invocation
8 name: (identifier) @function.method)
9 (super) @variable.builtin
10
11 ; Annotations
12
13 (annotation
14 name: (identifier) @attribute)
15 (marker_annotation
16 name: (identifier) @attribute)
17
18 ; Types
19
20 (interface_declaration
21 name: (identifier) @type)
22 (class_declaration
23 name: (identifier) @type)
24 (record_declaration
25 name: (identifier) @type)
26 (enum_declaration
27 name: (identifier) @type)
28
29 ((field_access
30 object: (identifier) @type)
31 (#match? @type "^[A-Z]"))
32 ((scoped_identifier
33 scope: (identifier) @type)
34 (#match? @type "^[A-Z]"))
35
36 (constructor_declaration
37 name: (identifier) @type)
38 (compact_constructor_declaration
39 name: (identifier) @type)
40
41 (type_identifier) @type
42
43 [
44 (boolean_type)
45 (integral_type)
46 (floating_point_type)
47 (floating_point_type)
48 (void_type)
49 ] @type.builtin
50
51 (type_arguments
52 (wildcard "?" @type.builtin))
53
54 ; Patterns (Java 21+): the record type name would otherwise be a @variable.
55 (record_pattern . (identifier) @type)
56 ; `when` is contextual — only a guard inside a switch label, never a keyword
57 ; elsewhere — so scope it to the guard rather than the flat keyword list.
58 (guard "when" @keyword.control.conditional)
59
60 ; Member access. `field_access` is a distinct node from `method_invocation`, so
61 ; this leaves method calls alone; placed before the SCREAMING @constant rule
62 ; below so `Type.CONST` stays a constant.
63 (field_access
64 field: (identifier) @variable.other.member)
65
66 ; Variables
67
68 ((identifier) @constant
69 (#match? @constant "^_*[A-Z][A-Z\\d_]+$"))
70
71 ; Unnamed variable / pattern `_` (Java 22) — dim as unused, like the discard in
72 ; other languages. It is an (underscore_pattern) in `var _ = …` and a plain
73 ; identifier in record components / `case _`.
74 (underscore_pattern) @comment.unused
75 ((identifier) @comment.unused
76 (#eq? @comment.unused "_"))
77
78 (this) @variable.builtin
79
80 ; Literals
81
82 [
83 (hex_integer_literal)
84 (decimal_integer_literal)
85 (octal_integer_literal)
86 (binary_integer_literal)
87 ] @constant.numeric.integer
88
89 [
90 (decimal_floating_point_literal)
91 (hex_floating_point_literal)
92 ] @constant.numeric.float
93
94 (character_literal) @constant.character
95
96 ; `string_literal` now also covers text blocks (`"""…"""`) and its fragments.
97 (string_literal) @string
98 (escape_sequence) @constant.character.escape
99 ; Interpolated expressions in string templates (a withdrawn preview) shouldn't
100 ; render as string; reset them rather than colour the whole literal.
101 (string_interpolation) @none
102
103 [
104 (true)
105 (false)
106 ] @constant.builtin.boolean
107 (null_literal) @constant.builtin
108
109 (line_comment) @comment
110 (block_comment) @comment
111
112 ; Punctuation
113
114 [
115 "::"
116 "."
117 ";"
118 ","
119 ] @punctuation.delimiter
120
121 [
122 "@"
123 "..."
124 ] @punctuation.special
125
126 [
127 "("
128 ")"
129 "["
130 "]"
131 "{"
132 "}"
133 ] @punctuation.bracket
134
135 (type_arguments
136 [
137 "<"
138 ">"
139 ] @punctuation.bracket)
140
141 (type_parameters
142 [
143 "<"
144 ">"
145 ] @punctuation.bracket)
146
147 ; Operators
148
149 [
150 "="
151 ">"
152 "<"
153 "!"
154 "~"
155 "?"
156 ":"
157 "->"
158 "=="
159 ">="
160 "<="
161 "!="
162 "&&"
163 "||"
164 "++"
165 "--"
166 "+"
167 "-"
168 "*"
169 "/"
170 "&"
171 "|"
172 "^"
173 "%"
174 "<<"
175 ">>"
176 ">>>"
177 "+="
178 "-="
179 "*="
180 "/="
181 "&="
182 "|="
183 "^="
184 "%="
185 "<<="
186 ">>="
187 ">>>="
188 ] @operator
189
190 ; Keywords
191
192 [
193 "abstract"
194 "assert"
195 "break"
196 "case"
197 "catch"
198 "class"
199 "continue"
200 "default"
201 "do"
202 "else"
203 "enum"
204 "exports"
205 "extends"
206 "final"
207 "finally"
208 "if"
209 "implements"
210 "import"
211 "instanceof"
212 "interface"
213 "module"
214 "native"
215 "new"
216 "non-sealed"
217 "open"
218 "opens"
219 "package"
220 "permits"
221 "private"
222 "protected"
223 "provides"
224 "public"
225 "requires"
226 "record"
227 "return"
228 "sealed"
229 "static"
230 "strictfp"
231 "switch"
232 "synchronized"
233 "throw"
234 "throws"
235 "to"
236 "transient"
237 "transitive"
238 "try"
239 "uses"
240 "volatile"
241 "with"
242 "yield"
243 ] @keyword
244
245 [
246 "while"
247 "for"
248 ] @keyword.control.repeat