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,378 @@
1
+ import Foundation
2
+ import Codepad
3
+
4
+ @objc(CPLangJava)
5
+ public final class CPLangJava: NSObject, CPLanguageProvider {
6
+ public let id: String = "java"
7
+ public var languagePointer: UnsafeRawPointer { UnsafeRawPointer(tree_sitter_java()) }
8
+ public let highlights: String = #"""
9
+ ; CREDITS @maxbrunsfeld (maxbrunsfeld@gmail.com)
10
+ ; Variables
11
+ (identifier) @variable
12
+
13
+ (underscore_pattern) @character.special
14
+
15
+ ; Methods
16
+ (method_declaration
17
+ name: (identifier) @function.method)
18
+
19
+ (method_invocation
20
+ name: (identifier) @function.method.call)
21
+
22
+ (super) @function.builtin
23
+
24
+ ; Parameters
25
+ (formal_parameter
26
+ name: (identifier) @variable.parameter)
27
+
28
+ (spread_parameter
29
+ (variable_declarator
30
+ name: (identifier) @variable.parameter)) ; int... foo
31
+
32
+ ; Lambda parameter
33
+ (inferred_parameters
34
+ (identifier) @variable.parameter) ; (x,y) -> ...
35
+
36
+ (lambda_expression
37
+ parameters: (identifier) @variable.parameter) ; x -> ...
38
+
39
+ ; Operators
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
+ ] @operator
77
+
78
+ ; Types
79
+ (interface_declaration
80
+ name: (identifier) @type)
81
+
82
+ (annotation_type_declaration
83
+ name: (identifier) @type)
84
+
85
+ (class_declaration
86
+ name: (identifier) @type)
87
+
88
+ (record_declaration
89
+ name: (identifier) @type)
90
+
91
+ (enum_declaration
92
+ name: (identifier) @type)
93
+
94
+ (constructor_declaration
95
+ name: (identifier) @type)
96
+
97
+ (compact_constructor_declaration
98
+ name: (identifier) @type)
99
+
100
+ (type_identifier) @type
101
+
102
+ ((type_identifier) @type.builtin
103
+ (#eq? @type.builtin "var"))
104
+
105
+ ((method_invocation
106
+ object: (identifier) @type)
107
+ (#match? @type "^[A-Z]"))
108
+
109
+ ((method_reference
110
+ .
111
+ (identifier) @type)
112
+ (#match? @type "^[A-Z]"))
113
+
114
+ ((field_access
115
+ object: (identifier) @type)
116
+ (#match? @type "^[A-Z]"))
117
+
118
+ (scoped_identifier
119
+ (identifier) @type
120
+ (#match? @type "^[A-Z]"))
121
+
122
+ ; Fields
123
+ (field_declaration
124
+ declarator: (variable_declarator
125
+ name: (identifier) @variable.member))
126
+
127
+ (field_access
128
+ field: (identifier) @variable.member)
129
+
130
+ [
131
+ (boolean_type)
132
+ (integral_type)
133
+ (floating_point_type)
134
+ (void_type)
135
+ ] @type.builtin
136
+
137
+ ; Variables
138
+ ((identifier) @constant
139
+ (#match? @constant "^[A-Z_][A-Z0-9_]+$"))
140
+
141
+ (this) @variable.builtin
142
+
143
+ ; Annotations
144
+ (annotation
145
+ "@" @attribute
146
+ name: (identifier) @attribute)
147
+
148
+ (marker_annotation
149
+ "@" @attribute
150
+ name: (identifier) @attribute)
151
+
152
+ ; Literals
153
+ (string_literal) @string
154
+
155
+ (escape_sequence) @string.escape
156
+
157
+ (character_literal) @character
158
+
159
+ [
160
+ (hex_integer_literal)
161
+ (decimal_integer_literal)
162
+ (octal_integer_literal)
163
+ (binary_integer_literal)
164
+ ] @number
165
+
166
+ [
167
+ (decimal_floating_point_literal)
168
+ (hex_floating_point_literal)
169
+ ] @number.float
170
+
171
+ [
172
+ (true)
173
+ (false)
174
+ ] @boolean
175
+
176
+ (null_literal) @constant.builtin
177
+
178
+ ; Keywords
179
+ [
180
+ "assert"
181
+ "default"
182
+ "extends"
183
+ "implements"
184
+ "instanceof"
185
+ "@interface"
186
+ "permits"
187
+ "to"
188
+ "with"
189
+ ] @keyword
190
+
191
+ [
192
+ "record"
193
+ "class"
194
+ "enum"
195
+ "interface"
196
+ ] @keyword.type
197
+
198
+ (synchronized_statement
199
+ "synchronized" @keyword)
200
+
201
+ [
202
+ "abstract"
203
+ "final"
204
+ "native"
205
+ "non-sealed"
206
+ "open"
207
+ "private"
208
+ "protected"
209
+ "public"
210
+ "sealed"
211
+ "static"
212
+ "strictfp"
213
+ "transitive"
214
+ ] @keyword.modifier
215
+
216
+ (modifiers
217
+ "synchronized" @keyword.modifier)
218
+
219
+ [
220
+ "transient"
221
+ "volatile"
222
+ ] @keyword.modifier
223
+
224
+ [
225
+ "return"
226
+ "yield"
227
+ ] @keyword.return
228
+
229
+ "new" @keyword.operator
230
+
231
+ ; Conditionals
232
+ [
233
+ "if"
234
+ "else"
235
+ "switch"
236
+ "case"
237
+ "when"
238
+ ] @keyword.conditional
239
+
240
+ (ternary_expression
241
+ [
242
+ "?"
243
+ ":"
244
+ ] @keyword.conditional.ternary)
245
+
246
+ (wildcard
247
+ "?" @character.special)
248
+
249
+ ; Loops
250
+ [
251
+ "for"
252
+ "while"
253
+ "do"
254
+ "continue"
255
+ "break"
256
+ ] @keyword.repeat
257
+
258
+ ; Includes
259
+ [
260
+ "exports"
261
+ "import"
262
+ "module"
263
+ "opens"
264
+ "package"
265
+ "provides"
266
+ "requires"
267
+ "uses"
268
+ ] @keyword.import
269
+
270
+ (import_declaration
271
+ (asterisk
272
+ "*" @character.special))
273
+
274
+ ; Punctuation
275
+ [
276
+ ";"
277
+ "."
278
+ "..."
279
+ ","
280
+ ] @punctuation.delimiter
281
+
282
+ [
283
+ "{"
284
+ "}"
285
+ ] @punctuation.bracket
286
+
287
+ [
288
+ "["
289
+ "]"
290
+ ] @punctuation.bracket
291
+
292
+ [
293
+ "("
294
+ ")"
295
+ ] @punctuation.bracket
296
+
297
+ (type_arguments
298
+ [
299
+ "<"
300
+ ">"
301
+ ] @punctuation.bracket)
302
+
303
+ (type_parameters
304
+ [
305
+ "<"
306
+ ">"
307
+ ] @punctuation.bracket)
308
+
309
+ (string_interpolation
310
+ [
311
+ "\\{"
312
+ "}"
313
+ ] @punctuation.special)
314
+
315
+ ; Exceptions
316
+ [
317
+ "throw"
318
+ "throws"
319
+ "finally"
320
+ "try"
321
+ "catch"
322
+ ] @keyword.exception
323
+
324
+ ; Labels
325
+ (labeled_statement
326
+ (identifier) @label)
327
+
328
+ ; Comments
329
+ [
330
+ (line_comment)
331
+ (block_comment)
332
+ ] @comment @spell
333
+
334
+ ((block_comment) @comment.documentation
335
+ (#match? @comment.documentation "^/[*][*][^*].*[*]/$"))
336
+
337
+ ((line_comment) @comment.documentation
338
+ (#match? @comment.documentation "^///[^/]"))
339
+
340
+ ((line_comment) @comment.documentation
341
+ (#match? @comment.documentation "^///$"))
342
+
343
+ """#
344
+ public let injections: String = #"""
345
+ ([
346
+ (block_comment)
347
+ (line_comment)
348
+ ] @injection.content
349
+ (#set! injection.language "comment"))
350
+
351
+ ((block_comment) @injection.content
352
+ (#match? @injection.content "/[*][*][\\s]")
353
+ (#set! injection.language "javadoc"))
354
+
355
+ ; markdown-style javadocs https://openjdk.org/jeps/467
356
+ ((line_comment) @injection.content
357
+ (#match? @injection.content "^///\\s")
358
+ (#set! injection.language "javadoc"))
359
+
360
+ ((method_invocation
361
+ name: (identifier) @_method
362
+ arguments: (argument_list
363
+ .
364
+ (string_literal
365
+ .
366
+ (_) @injection.content)))
367
+ (#any-of? @_method "format" "printf")
368
+ (#set! injection.language "printf"))
369
+
370
+ ((method_invocation
371
+ object: (string_literal
372
+ (string_fragment) @injection.content)
373
+ name: (identifier) @_method)
374
+ (#eq? @_method "formatted")
375
+ (#set! injection.language "printf"))
376
+
377
+ """#
378
+ }
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "react-native-codepad-lang-java",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "tree-sitter Java grammar and highlight queries for react-native-codepad",
5
+ "main": "./src/index.ts",
6
+ "types": "./src/index.ts",
7
+ "files": [
8
+ "src",
9
+ "android",
10
+ "ios",
11
+ "grammar",
12
+ "queries",
13
+ "*.podspec",
14
+ "!android/build",
15
+ "!android/.cxx"
16
+ ],
17
+ "keywords": [
18
+ "react-native",
19
+ "codepad",
20
+ "tree-sitter",
21
+ "java"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/SectionTN/react-native-codepad.git",
26
+ "directory": "languages/java"
27
+ },
28
+ "author": "Rayen Sbai <rayensbai2@gmail.com> (https://github.com/SectionTN)",
29
+ "license": "MIT",
30
+ "homepage": "https://github.com/SectionTN/react-native-codepad#readme",
31
+ "peerDependencies": {
32
+ "react-native-codepad": "0.1.0"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/"
36
+ },
37
+ "codepad": {
38
+ "generated": true,
39
+ "grammar": "tree-sitter/tree-sitter-java@e10607b45ff745f5f876bfa3e94fbcc6b44bdc11",
40
+ "queries": "nvim-treesitter/nvim-treesitter@e289100ff98969e118c702199d88b764ce9e7fdf"
41
+ }
42
+ }