@futpib/parser 1.0.3 → 1.0.6

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.
Files changed (262) hide show
  1. package/.claude/settings.local.json +24 -0
  2. package/.github/workflows/main.yml +1 -0
  3. package/build/androidPackageParser.js +30 -32
  4. package/build/arbitraryDalvikBytecode.d.ts +3 -3
  5. package/build/arbitraryDalvikBytecode.js +33 -27
  6. package/build/arbitraryDalvikExecutable.js +55 -17
  7. package/build/arbitraryJava.d.ts +31 -0
  8. package/build/arbitraryJava.js +532 -0
  9. package/build/arbitraryJavaScript.d.ts +3 -0
  10. package/build/arbitraryJavaScript.js +263 -0
  11. package/build/arbitraryJavascript.d.ts +3 -0
  12. package/build/arbitraryJavascript.js +263 -0
  13. package/build/arbitraryZig.d.ts +3 -0
  14. package/build/arbitraryZig.js +240 -0
  15. package/build/arbitraryZipStream.d.ts +1 -1
  16. package/build/arrayParser.js +72 -13
  17. package/build/backsmali.d.ts +4 -3
  18. package/build/backsmali.js +26 -6
  19. package/build/bash.d.ts +89 -0
  20. package/build/bash.js +1 -0
  21. package/build/bashParser.d.ts +6 -0
  22. package/build/bashParser.js +335 -0
  23. package/build/bashParser.test.d.ts +1 -0
  24. package/build/bashParser.test.js +343 -0
  25. package/build/bashParserEdgeCases.test.d.ts +1 -0
  26. package/build/bashParserEdgeCases.test.js +117 -0
  27. package/build/dalvikBytecodeParser/addressConversion.d.ts +110 -0
  28. package/build/dalvikBytecodeParser/addressConversion.js +334 -0
  29. package/build/dalvikBytecodeParser/formatParsers.d.ts +7 -6
  30. package/build/dalvikBytecodeParser/formatParsers.js +13 -14
  31. package/build/dalvikBytecodeParser.d.ts +60 -31
  32. package/build/dalvikBytecodeParser.js +92 -35
  33. package/build/dalvikBytecodeParser.test-d.d.ts +1 -0
  34. package/build/dalvikBytecodeParser.test-d.js +268 -0
  35. package/build/dalvikBytecodeUnparser/formatUnparsers.d.ts +9 -8
  36. package/build/dalvikBytecodeUnparser/formatUnparsers.js +13 -12
  37. package/build/dalvikBytecodeUnparser.d.ts +2 -2
  38. package/build/dalvikBytecodeUnparser.js +23 -23
  39. package/build/dalvikBytecodeUnparser.test.js +7 -7
  40. package/build/dalvikExecutable.d.ts +3 -3
  41. package/build/dalvikExecutable.test-d.d.ts +1 -0
  42. package/build/dalvikExecutable.test-d.js +59 -0
  43. package/build/dalvikExecutableParser/typedNumbers.d.ts +18 -0
  44. package/build/dalvikExecutableParser/typedNumbers.js +3 -0
  45. package/build/dalvikExecutableParser.d.ts +2 -1
  46. package/build/dalvikExecutableParser.js +96 -77
  47. package/build/dalvikExecutableParser.test.js +24 -3
  48. package/build/dalvikExecutableParserAgainstSmaliParser.test.js +3 -0
  49. package/build/dalvikExecutableUnparser/poolScanners.d.ts +2 -2
  50. package/build/dalvikExecutableUnparser/sectionUnparsers.d.ts +3 -3
  51. package/build/dalvikExecutableUnparser/sectionUnparsers.js +26 -11
  52. package/build/dalvikExecutableUnparser.d.ts +2 -2
  53. package/build/dalvikExecutableUnparser.test.js +2 -1
  54. package/build/disjunctionParser.d.ts +5 -3
  55. package/build/disjunctionParser.js +79 -17
  56. package/build/disjunctionParser.test-d.d.ts +1 -0
  57. package/build/disjunctionParser.test-d.js +72 -0
  58. package/build/elementSwitchParser.d.ts +4 -0
  59. package/build/{exactElementSwitchParser.js → elementSwitchParser.js} +3 -4
  60. package/build/elementSwitchParser.test-d.d.ts +1 -0
  61. package/build/elementSwitchParser.test-d.js +44 -0
  62. package/build/exactSequenceParser.d.ts +4 -2
  63. package/build/exactSequenceParser.test-d.d.ts +1 -0
  64. package/build/exactSequenceParser.test-d.js +36 -0
  65. package/build/fetchCid.js +2 -66
  66. package/build/index.d.ts +25 -2
  67. package/build/index.js +23 -1
  68. package/build/index.test.js +16 -1
  69. package/build/inputReader.d.ts +10 -0
  70. package/build/inputReader.js +36 -0
  71. package/build/java.d.ts +502 -0
  72. package/build/java.js +2 -0
  73. package/build/javaKeyStoreParser.js +14 -17
  74. package/build/javaParser.d.ts +51 -0
  75. package/build/javaParser.js +1538 -0
  76. package/build/javaParser.test.d.ts +1 -0
  77. package/build/javaParser.test.js +1287 -0
  78. package/build/javaScript.d.ts +35 -0
  79. package/build/javaScript.js +1 -0
  80. package/build/javaScriptParser.d.ts +9 -0
  81. package/build/javaScriptParser.js +34 -0
  82. package/build/javaScriptUnparser.d.ts +3 -0
  83. package/build/javaScriptUnparser.js +4 -0
  84. package/build/javaScriptUnparser.test.d.ts +1 -0
  85. package/build/javaScriptUnparser.test.js +24 -0
  86. package/build/javaUnparser.d.ts +2 -0
  87. package/build/javaUnparser.js +519 -0
  88. package/build/javaUnparser.test.d.ts +1 -0
  89. package/build/javaUnparser.test.js +24 -0
  90. package/build/javascript.d.ts +35 -0
  91. package/build/javascript.js +1 -0
  92. package/build/javascriptParser.d.ts +9 -0
  93. package/build/javascriptParser.js +34 -0
  94. package/build/javascriptUnparser.d.ts +3 -0
  95. package/build/javascriptUnparser.js +4 -0
  96. package/build/javascriptUnparser.test.d.ts +1 -0
  97. package/build/javascriptUnparser.test.js +24 -0
  98. package/build/jsonParser.js +2 -12
  99. package/build/lazyMessageError.d.ts +3 -0
  100. package/build/lookaheadParser.js +60 -3
  101. package/build/negativeLookaheadParser.js +70 -11
  102. package/build/nonEmptyArrayParser.js +72 -13
  103. package/build/objectParser.d.ts +12 -0
  104. package/build/objectParser.js +31 -0
  105. package/build/objectParser.test-d.d.ts +1 -0
  106. package/build/objectParser.test-d.js +112 -0
  107. package/build/objectParser.test.d.ts +1 -0
  108. package/build/objectParser.test.js +55 -0
  109. package/build/optionalParser.js +69 -10
  110. package/build/parser.d.ts +4 -0
  111. package/build/parser.js +3 -1
  112. package/build/parser.test.js +114 -1
  113. package/build/parserConsumedSequenceParser.js +66 -7
  114. package/build/parserContext.d.ts +6 -0
  115. package/build/parserContext.js +20 -11
  116. package/build/parserError.d.ts +119 -27
  117. package/build/parserError.js +16 -8
  118. package/build/regexpParser.d.ts +2 -0
  119. package/build/regexpParser.js +101 -0
  120. package/build/regexpParser.test.d.ts +1 -0
  121. package/build/regexpParser.test.js +114 -0
  122. package/build/regularExpression.d.ts +63 -0
  123. package/build/regularExpression.js +1 -0
  124. package/build/regularExpressionParser.d.ts +3 -0
  125. package/build/regularExpressionParser.js +600 -0
  126. package/build/regularExpressionParser.test.d.ts +1 -0
  127. package/build/regularExpressionParser.test.js +89 -0
  128. package/build/separatedArrayParser.js +73 -14
  129. package/build/separatedNonEmptyArrayParser.js +73 -14
  130. package/build/sliceBoundedParser.js +62 -5
  131. package/build/smaliParser.d.ts +7 -7
  132. package/build/smaliParser.js +185 -268
  133. package/build/smaliParser.test.js +58 -0
  134. package/build/stringEscapes.d.ts +5 -0
  135. package/build/stringEscapes.js +244 -0
  136. package/build/symbolicExpression.d.ts +29 -0
  137. package/build/symbolicExpression.js +1 -0
  138. package/build/symbolicExpressionParser.d.ts +4 -0
  139. package/build/symbolicExpressionParser.js +123 -0
  140. package/build/symbolicExpressionParser.test.d.ts +1 -0
  141. package/build/symbolicExpressionParser.test.js +289 -0
  142. package/build/terminatedArrayParser.js +113 -38
  143. package/build/terminatedArrayParser.test.js +4 -2
  144. package/build/tupleParser.d.ts +7 -15
  145. package/build/tupleParser.js +1 -0
  146. package/build/unionParser.d.ts +5 -3
  147. package/build/unionParser.js +7 -2
  148. package/build/unionParser.test-d.d.ts +1 -0
  149. package/build/unionParser.test-d.js +72 -0
  150. package/build/unionParser.test.js +10 -11
  151. package/build/zig.d.ts +280 -0
  152. package/build/zig.js +2 -0
  153. package/build/zigParser.d.ts +3 -0
  154. package/build/zigParser.js +1119 -0
  155. package/build/zigParser.test.d.ts +1 -0
  156. package/build/zigParser.test.js +1590 -0
  157. package/build/zigUnparser.d.ts +2 -0
  158. package/build/zigUnparser.js +460 -0
  159. package/build/zigUnparser.test.d.ts +1 -0
  160. package/build/zigUnparser.test.js +24 -0
  161. package/build/zipParser.js +19 -32
  162. package/build/zipUnparser.js +19 -7
  163. package/build/zipUnparser.test.js +1 -1
  164. package/node_modules-@types/s-expression/index.d.ts +5 -0
  165. package/package.json +25 -6
  166. package/src/androidPackageParser.ts +33 -60
  167. package/src/arbitraryDalvikBytecode.ts +39 -31
  168. package/src/arbitraryDalvikExecutable.ts +65 -20
  169. package/src/arbitraryJava.ts +804 -0
  170. package/src/arbitraryJavaScript.ts +410 -0
  171. package/src/arbitraryZig.ts +380 -0
  172. package/src/arrayParser.ts +1 -3
  173. package/src/backsmali.ts +35 -4
  174. package/src/bash.ts +127 -0
  175. package/src/bashParser.test.ts +590 -0
  176. package/src/bashParser.ts +498 -0
  177. package/src/dalvikBytecodeParser/addressConversion.ts +496 -0
  178. package/src/dalvikBytecodeParser/formatParsers.ts +19 -29
  179. package/src/dalvikBytecodeParser.test-d.ts +310 -0
  180. package/src/dalvikBytecodeParser.ts +194 -69
  181. package/src/dalvikBytecodeUnparser/formatUnparsers.ts +27 -26
  182. package/src/dalvikBytecodeUnparser.test.ts +7 -7
  183. package/src/dalvikBytecodeUnparser.ts +31 -30
  184. package/src/dalvikExecutable.test-d.ts +132 -0
  185. package/src/dalvikExecutable.ts +3 -3
  186. package/src/dalvikExecutableParser/typedNumbers.ts +11 -0
  187. package/src/dalvikExecutableParser.test.ts +37 -3
  188. package/src/dalvikExecutableParser.test.ts.md +163 -2
  189. package/src/dalvikExecutableParser.test.ts.snap +0 -0
  190. package/src/dalvikExecutableParser.ts +121 -139
  191. package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +4 -0
  192. package/src/dalvikExecutableUnparser/poolScanners.ts +6 -6
  193. package/src/dalvikExecutableUnparser/sectionUnparsers.ts +38 -14
  194. package/src/dalvikExecutableUnparser.test.ts +3 -2
  195. package/src/dalvikExecutableUnparser.ts +4 -4
  196. package/src/disjunctionParser.test-d.ts +105 -0
  197. package/src/disjunctionParser.ts +18 -15
  198. package/src/elementSwitchParser.test-d.ts +74 -0
  199. package/src/elementSwitchParser.ts +51 -0
  200. package/src/exactSequenceParser.test-d.ts +43 -0
  201. package/src/exactSequenceParser.ts +13 -8
  202. package/src/fetchCid.ts +2 -76
  203. package/src/index.test.ts +22 -1
  204. package/src/index.ts +119 -2
  205. package/src/inputReader.ts +53 -0
  206. package/src/java.ts +708 -0
  207. package/src/javaKeyStoreParser.ts +18 -32
  208. package/src/javaParser.test.ts +1592 -0
  209. package/src/javaParser.ts +2640 -0
  210. package/src/javaScript.ts +36 -0
  211. package/src/javaScriptParser.ts +57 -0
  212. package/src/javaScriptUnparser.test.ts +37 -0
  213. package/src/javaScriptUnparser.ts +7 -0
  214. package/src/javaUnparser.test.ts +37 -0
  215. package/src/javaUnparser.ts +640 -0
  216. package/src/jsonParser.ts +6 -27
  217. package/src/lookaheadParser.ts +2 -6
  218. package/src/negativeLookaheadParser.ts +1 -3
  219. package/src/nonEmptyArrayParser.ts +1 -3
  220. package/src/objectParser.test-d.ts +152 -0
  221. package/src/objectParser.test.ts +71 -0
  222. package/src/objectParser.ts +69 -0
  223. package/src/optionalParser.ts +1 -3
  224. package/src/parser.test.ts +151 -4
  225. package/src/parser.ts +11 -1
  226. package/src/parserConsumedSequenceParser.ts +2 -4
  227. package/src/parserContext.ts +26 -11
  228. package/src/parserError.ts +17 -3
  229. package/src/regexpParser.test.ts +264 -0
  230. package/src/regexpParser.ts +126 -0
  231. package/src/regularExpression.ts +24 -0
  232. package/src/regularExpressionParser.test.ts +102 -0
  233. package/src/regularExpressionParser.ts +920 -0
  234. package/src/separatedArrayParser.ts +1 -3
  235. package/src/separatedNonEmptyArrayParser.ts +1 -3
  236. package/src/sliceBoundedParser.test.ts +2 -2
  237. package/src/sliceBoundedParser.ts +15 -19
  238. package/src/smaliParser.test.ts +64 -0
  239. package/src/smaliParser.test.ts.md +12 -12
  240. package/src/smaliParser.test.ts.snap +0 -0
  241. package/src/smaliParser.ts +246 -534
  242. package/src/stringEscapes.ts +253 -0
  243. package/src/symbolicExpression.ts +17 -0
  244. package/src/symbolicExpressionParser.test.ts +466 -0
  245. package/src/symbolicExpressionParser.ts +190 -0
  246. package/src/terminatedArrayParser.test.ts +9 -6
  247. package/src/terminatedArrayParser.ts +25 -29
  248. package/src/tupleParser.ts +21 -18
  249. package/src/unionParser.test-d.ts +105 -0
  250. package/src/unionParser.test.ts +18 -17
  251. package/src/unionParser.ts +28 -16
  252. package/src/zig.ts +411 -0
  253. package/src/zigParser.test.ts +1693 -0
  254. package/src/zigParser.ts +1745 -0
  255. package/src/zigUnparser.test.ts +37 -0
  256. package/src/zigUnparser.ts +615 -0
  257. package/src/zipParser.ts +20 -56
  258. package/src/zipUnparser.test.ts +1 -1
  259. package/src/zipUnparser.ts +22 -7
  260. package/tsconfig.json +2 -2
  261. package/build/exactElementSwitchParser.d.ts +0 -3
  262. package/src/exactElementSwitchParser.ts +0 -41
