react-native-codepad-lang-java 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,333 @@
1
+ ; CREDITS @maxbrunsfeld (maxbrunsfeld@gmail.com)
2
+ ; Variables
3
+ (identifier) @variable
4
+
5
+ (underscore_pattern) @character.special
6
+
7
+ ; Methods
8
+ (method_declaration
9
+ name: (identifier) @function.method)
10
+
11
+ (method_invocation
12
+ name: (identifier) @function.method.call)
13
+
14
+ (super) @function.builtin
15
+
16
+ ; Parameters
17
+ (formal_parameter
18
+ name: (identifier) @variable.parameter)
19
+
20
+ (spread_parameter
21
+ (variable_declarator
22
+ name: (identifier) @variable.parameter)) ; int... foo
23
+
24
+ ; Lambda parameter
25
+ (inferred_parameters
26
+ (identifier) @variable.parameter) ; (x,y) -> ...
27
+
28
+ (lambda_expression
29
+ parameters: (identifier) @variable.parameter) ; x -> ...
30
+
31
+ ; Operators
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
+ ] @operator
69
+
70
+ ; Types
71
+ (interface_declaration
72
+ name: (identifier) @type)
73
+
74
+ (annotation_type_declaration
75
+ name: (identifier) @type)
76
+
77
+ (class_declaration
78
+ name: (identifier) @type)
79
+
80
+ (record_declaration
81
+ name: (identifier) @type)
82
+
83
+ (enum_declaration
84
+ name: (identifier) @type)
85
+
86
+ (constructor_declaration
87
+ name: (identifier) @type)
88
+
89
+ (compact_constructor_declaration
90
+ name: (identifier) @type)
91
+
92
+ (type_identifier) @type
93
+
94
+ ((type_identifier) @type.builtin
95
+ (#eq? @type.builtin "var"))
96
+
97
+ ((method_invocation
98
+ object: (identifier) @type)
99
+ (#match? @type "^[A-Z]"))
100
+
101
+ ((method_reference
102
+ .
103
+ (identifier) @type)
104
+ (#match? @type "^[A-Z]"))
105
+
106
+ ((field_access
107
+ object: (identifier) @type)
108
+ (#match? @type "^[A-Z]"))
109
+
110
+ (scoped_identifier
111
+ (identifier) @type
112
+ (#match? @type "^[A-Z]"))
113
+
114
+ ; Fields
115
+ (field_declaration
116
+ declarator: (variable_declarator
117
+ name: (identifier) @variable.member))
118
+
119
+ (field_access
120
+ field: (identifier) @variable.member)
121
+
122
+ [
123
+ (boolean_type)
124
+ (integral_type)
125
+ (floating_point_type)
126
+ (void_type)
127
+ ] @type.builtin
128
+
129
+ ; Variables
130
+ ((identifier) @constant
131
+ (#match? @constant "^[A-Z_][A-Z0-9_]+$"))
132
+
133
+ (this) @variable.builtin
134
+
135
+ ; Annotations
136
+ (annotation
137
+ "@" @attribute
138
+ name: (identifier) @attribute)
139
+
140
+ (marker_annotation
141
+ "@" @attribute
142
+ name: (identifier) @attribute)
143
+
144
+ ; Literals
145
+ (string_literal) @string
146
+
147
+ (escape_sequence) @string.escape
148
+
149
+ (character_literal) @character
150
+
151
+ [
152
+ (hex_integer_literal)
153
+ (decimal_integer_literal)
154
+ (octal_integer_literal)
155
+ (binary_integer_literal)
156
+ ] @number
157
+
158
+ [
159
+ (decimal_floating_point_literal)
160
+ (hex_floating_point_literal)
161
+ ] @number.float
162
+
163
+ [
164
+ (true)
165
+ (false)
166
+ ] @boolean
167
+
168
+ (null_literal) @constant.builtin
169
+
170
+ ; Keywords
171
+ [
172
+ "assert"
173
+ "default"
174
+ "extends"
175
+ "implements"
176
+ "instanceof"
177
+ "@interface"
178
+ "permits"
179
+ "to"
180
+ "with"
181
+ ] @keyword
182
+
183
+ [
184
+ "record"
185
+ "class"
186
+ "enum"
187
+ "interface"
188
+ ] @keyword.type
189
+
190
+ (synchronized_statement
191
+ "synchronized" @keyword)
192
+
193
+ [
194
+ "abstract"
195
+ "final"
196
+ "native"
197
+ "non-sealed"
198
+ "open"
199
+ "private"
200
+ "protected"
201
+ "public"
202
+ "sealed"
203
+ "static"
204
+ "strictfp"
205
+ "transitive"
206
+ ] @keyword.modifier
207
+
208
+ (modifiers
209
+ "synchronized" @keyword.modifier)
210
+
211
+ [
212
+ "transient"
213
+ "volatile"
214
+ ] @keyword.modifier
215
+
216
+ [
217
+ "return"
218
+ "yield"
219
+ ] @keyword.return
220
+
221
+ "new" @keyword.operator
222
+
223
+ ; Conditionals
224
+ [
225
+ "if"
226
+ "else"
227
+ "switch"
228
+ "case"
229
+ "when"
230
+ ] @keyword.conditional
231
+
232
+ (ternary_expression
233
+ [
234
+ "?"
235
+ ":"
236
+ ] @keyword.conditional.ternary)
237
+
238
+ (wildcard
239
+ "?" @character.special)
240
+
241
+ ; Loops
242
+ [
243
+ "for"
244
+ "while"
245
+ "do"
246
+ "continue"
247
+ "break"
248
+ ] @keyword.repeat
249
+
250
+ ; Includes
251
+ [
252
+ "exports"
253
+ "import"
254
+ "module"
255
+ "opens"
256
+ "package"
257
+ "provides"
258
+ "requires"
259
+ "uses"
260
+ ] @keyword.import
261
+
262
+ (import_declaration
263
+ (asterisk
264
+ "*" @character.special))
265
+
266
+ ; Punctuation
267
+ [
268
+ ";"
269
+ "."
270
+ "..."
271
+ ","
272
+ ] @punctuation.delimiter
273
+
274
+ [
275
+ "{"
276
+ "}"
277
+ ] @punctuation.bracket
278
+
279
+ [
280
+ "["
281
+ "]"
282
+ ] @punctuation.bracket
283
+
284
+ [
285
+ "("
286
+ ")"
287
+ ] @punctuation.bracket
288
+
289
+ (type_arguments
290
+ [
291
+ "<"
292
+ ">"
293
+ ] @punctuation.bracket)
294
+
295
+ (type_parameters
296
+ [
297
+ "<"
298
+ ">"
299
+ ] @punctuation.bracket)
300
+
301
+ (string_interpolation
302
+ [
303
+ "\\{"
304
+ "}"
305
+ ] @punctuation.special)
306
+
307
+ ; Exceptions
308
+ [
309
+ "throw"
310
+ "throws"
311
+ "finally"
312
+ "try"
313
+ "catch"
314
+ ] @keyword.exception
315
+
316
+ ; Labels
317
+ (labeled_statement
318
+ (identifier) @label)
319
+
320
+ ; Comments
321
+ [
322
+ (line_comment)
323
+ (block_comment)
324
+ ] @comment @spell
325
+
326
+ ((block_comment) @comment.documentation
327
+ (#match? @comment.documentation "^/[*][*][^*].*[*]/$"))
328
+
329
+ ((line_comment) @comment.documentation
330
+ (#match? @comment.documentation "^///[^/]"))
331
+
332
+ ((line_comment) @comment.documentation
333
+ (#match? @comment.documentation "^///$"))
@@ -0,0 +1,40 @@
1
+ ; format-ignore
2
+ [
3
+ ; ... refers to the portion that this indent query will have effects on
4
+ (class_body) ; { ... } of `class X`
5
+ (enum_body) ; { ... } of `enum X`
6
+ (interface_body) ; { ... } of `interface X`
7
+ (constructor_body) ; { `modifier` X() {...} } inside `class X`
8
+ (annotation_type_body) ; { ... } of `@interface X`
9
+ (block) ; { ... } that's not mentioned in this scope
10
+ (switch_block) ; { ... } in `switch X`
11
+ (array_initializer) ; [1, 2]
12
+ (argument_list) ; foo(...)
13
+ (formal_parameters) ; method foo(...)
14
+ (annotation_argument_list) ; @Annotation(...)
15
+ (element_value_array_initializer) ; { a, b } inside @Annotation()
16
+ ] @indent.begin
17
+
18
+ (expression_statement
19
+ (method_invocation) @indent.begin)
20
+
21
+ [
22
+ "("
23
+ ")"
24
+ "{"
25
+ "}"
26
+ "["
27
+ "]"
28
+ ] @indent.branch
29
+
30
+ (annotation_argument_list
31
+ ")" @indent.end) ; This should be a special cased as `()` here doesn't have ending `;`
32
+
33
+ "}" @indent.end
34
+
35
+ (line_comment) @indent.ignore
36
+
37
+ [
38
+ (ERROR)
39
+ (block_comment)
40
+ ] @indent.auto
@@ -0,0 +1,31 @@
1
+ ([
2
+ (block_comment)
3
+ (line_comment)
4
+ ] @injection.content
5
+ (#set! injection.language "comment"))
6
+
7
+ ((block_comment) @injection.content
8
+ (#match? @injection.content "/[*][*][\\s]")
9
+ (#set! injection.language "javadoc"))
10
+
11
+ ; markdown-style javadocs https://openjdk.org/jeps/467
12
+ ((line_comment) @injection.content
13
+ (#match? @injection.content "^///\\s")
14
+ (#set! injection.language "javadoc"))
15
+
16
+ ((method_invocation
17
+ name: (identifier) @_method
18
+ arguments: (argument_list
19
+ .
20
+ (string_literal
21
+ .
22
+ (_) @injection.content)))
23
+ (#any-of? @_method "format" "printf")
24
+ (#set! injection.language "printf"))
25
+
26
+ ((method_invocation
27
+ object: (string_literal
28
+ (string_fragment) @injection.content)
29
+ name: (identifier) @_method)
30
+ (#eq? @_method "formatted")
31
+ (#set! injection.language "printf"))
@@ -0,0 +1,100 @@
1
+ ; SCOPES
2
+ ; declarations
3
+ (program) @local.scope
4
+
5
+ (class_declaration
6
+ body: (_) @local.scope)
7
+
8
+ (record_declaration
9
+ body: (_) @local.scope)
10
+
11
+ (enum_declaration
12
+ body: (_) @local.scope)
13
+
14
+ (lambda_expression) @local.scope
15
+
16
+ (enhanced_for_statement) @local.scope
17
+
18
+ ; block
19
+ (block) @local.scope
20
+
21
+ ; if/else
22
+ (if_statement) @local.scope ; if+else
23
+
24
+ (if_statement
25
+ consequence: (_) @local.scope) ; if body in case there are no braces
26
+
27
+ (if_statement
28
+ alternative: (_) @local.scope) ; else body in case there are no braces
29
+
30
+ ; try/catch
31
+ (try_statement) @local.scope ; covers try+catch, individual try and catch are covered by (block)
32
+
33
+ (catch_clause) @local.scope ; needed because `Exception` variable
34
+
35
+ ; loops
36
+ (for_statement) @local.scope ; whole for_statement because loop iterator variable
37
+
38
+ (for_statement
39
+ ; "for" body in case there are no braces
40
+ body: (_) @local.scope)
41
+
42
+ (do_statement
43
+ body: (_) @local.scope)
44
+
45
+ (while_statement
46
+ body: (_) @local.scope)
47
+
48
+ ; Functions
49
+ (constructor_declaration) @local.scope
50
+
51
+ (method_declaration) @local.scope
52
+
53
+ ; DEFINITIONS
54
+ (package_declaration
55
+ (identifier) @local.definition.namespace)
56
+
57
+ (class_declaration
58
+ name: (identifier) @local.definition.type)
59
+
60
+ (record_declaration
61
+ name: (identifier) @local.definition.type)
62
+
63
+ (enum_declaration
64
+ name: (identifier) @local.definition.enum)
65
+
66
+ (method_declaration
67
+ name: (identifier) @local.definition.method)
68
+
69
+ (local_variable_declaration
70
+ declarator: (variable_declarator
71
+ name: (identifier) @local.definition.var))
72
+
73
+ (enhanced_for_statement
74
+ ; for (var item : items) {
75
+ name: (identifier) @local.definition.var)
76
+
77
+ (formal_parameter
78
+ name: (identifier) @local.definition.parameter)
79
+
80
+ (catch_formal_parameter
81
+ name: (identifier) @local.definition.parameter)
82
+
83
+ (inferred_parameters
84
+ (identifier) @local.definition.parameter) ; (x,y) -> ...
85
+
86
+ (lambda_expression
87
+ parameters: (identifier) @local.definition.parameter) ; x -> ...
88
+
89
+ ((scoped_identifier
90
+ (identifier) @local.definition.import)
91
+ (#has-ancestor? @local.definition.import import_declaration))
92
+
93
+ (field_declaration
94
+ declarator: (variable_declarator
95
+ name: (identifier) @local.definition.field))
96
+
97
+ ; REFERENCES
98
+ (identifier) @local.reference
99
+
100
+ (type_identifier) @local.reference
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export const java = 'java' as const;