package/src/java.ts ADDED
@@ -0,0 +1,708 @@
1
+ // Java AST type definitions - matches javaparser's JSON output format
2
+
3
+ // Name node (qualified name as nested structure)
4
+ export type JavaName = {
5
+ type: 'Name';
6
+ identifier: string;
7
+ qualifier?: JavaName;
8
+ };
9
+
10
+ // SimpleName node
11
+ export type JavaSimpleName = {
12
+ type: 'SimpleName';
13
+ identifier: string;
14
+ };
15
+
16
+ // Modifier node
17
+ export type JavaModifierKeyword =
18
+ | 'PUBLIC'
19
+ | 'PROTECTED'
20
+ | 'PRIVATE'
21
+ | 'STATIC'
22
+ | 'FINAL'
23
+ | 'ABSTRACT'
24
+ | 'SYNCHRONIZED'
25
+ | 'NATIVE'
26
+ | 'TRANSIENT'
27
+ | 'VOLATILE'
28
+ | 'STRICTFP'
29
+ | 'DEFAULT'
30
+ | 'SEALED'
31
+ | 'NON_SEALED';
32
+
33
+ export type JavaModifier = {
34
+ type: 'Modifier';
35
+ keyword: JavaModifierKeyword;
36
+ };
37
+
38
+ // Annotation expressions
39
+ export type JavaMarkerAnnotationExpr = {
40
+ type: 'MarkerAnnotationExpr';
41
+ name: JavaName;
42
+ };
43
+
44
+ export type JavaSingleMemberAnnotationExpr = {
45
+ type: 'SingleMemberAnnotationExpr';
46
+ name: JavaName;
47
+ memberValue: JavaExpression;
48
+ };
49
+
50
+ export type JavaMemberValuePair = {
51
+ type: 'MemberValuePair';
52
+ name: JavaSimpleName;
53
+ value: JavaExpression;
54
+ };
55
+
56
+ export type JavaNormalAnnotationExpr = {
57
+ type: 'NormalAnnotationExpr';
58
+ name: JavaName;
59
+ pairs: JavaMemberValuePair[];
60
+ };
61
+
62
+ export type JavaAnnotationExpr =
63
+ | JavaMarkerAnnotationExpr
64
+ | JavaSingleMemberAnnotationExpr
65
+ | JavaNormalAnnotationExpr;
66
+
67
+ // Package declaration
68
+ export type JavaPackageDeclaration = {
69
+ type: 'PackageDeclaration';
70
+ annotations: JavaAnnotationExpr[];
71
+ name: JavaName;
72
+ };
73
+
74
+ // Import declaration
75
+ export type JavaImportDeclaration = {
76
+ type: 'ImportDeclaration';
77
+ isStatic: boolean;
78
+ isAsterisk: boolean;
79
+ name: JavaName;
80
+ };
81
+
82
+ // Type parameters and arguments
83
+ export type JavaTypeParameter = {
84
+ type: 'TypeParameter';
85
+ name: JavaSimpleName;
86
+ typeBound: JavaClassOrInterfaceType[];
87
+ annotations: JavaAnnotationExpr[];
88
+ };
89
+
90
+ export type JavaClassOrInterfaceType = {
91
+ type: 'ClassOrInterfaceType';
92
+ name: JavaSimpleName;
93
+ scope?: JavaClassOrInterfaceType;
94
+ typeArguments?: JavaType[];
95
+ annotations: JavaAnnotationExpr[];
96
+ };
97
+
98
+ export type JavaPrimitiveType = {
99
+ type: 'PrimitiveType';
100
+ type_: 'BOOLEAN' | 'BYTE' | 'CHAR' | 'DOUBLE' | 'FLOAT' | 'INT' | 'LONG' | 'SHORT';
101
+ annotations: JavaAnnotationExpr[];
102
+ };
103
+
104
+ export type JavaArrayType = {
105
+ type: 'ArrayType';
106
+ componentType: JavaType;
107
+ origin: 'NAME' | 'TYPE';
108
+ annotations: JavaAnnotationExpr[];
109
+ };
110
+
111
+ export type JavaVoidType = {
112
+ type: 'VoidType';
113
+ annotations: JavaAnnotationExpr[];
114
+ };
115
+
116
+ export type JavaWildcardType = {
117
+ type: 'WildcardType';
118
+ extendedType?: JavaReferenceType;
119
+ superType?: JavaReferenceType;
120
+ annotations: JavaAnnotationExpr[];
121
+ };
122
+
123
+ export type JavaVarType = {
124
+ type: 'VarType';
125
+ annotations: JavaAnnotationExpr[];
126
+ };
127
+
128
+ export type JavaUnionType = {
129
+ type: 'UnionType';
130
+ elements: JavaReferenceType[];
131
+ annotations: JavaAnnotationExpr[];
132
+ };
133
+
134
+ export type JavaIntersectionType = {
135
+ type: 'IntersectionType';
136
+ elements: JavaReferenceType[];
137
+ annotations: JavaAnnotationExpr[];
138
+ };
139
+
140
+ export type JavaReferenceType = JavaClassOrInterfaceType | JavaArrayType;
141
+
142
+ export type JavaType =
143
+ | JavaPrimitiveType
144
+ | JavaClassOrInterfaceType
145
+ | JavaArrayType
146
+ | JavaVoidType
147
+ | JavaWildcardType
148
+ | JavaVarType
149
+ | JavaUnionType
150
+ | JavaIntersectionType;
151
+
152
+ // Expressions
153
+ export type JavaNameExpr = {
154
+ type: 'NameExpr';
155
+ name: JavaSimpleName;
156
+ };
157
+
158
+ export type JavaLiteralExpr =
159
+ | JavaIntegerLiteralExpr
160
+ | JavaLongLiteralExpr
161
+ | JavaDoubleLiteralExpr
162
+ | JavaCharLiteralExpr
163
+ | JavaStringLiteralExpr
164
+ | JavaTextBlockLiteralExpr
165
+ | JavaBooleanLiteralExpr
166
+ | JavaNullLiteralExpr;
167
+
168
+ export type JavaIntegerLiteralExpr = {
169
+ type: 'IntegerLiteralExpr';
170
+ value: string;
171
+ };
172
+
173
+ export type JavaLongLiteralExpr = {
174
+ type: 'LongLiteralExpr';
175
+ value: string;
176
+ };
177
+
178
+ export type JavaDoubleLiteralExpr = {
179
+ type: 'DoubleLiteralExpr';
180
+ value: string;
181
+ };
182
+
183
+ export type JavaCharLiteralExpr = {
184
+ type: 'CharLiteralExpr';
185
+ value: string;
186
+ };
187
+
188
+ export type JavaStringLiteralExpr = {
189
+ type: 'StringLiteralExpr';
190
+ value: string;
191
+ };
192
+
193
+ export type JavaTextBlockLiteralExpr = {
194
+ type: 'TextBlockLiteralExpr';
195
+ value: string;
196
+ };
197
+
198
+ export type JavaBooleanLiteralExpr = {
199
+ type: 'BooleanLiteralExpr';
200
+ value: boolean;
201
+ };
202
+
203
+ export type JavaNullLiteralExpr = {
204
+ type: 'NullLiteralExpr';
205
+ };
206
+
207
+ export type JavaThisExpr = {
208
+ type: 'ThisExpr';
209
+ typeName?: JavaName;
210
+ };
211
+
212
+ export type JavaSuperExpr = {
213
+ type: 'SuperExpr';
214
+ typeName?: JavaName;
215
+ };
216
+
217
+ export type JavaFieldAccessExpr = {
218
+ type: 'FieldAccessExpr';
219
+ scope: JavaExpression;
220
+ name: JavaSimpleName;
221
+ typeArguments?: JavaType[];
222
+ };
223
+
224
+ export type JavaArrayAccessExpr = {
225
+ type: 'ArrayAccessExpr';
226
+ name: JavaExpression;
227
+ index: JavaExpression;
228
+ };
229
+
230
+ export type JavaMethodCallExpr = {
231
+ type: 'MethodCallExpr';
232
+ scope?: JavaExpression;
233
+ name: JavaSimpleName;
234
+ arguments: JavaExpression[];
235
+ typeArguments?: JavaType[];
236
+ };
237
+
238
+ export type JavaObjectCreationExpr = {
239
+ type: 'ObjectCreationExpr';
240
+ scope?: JavaExpression;
241
+ type_: JavaClassOrInterfaceType;
242
+ arguments: JavaExpression[];
243
+ typeArguments?: JavaType[];
244
+ anonymousClassBody?: JavaBodyDeclaration[];
245
+ };
246
+
247
+ export type JavaArrayCreationExpr = {
248
+ type: 'ArrayCreationExpr';
249
+ elementType: JavaType;
250
+ levels: JavaArrayCreationLevel[];
251
+ initializer?: JavaArrayInitializerExpr;
252
+ };
253
+
254
+ export type JavaArrayCreationLevel = {
255
+ type: 'ArrayCreationLevel';
256
+ dimension?: JavaExpression;
257
+ annotations: JavaAnnotationExpr[];
258
+ };
259
+
260
+ export type JavaArrayInitializerExpr = {
261
+ type: 'ArrayInitializerExpr';
262
+ values: JavaExpression[];
263
+ };
264
+
265
+ export type JavaBinaryExpr = {
266
+ type: 'BinaryExpr';
267
+ left: JavaExpression;
268
+ right: JavaExpression;
269
+ operator: string;
270
+ };
271
+
272
+ export type JavaUnaryExpr = {
273
+ type: 'UnaryExpr';
274
+ expression: JavaExpression;
275
+ operator: string;
276
+ prefix: boolean;
277
+ };
278
+
279
+ export type JavaAssignExpr = {
280
+ type: 'AssignExpr';
281
+ target: JavaExpression;
282
+ value: JavaExpression;
283
+ operator: string;
284
+ };
285
+
286
+ export type JavaConditionalExpr = {
287
+ type: 'ConditionalExpr';
288
+ condition: JavaExpression;
289
+ thenExpr: JavaExpression;
290
+ elseExpr: JavaExpression;
291
+ };
292
+
293
+ export type JavaEnclosedExpr = {
294
+ type: 'EnclosedExpr';
295
+ inner: JavaExpression;
296
+ };
297
+
298
+ export type JavaCastExpr = {
299
+ type: 'CastExpr';
300
+ type_: JavaType;
301
+ expression: JavaExpression;
302
+ };
303
+
304
+ export type JavaInstanceOfExpr = {
305
+ type: 'InstanceOfExpr';
306
+ expression: JavaExpression;
307
+ type_: JavaReferenceType;
308
+ pattern?: JavaPatternExpr;
309
+ };
310
+
311
+ export type JavaTypePatternExpr = {
312
+ type: 'TypePatternExpr';
313
+ type_: JavaType;
314
+ name: JavaSimpleName;
315
+ modifiers: JavaModifier[];
316
+ };
317
+
318
+ export type JavaRecordPatternExpr = {
319
+ type: 'RecordPatternExpr';
320
+ type_: JavaType;
321
+ patternList: JavaPatternExpr[];
322
+ };
323
+
324
+ export type JavaPatternExpr = JavaTypePatternExpr | JavaRecordPatternExpr;
325
+
326
+ export type JavaClassExpr = {
327
+ type: 'ClassExpr';
328
+ type_: JavaType;
329
+ };
330
+
331
+ export type JavaLambdaExpr = {
332
+ type: 'LambdaExpr';
333
+ parameters: JavaParameter[];
334
+ body: JavaStatement | JavaExpression;
335
+ isEnclosingParameters: boolean;
336
+ };
337
+
338
+ export type JavaMethodReferenceExpr = {
339
+ type: 'MethodReferenceExpr';
340
+ scope: JavaExpression | JavaType;
341
+ identifier: string;
342
+ typeArguments?: JavaType[];
343
+ };
344
+
345
+ export type JavaSwitchExpr = {
346
+ type: 'SwitchExpr';
347
+ selector: JavaExpression;
348
+ entries: JavaSwitchEntry[];
349
+ };
350
+
351
+ export type JavaExpression =
352
+ | JavaNameExpr
353
+ | JavaLiteralExpr
354
+ | JavaThisExpr
355
+ | JavaSuperExpr
356
+ | JavaFieldAccessExpr
357
+ | JavaArrayAccessExpr
358
+ | JavaMethodCallExpr
359
+ | JavaObjectCreationExpr
360
+ | JavaArrayCreationExpr
361
+ | JavaArrayInitializerExpr
362
+ | JavaBinaryExpr
363
+ | JavaUnaryExpr
364
+ | JavaAssignExpr
365
+ | JavaConditionalExpr
366
+ | JavaEnclosedExpr
367
+ | JavaCastExpr
368
+ | JavaInstanceOfExpr
369
+ | JavaClassExpr
370
+ | JavaLambdaExpr
371
+ | JavaMethodReferenceExpr
372
+ | JavaAnnotationExpr
373
+ | JavaSwitchExpr;
374
+
375
+ // Statements
376
+ export type JavaBlockStmt = {
377
+ type: 'BlockStmt';
378
+ statements: JavaStatement[];
379
+ };
380
+
381
+ export type JavaExpressionStmt = {
382
+ type: 'ExpressionStmt';
383
+ expression: JavaExpression;
384
+ };
385
+
386
+ export type JavaReturnStmt = {
387
+ type: 'ReturnStmt';
388
+ expression?: JavaExpression;
389
+ };
390
+
391
+ export type JavaIfStmt = {
392
+ type: 'IfStmt';
393
+ condition: JavaExpression;
394
+ thenStmt: JavaStatement;
395
+ elseStmt?: JavaStatement;
396
+ };
397
+
398
+ export type JavaForStmt = {
399
+ type: 'ForStmt';
400
+ initialization: JavaExpression[];
401
+ compare?: JavaExpression;
402
+ update: JavaExpression[];
403
+ body: JavaStatement;
404
+ };
405
+
406
+ export type JavaForEachStmt = {
407
+ type: 'ForEachStmt';
408
+ variable: JavaVariableDeclarationExpr;
409
+ iterable: JavaExpression;
410
+ body: JavaStatement;
411
+ };
412
+
413
+ export type JavaWhileStmt = {
414
+ type: 'WhileStmt';
415
+ condition: JavaExpression;
416
+ body: JavaStatement;
417
+ };
418
+
419
+ export type JavaDoStmt = {
420
+ type: 'DoStmt';
421
+ body: JavaStatement;
422
+ condition: JavaExpression;
423
+ };
424
+
425
+ export type JavaSwitchStmt = {
426
+ type: 'SwitchStmt';
427
+ selector: JavaExpression;
428
+ entries: JavaSwitchEntry[];
429
+ };
430
+
431
+ export type JavaSwitchEntry = {
432
+ type: 'SwitchEntry';
433
+ labels: JavaExpression[];
434
+ type_: 'STATEMENT_GROUP' | 'EXPRESSION' | 'BLOCK' | 'THROWS_STATEMENT';
435
+ statements: JavaStatement[];
436
+ guard?: JavaExpression;
437
+ };
438
+
439
+ export type JavaBreakStmt = {
440
+ type: 'BreakStmt';
441
+ label?: JavaSimpleName;
442
+ };
443
+
444
+ export type JavaContinueStmt = {
445
+ type: 'ContinueStmt';
446
+ label?: JavaSimpleName;
447
+ };
448
+
449
+ export type JavaYieldStmt = {
450
+ type: 'YieldStmt';
451
+ expression: JavaExpression;
452
+ };
453
+
454
+ export type JavaThrowStmt = {
455
+ type: 'ThrowStmt';
456
+ expression: JavaExpression;
457
+ };
458
+
459
+ export type JavaTryStmt = {
460
+ type: 'TryStmt';
461
+ resources: JavaExpression[];
462
+ tryBlock: JavaBlockStmt;
463
+ catchClauses: JavaCatchClause[];
464
+ finallyBlock?: JavaBlockStmt;
465
+ };
466
+
467
+ export type JavaCatchClause = {
468
+ type: 'CatchClause';
469
+ parameter: JavaParameter;
470
+ body: JavaBlockStmt;
471
+ };
472
+
473
+ export type JavaSynchronizedStmt = {
474
+ type: 'SynchronizedStmt';
475
+ expression: JavaExpression;
476
+ body: JavaBlockStmt;
477
+ };
478
+
479
+ export type JavaLabeledStmt = {
480
+ type: 'LabeledStmt';
481
+ label: JavaSimpleName;
482
+ statement: JavaStatement;
483
+ };
484
+
485
+ export type JavaAssertStmt = {
486
+ type: 'AssertStmt';
487
+ check: JavaExpression;
488
+ message?: JavaExpression;
489
+ };
490
+
491
+ export type JavaLocalClassDeclarationStmt = {
492
+ type: 'LocalClassDeclarationStmt';
493
+ classDeclaration: JavaClassOrInterfaceDeclaration;
494
+ };
495
+
496
+ export type JavaLocalRecordDeclarationStmt = {
497
+ type: 'LocalRecordDeclarationStmt';
498
+ recordDeclaration: JavaRecordDeclaration;
499
+ };
500
+
501
+ export type JavaEmptyStmt = {
502
+ type: 'EmptyStmt';
503
+ };
504
+
505
+ export type JavaExplicitConstructorInvocationStmt = {
506
+ type: 'ExplicitConstructorInvocationStmt';
507
+ isThis: boolean;
508
+ expression?: JavaExpression;
509
+ arguments: JavaExpression[];
510
+ typeArguments?: JavaType[];
511
+ };
512
+
513
+ export type JavaUnparsableStmt = {
514
+ type: 'UnparsableStmt';
515
+ };
516
+
517
+ export type JavaStatement =
518
+ | JavaBlockStmt
519
+ | JavaExpressionStmt
520
+ | JavaReturnStmt
521
+ | JavaIfStmt
522
+ | JavaForStmt
523
+ | JavaForEachStmt
524
+ | JavaWhileStmt
525
+ | JavaDoStmt
526
+ | JavaSwitchStmt
527
+ | JavaBreakStmt
528
+ | JavaContinueStmt
529
+ | JavaYieldStmt
530
+ | JavaThrowStmt
531
+ | JavaTryStmt
532
+ | JavaSynchronizedStmt
533
+ | JavaLabeledStmt
534
+ | JavaAssertStmt
535
+ | JavaLocalClassDeclarationStmt
536
+ | JavaLocalRecordDeclarationStmt
537
+ | JavaEmptyStmt
538
+ | JavaExplicitConstructorInvocationStmt
539
+ | JavaUnparsableStmt;
540
+
541
+ // Variable declarations
542
+ export type JavaVariableDeclarator = {
543
+ type: 'VariableDeclarator';
544
+ name: JavaSimpleName;
545
+ type_: JavaType;
546
+ initializer?: JavaExpression;
547
+ };
548
+
549
+ export type JavaVariableDeclarationExpr = {
550
+ type: 'VariableDeclarationExpr';
551
+ modifiers: JavaModifier[];
552
+ annotations: JavaAnnotationExpr[];
553
+ variables: JavaVariableDeclarator[];
554
+ };
555
+
556
+ // Parameters
557
+ export type JavaParameter = {
558
+ type: 'Parameter';
559
+ modifiers: JavaModifier[];
560
+ annotations: JavaAnnotationExpr[];
561
+ type_: JavaType;
562
+ isVarArgs: boolean;
563
+ varArgsAnnotations: JavaAnnotationExpr[];
564
+ name: JavaSimpleName;
565
+ };
566
+
567
+ export type JavaReceiverParameter = {
568
+ type: 'ReceiverParameter';
569
+ annotations: JavaAnnotationExpr[];
570
+ type_: JavaType;
571
+ name: JavaName;
572
+ };
573
+
574
+ // Body declarations (members)
575
+ export type JavaFieldDeclaration = {
576
+ type: 'FieldDeclaration';
577
+ modifiers: JavaModifier[];
578
+ annotations: JavaAnnotationExpr[];
579
+ variables: JavaVariableDeclarator[];
580
+ };
581
+
582
+ export type JavaMethodDeclaration = {
583
+ type: 'MethodDeclaration';
584
+ modifiers: JavaModifier[];
585
+ annotations: JavaAnnotationExpr[];
586
+ typeParameters: JavaTypeParameter[];
587
+ type_: JavaType;
588
+ name: JavaSimpleName;
589
+ parameters: JavaParameter[];
590
+ receiverParameter?: JavaReceiverParameter;
591
+ thrownExceptions: JavaReferenceType[];
592
+ body?: JavaBlockStmt;
593
+ };
594
+
595
+ export type JavaConstructorDeclaration = {
596
+ type: 'ConstructorDeclaration';
597
+ modifiers: JavaModifier[];
598
+ annotations: JavaAnnotationExpr[];
599
+ typeParameters: JavaTypeParameter[];
600
+ name: JavaSimpleName;
601
+ parameters: JavaParameter[];
602
+ receiverParameter?: JavaReceiverParameter;
603
+ thrownExceptions: JavaReferenceType[];
604
+ body: JavaBlockStmt;
605
+ };
606
+
607
+ export type JavaInitializerDeclaration = {
608
+ type: 'InitializerDeclaration';
609
+ isStatic: boolean;
610
+ body: JavaBlockStmt;
611
+ };
612
+
613
+ export type JavaEnumConstantDeclaration = {
614
+ type: 'EnumConstantDeclaration';
615
+ annotations: JavaAnnotationExpr[];
616
+ name: JavaSimpleName;
617
+ arguments: JavaExpression[];
618
+ classBody: JavaBodyDeclaration[];
619
+ };
620
+
621
+ export type JavaAnnotationMemberDeclaration = {
622
+ type: 'AnnotationMemberDeclaration';
623
+ modifiers: JavaModifier[];
624
+ annotations: JavaAnnotationExpr[];
625
+ type_: JavaType;
626
+ name: JavaSimpleName;
627
+ defaultValue?: JavaExpression;
628
+ };
629
+
630
+ export type JavaCompactConstructorDeclaration = {
631
+ type: 'CompactConstructorDeclaration';
632
+ modifiers: JavaModifier[];
633
+ annotations: JavaAnnotationExpr[];
634
+ typeParameters: JavaTypeParameter[];
635
+ name: JavaSimpleName;
636
+ thrownExceptions: JavaReferenceType[];
637
+ body: JavaBlockStmt;
638
+ };
639
+
640
+ export type JavaBodyDeclaration =
641
+ | JavaFieldDeclaration
642
+ | JavaMethodDeclaration
643
+ | JavaConstructorDeclaration
644
+ | JavaInitializerDeclaration
645
+ | JavaEnumConstantDeclaration
646
+ | JavaAnnotationMemberDeclaration
647
+ | JavaCompactConstructorDeclaration
648
+ | JavaClassOrInterfaceDeclaration
649
+ | JavaEnumDeclaration
650
+ | JavaRecordDeclaration
651
+ | JavaAnnotationDeclaration;
652
+
653
+ // Type declarations
654
+ export type JavaClassOrInterfaceDeclaration = {
655
+ type: 'ClassOrInterfaceDeclaration';
656
+ modifiers: JavaModifier[];
657
+ annotations: JavaAnnotationExpr[];
658
+ name: JavaSimpleName;
659
+ isInterface: boolean;
660
+ typeParameters: JavaTypeParameter[];
661
+ extendedTypes: JavaClassOrInterfaceType[];
662
+ implementedTypes: JavaClassOrInterfaceType[];
663
+ permittedTypes: JavaClassOrInterfaceType[];
664
+ members: JavaBodyDeclaration[];
665
+ };
666
+
667
+ export type JavaEnumDeclaration = {
668
+ type: 'EnumDeclaration';
669
+ modifiers: JavaModifier[];
670
+ annotations: JavaAnnotationExpr[];
671
+ name: JavaSimpleName;
672
+ implementedTypes: JavaClassOrInterfaceType[];
673
+ entries: JavaEnumConstantDeclaration[];
674
+ members: JavaBodyDeclaration[];
675
+ };
676
+
677
+ export type JavaRecordDeclaration = {
678
+ type: 'RecordDeclaration';
679
+ modifiers: JavaModifier[];
680
+ annotations: JavaAnnotationExpr[];
681
+ name: JavaSimpleName;
682
+ typeParameters: JavaTypeParameter[];
683
+ parameters: JavaParameter[];
684
+ implementedTypes: JavaClassOrInterfaceType[];
685
+ members: JavaBodyDeclaration[];
686
+ };
687
+
688
+ export type JavaAnnotationDeclaration = {
689
+ type: 'AnnotationDeclaration';
690
+ modifiers: JavaModifier[];
691
+ annotations: JavaAnnotationExpr[];
692
+ name: JavaSimpleName;
693
+ members: JavaBodyDeclaration[];
694
+ };
695
+
696
+ export type JavaTypeDeclaration =
697
+ | JavaClassOrInterfaceDeclaration
698
+ | JavaEnumDeclaration
699
+ | JavaRecordDeclaration
700
+ | JavaAnnotationDeclaration;
701
+
702
+ // Compilation unit (top-level)
703
+ export type JavaCompilationUnit = {
704
+ type: 'CompilationUnit';
705
+ packageDeclaration?: JavaPackageDeclaration;
706
+ imports: JavaImportDeclaration[];
707
+ types: JavaTypeDeclaration[];
708
+ };