@openrewrite/rewrite 8.72.2 → 8.72.3

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 (197) hide show
  1. package/dist/execution.js +3 -16
  2. package/dist/execution.js.map +1 -1
  3. package/dist/index.js +34 -49
  4. package/dist/index.js.map +1 -1
  5. package/dist/java/markers.js +12 -29
  6. package/dist/java/markers.js.map +1 -1
  7. package/dist/java/print.js +2 -13
  8. package/dist/java/print.js.map +1 -1
  9. package/dist/java/rpc.js +1344 -1725
  10. package/dist/java/rpc.js.map +1 -1
  11. package/dist/java/type-visitor.js +143 -184
  12. package/dist/java/type-visitor.js.map +1 -1
  13. package/dist/java/visitor.js +1072 -1249
  14. package/dist/java/visitor.js.map +1 -1
  15. package/dist/javascript/add-import.js +495 -534
  16. package/dist/javascript/add-import.js.map +1 -1
  17. package/dist/javascript/autodetect.js +116 -159
  18. package/dist/javascript/autodetect.js.map +1 -1
  19. package/dist/javascript/cleanup/add-parse-int-radix.js +41 -57
  20. package/dist/javascript/cleanup/add-parse-int-radix.js.map +1 -1
  21. package/dist/javascript/cleanup/prefer-optional-chain.js +89 -105
  22. package/dist/javascript/cleanup/prefer-optional-chain.js.map +1 -1
  23. package/dist/javascript/cleanup/use-object-property-shorthand.js +74 -95
  24. package/dist/javascript/cleanup/use-object-property-shorthand.js.map +1 -1
  25. package/dist/javascript/comparator.js +815 -1167
  26. package/dist/javascript/comparator.js.map +1 -1
  27. package/dist/javascript/dependency-workspace.js +206 -219
  28. package/dist/javascript/dependency-workspace.js.map +1 -1
  29. package/dist/javascript/format/format.js +682 -908
  30. package/dist/javascript/format/format.js.map +1 -1
  31. package/dist/javascript/format/minimum-viable-spacing-visitor.js +152 -231
  32. package/dist/javascript/format/minimum-viable-spacing-visitor.js.map +1 -1
  33. package/dist/javascript/format/normalize-whitespace-visitor.js +12 -31
  34. package/dist/javascript/format/normalize-whitespace-visitor.js.map +1 -1
  35. package/dist/javascript/format/prettier-config-loader.js +134 -153
  36. package/dist/javascript/format/prettier-config-loader.js.map +1 -1
  37. package/dist/javascript/format/prettier-format.js +112 -129
  38. package/dist/javascript/format/prettier-format.js.map +1 -1
  39. package/dist/javascript/format/tabs-and-indents-visitor.js +112 -136
  40. package/dist/javascript/format/tabs-and-indents-visitor.js.map +1 -1
  41. package/dist/javascript/markers.js +59 -92
  42. package/dist/javascript/markers.js.map +1 -1
  43. package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js +39 -52
  44. package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js.map +1 -1
  45. package/dist/javascript/migrate/es6/modernize-octal-literals.js +25 -38
  46. package/dist/javascript/migrate/es6/modernize-octal-literals.js.map +1 -1
  47. package/dist/javascript/migrate/es6/remove-duplicate-object-keys.js +66 -82
  48. package/dist/javascript/migrate/es6/remove-duplicate-object-keys.js.map +1 -1
  49. package/dist/javascript/migrate/typescript/export-assignment-to-export-default.js +10 -23
  50. package/dist/javascript/migrate/typescript/export-assignment-to-export-default.js.map +1 -1
  51. package/dist/javascript/node-resolution-result.js +137 -166
  52. package/dist/javascript/node-resolution-result.js.map +1 -1
  53. package/dist/javascript/package-json-parser.js +312 -343
  54. package/dist/javascript/package-json-parser.js.map +1 -1
  55. package/dist/javascript/package-manager.js +145 -170
  56. package/dist/javascript/package-manager.js.map +1 -1
  57. package/dist/javascript/parser.d.ts.map +1 -1
  58. package/dist/javascript/parser.js +94 -68
  59. package/dist/javascript/parser.js.map +1 -1
  60. package/dist/javascript/print.js +1572 -1835
  61. package/dist/javascript/print.js.map +1 -1
  62. package/dist/javascript/project-parser.js +151 -172
  63. package/dist/javascript/project-parser.js.map +1 -1
  64. package/dist/javascript/recipes/add-dependency.js +140 -175
  65. package/dist/javascript/recipes/add-dependency.js.map +1 -1
  66. package/dist/javascript/recipes/async-callback-in-sync-array-method.js +20 -36
  67. package/dist/javascript/recipes/async-callback-in-sync-array-method.js.map +1 -1
  68. package/dist/javascript/recipes/auto-format.js +3 -14
  69. package/dist/javascript/recipes/auto-format.js.map +1 -1
  70. package/dist/javascript/recipes/change-import.js +447 -495
  71. package/dist/javascript/recipes/change-import.js.map +1 -1
  72. package/dist/javascript/recipes/order-imports.js +162 -175
  73. package/dist/javascript/recipes/order-imports.js.map +1 -1
  74. package/dist/javascript/recipes/upgrade-dependency-version.js +167 -197
  75. package/dist/javascript/recipes/upgrade-dependency-version.js.map +1 -1
  76. package/dist/javascript/recipes/upgrade-transitive-dependency-version.js +166 -193
  77. package/dist/javascript/recipes/upgrade-transitive-dependency-version.js.map +1 -1
  78. package/dist/javascript/remove-import.js +689 -724
  79. package/dist/javascript/remove-import.js.map +1 -1
  80. package/dist/javascript/rpc.js +1007 -1332
  81. package/dist/javascript/rpc.js.map +1 -1
  82. package/dist/javascript/search/find-dependency.js +84 -110
  83. package/dist/javascript/search/find-dependency.js.map +1 -1
  84. package/dist/javascript/search/uses-method.js +5 -19
  85. package/dist/javascript/search/uses-method.js.map +1 -1
  86. package/dist/javascript/search/uses-type.js +9 -20
  87. package/dist/javascript/search/uses-type.js.map +1 -1
  88. package/dist/javascript/templating/comparator.js +737 -822
  89. package/dist/javascript/templating/comparator.js.map +1 -1
  90. package/dist/javascript/templating/engine.js +211 -245
  91. package/dist/javascript/templating/engine.js.map +1 -1
  92. package/dist/javascript/templating/pattern.js +169 -190
  93. package/dist/javascript/templating/pattern.js.map +1 -1
  94. package/dist/javascript/templating/placeholder-replacement.js +172 -210
  95. package/dist/javascript/templating/placeholder-replacement.js.map +1 -1
  96. package/dist/javascript/templating/rewrite.js +75 -97
  97. package/dist/javascript/templating/rewrite.js.map +1 -1
  98. package/dist/javascript/templating/template.js +69 -82
  99. package/dist/javascript/templating/template.js.map +1 -1
  100. package/dist/javascript/tree-debug.js +109 -137
  101. package/dist/javascript/tree-debug.js.map +1 -1
  102. package/dist/javascript/visitor.js +1090 -1254
  103. package/dist/javascript/visitor.js.map +1 -1
  104. package/dist/json/print.js +72 -103
  105. package/dist/json/print.js.map +1 -1
  106. package/dist/json/rpc.js +120 -181
  107. package/dist/json/rpc.js.map +1 -1
  108. package/dist/json/visitor.js +69 -100
  109. package/dist/json/visitor.js.map +1 -1
  110. package/dist/marketplace.js +20 -33
  111. package/dist/marketplace.js.map +1 -1
  112. package/dist/parse-error.js +41 -62
  113. package/dist/parse-error.js.map +1 -1
  114. package/dist/parser.js +7 -18
  115. package/dist/parser.js.map +1 -1
  116. package/dist/path-utils.js +46 -59
  117. package/dist/path-utils.js.map +1 -1
  118. package/dist/preconditions.js +30 -47
  119. package/dist/preconditions.js.map +1 -1
  120. package/dist/print.js +6 -19
  121. package/dist/print.js.map +1 -1
  122. package/dist/recipe.js +42 -73
  123. package/dist/recipe.js.map +1 -1
  124. package/dist/rpc/index.js +74 -115
  125. package/dist/rpc/index.js.map +1 -1
  126. package/dist/rpc/queue.js +71 -90
  127. package/dist/rpc/queue.js.map +1 -1
  128. package/dist/rpc/recipe.js +32 -57
  129. package/dist/rpc/recipe.js.map +1 -1
  130. package/dist/rpc/request/generate.js +4 -13
  131. package/dist/rpc/request/generate.js.map +1 -1
  132. package/dist/rpc/request/get-languages.js +2 -11
  133. package/dist/rpc/request/get-languages.js.map +1 -1
  134. package/dist/rpc/request/get-marketplace.js +9 -20
  135. package/dist/rpc/request/get-marketplace.js.map +1 -1
  136. package/dist/rpc/request/get-object.js +4 -13
  137. package/dist/rpc/request/get-object.js.map +1 -1
  138. package/dist/rpc/request/install-recipes.js +25 -36
  139. package/dist/rpc/request/install-recipes.js.map +1 -1
  140. package/dist/rpc/request/metrics.js +8 -17
  141. package/dist/rpc/request/metrics.js.map +1 -1
  142. package/dist/rpc/request/parse-project.js +36 -45
  143. package/dist/rpc/request/parse-project.js.map +1 -1
  144. package/dist/rpc/request/parse.js +5 -14
  145. package/dist/rpc/request/parse.js.map +1 -1
  146. package/dist/rpc/request/prepare-recipe.js +37 -52
  147. package/dist/rpc/request/prepare-recipe.js.map +1 -1
  148. package/dist/rpc/request/print.js +5 -14
  149. package/dist/rpc/request/print.js.map +1 -1
  150. package/dist/rpc/request/visit.js +56 -71
  151. package/dist/rpc/request/visit.js.map +1 -1
  152. package/dist/rpc/rewrite-rpc.js +70 -97
  153. package/dist/rpc/rewrite-rpc.js.map +1 -1
  154. package/dist/rpc/server.js +76 -89
  155. package/dist/rpc/server.js.map +1 -1
  156. package/dist/run.js +47 -66
  157. package/dist/run.js.map +1 -1
  158. package/dist/search/is-source-file.js +8 -19
  159. package/dist/search/is-source-file.js.map +1 -1
  160. package/dist/test/rewrite-test.js +154 -188
  161. package/dist/test/rewrite-test.js.map +1 -1
  162. package/dist/text/print.js +23 -38
  163. package/dist/text/print.js.map +1 -1
  164. package/dist/text/rpc.js +29 -44
  165. package/dist/text/rpc.js.map +1 -1
  166. package/dist/text/visitor.js +16 -33
  167. package/dist/text/visitor.js.map +1 -1
  168. package/dist/util.js +13 -24
  169. package/dist/util.js.map +1 -1
  170. package/dist/version.txt +1 -1
  171. package/dist/visitor.js +84 -115
  172. package/dist/visitor.js.map +1 -1
  173. package/dist/yaml/index.d.ts +2 -0
  174. package/dist/yaml/index.d.ts.map +1 -1
  175. package/dist/yaml/index.js +2 -0
  176. package/dist/yaml/index.js.map +1 -1
  177. package/dist/yaml/markers.d.ts +21 -0
  178. package/dist/yaml/markers.d.ts.map +1 -0
  179. package/dist/yaml/markers.js +37 -0
  180. package/dist/yaml/markers.js.map +1 -0
  181. package/dist/yaml/parser.d.ts.map +1 -1
  182. package/dist/yaml/parser.js +4 -1
  183. package/dist/yaml/parser.js.map +1 -1
  184. package/dist/yaml/print.d.ts +1 -1
  185. package/dist/yaml/print.d.ts.map +1 -1
  186. package/dist/yaml/print.js +175 -208
  187. package/dist/yaml/print.js.map +1 -1
  188. package/dist/yaml/rpc.js +154 -219
  189. package/dist/yaml/rpc.js.map +1 -1
  190. package/dist/yaml/visitor.js +78 -113
  191. package/dist/yaml/visitor.js.map +1 -1
  192. package/package.json +1 -1
  193. package/src/javascript/parser.ts +56 -14
  194. package/src/yaml/index.ts +2 -0
  195. package/src/yaml/markers.ts +70 -0
  196. package/src/yaml/parser.ts +5 -1
  197. package/src/yaml/print.ts +5 -2
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.JavaVisitor = void 0;
13
4
  exports.registerJavaExtensionKinds = registerJavaExtensionKinds;
@@ -50,1256 +41,1088 @@ function isJava(tree) {
50
41
  }
51
42
  class JavaVisitor extends visitor_1.TreeVisitor {
52
43
  // protected javadocVisitor: any | null = null;
53
- isAcceptable(sourceFile) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- return isJava(sourceFile);
56
- });
44
+ async isAcceptable(sourceFile) {
45
+ return isJava(sourceFile);
57
46
  }
58
47
  // noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
59
- visitExpression(expression, p) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- return expression;
62
- });
48
+ async visitExpression(expression, p) {
49
+ return expression;
63
50
  }
64
51
  // noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
65
- visitStatement(statement, p) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- return statement;
68
- });
52
+ async visitStatement(statement, p) {
53
+ return statement;
69
54
  }
70
55
  // noinspection JSUnusedLocalSymbols
71
- visitSpace(space, p) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- return space;
74
- });
56
+ async visitSpace(space, p) {
57
+ return space;
75
58
  }
76
59
  // noinspection JSUnusedLocalSymbols
77
- visitType(javaType, p) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- return javaType;
80
- });
60
+ async visitType(javaType, p) {
61
+ return javaType;
81
62
  }
82
63
  // noinspection JSUnusedLocalSymbols
83
- visitTypeName(nameTree, p) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- return nameTree;
86
- });
87
- }
88
- visitAnnotatedType(annotatedType, p) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const expression = yield this.visitExpression(annotatedType, p);
91
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.AnnotatedType) {
92
- return expression;
93
- }
94
- annotatedType = expression;
95
- const updates = {
96
- prefix: yield this.visitSpace(annotatedType.prefix, p),
97
- markers: yield this.visitMarkers(annotatedType.markers, p),
98
- annotations: yield (0, util_1.mapAsync)(annotatedType.annotations, a => this.visitDefined(a, p)),
99
- typeExpression: yield this.visitDefined(annotatedType.typeExpression, p)
100
- };
101
- return (0, util_1.updateIfChanged)(annotatedType, updates);
102
- });
103
- }
104
- visitAnnotation(annotation, p) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- const expression = yield this.visitExpression(annotation, p);
107
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Annotation) {
108
- return expression;
109
- }
110
- annotation = expression;
111
- const updates = {
112
- prefix: yield this.visitSpace(annotation.prefix, p),
113
- markers: yield this.visitMarkers(annotation.markers, p),
114
- annotationType: yield this.visitTypeName(annotation.annotationType, p),
115
- arguments: yield this.visitOptionalContainer(annotation.arguments, p)
116
- };
117
- return (0, util_1.updateIfChanged)(annotation, updates);
118
- });
119
- }
120
- visitArrayAccess(arrayAccess, p) {
121
- return __awaiter(this, void 0, void 0, function* () {
122
- const expression = yield this.visitExpression(arrayAccess, p);
123
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.ArrayAccess) {
124
- return expression;
125
- }
126
- arrayAccess = expression;
127
- const updates = {
128
- prefix: yield this.visitSpace(arrayAccess.prefix, p),
129
- markers: yield this.visitMarkers(arrayAccess.markers, p),
130
- indexed: yield this.visitDefined(arrayAccess.indexed, p),
131
- dimension: yield this.visitDefined(arrayAccess.dimension, p)
132
- };
133
- return (0, util_1.updateIfChanged)(arrayAccess, updates);
134
- });
135
- }
136
- visitArrayDimension(arrayDimension, p) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- const updates = {
139
- prefix: yield this.visitSpace(arrayDimension.prefix, p),
140
- markers: yield this.visitMarkers(arrayDimension.markers, p),
141
- index: yield this.visitRightPadded(arrayDimension.index, p)
142
- };
143
- return (0, util_1.updateIfChanged)(arrayDimension, updates);
144
- });
145
- }
146
- visitArrayType(arrayType, p) {
147
- return __awaiter(this, void 0, void 0, function* () {
148
- const expression = yield this.visitExpression(arrayType, p);
149
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.ArrayType) {
150
- return expression;
151
- }
152
- arrayType = expression;
153
- const updates = {
154
- prefix: yield this.visitSpace(arrayType.prefix, p),
155
- markers: yield this.visitMarkers(arrayType.markers, p),
156
- elementType: yield this.visitDefined(arrayType.elementType, p),
157
- dimension: yield this.visitLeftPadded(arrayType.dimension, p),
158
- type: yield this.visitType(arrayType.type, p)
159
- };
160
- if (arrayType.annotations) {
161
- updates.annotations = yield (0, util_1.mapAsync)(arrayType.annotations, a => this.visitDefined(a, p));
162
- }
163
- return (0, util_1.updateIfChanged)(arrayType, updates);
164
- });
165
- }
166
- visitAssert(anAssert, p) {
167
- return __awaiter(this, void 0, void 0, function* () {
168
- const statement = yield this.visitStatement(anAssert, p);
169
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Assert) {
170
- return statement;
171
- }
172
- anAssert = statement;
173
- const updates = {
174
- prefix: yield this.visitSpace(anAssert.prefix, p),
175
- markers: yield this.visitMarkers(anAssert.markers, p),
176
- condition: yield this.visitDefined(anAssert.condition, p),
177
- detail: yield this.visitOptionalLeftPadded(anAssert.detail, p)
178
- };
179
- return (0, util_1.updateIfChanged)(anAssert, updates);
180
- });
181
- }
182
- visitAssignment(assignment, p) {
183
- return __awaiter(this, void 0, void 0, function* () {
184
- const expression = yield this.visitExpression(assignment, p);
185
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Assignment) {
186
- return expression;
187
- }
188
- assignment = expression;
189
- const statement = yield this.visitStatement(assignment, p);
190
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Assignment) {
191
- return statement;
192
- }
193
- assignment = statement;
194
- const updates = {
195
- prefix: yield this.visitSpace(assignment.prefix, p),
196
- markers: yield this.visitMarkers(assignment.markers, p),
197
- variable: yield this.visitDefined(assignment.variable, p),
198
- assignment: yield this.visitLeftPadded(assignment.assignment, p),
199
- type: yield this.visitType(assignment.type, p)
200
- };
201
- return (0, util_1.updateIfChanged)(assignment, updates);
202
- });
203
- }
204
- visitAssignmentOperation(assignOp, p) {
205
- return __awaiter(this, void 0, void 0, function* () {
206
- const expression = yield this.visitExpression(assignOp, p);
207
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.AssignmentOperation) {
208
- return expression;
209
- }
210
- assignOp = expression;
211
- const updates = {
212
- prefix: yield this.visitSpace(assignOp.prefix, p),
213
- markers: yield this.visitMarkers(assignOp.markers, p),
214
- variable: yield this.visitDefined(assignOp.variable, p),
215
- operator: yield this.visitLeftPadded(assignOp.operator, p),
216
- assignment: yield this.visitDefined(assignOp.assignment, p),
217
- type: yield this.visitType(assignOp.type, p)
218
- };
219
- return (0, util_1.updateIfChanged)(assignOp, updates);
220
- });
221
- }
222
- visitBinary(binary, p) {
223
- return __awaiter(this, void 0, void 0, function* () {
224
- const expression = yield this.visitExpression(binary, p);
225
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Binary) {
226
- return expression;
227
- }
228
- binary = expression;
229
- const updates = {
230
- prefix: yield this.visitSpace(binary.prefix, p),
231
- markers: yield this.visitMarkers(binary.markers, p),
232
- left: yield this.visitDefined(binary.left, p),
233
- operator: yield this.visitLeftPadded(binary.operator, p),
234
- right: yield this.visitDefined(binary.right, p),
235
- type: yield this.visitType(binary.type, p)
236
- };
237
- return (0, util_1.updateIfChanged)(binary, updates);
238
- });
239
- }
240
- visitBlock(block, p) {
241
- return __awaiter(this, void 0, void 0, function* () {
242
- const updates = {
243
- prefix: yield this.visitSpace(block.prefix, p),
244
- markers: yield this.visitMarkers(block.markers, p),
245
- static: yield this.visitRightPadded(block.static, p),
246
- statements: yield (0, util_1.mapAsync)(block.statements, stmt => this.visitRightPadded(stmt, p)),
247
- end: yield this.visitSpace(block.end, p)
248
- };
249
- return (0, util_1.updateIfChanged)(block, updates);
250
- });
251
- }
252
- visitBreak(breakStatement, p) {
253
- return __awaiter(this, void 0, void 0, function* () {
254
- const statement = yield this.visitStatement(breakStatement, p);
255
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Break) {
256
- return statement;
257
- }
258
- breakStatement = statement;
259
- const updates = {
260
- prefix: yield this.visitSpace(breakStatement.prefix, p),
261
- markers: yield this.visitMarkers(breakStatement.markers, p)
262
- };
263
- if (breakStatement.label) {
264
- updates.label = (yield this.visitDefined(breakStatement.label, p));
265
- }
266
- return (0, util_1.updateIfChanged)(breakStatement, updates);
267
- });
268
- }
269
- visitCase(aCase, p) {
270
- return __awaiter(this, void 0, void 0, function* () {
271
- const statement = yield this.visitStatement(aCase, p);
272
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Case) {
273
- return statement;
274
- }
275
- aCase = statement;
276
- const updates = {
277
- prefix: yield this.visitSpace(aCase.prefix, p),
278
- markers: yield this.visitMarkers(aCase.markers, p),
279
- caseLabels: yield this.visitContainer(aCase.caseLabels, p),
280
- statements: yield this.visitContainer(aCase.statements, p),
281
- body: yield this.visitOptionalRightPadded(aCase.body, p)
282
- };
283
- if (aCase.guard) {
284
- updates.guard = (yield this.visitDefined(aCase.guard, p));
285
- }
286
- return (0, util_1.updateIfChanged)(aCase, updates);
287
- });
288
- }
289
- visitClassDeclaration(classDecl, p) {
290
- return __awaiter(this, void 0, void 0, function* () {
291
- const statement = yield this.visitStatement(classDecl, p);
292
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.ClassDeclaration) {
293
- return statement;
294
- }
295
- classDecl = statement;
296
- const updates = {
297
- prefix: yield this.visitSpace(classDecl.prefix, p),
298
- markers: yield this.visitMarkers(classDecl.markers, p),
299
- leadingAnnotations: yield (0, util_1.mapAsync)(classDecl.leadingAnnotations, a => this.visitDefined(a, p)),
300
- modifiers: yield (0, util_1.mapAsync)(classDecl.modifiers, m => this.visitDefined(m, p)),
301
- classKind: yield this.visitDefined(classDecl.classKind, p),
302
- name: yield this.visitDefined(classDecl.name, p),
303
- typeParameters: yield this.visitOptionalContainer(classDecl.typeParameters, p),
304
- primaryConstructor: yield this.visitOptionalContainer(classDecl.primaryConstructor, p),
305
- extends: yield this.visitOptionalLeftPadded(classDecl.extends, p),
306
- implements: yield this.visitOptionalContainer(classDecl.implements, p),
307
- permitting: yield this.visitOptionalContainer(classDecl.permitting, p),
308
- body: yield this.visitDefined(classDecl.body, p),
309
- type: yield this.visitType(classDecl.type, p)
310
- };
311
- return (0, util_1.updateIfChanged)(classDecl, updates);
312
- });
313
- }
314
- visitClassDeclarationKind(kind, p) {
315
- return __awaiter(this, void 0, void 0, function* () {
316
- const updates = {
317
- prefix: yield this.visitSpace(kind.prefix, p),
318
- markers: yield this.visitMarkers(kind.markers, p),
319
- annotations: yield (0, util_1.mapAsync)(kind.annotations, a => this.visitDefined(a, p))
320
- };
321
- return (0, util_1.updateIfChanged)(kind, updates);
322
- });
323
- }
324
- visitCompilationUnit(cu, p) {
325
- return __awaiter(this, void 0, void 0, function* () {
326
- const updates = {
327
- prefix: yield this.visitSpace(cu.prefix, p),
328
- markers: yield this.visitMarkers(cu.markers, p),
329
- packageDeclaration: yield this.visitRightPadded(cu.packageDeclaration, p),
330
- imports: yield (0, util_1.mapAsync)(cu.imports, imp => this.visitRightPadded(imp, p)),
331
- classes: yield (0, util_1.mapAsync)(cu.classes, cls => this.visitDefined(cls, p)),
332
- eof: yield this.visitSpace(cu.eof, p)
333
- };
334
- return (0, util_1.updateIfChanged)(cu, updates);
335
- });
336
- }
337
- visitContinue(continueStatement, p) {
338
- return __awaiter(this, void 0, void 0, function* () {
339
- const statement = yield this.visitStatement(continueStatement, p);
340
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Continue) {
341
- return statement;
342
- }
343
- continueStatement = statement;
344
- const updates = {
345
- prefix: yield this.visitSpace(continueStatement.prefix, p),
346
- markers: yield this.visitMarkers(continueStatement.markers, p)
347
- };
348
- if (continueStatement.label) {
349
- updates.label = (yield this.visitDefined(continueStatement.label, p));
350
- }
351
- return (0, util_1.updateIfChanged)(continueStatement, updates);
352
- });
353
- }
354
- visitControlParentheses(controlParens, p) {
355
- return __awaiter(this, void 0, void 0, function* () {
356
- const updates = {
357
- prefix: yield this.visitSpace(controlParens.prefix, p),
358
- markers: yield this.visitMarkers(controlParens.markers, p),
359
- tree: yield this.visitRightPadded(controlParens.tree, p)
360
- };
361
- return (0, util_1.updateIfChanged)(controlParens, updates);
362
- });
363
- }
364
- visitDeconstructionPattern(pattern, p) {
365
- return __awaiter(this, void 0, void 0, function* () {
366
- const updates = {
367
- prefix: yield this.visitSpace(pattern.prefix, p),
368
- markers: yield this.visitMarkers(pattern.markers, p),
369
- deconstructor: yield this.visitDefined(pattern.deconstructor, p),
370
- nested: yield this.visitContainer(pattern.nested, p),
371
- type: yield this.visitType(pattern.type, p)
372
- };
373
- return (0, util_1.updateIfChanged)(pattern, updates);
374
- });
375
- }
376
- visitDoWhileLoop(doWhileLoop, p) {
377
- return __awaiter(this, void 0, void 0, function* () {
378
- const statement = yield this.visitStatement(doWhileLoop, p);
379
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.DoWhileLoop) {
380
- return statement;
381
- }
382
- doWhileLoop = statement;
383
- const updates = {
384
- prefix: yield this.visitSpace(doWhileLoop.prefix, p),
385
- markers: yield this.visitMarkers(doWhileLoop.markers, p),
386
- body: yield this.visitRightPadded(doWhileLoop.body, p),
387
- whileCondition: yield this.visitLeftPadded(doWhileLoop.whileCondition, p)
388
- };
389
- return (0, util_1.updateIfChanged)(doWhileLoop, updates);
390
- });
391
- }
392
- visitEmpty(empty, p) {
393
- return __awaiter(this, void 0, void 0, function* () {
394
- const expression = yield this.visitExpression(empty, p);
395
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Empty) {
396
- return expression;
397
- }
398
- empty = expression;
399
- const statement = yield this.visitStatement(empty, p);
400
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Empty) {
401
- return statement;
402
- }
403
- empty = statement;
404
- const updates = {
405
- prefix: yield this.visitSpace(empty.prefix, p),
406
- markers: yield this.visitMarkers(empty.markers, p)
407
- };
408
- return (0, util_1.updateIfChanged)(empty, updates);
409
- });
410
- }
411
- visitEnumValue(enumValue, p) {
412
- return __awaiter(this, void 0, void 0, function* () {
413
- const updates = {
414
- prefix: yield this.visitSpace(enumValue.prefix, p),
415
- markers: yield this.visitMarkers(enumValue.markers, p),
416
- annotations: yield (0, util_1.mapAsync)(enumValue.annotations, a => this.visitDefined(a, p)),
417
- name: yield this.visitDefined(enumValue.name, p)
418
- };
419
- if (enumValue.initializer) {
420
- updates.initializer = (yield this.visitDefined(enumValue.initializer, p));
421
- }
422
- return (0, util_1.updateIfChanged)(enumValue, updates);
423
- });
424
- }
425
- visitEnumValueSet(enumValueSet, p) {
426
- return __awaiter(this, void 0, void 0, function* () {
427
- const statement = yield this.visitStatement(enumValueSet, p);
428
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.EnumValueSet) {
429
- return statement;
430
- }
431
- enumValueSet = statement;
432
- const updates = {
433
- prefix: yield this.visitSpace(enumValueSet.prefix, p),
434
- markers: yield this.visitMarkers(enumValueSet.markers, p),
435
- enums: yield (0, util_1.mapAsync)(enumValueSet.enums, e => this.visitRightPadded(e, p))
436
- };
437
- return (0, util_1.updateIfChanged)(enumValueSet, updates);
438
- });
439
- }
440
- visitErroneous(erroneous, p) {
441
- return __awaiter(this, void 0, void 0, function* () {
442
- const expression = yield this.visitExpression(erroneous, p);
443
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Erroneous) {
444
- return expression;
445
- }
446
- erroneous = expression;
447
- const statement = yield this.visitStatement(erroneous, p);
448
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Erroneous) {
449
- return statement;
450
- }
451
- erroneous = statement;
452
- const updates = {
453
- prefix: yield this.visitSpace(erroneous.prefix, p),
454
- markers: yield this.visitMarkers(erroneous.markers, p)
455
- };
456
- return (0, util_1.updateIfChanged)(erroneous, updates);
457
- });
458
- }
459
- visitFieldAccess(fieldAccess, p) {
460
- return __awaiter(this, void 0, void 0, function* () {
461
- const expression = yield this.visitExpression(fieldAccess, p);
462
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.FieldAccess) {
463
- return expression;
464
- }
465
- fieldAccess = expression;
466
- const statement = yield this.visitStatement(fieldAccess, p);
467
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.FieldAccess) {
468
- return statement;
469
- }
470
- fieldAccess = statement;
471
- const updates = {
472
- prefix: yield this.visitSpace(fieldAccess.prefix, p),
473
- markers: yield this.visitMarkers(fieldAccess.markers, p),
474
- target: yield this.visitDefined(fieldAccess.target, p),
475
- name: yield this.visitLeftPadded(fieldAccess.name, p),
476
- type: yield this.visitType(fieldAccess.type, p)
477
- };
478
- return (0, util_1.updateIfChanged)(fieldAccess, updates);
479
- });
480
- }
481
- visitForEachLoop(forLoop, p) {
482
- return __awaiter(this, void 0, void 0, function* () {
483
- const statement = yield this.visitStatement(forLoop, p);
484
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.ForEachLoop) {
485
- return statement;
486
- }
487
- forLoop = statement;
488
- const updates = {
489
- prefix: yield this.visitSpace(forLoop.prefix, p),
490
- markers: yield this.visitMarkers(forLoop.markers, p),
491
- control: yield this.visitDefined(forLoop.control, p),
492
- body: yield this.visitRightPadded(forLoop.body, p)
493
- };
494
- return (0, util_1.updateIfChanged)(forLoop, updates);
495
- });
496
- }
497
- visitForEachLoopControl(control, p) {
498
- return __awaiter(this, void 0, void 0, function* () {
499
- const updates = {
500
- prefix: yield this.visitSpace(control.prefix, p),
501
- markers: yield this.visitMarkers(control.markers, p),
502
- variable: yield this.visitRightPadded(control.variable, p),
503
- iterable: yield this.visitRightPadded(control.iterable, p)
504
- };
505
- return (0, util_1.updateIfChanged)(control, updates);
506
- });
507
- }
508
- visitForLoop(forLoop, p) {
509
- return __awaiter(this, void 0, void 0, function* () {
510
- const statement = yield this.visitStatement(forLoop, p);
511
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.ForLoop) {
512
- return statement;
513
- }
514
- forLoop = statement;
515
- const updates = {
516
- prefix: yield this.visitSpace(forLoop.prefix, p),
517
- markers: yield this.visitMarkers(forLoop.markers, p),
518
- control: yield this.visitDefined(forLoop.control, p),
519
- body: yield this.visitRightPadded(forLoop.body, p)
520
- };
521
- return (0, util_1.updateIfChanged)(forLoop, updates);
522
- });
523
- }
524
- visitForLoopControl(control, p) {
525
- return __awaiter(this, void 0, void 0, function* () {
526
- const updates = {
527
- prefix: yield this.visitSpace(control.prefix, p),
528
- markers: yield this.visitMarkers(control.markers, p),
529
- init: yield (0, util_1.mapAsync)(control.init, i => this.visitRightPadded(i, p)),
530
- condition: yield this.visitOptionalRightPadded(control.condition, p),
531
- update: yield (0, util_1.mapAsync)(control.update, u => this.visitRightPadded(u, p))
532
- };
533
- return (0, util_1.updateIfChanged)(control, updates);
534
- });
535
- }
536
- visitIdentifier(ident, p) {
537
- return __awaiter(this, void 0, void 0, function* () {
538
- const expression = yield this.visitExpression(ident, p);
539
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Identifier) {
540
- return expression;
541
- }
542
- ident = expression;
543
- const updates = {
544
- prefix: yield this.visitSpace(ident.prefix, p),
545
- markers: yield this.visitMarkers(ident.markers, p),
546
- annotations: yield (0, util_1.mapAsync)(ident.annotations, a => this.visitDefined(a, p)),
547
- type: yield this.visitType(ident.type, p),
548
- fieldType: yield this.visitType(ident.fieldType, p)
549
- };
550
- return (0, util_1.updateIfChanged)(ident, updates);
551
- });
552
- }
553
- visitIf(iff, p) {
554
- return __awaiter(this, void 0, void 0, function* () {
555
- const statement = yield this.visitStatement(iff, p);
556
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.If) {
557
- return statement;
558
- }
559
- iff = statement;
560
- const updates = {
561
- prefix: yield this.visitSpace(iff.prefix, p),
562
- markers: yield this.visitMarkers(iff.markers, p),
563
- ifCondition: yield this.visitDefined(iff.ifCondition, p),
564
- thenPart: yield this.visitRightPadded(iff.thenPart, p)
565
- };
566
- if (iff.elsePart) {
567
- updates.elsePart = (yield this.visitDefined(iff.elsePart, p));
568
- }
569
- return (0, util_1.updateIfChanged)(iff, updates);
570
- });
571
- }
572
- visitElse(anElse, p) {
573
- return __awaiter(this, void 0, void 0, function* () {
574
- const updates = {
575
- prefix: yield this.visitSpace(anElse.prefix, p),
576
- markers: yield this.visitMarkers(anElse.markers, p),
577
- body: yield this.visitRightPadded(anElse.body, p)
578
- };
579
- return (0, util_1.updateIfChanged)(anElse, updates);
580
- });
581
- }
582
- visitImport(anImport, p) {
583
- return __awaiter(this, void 0, void 0, function* () {
584
- const updates = {
585
- prefix: yield this.visitSpace(anImport.prefix, p),
586
- markers: yield this.visitMarkers(anImport.markers, p),
587
- static: yield this.visitLeftPadded(anImport.static, p),
588
- qualid: yield this.visitDefined(anImport.qualid, p),
589
- alias: yield this.visitOptionalLeftPadded(anImport.alias, p)
590
- };
591
- return (0, util_1.updateIfChanged)(anImport, updates);
592
- });
593
- }
594
- visitInstanceOf(instanceOf, p) {
595
- return __awaiter(this, void 0, void 0, function* () {
596
- const expression = yield this.visitExpression(instanceOf, p);
597
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.InstanceOf) {
598
- return expression;
599
- }
600
- instanceOf = expression;
601
- const updates = {
602
- prefix: yield this.visitSpace(instanceOf.prefix, p),
603
- markers: yield this.visitMarkers(instanceOf.markers, p),
604
- expression: yield this.visitRightPadded(instanceOf.expression, p),
605
- class: yield this.visitDefined(instanceOf.class, p),
606
- type: yield this.visitType(instanceOf.type, p)
607
- };
608
- if (instanceOf.pattern) {
609
- updates.pattern = (yield this.visitDefined(instanceOf.pattern, p));
610
- }
611
- if (instanceOf.modifier) {
612
- updates.modifier = (yield this.visitDefined(instanceOf.modifier, p));
613
- }
614
- return (0, util_1.updateIfChanged)(instanceOf, updates);
615
- });
616
- }
617
- visitIntersectionType(intersectionType, p) {
618
- return __awaiter(this, void 0, void 0, function* () {
619
- const expression = yield this.visitExpression(intersectionType, p);
620
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.IntersectionType) {
621
- return expression;
622
- }
623
- intersectionType = expression;
624
- const updates = {
625
- prefix: yield this.visitSpace(intersectionType.prefix, p),
626
- markers: yield this.visitMarkers(intersectionType.markers, p),
627
- bounds: yield this.visitContainer(intersectionType.bounds, p)
628
- };
629
- return (0, util_1.updateIfChanged)(intersectionType, updates);
630
- });
631
- }
632
- visitLabel(label, p) {
633
- return __awaiter(this, void 0, void 0, function* () {
634
- const statement = yield this.visitStatement(label, p);
635
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Label) {
636
- return statement;
637
- }
638
- label = statement;
639
- const updates = {
640
- prefix: yield this.visitSpace(label.prefix, p),
641
- markers: yield this.visitMarkers(label.markers, p),
642
- label: yield this.visitRightPadded(label.label, p),
643
- statement: yield this.visitDefined(label.statement, p)
644
- };
645
- return (0, util_1.updateIfChanged)(label, updates);
646
- });
647
- }
648
- visitLambda(lambda, p) {
649
- return __awaiter(this, void 0, void 0, function* () {
650
- const expression = yield this.visitExpression(lambda, p);
651
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Lambda) {
652
- return expression;
653
- }
654
- lambda = expression;
655
- const statement = yield this.visitStatement(lambda, p);
656
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Lambda) {
657
- return statement;
658
- }
659
- lambda = statement;
660
- const updates = {
661
- prefix: yield this.visitSpace(lambda.prefix, p),
662
- markers: yield this.visitMarkers(lambda.markers, p),
663
- parameters: yield this.visitDefined(lambda.parameters, p),
664
- arrow: yield this.visitSpace(lambda.arrow, p),
665
- body: yield this.visitDefined(lambda.body, p),
666
- type: yield this.visitType(lambda.type, p)
667
- };
668
- return (0, util_1.updateIfChanged)(lambda, updates);
669
- });
670
- }
671
- visitLambdaParameters(params, p) {
672
- return __awaiter(this, void 0, void 0, function* () {
673
- const updates = {
674
- prefix: yield this.visitSpace(params.prefix, p),
675
- markers: yield this.visitMarkers(params.markers, p),
676
- parameters: yield (0, util_1.mapAsync)(params.parameters, param => this.visitRightPadded(param, p))
677
- };
678
- return (0, util_1.updateIfChanged)(params, updates);
679
- });
680
- }
681
- visitLiteral(literal, p) {
682
- return __awaiter(this, void 0, void 0, function* () {
683
- const expression = yield this.visitExpression(literal, p);
684
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Literal) {
685
- return expression;
686
- }
687
- literal = expression;
688
- const updates = {
689
- prefix: yield this.visitSpace(literal.prefix, p),
690
- markers: yield this.visitMarkers(literal.markers, p),
691
- type: yield this.visitType(literal.type, p)
692
- };
693
- return (0, util_1.updateIfChanged)(literal, updates);
694
- });
695
- }
696
- visitMemberReference(memberRef, p) {
697
- return __awaiter(this, void 0, void 0, function* () {
698
- const expression = yield this.visitExpression(memberRef, p);
699
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.MemberReference) {
700
- return expression;
701
- }
702
- memberRef = expression;
703
- const updates = {
704
- prefix: yield this.visitSpace(memberRef.prefix, p),
705
- markers: yield this.visitMarkers(memberRef.markers, p),
706
- containing: yield this.visitRightPadded(memberRef.containing, p),
707
- typeParameters: yield this.visitOptionalContainer(memberRef.typeParameters, p),
708
- reference: yield this.visitLeftPadded(memberRef.reference, p),
709
- type: yield this.visitType(memberRef.type, p),
710
- methodType: yield this.visitType(memberRef.methodType, p),
711
- variableType: yield this.visitType(memberRef.variableType, p)
712
- };
713
- return (0, util_1.updateIfChanged)(memberRef, updates);
714
- });
715
- }
716
- visitMethodDeclaration(method, p) {
717
- return __awaiter(this, void 0, void 0, function* () {
718
- const statement = yield this.visitStatement(method, p);
719
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.MethodDeclaration) {
720
- return statement;
721
- }
722
- method = statement;
723
- const updates = {
724
- prefix: yield this.visitSpace(method.prefix, p),
725
- markers: yield this.visitMarkers(method.markers, p),
726
- leadingAnnotations: yield (0, util_1.mapAsync)(method.leadingAnnotations, a => this.visitDefined(a, p)),
727
- modifiers: yield (0, util_1.mapAsync)(method.modifiers, m => this.visitDefined(m, p)),
728
- nameAnnotations: yield (0, util_1.mapAsync)(method.nameAnnotations, a => this.visitDefined(a, p)),
729
- name: yield this.visitDefined(method.name, p),
730
- parameters: yield this.visitContainer(method.parameters, p),
731
- throws: method.throws && (yield this.visitContainer(method.throws, p)),
732
- body: method.body && (yield this.visitDefined(method.body, p)),
733
- defaultValue: yield this.visitOptionalLeftPadded(method.defaultValue, p),
734
- methodType: yield this.visitType(method.methodType, p)
735
- };
736
- if (method.typeParameters) {
737
- updates.typeParameters = (yield this.visitDefined(method.typeParameters, p));
738
- }
739
- if (method.returnTypeExpression) {
740
- updates.returnTypeExpression = (yield this.visitDefined(method.returnTypeExpression, p));
741
- }
742
- return (0, util_1.updateIfChanged)(method, updates);
743
- });
744
- }
745
- visitMethodInvocation(method, p) {
746
- return __awaiter(this, void 0, void 0, function* () {
747
- const expression = yield this.visitExpression(method, p);
748
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.MethodInvocation) {
749
- return expression;
750
- }
751
- method = expression;
752
- const statement = yield this.visitStatement(method, p);
753
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.MethodInvocation) {
754
- return statement;
755
- }
756
- method = statement;
757
- const updates = {
758
- prefix: yield this.visitSpace(method.prefix, p),
759
- markers: yield this.visitMarkers(method.markers, p),
760
- select: yield this.visitOptionalRightPadded(method.select, p),
761
- typeParameters: yield this.visitOptionalContainer(method.typeParameters, p),
762
- name: yield this.visitDefined(method.name, p),
763
- arguments: yield this.visitContainer(method.arguments, p),
764
- methodType: yield this.visitType(method.methodType, p)
765
- };
766
- return (0, util_1.updateIfChanged)(method, updates);
767
- });
768
- }
769
- visitModifier(modifier, p) {
770
- return __awaiter(this, void 0, void 0, function* () {
771
- const updates = {
772
- prefix: yield this.visitSpace(modifier.prefix, p),
773
- markers: yield this.visitMarkers(modifier.markers, p),
774
- annotations: yield (0, util_1.mapAsync)(modifier.annotations, a => this.visitDefined(a, p))
775
- };
776
- return (0, util_1.updateIfChanged)(modifier, updates);
777
- });
778
- }
779
- visitMultiCatch(multiCatch, p) {
780
- return __awaiter(this, void 0, void 0, function* () {
781
- const updates = {
782
- prefix: yield this.visitSpace(multiCatch.prefix, p),
783
- markers: yield this.visitMarkers(multiCatch.markers, p),
784
- alternatives: yield (0, util_1.mapAsync)(multiCatch.alternatives, alt => this.visitRightPadded(alt, p))
785
- };
786
- return (0, util_1.updateIfChanged)(multiCatch, updates);
787
- });
788
- }
789
- visitNewArray(newArray, p) {
790
- return __awaiter(this, void 0, void 0, function* () {
791
- const expression = yield this.visitExpression(newArray, p);
792
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.NewArray) {
793
- return expression;
794
- }
795
- newArray = expression;
796
- const updates = {
797
- prefix: yield this.visitSpace(newArray.prefix, p),
798
- markers: yield this.visitMarkers(newArray.markers, p),
799
- dimensions: yield (0, util_1.mapAsync)(newArray.dimensions, dim => this.visitDefined(dim, p)),
800
- initializer: yield this.visitOptionalContainer(newArray.initializer, p),
801
- type: yield this.visitType(newArray.type, p)
802
- };
803
- if (newArray.typeExpression) {
804
- updates.typeExpression = (yield this.visitDefined(newArray.typeExpression, p));
805
- }
806
- return (0, util_1.updateIfChanged)(newArray, updates);
807
- });
808
- }
809
- visitNewClass(newClass, p) {
810
- return __awaiter(this, void 0, void 0, function* () {
811
- const expression = yield this.visitExpression(newClass, p);
812
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.NewClass) {
813
- return expression;
814
- }
815
- newClass = expression;
816
- const updates = {
817
- prefix: yield this.visitSpace(newClass.prefix, p),
818
- markers: yield this.visitMarkers(newClass.markers, p),
819
- new: yield this.visitSpace(newClass.new, p),
820
- arguments: yield this.visitContainer(newClass.arguments, p),
821
- constructorType: yield this.visitType(newClass.constructorType, p)
822
- };
823
- if (newClass.enclosing) {
824
- updates.enclosing = yield this.visitRightPadded(newClass.enclosing, p);
825
- }
826
- if (newClass.class) {
827
- updates.class = (yield this.visitDefined(newClass.class, p));
828
- }
829
- if (newClass.body) {
830
- updates.body = (yield this.visitDefined(newClass.body, p));
831
- }
832
- return (0, util_1.updateIfChanged)(newClass, updates);
833
- });
834
- }
835
- visitNullableType(nullableType, p) {
836
- return __awaiter(this, void 0, void 0, function* () {
837
- const expression = yield this.visitExpression(nullableType, p);
838
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.NullableType) {
839
- return expression;
840
- }
841
- nullableType = expression;
842
- const updates = {
843
- prefix: yield this.visitSpace(nullableType.prefix, p),
844
- markers: yield this.visitMarkers(nullableType.markers, p),
845
- annotations: yield (0, util_1.mapAsync)(nullableType.annotations, a => this.visitDefined(a, p)),
846
- typeTree: yield this.visitRightPadded(nullableType.typeTree, p)
847
- };
848
- return (0, util_1.updateIfChanged)(nullableType, updates);
849
- });
850
- }
851
- visitPackage(aPackage, p) {
852
- return __awaiter(this, void 0, void 0, function* () {
853
- const updates = {
854
- prefix: yield this.visitSpace(aPackage.prefix, p),
855
- markers: yield this.visitMarkers(aPackage.markers, p),
856
- expression: yield this.visitDefined(aPackage.expression, p)
857
- };
858
- if (aPackage.annotations) {
859
- updates.annotations = yield (0, util_1.mapAsync)(aPackage.annotations, a => this.visitDefined(a, p));
860
- }
861
- return (0, util_1.updateIfChanged)(aPackage, updates);
862
- });
863
- }
864
- visitParameterizedType(parameterizedType, p) {
865
- return __awaiter(this, void 0, void 0, function* () {
866
- const updates = {
867
- prefix: yield this.visitSpace(parameterizedType.prefix, p),
868
- markers: yield this.visitMarkers(parameterizedType.markers, p),
869
- class: yield this.visitTypeName(parameterizedType.class, p),
870
- typeParameters: yield this.visitOptionalContainer(parameterizedType.typeParameters, p),
871
- type: yield this.visitType(parameterizedType.type, p)
872
- };
873
- return (0, util_1.updateIfChanged)(parameterizedType, updates);
874
- });
875
- }
876
- visitParentheses(parentheses, p) {
877
- return __awaiter(this, void 0, void 0, function* () {
878
- const updates = {
879
- prefix: yield this.visitSpace(parentheses.prefix, p),
880
- markers: yield this.visitMarkers(parentheses.markers, p),
881
- tree: yield this.visitRightPadded(parentheses.tree, p)
882
- };
883
- return (0, util_1.updateIfChanged)(parentheses, updates);
884
- });
885
- }
886
- visitParenthesizedTypeTree(parTypeTree, p) {
887
- return __awaiter(this, void 0, void 0, function* () {
888
- const expression = yield this.visitExpression(parTypeTree, p);
889
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.ParenthesizedTypeTree) {
890
- return expression;
891
- }
892
- parTypeTree = expression;
893
- const updates = {
894
- prefix: yield this.visitSpace(parTypeTree.prefix, p),
895
- markers: yield this.visitMarkers(parTypeTree.markers, p),
896
- annotations: yield (0, util_1.mapAsync)(parTypeTree.annotations, a => this.visitDefined(a, p)),
897
- parenthesizedType: yield this.visitDefined(parTypeTree.parenthesizedType, p)
898
- };
899
- return (0, util_1.updateIfChanged)(parTypeTree, updates);
900
- });
901
- }
902
- visitPrimitive(primitive, p) {
903
- return __awaiter(this, void 0, void 0, function* () {
904
- const expression = yield this.visitExpression(primitive, p);
905
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Primitive) {
906
- return expression;
907
- }
908
- primitive = expression;
909
- const updates = {
910
- prefix: yield this.visitSpace(primitive.prefix, p),
911
- markers: yield this.visitMarkers(primitive.markers, p),
912
- type: yield this.visitType(primitive.type, p)
913
- };
914
- return (0, util_1.updateIfChanged)(primitive, updates);
915
- });
916
- }
917
- visitReturn(ret, p) {
918
- return __awaiter(this, void 0, void 0, function* () {
919
- const statement = yield this.visitStatement(ret, p);
920
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Return) {
921
- return statement;
922
- }
923
- ret = statement;
924
- const updates = {
925
- prefix: yield this.visitSpace(ret.prefix, p),
926
- markers: yield this.visitMarkers(ret.markers, p)
927
- };
928
- if (ret.expression) {
929
- updates.expression = (yield this.visitDefined(ret.expression, p));
930
- }
931
- return (0, util_1.updateIfChanged)(ret, updates);
932
- });
933
- }
934
- visitSwitch(aSwitch, p) {
935
- return __awaiter(this, void 0, void 0, function* () {
936
- const statement = yield this.visitStatement(aSwitch, p);
937
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Switch) {
938
- return statement;
939
- }
940
- aSwitch = statement;
941
- const updates = {
942
- prefix: yield this.visitSpace(aSwitch.prefix, p),
943
- markers: yield this.visitMarkers(aSwitch.markers, p),
944
- selector: yield this.visitDefined(aSwitch.selector, p),
945
- cases: yield this.visitDefined(aSwitch.cases, p)
946
- };
947
- return (0, util_1.updateIfChanged)(aSwitch, updates);
948
- });
949
- }
950
- visitSwitchExpression(switchExpr, p) {
951
- return __awaiter(this, void 0, void 0, function* () {
952
- const expression = yield this.visitExpression(switchExpr, p);
953
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.SwitchExpression) {
954
- return expression;
955
- }
956
- switchExpr = expression;
957
- const updates = {
958
- prefix: yield this.visitSpace(switchExpr.prefix, p),
959
- markers: yield this.visitMarkers(switchExpr.markers, p),
960
- selector: yield this.visitDefined(switchExpr.selector, p),
961
- cases: yield this.visitDefined(switchExpr.cases, p),
962
- type: yield this.visitType(switchExpr.type, p)
963
- };
964
- return (0, util_1.updateIfChanged)(switchExpr, updates);
965
- });
966
- }
967
- visitSynchronized(sync, p) {
968
- return __awaiter(this, void 0, void 0, function* () {
969
- const statement = yield this.visitStatement(sync, p);
970
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Synchronized) {
971
- return statement;
972
- }
973
- sync = statement;
974
- const updates = {
975
- prefix: yield this.visitSpace(sync.prefix, p),
976
- markers: yield this.visitMarkers(sync.markers, p),
977
- lock: yield this.visitDefined(sync.lock, p),
978
- body: yield this.visitDefined(sync.body, p)
979
- };
980
- return (0, util_1.updateIfChanged)(sync, updates);
981
- });
982
- }
983
- visitTernary(ternary, p) {
984
- return __awaiter(this, void 0, void 0, function* () {
985
- const expression = yield this.visitExpression(ternary, p);
986
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Ternary) {
987
- return expression;
988
- }
989
- ternary = expression;
990
- const statement = yield this.visitStatement(ternary, p);
991
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Ternary) {
992
- return statement;
993
- }
994
- ternary = statement;
995
- const updates = {
996
- prefix: yield this.visitSpace(ternary.prefix, p),
997
- markers: yield this.visitMarkers(ternary.markers, p),
998
- condition: yield this.visitDefined(ternary.condition, p),
999
- truePart: yield this.visitLeftPadded(ternary.truePart, p),
1000
- falsePart: yield this.visitLeftPadded(ternary.falsePart, p),
1001
- type: yield this.visitType(ternary.type, p)
1002
- };
1003
- return (0, util_1.updateIfChanged)(ternary, updates);
1004
- });
1005
- }
1006
- visitThrow(thrown, p) {
1007
- return __awaiter(this, void 0, void 0, function* () {
1008
- const statement = yield this.visitStatement(thrown, p);
1009
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Throw) {
1010
- return statement;
1011
- }
1012
- thrown = statement;
1013
- const updates = {
1014
- prefix: yield this.visitSpace(thrown.prefix, p),
1015
- markers: yield this.visitMarkers(thrown.markers, p),
1016
- exception: yield this.visitDefined(thrown.exception, p)
1017
- };
1018
- return (0, util_1.updateIfChanged)(thrown, updates);
1019
- });
1020
- }
1021
- visitTry(tryable, p) {
1022
- return __awaiter(this, void 0, void 0, function* () {
1023
- const statement = yield this.visitStatement(tryable, p);
1024
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Try) {
1025
- return statement;
1026
- }
1027
- tryable = statement;
1028
- const updates = {
1029
- prefix: yield this.visitSpace(tryable.prefix, p),
1030
- markers: yield this.visitMarkers(tryable.markers, p),
1031
- resources: yield this.visitOptionalContainer(tryable.resources, p),
1032
- body: yield this.visitDefined(tryable.body, p),
1033
- catches: yield (0, util_1.mapAsync)(tryable.catches, c => this.visitDefined(c, p)),
1034
- finally: yield this.visitOptionalLeftPadded(tryable.finally, p)
1035
- };
1036
- return (0, util_1.updateIfChanged)(tryable, updates);
1037
- });
1038
- }
1039
- visitTryResource(resource, p) {
1040
- return __awaiter(this, void 0, void 0, function* () {
1041
- const updates = {
1042
- prefix: yield this.visitSpace(resource.prefix, p),
1043
- markers: yield this.visitMarkers(resource.markers, p),
1044
- variableDeclarations: yield this.visitDefined(resource.variableDeclarations, p)
1045
- };
1046
- return (0, util_1.updateIfChanged)(resource, updates);
1047
- });
1048
- }
1049
- visitTryCatch(tryCatch, p) {
1050
- return __awaiter(this, void 0, void 0, function* () {
1051
- const updates = {
1052
- prefix: yield this.visitSpace(tryCatch.prefix, p),
1053
- markers: yield this.visitMarkers(tryCatch.markers, p),
1054
- parameter: yield this.visitDefined(tryCatch.parameter, p),
1055
- body: yield this.visitDefined(tryCatch.body, p)
1056
- };
1057
- return (0, util_1.updateIfChanged)(tryCatch, updates);
1058
- });
1059
- }
1060
- visitTypeCast(typeCast, p) {
1061
- return __awaiter(this, void 0, void 0, function* () {
1062
- const expression = yield this.visitExpression(typeCast, p);
1063
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.TypeCast) {
1064
- return expression;
1065
- }
1066
- typeCast = expression;
1067
- const updates = {
1068
- prefix: yield this.visitSpace(typeCast.prefix, p),
1069
- markers: yield this.visitMarkers(typeCast.markers, p),
1070
- class: yield this.visitDefined(typeCast.class, p),
1071
- expression: yield this.visitDefined(typeCast.expression, p)
1072
- };
1073
- return (0, util_1.updateIfChanged)(typeCast, updates);
1074
- });
1075
- }
1076
- visitTypeParameter(typeParam, p) {
1077
- return __awaiter(this, void 0, void 0, function* () {
1078
- const updates = {
1079
- prefix: yield this.visitSpace(typeParam.prefix, p),
1080
- markers: yield this.visitMarkers(typeParam.markers, p),
1081
- annotations: yield (0, util_1.mapAsync)(typeParam.annotations, a => this.visitDefined(a, p)),
1082
- modifiers: yield (0, util_1.mapAsync)(typeParam.modifiers, m => this.visitDefined(m, p)),
1083
- name: yield this.visitDefined(typeParam.name, p),
1084
- bounds: yield this.visitOptionalContainer(typeParam.bounds, p)
1085
- };
1086
- return (0, util_1.updateIfChanged)(typeParam, updates);
1087
- });
1088
- }
1089
- visitTypeParameters(typeParams, p) {
1090
- return __awaiter(this, void 0, void 0, function* () {
1091
- const updates = {
1092
- prefix: yield this.visitSpace(typeParams.prefix, p),
1093
- markers: yield this.visitMarkers(typeParams.markers, p),
1094
- annotations: yield (0, util_1.mapAsync)(typeParams.annotations, a => this.visitDefined(a, p)),
1095
- typeParameters: yield (0, util_1.mapAsync)(typeParams.typeParameters, tp => this.visitRightPadded(tp, p))
1096
- };
1097
- return (0, util_1.updateIfChanged)(typeParams, updates);
1098
- });
1099
- }
1100
- visitUnary(unary, p) {
1101
- return __awaiter(this, void 0, void 0, function* () {
1102
- const expression = yield this.visitExpression(unary, p);
1103
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Unary) {
1104
- return expression;
1105
- }
1106
- unary = expression;
1107
- const statement = yield this.visitStatement(unary, p);
1108
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Unary) {
1109
- return statement;
1110
- }
1111
- unary = statement;
1112
- const updates = {
1113
- prefix: yield this.visitSpace(unary.prefix, p),
1114
- markers: yield this.visitMarkers(unary.markers, p),
1115
- operator: yield this.visitLeftPadded(unary.operator, p),
1116
- expression: yield this.visitDefined(unary.expression, p),
1117
- type: yield this.visitType(unary.type, p)
1118
- };
1119
- return (0, util_1.updateIfChanged)(unary, updates);
1120
- });
1121
- }
1122
- visitUnknown(unknown, p) {
1123
- return __awaiter(this, void 0, void 0, function* () {
1124
- const expression = yield this.visitExpression(unknown, p);
1125
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Unknown) {
1126
- return expression;
1127
- }
1128
- unknown = expression;
1129
- const statement = yield this.visitStatement(unknown, p);
1130
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Unknown) {
1131
- return statement;
1132
- }
1133
- unknown = statement;
1134
- const updates = {
1135
- prefix: yield this.visitSpace(unknown.prefix, p),
1136
- markers: yield this.visitMarkers(unknown.markers, p),
1137
- source: yield this.visitDefined(unknown.source, p)
1138
- };
1139
- return (0, util_1.updateIfChanged)(unknown, updates);
1140
- });
1141
- }
1142
- visitUnknownSource(source, p) {
1143
- return __awaiter(this, void 0, void 0, function* () {
1144
- const updates = {
1145
- prefix: yield this.visitSpace(source.prefix, p),
1146
- markers: yield this.visitMarkers(source.markers, p)
1147
- };
1148
- return (0, util_1.updateIfChanged)(source, updates);
1149
- });
1150
- }
1151
- visitVariableDeclarations(varDecls, p) {
1152
- return __awaiter(this, void 0, void 0, function* () {
1153
- const statement = yield this.visitStatement(varDecls, p);
1154
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.VariableDeclarations) {
1155
- return statement;
1156
- }
1157
- varDecls = statement;
1158
- const updates = {
1159
- prefix: yield this.visitSpace(varDecls.prefix, p),
1160
- markers: yield this.visitMarkers(varDecls.markers, p),
1161
- leadingAnnotations: yield (0, util_1.mapAsync)(varDecls.leadingAnnotations, a => this.visitDefined(a, p)),
1162
- modifiers: yield (0, util_1.mapAsync)(varDecls.modifiers, m => this.visitDefined(m, p)),
1163
- variables: yield (0, util_1.mapAsync)(varDecls.variables, v => this.visitRightPadded(v, p))
1164
- };
1165
- if (varDecls.typeExpression) {
1166
- updates.typeExpression = (yield this.visitDefined(varDecls.typeExpression, p));
1167
- }
1168
- if (varDecls.varargs) {
1169
- updates.varargs = yield this.visitSpace(varDecls.varargs, p);
1170
- }
1171
- return (0, util_1.updateIfChanged)(varDecls, updates);
1172
- });
1173
- }
1174
- visitVariable(variable, p) {
1175
- return __awaiter(this, void 0, void 0, function* () {
1176
- const updates = {
1177
- prefix: yield this.visitSpace(variable.prefix, p),
1178
- markers: yield this.visitMarkers(variable.markers, p),
1179
- name: yield this.visitDefined(variable.name, p),
1180
- dimensionsAfterName: yield (0, util_1.mapAsync)(variable.dimensionsAfterName, dim => this.visitLeftPadded(dim, p)),
1181
- initializer: yield this.visitOptionalLeftPadded(variable.initializer, p),
1182
- variableType: yield this.visitType(variable.variableType, p)
1183
- };
1184
- return (0, util_1.updateIfChanged)(variable, updates);
1185
- });
1186
- }
1187
- visitWhileLoop(whileLoop, p) {
1188
- return __awaiter(this, void 0, void 0, function* () {
1189
- const statement = yield this.visitStatement(whileLoop, p);
1190
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.WhileLoop) {
1191
- return statement;
1192
- }
1193
- whileLoop = statement;
1194
- const updates = {
1195
- prefix: yield this.visitSpace(whileLoop.prefix, p),
1196
- markers: yield this.visitMarkers(whileLoop.markers, p),
1197
- condition: yield this.visitDefined(whileLoop.condition, p),
1198
- body: yield this.visitRightPadded(whileLoop.body, p)
1199
- };
1200
- return (0, util_1.updateIfChanged)(whileLoop, updates);
1201
- });
1202
- }
1203
- visitWildcard(wildcard, p) {
1204
- return __awaiter(this, void 0, void 0, function* () {
1205
- const expression = yield this.visitExpression(wildcard, p);
1206
- if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Wildcard) {
1207
- return expression;
1208
- }
1209
- wildcard = expression;
1210
- const updates = {
1211
- prefix: yield this.visitSpace(wildcard.prefix, p),
1212
- markers: yield this.visitMarkers(wildcard.markers, p),
1213
- bound: yield this.visitOptionalLeftPadded(wildcard.bound, p)
1214
- };
1215
- if (wildcard.boundedType) {
1216
- updates.boundedType = yield this.visitTypeName(wildcard.boundedType, p);
1217
- }
1218
- return (0, util_1.updateIfChanged)(wildcard, updates);
1219
- });
1220
- }
1221
- visitYield(aYield, p) {
1222
- return __awaiter(this, void 0, void 0, function* () {
1223
- const statement = yield this.visitStatement(aYield, p);
1224
- if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Yield) {
1225
- return statement;
1226
- }
1227
- aYield = statement;
1228
- const updates = {
1229
- prefix: yield this.visitSpace(aYield.prefix, p),
1230
- markers: yield this.visitMarkers(aYield.markers, p),
1231
- value: yield this.visitDefined(aYield.value, p)
1232
- };
1233
- return (0, util_1.updateIfChanged)(aYield, updates);
1234
- });
1235
- }
1236
- visitOptionalRightPadded(right, p) {
1237
- return __awaiter(this, void 0, void 0, function* () {
1238
- return right ? this.visitRightPadded(right, p) : undefined;
1239
- });
1240
- }
1241
- visitRightPadded(right, p) {
1242
- return __awaiter(this, void 0, void 0, function* () {
1243
- this.cursor = new tree_1.Cursor(right, this.cursor);
1244
- const element = (0, tree_1.isTree)(right.element) ? yield this.visitDefined(right.element, p) : right.element;
1245
- const after = yield this.visitSpace(right.after, p);
1246
- const markers = yield this.visitMarkers(right.markers, p);
1247
- this.cursor = this.cursor.parent;
1248
- if (element === undefined) {
1249
- return undefined;
1250
- }
1251
- return (0, util_1.updateIfChanged)(right, { element, after, markers });
1252
- });
1253
- }
1254
- visitOptionalLeftPadded(left, p) {
1255
- return __awaiter(this, void 0, void 0, function* () {
1256
- return left ? this.visitLeftPadded(left, p) : undefined;
1257
- });
1258
- }
1259
- visitLeftPadded(left, p) {
1260
- return __awaiter(this, void 0, void 0, function* () {
1261
- this.cursor = new tree_1.Cursor(left, this.cursor);
1262
- const before = yield this.visitSpace(left.before, p);
1263
- let element = left.element;
1264
- if ((0, tree_1.isTree)(left.element)) {
1265
- element = (yield this.visitDefined(left.element, p));
1266
- }
1267
- else if ((0, tree_2.isSpace)(left.element)) {
1268
- element = (yield this.visitSpace(left.element, p));
1269
- }
1270
- const markers = yield this.visitMarkers(left.markers, p);
1271
- this.cursor = this.cursor.parent;
1272
- if (element === undefined) {
1273
- return undefined;
1274
- }
1275
- return (0, util_1.updateIfChanged)(left, { before, element, markers });
1276
- });
1277
- }
1278
- visitOptionalContainer(container, p) {
1279
- return __awaiter(this, void 0, void 0, function* () {
1280
- return container ? this.visitContainer(container, p) : undefined;
1281
- });
1282
- }
1283
- visitContainer(container, p) {
1284
- return __awaiter(this, void 0, void 0, function* () {
1285
- this.cursor = new tree_1.Cursor(container, this.cursor);
1286
- const before = yield this.visitSpace(container.before, p);
1287
- const elements = yield (0, util_1.mapAsync)(container.elements, e => this.visitRightPadded(e, p));
1288
- const markers = yield this.visitMarkers(container.markers, p);
1289
- this.cursor = this.cursor.parent;
1290
- return (0, util_1.updateIfChanged)(container, { before, elements, markers });
1291
- });
1292
- }
1293
- produceJava(before, p, recipe) {
1294
- return __awaiter(this, void 0, void 0, function* () {
1295
- const [draft, finishDraft] = (0, mutative_1.create)(before);
1296
- draft.prefix = yield this.visitSpace(before.prefix, p);
1297
- draft.markers = yield this.visitMarkers(before.markers, p);
1298
- if (recipe) {
1299
- yield recipe(draft);
1300
- }
1301
- return finishDraft();
1302
- });
64
+ async visitTypeName(nameTree, p) {
65
+ return nameTree;
66
+ }
67
+ async visitAnnotatedType(annotatedType, p) {
68
+ const expression = await this.visitExpression(annotatedType, p);
69
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.AnnotatedType) {
70
+ return expression;
71
+ }
72
+ annotatedType = expression;
73
+ const updates = {
74
+ prefix: await this.visitSpace(annotatedType.prefix, p),
75
+ markers: await this.visitMarkers(annotatedType.markers, p),
76
+ annotations: await (0, util_1.mapAsync)(annotatedType.annotations, a => this.visitDefined(a, p)),
77
+ typeExpression: await this.visitDefined(annotatedType.typeExpression, p)
78
+ };
79
+ return (0, util_1.updateIfChanged)(annotatedType, updates);
80
+ }
81
+ async visitAnnotation(annotation, p) {
82
+ const expression = await this.visitExpression(annotation, p);
83
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Annotation) {
84
+ return expression;
85
+ }
86
+ annotation = expression;
87
+ const updates = {
88
+ prefix: await this.visitSpace(annotation.prefix, p),
89
+ markers: await this.visitMarkers(annotation.markers, p),
90
+ annotationType: await this.visitTypeName(annotation.annotationType, p),
91
+ arguments: await this.visitOptionalContainer(annotation.arguments, p)
92
+ };
93
+ return (0, util_1.updateIfChanged)(annotation, updates);
94
+ }
95
+ async visitArrayAccess(arrayAccess, p) {
96
+ const expression = await this.visitExpression(arrayAccess, p);
97
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.ArrayAccess) {
98
+ return expression;
99
+ }
100
+ arrayAccess = expression;
101
+ const updates = {
102
+ prefix: await this.visitSpace(arrayAccess.prefix, p),
103
+ markers: await this.visitMarkers(arrayAccess.markers, p),
104
+ indexed: await this.visitDefined(arrayAccess.indexed, p),
105
+ dimension: await this.visitDefined(arrayAccess.dimension, p)
106
+ };
107
+ return (0, util_1.updateIfChanged)(arrayAccess, updates);
108
+ }
109
+ async visitArrayDimension(arrayDimension, p) {
110
+ const updates = {
111
+ prefix: await this.visitSpace(arrayDimension.prefix, p),
112
+ markers: await this.visitMarkers(arrayDimension.markers, p),
113
+ index: await this.visitRightPadded(arrayDimension.index, p)
114
+ };
115
+ return (0, util_1.updateIfChanged)(arrayDimension, updates);
116
+ }
117
+ async visitArrayType(arrayType, p) {
118
+ const expression = await this.visitExpression(arrayType, p);
119
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.ArrayType) {
120
+ return expression;
121
+ }
122
+ arrayType = expression;
123
+ const updates = {
124
+ prefix: await this.visitSpace(arrayType.prefix, p),
125
+ markers: await this.visitMarkers(arrayType.markers, p),
126
+ elementType: await this.visitDefined(arrayType.elementType, p),
127
+ dimension: await this.visitLeftPadded(arrayType.dimension, p),
128
+ type: await this.visitType(arrayType.type, p)
129
+ };
130
+ if (arrayType.annotations) {
131
+ updates.annotations = await (0, util_1.mapAsync)(arrayType.annotations, a => this.visitDefined(a, p));
132
+ }
133
+ return (0, util_1.updateIfChanged)(arrayType, updates);
134
+ }
135
+ async visitAssert(anAssert, p) {
136
+ const statement = await this.visitStatement(anAssert, p);
137
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Assert) {
138
+ return statement;
139
+ }
140
+ anAssert = statement;
141
+ const updates = {
142
+ prefix: await this.visitSpace(anAssert.prefix, p),
143
+ markers: await this.visitMarkers(anAssert.markers, p),
144
+ condition: await this.visitDefined(anAssert.condition, p),
145
+ detail: await this.visitOptionalLeftPadded(anAssert.detail, p)
146
+ };
147
+ return (0, util_1.updateIfChanged)(anAssert, updates);
148
+ }
149
+ async visitAssignment(assignment, p) {
150
+ const expression = await this.visitExpression(assignment, p);
151
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Assignment) {
152
+ return expression;
153
+ }
154
+ assignment = expression;
155
+ const statement = await this.visitStatement(assignment, p);
156
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Assignment) {
157
+ return statement;
158
+ }
159
+ assignment = statement;
160
+ const updates = {
161
+ prefix: await this.visitSpace(assignment.prefix, p),
162
+ markers: await this.visitMarkers(assignment.markers, p),
163
+ variable: await this.visitDefined(assignment.variable, p),
164
+ assignment: await this.visitLeftPadded(assignment.assignment, p),
165
+ type: await this.visitType(assignment.type, p)
166
+ };
167
+ return (0, util_1.updateIfChanged)(assignment, updates);
168
+ }
169
+ async visitAssignmentOperation(assignOp, p) {
170
+ const expression = await this.visitExpression(assignOp, p);
171
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.AssignmentOperation) {
172
+ return expression;
173
+ }
174
+ assignOp = expression;
175
+ const updates = {
176
+ prefix: await this.visitSpace(assignOp.prefix, p),
177
+ markers: await this.visitMarkers(assignOp.markers, p),
178
+ variable: await this.visitDefined(assignOp.variable, p),
179
+ operator: await this.visitLeftPadded(assignOp.operator, p),
180
+ assignment: await this.visitDefined(assignOp.assignment, p),
181
+ type: await this.visitType(assignOp.type, p)
182
+ };
183
+ return (0, util_1.updateIfChanged)(assignOp, updates);
184
+ }
185
+ async visitBinary(binary, p) {
186
+ const expression = await this.visitExpression(binary, p);
187
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Binary) {
188
+ return expression;
189
+ }
190
+ binary = expression;
191
+ const updates = {
192
+ prefix: await this.visitSpace(binary.prefix, p),
193
+ markers: await this.visitMarkers(binary.markers, p),
194
+ left: await this.visitDefined(binary.left, p),
195
+ operator: await this.visitLeftPadded(binary.operator, p),
196
+ right: await this.visitDefined(binary.right, p),
197
+ type: await this.visitType(binary.type, p)
198
+ };
199
+ return (0, util_1.updateIfChanged)(binary, updates);
200
+ }
201
+ async visitBlock(block, p) {
202
+ const updates = {
203
+ prefix: await this.visitSpace(block.prefix, p),
204
+ markers: await this.visitMarkers(block.markers, p),
205
+ static: await this.visitRightPadded(block.static, p),
206
+ statements: await (0, util_1.mapAsync)(block.statements, stmt => this.visitRightPadded(stmt, p)),
207
+ end: await this.visitSpace(block.end, p)
208
+ };
209
+ return (0, util_1.updateIfChanged)(block, updates);
210
+ }
211
+ async visitBreak(breakStatement, p) {
212
+ const statement = await this.visitStatement(breakStatement, p);
213
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Break) {
214
+ return statement;
215
+ }
216
+ breakStatement = statement;
217
+ const updates = {
218
+ prefix: await this.visitSpace(breakStatement.prefix, p),
219
+ markers: await this.visitMarkers(breakStatement.markers, p)
220
+ };
221
+ if (breakStatement.label) {
222
+ updates.label = await this.visitDefined(breakStatement.label, p);
223
+ }
224
+ return (0, util_1.updateIfChanged)(breakStatement, updates);
225
+ }
226
+ async visitCase(aCase, p) {
227
+ const statement = await this.visitStatement(aCase, p);
228
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Case) {
229
+ return statement;
230
+ }
231
+ aCase = statement;
232
+ const updates = {
233
+ prefix: await this.visitSpace(aCase.prefix, p),
234
+ markers: await this.visitMarkers(aCase.markers, p),
235
+ caseLabels: await this.visitContainer(aCase.caseLabels, p),
236
+ statements: await this.visitContainer(aCase.statements, p),
237
+ body: await this.visitOptionalRightPadded(aCase.body, p)
238
+ };
239
+ if (aCase.guard) {
240
+ updates.guard = await this.visitDefined(aCase.guard, p);
241
+ }
242
+ return (0, util_1.updateIfChanged)(aCase, updates);
243
+ }
244
+ async visitClassDeclaration(classDecl, p) {
245
+ const statement = await this.visitStatement(classDecl, p);
246
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.ClassDeclaration) {
247
+ return statement;
248
+ }
249
+ classDecl = statement;
250
+ const updates = {
251
+ prefix: await this.visitSpace(classDecl.prefix, p),
252
+ markers: await this.visitMarkers(classDecl.markers, p),
253
+ leadingAnnotations: await (0, util_1.mapAsync)(classDecl.leadingAnnotations, a => this.visitDefined(a, p)),
254
+ modifiers: await (0, util_1.mapAsync)(classDecl.modifiers, m => this.visitDefined(m, p)),
255
+ classKind: await this.visitDefined(classDecl.classKind, p),
256
+ name: await this.visitDefined(classDecl.name, p),
257
+ typeParameters: await this.visitOptionalContainer(classDecl.typeParameters, p),
258
+ primaryConstructor: await this.visitOptionalContainer(classDecl.primaryConstructor, p),
259
+ extends: await this.visitOptionalLeftPadded(classDecl.extends, p),
260
+ implements: await this.visitOptionalContainer(classDecl.implements, p),
261
+ permitting: await this.visitOptionalContainer(classDecl.permitting, p),
262
+ body: await this.visitDefined(classDecl.body, p),
263
+ type: await this.visitType(classDecl.type, p)
264
+ };
265
+ return (0, util_1.updateIfChanged)(classDecl, updates);
266
+ }
267
+ async visitClassDeclarationKind(kind, p) {
268
+ const updates = {
269
+ prefix: await this.visitSpace(kind.prefix, p),
270
+ markers: await this.visitMarkers(kind.markers, p),
271
+ annotations: await (0, util_1.mapAsync)(kind.annotations, a => this.visitDefined(a, p))
272
+ };
273
+ return (0, util_1.updateIfChanged)(kind, updates);
274
+ }
275
+ async visitCompilationUnit(cu, p) {
276
+ const updates = {
277
+ prefix: await this.visitSpace(cu.prefix, p),
278
+ markers: await this.visitMarkers(cu.markers, p),
279
+ packageDeclaration: await this.visitRightPadded(cu.packageDeclaration, p),
280
+ imports: await (0, util_1.mapAsync)(cu.imports, imp => this.visitRightPadded(imp, p)),
281
+ classes: await (0, util_1.mapAsync)(cu.classes, cls => this.visitDefined(cls, p)),
282
+ eof: await this.visitSpace(cu.eof, p)
283
+ };
284
+ return (0, util_1.updateIfChanged)(cu, updates);
285
+ }
286
+ async visitContinue(continueStatement, p) {
287
+ const statement = await this.visitStatement(continueStatement, p);
288
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Continue) {
289
+ return statement;
290
+ }
291
+ continueStatement = statement;
292
+ const updates = {
293
+ prefix: await this.visitSpace(continueStatement.prefix, p),
294
+ markers: await this.visitMarkers(continueStatement.markers, p)
295
+ };
296
+ if (continueStatement.label) {
297
+ updates.label = await this.visitDefined(continueStatement.label, p);
298
+ }
299
+ return (0, util_1.updateIfChanged)(continueStatement, updates);
300
+ }
301
+ async visitControlParentheses(controlParens, p) {
302
+ const updates = {
303
+ prefix: await this.visitSpace(controlParens.prefix, p),
304
+ markers: await this.visitMarkers(controlParens.markers, p),
305
+ tree: await this.visitRightPadded(controlParens.tree, p)
306
+ };
307
+ return (0, util_1.updateIfChanged)(controlParens, updates);
308
+ }
309
+ async visitDeconstructionPattern(pattern, p) {
310
+ const updates = {
311
+ prefix: await this.visitSpace(pattern.prefix, p),
312
+ markers: await this.visitMarkers(pattern.markers, p),
313
+ deconstructor: await this.visitDefined(pattern.deconstructor, p),
314
+ nested: await this.visitContainer(pattern.nested, p),
315
+ type: await this.visitType(pattern.type, p)
316
+ };
317
+ return (0, util_1.updateIfChanged)(pattern, updates);
318
+ }
319
+ async visitDoWhileLoop(doWhileLoop, p) {
320
+ const statement = await this.visitStatement(doWhileLoop, p);
321
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.DoWhileLoop) {
322
+ return statement;
323
+ }
324
+ doWhileLoop = statement;
325
+ const updates = {
326
+ prefix: await this.visitSpace(doWhileLoop.prefix, p),
327
+ markers: await this.visitMarkers(doWhileLoop.markers, p),
328
+ body: await this.visitRightPadded(doWhileLoop.body, p),
329
+ whileCondition: await this.visitLeftPadded(doWhileLoop.whileCondition, p)
330
+ };
331
+ return (0, util_1.updateIfChanged)(doWhileLoop, updates);
332
+ }
333
+ async visitEmpty(empty, p) {
334
+ const expression = await this.visitExpression(empty, p);
335
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Empty) {
336
+ return expression;
337
+ }
338
+ empty = expression;
339
+ const statement = await this.visitStatement(empty, p);
340
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Empty) {
341
+ return statement;
342
+ }
343
+ empty = statement;
344
+ const updates = {
345
+ prefix: await this.visitSpace(empty.prefix, p),
346
+ markers: await this.visitMarkers(empty.markers, p)
347
+ };
348
+ return (0, util_1.updateIfChanged)(empty, updates);
349
+ }
350
+ async visitEnumValue(enumValue, p) {
351
+ const updates = {
352
+ prefix: await this.visitSpace(enumValue.prefix, p),
353
+ markers: await this.visitMarkers(enumValue.markers, p),
354
+ annotations: await (0, util_1.mapAsync)(enumValue.annotations, a => this.visitDefined(a, p)),
355
+ name: await this.visitDefined(enumValue.name, p)
356
+ };
357
+ if (enumValue.initializer) {
358
+ updates.initializer = await this.visitDefined(enumValue.initializer, p);
359
+ }
360
+ return (0, util_1.updateIfChanged)(enumValue, updates);
361
+ }
362
+ async visitEnumValueSet(enumValueSet, p) {
363
+ const statement = await this.visitStatement(enumValueSet, p);
364
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.EnumValueSet) {
365
+ return statement;
366
+ }
367
+ enumValueSet = statement;
368
+ const updates = {
369
+ prefix: await this.visitSpace(enumValueSet.prefix, p),
370
+ markers: await this.visitMarkers(enumValueSet.markers, p),
371
+ enums: await (0, util_1.mapAsync)(enumValueSet.enums, e => this.visitRightPadded(e, p))
372
+ };
373
+ return (0, util_1.updateIfChanged)(enumValueSet, updates);
374
+ }
375
+ async visitErroneous(erroneous, p) {
376
+ const expression = await this.visitExpression(erroneous, p);
377
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Erroneous) {
378
+ return expression;
379
+ }
380
+ erroneous = expression;
381
+ const statement = await this.visitStatement(erroneous, p);
382
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Erroneous) {
383
+ return statement;
384
+ }
385
+ erroneous = statement;
386
+ const updates = {
387
+ prefix: await this.visitSpace(erroneous.prefix, p),
388
+ markers: await this.visitMarkers(erroneous.markers, p)
389
+ };
390
+ return (0, util_1.updateIfChanged)(erroneous, updates);
391
+ }
392
+ async visitFieldAccess(fieldAccess, p) {
393
+ const expression = await this.visitExpression(fieldAccess, p);
394
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.FieldAccess) {
395
+ return expression;
396
+ }
397
+ fieldAccess = expression;
398
+ const statement = await this.visitStatement(fieldAccess, p);
399
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.FieldAccess) {
400
+ return statement;
401
+ }
402
+ fieldAccess = statement;
403
+ const updates = {
404
+ prefix: await this.visitSpace(fieldAccess.prefix, p),
405
+ markers: await this.visitMarkers(fieldAccess.markers, p),
406
+ target: await this.visitDefined(fieldAccess.target, p),
407
+ name: await this.visitLeftPadded(fieldAccess.name, p),
408
+ type: await this.visitType(fieldAccess.type, p)
409
+ };
410
+ return (0, util_1.updateIfChanged)(fieldAccess, updates);
411
+ }
412
+ async visitForEachLoop(forLoop, p) {
413
+ const statement = await this.visitStatement(forLoop, p);
414
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.ForEachLoop) {
415
+ return statement;
416
+ }
417
+ forLoop = statement;
418
+ const updates = {
419
+ prefix: await this.visitSpace(forLoop.prefix, p),
420
+ markers: await this.visitMarkers(forLoop.markers, p),
421
+ control: await this.visitDefined(forLoop.control, p),
422
+ body: await this.visitRightPadded(forLoop.body, p)
423
+ };
424
+ return (0, util_1.updateIfChanged)(forLoop, updates);
425
+ }
426
+ async visitForEachLoopControl(control, p) {
427
+ const updates = {
428
+ prefix: await this.visitSpace(control.prefix, p),
429
+ markers: await this.visitMarkers(control.markers, p),
430
+ variable: await this.visitRightPadded(control.variable, p),
431
+ iterable: await this.visitRightPadded(control.iterable, p)
432
+ };
433
+ return (0, util_1.updateIfChanged)(control, updates);
434
+ }
435
+ async visitForLoop(forLoop, p) {
436
+ const statement = await this.visitStatement(forLoop, p);
437
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.ForLoop) {
438
+ return statement;
439
+ }
440
+ forLoop = statement;
441
+ const updates = {
442
+ prefix: await this.visitSpace(forLoop.prefix, p),
443
+ markers: await this.visitMarkers(forLoop.markers, p),
444
+ control: await this.visitDefined(forLoop.control, p),
445
+ body: await this.visitRightPadded(forLoop.body, p)
446
+ };
447
+ return (0, util_1.updateIfChanged)(forLoop, updates);
448
+ }
449
+ async visitForLoopControl(control, p) {
450
+ const updates = {
451
+ prefix: await this.visitSpace(control.prefix, p),
452
+ markers: await this.visitMarkers(control.markers, p),
453
+ init: await (0, util_1.mapAsync)(control.init, i => this.visitRightPadded(i, p)),
454
+ condition: await this.visitOptionalRightPadded(control.condition, p),
455
+ update: await (0, util_1.mapAsync)(control.update, u => this.visitRightPadded(u, p))
456
+ };
457
+ return (0, util_1.updateIfChanged)(control, updates);
458
+ }
459
+ async visitIdentifier(ident, p) {
460
+ const expression = await this.visitExpression(ident, p);
461
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Identifier) {
462
+ return expression;
463
+ }
464
+ ident = expression;
465
+ const updates = {
466
+ prefix: await this.visitSpace(ident.prefix, p),
467
+ markers: await this.visitMarkers(ident.markers, p),
468
+ annotations: await (0, util_1.mapAsync)(ident.annotations, a => this.visitDefined(a, p)),
469
+ type: await this.visitType(ident.type, p),
470
+ fieldType: await this.visitType(ident.fieldType, p)
471
+ };
472
+ return (0, util_1.updateIfChanged)(ident, updates);
473
+ }
474
+ async visitIf(iff, p) {
475
+ const statement = await this.visitStatement(iff, p);
476
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.If) {
477
+ return statement;
478
+ }
479
+ iff = statement;
480
+ const updates = {
481
+ prefix: await this.visitSpace(iff.prefix, p),
482
+ markers: await this.visitMarkers(iff.markers, p),
483
+ ifCondition: await this.visitDefined(iff.ifCondition, p),
484
+ thenPart: await this.visitRightPadded(iff.thenPart, p)
485
+ };
486
+ if (iff.elsePart) {
487
+ updates.elsePart = await this.visitDefined(iff.elsePart, p);
488
+ }
489
+ return (0, util_1.updateIfChanged)(iff, updates);
490
+ }
491
+ async visitElse(anElse, p) {
492
+ const updates = {
493
+ prefix: await this.visitSpace(anElse.prefix, p),
494
+ markers: await this.visitMarkers(anElse.markers, p),
495
+ body: await this.visitRightPadded(anElse.body, p)
496
+ };
497
+ return (0, util_1.updateIfChanged)(anElse, updates);
498
+ }
499
+ async visitImport(anImport, p) {
500
+ const updates = {
501
+ prefix: await this.visitSpace(anImport.prefix, p),
502
+ markers: await this.visitMarkers(anImport.markers, p),
503
+ static: await this.visitLeftPadded(anImport.static, p),
504
+ qualid: await this.visitDefined(anImport.qualid, p),
505
+ alias: await this.visitOptionalLeftPadded(anImport.alias, p)
506
+ };
507
+ return (0, util_1.updateIfChanged)(anImport, updates);
508
+ }
509
+ async visitInstanceOf(instanceOf, p) {
510
+ const expression = await this.visitExpression(instanceOf, p);
511
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.InstanceOf) {
512
+ return expression;
513
+ }
514
+ instanceOf = expression;
515
+ const updates = {
516
+ prefix: await this.visitSpace(instanceOf.prefix, p),
517
+ markers: await this.visitMarkers(instanceOf.markers, p),
518
+ expression: await this.visitRightPadded(instanceOf.expression, p),
519
+ class: await this.visitDefined(instanceOf.class, p),
520
+ type: await this.visitType(instanceOf.type, p)
521
+ };
522
+ if (instanceOf.pattern) {
523
+ updates.pattern = await this.visitDefined(instanceOf.pattern, p);
524
+ }
525
+ if (instanceOf.modifier) {
526
+ updates.modifier = await this.visitDefined(instanceOf.modifier, p);
527
+ }
528
+ return (0, util_1.updateIfChanged)(instanceOf, updates);
529
+ }
530
+ async visitIntersectionType(intersectionType, p) {
531
+ const expression = await this.visitExpression(intersectionType, p);
532
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.IntersectionType) {
533
+ return expression;
534
+ }
535
+ intersectionType = expression;
536
+ const updates = {
537
+ prefix: await this.visitSpace(intersectionType.prefix, p),
538
+ markers: await this.visitMarkers(intersectionType.markers, p),
539
+ bounds: await this.visitContainer(intersectionType.bounds, p)
540
+ };
541
+ return (0, util_1.updateIfChanged)(intersectionType, updates);
542
+ }
543
+ async visitLabel(label, p) {
544
+ const statement = await this.visitStatement(label, p);
545
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Label) {
546
+ return statement;
547
+ }
548
+ label = statement;
549
+ const updates = {
550
+ prefix: await this.visitSpace(label.prefix, p),
551
+ markers: await this.visitMarkers(label.markers, p),
552
+ label: await this.visitRightPadded(label.label, p),
553
+ statement: await this.visitDefined(label.statement, p)
554
+ };
555
+ return (0, util_1.updateIfChanged)(label, updates);
556
+ }
557
+ async visitLambda(lambda, p) {
558
+ const expression = await this.visitExpression(lambda, p);
559
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Lambda) {
560
+ return expression;
561
+ }
562
+ lambda = expression;
563
+ const statement = await this.visitStatement(lambda, p);
564
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Lambda) {
565
+ return statement;
566
+ }
567
+ lambda = statement;
568
+ const updates = {
569
+ prefix: await this.visitSpace(lambda.prefix, p),
570
+ markers: await this.visitMarkers(lambda.markers, p),
571
+ parameters: await this.visitDefined(lambda.parameters, p),
572
+ arrow: await this.visitSpace(lambda.arrow, p),
573
+ body: await this.visitDefined(lambda.body, p),
574
+ type: await this.visitType(lambda.type, p)
575
+ };
576
+ return (0, util_1.updateIfChanged)(lambda, updates);
577
+ }
578
+ async visitLambdaParameters(params, p) {
579
+ const updates = {
580
+ prefix: await this.visitSpace(params.prefix, p),
581
+ markers: await this.visitMarkers(params.markers, p),
582
+ parameters: await (0, util_1.mapAsync)(params.parameters, param => this.visitRightPadded(param, p))
583
+ };
584
+ return (0, util_1.updateIfChanged)(params, updates);
585
+ }
586
+ async visitLiteral(literal, p) {
587
+ const expression = await this.visitExpression(literal, p);
588
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Literal) {
589
+ return expression;
590
+ }
591
+ literal = expression;
592
+ const updates = {
593
+ prefix: await this.visitSpace(literal.prefix, p),
594
+ markers: await this.visitMarkers(literal.markers, p),
595
+ type: await this.visitType(literal.type, p)
596
+ };
597
+ return (0, util_1.updateIfChanged)(literal, updates);
598
+ }
599
+ async visitMemberReference(memberRef, p) {
600
+ const expression = await this.visitExpression(memberRef, p);
601
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.MemberReference) {
602
+ return expression;
603
+ }
604
+ memberRef = expression;
605
+ const updates = {
606
+ prefix: await this.visitSpace(memberRef.prefix, p),
607
+ markers: await this.visitMarkers(memberRef.markers, p),
608
+ containing: await this.visitRightPadded(memberRef.containing, p),
609
+ typeParameters: await this.visitOptionalContainer(memberRef.typeParameters, p),
610
+ reference: await this.visitLeftPadded(memberRef.reference, p),
611
+ type: await this.visitType(memberRef.type, p),
612
+ methodType: await this.visitType(memberRef.methodType, p),
613
+ variableType: await this.visitType(memberRef.variableType, p)
614
+ };
615
+ return (0, util_1.updateIfChanged)(memberRef, updates);
616
+ }
617
+ async visitMethodDeclaration(method, p) {
618
+ const statement = await this.visitStatement(method, p);
619
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.MethodDeclaration) {
620
+ return statement;
621
+ }
622
+ method = statement;
623
+ const updates = {
624
+ prefix: await this.visitSpace(method.prefix, p),
625
+ markers: await this.visitMarkers(method.markers, p),
626
+ leadingAnnotations: await (0, util_1.mapAsync)(method.leadingAnnotations, a => this.visitDefined(a, p)),
627
+ modifiers: await (0, util_1.mapAsync)(method.modifiers, m => this.visitDefined(m, p)),
628
+ nameAnnotations: await (0, util_1.mapAsync)(method.nameAnnotations, a => this.visitDefined(a, p)),
629
+ name: await this.visitDefined(method.name, p),
630
+ parameters: await this.visitContainer(method.parameters, p),
631
+ throws: method.throws && await this.visitContainer(method.throws, p),
632
+ body: method.body && await this.visitDefined(method.body, p),
633
+ defaultValue: await this.visitOptionalLeftPadded(method.defaultValue, p),
634
+ methodType: await this.visitType(method.methodType, p)
635
+ };
636
+ if (method.typeParameters) {
637
+ updates.typeParameters = await this.visitDefined(method.typeParameters, p);
638
+ }
639
+ if (method.returnTypeExpression) {
640
+ updates.returnTypeExpression = await this.visitDefined(method.returnTypeExpression, p);
641
+ }
642
+ return (0, util_1.updateIfChanged)(method, updates);
643
+ }
644
+ async visitMethodInvocation(method, p) {
645
+ const expression = await this.visitExpression(method, p);
646
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.MethodInvocation) {
647
+ return expression;
648
+ }
649
+ method = expression;
650
+ const statement = await this.visitStatement(method, p);
651
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.MethodInvocation) {
652
+ return statement;
653
+ }
654
+ method = statement;
655
+ const updates = {
656
+ prefix: await this.visitSpace(method.prefix, p),
657
+ markers: await this.visitMarkers(method.markers, p),
658
+ select: await this.visitOptionalRightPadded(method.select, p),
659
+ typeParameters: await this.visitOptionalContainer(method.typeParameters, p),
660
+ name: await this.visitDefined(method.name, p),
661
+ arguments: await this.visitContainer(method.arguments, p),
662
+ methodType: await this.visitType(method.methodType, p)
663
+ };
664
+ return (0, util_1.updateIfChanged)(method, updates);
665
+ }
666
+ async visitModifier(modifier, p) {
667
+ const updates = {
668
+ prefix: await this.visitSpace(modifier.prefix, p),
669
+ markers: await this.visitMarkers(modifier.markers, p),
670
+ annotations: await (0, util_1.mapAsync)(modifier.annotations, a => this.visitDefined(a, p))
671
+ };
672
+ return (0, util_1.updateIfChanged)(modifier, updates);
673
+ }
674
+ async visitMultiCatch(multiCatch, p) {
675
+ const updates = {
676
+ prefix: await this.visitSpace(multiCatch.prefix, p),
677
+ markers: await this.visitMarkers(multiCatch.markers, p),
678
+ alternatives: await (0, util_1.mapAsync)(multiCatch.alternatives, alt => this.visitRightPadded(alt, p))
679
+ };
680
+ return (0, util_1.updateIfChanged)(multiCatch, updates);
681
+ }
682
+ async visitNewArray(newArray, p) {
683
+ const expression = await this.visitExpression(newArray, p);
684
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.NewArray) {
685
+ return expression;
686
+ }
687
+ newArray = expression;
688
+ const updates = {
689
+ prefix: await this.visitSpace(newArray.prefix, p),
690
+ markers: await this.visitMarkers(newArray.markers, p),
691
+ dimensions: await (0, util_1.mapAsync)(newArray.dimensions, dim => this.visitDefined(dim, p)),
692
+ initializer: await this.visitOptionalContainer(newArray.initializer, p),
693
+ type: await this.visitType(newArray.type, p)
694
+ };
695
+ if (newArray.typeExpression) {
696
+ updates.typeExpression = await this.visitDefined(newArray.typeExpression, p);
697
+ }
698
+ return (0, util_1.updateIfChanged)(newArray, updates);
699
+ }
700
+ async visitNewClass(newClass, p) {
701
+ const expression = await this.visitExpression(newClass, p);
702
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.NewClass) {
703
+ return expression;
704
+ }
705
+ newClass = expression;
706
+ const updates = {
707
+ prefix: await this.visitSpace(newClass.prefix, p),
708
+ markers: await this.visitMarkers(newClass.markers, p),
709
+ new: await this.visitSpace(newClass.new, p),
710
+ arguments: await this.visitContainer(newClass.arguments, p),
711
+ constructorType: await this.visitType(newClass.constructorType, p)
712
+ };
713
+ if (newClass.enclosing) {
714
+ updates.enclosing = await this.visitRightPadded(newClass.enclosing, p);
715
+ }
716
+ if (newClass.class) {
717
+ updates.class = await this.visitDefined(newClass.class, p);
718
+ }
719
+ if (newClass.body) {
720
+ updates.body = await this.visitDefined(newClass.body, p);
721
+ }
722
+ return (0, util_1.updateIfChanged)(newClass, updates);
723
+ }
724
+ async visitNullableType(nullableType, p) {
725
+ const expression = await this.visitExpression(nullableType, p);
726
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.NullableType) {
727
+ return expression;
728
+ }
729
+ nullableType = expression;
730
+ const updates = {
731
+ prefix: await this.visitSpace(nullableType.prefix, p),
732
+ markers: await this.visitMarkers(nullableType.markers, p),
733
+ annotations: await (0, util_1.mapAsync)(nullableType.annotations, a => this.visitDefined(a, p)),
734
+ typeTree: await this.visitRightPadded(nullableType.typeTree, p)
735
+ };
736
+ return (0, util_1.updateIfChanged)(nullableType, updates);
737
+ }
738
+ async visitPackage(aPackage, p) {
739
+ const updates = {
740
+ prefix: await this.visitSpace(aPackage.prefix, p),
741
+ markers: await this.visitMarkers(aPackage.markers, p),
742
+ expression: await this.visitDefined(aPackage.expression, p)
743
+ };
744
+ if (aPackage.annotations) {
745
+ updates.annotations = await (0, util_1.mapAsync)(aPackage.annotations, a => this.visitDefined(a, p));
746
+ }
747
+ return (0, util_1.updateIfChanged)(aPackage, updates);
748
+ }
749
+ async visitParameterizedType(parameterizedType, p) {
750
+ const updates = {
751
+ prefix: await this.visitSpace(parameterizedType.prefix, p),
752
+ markers: await this.visitMarkers(parameterizedType.markers, p),
753
+ class: await this.visitTypeName(parameterizedType.class, p),
754
+ typeParameters: await this.visitOptionalContainer(parameterizedType.typeParameters, p),
755
+ type: await this.visitType(parameterizedType.type, p)
756
+ };
757
+ return (0, util_1.updateIfChanged)(parameterizedType, updates);
758
+ }
759
+ async visitParentheses(parentheses, p) {
760
+ const updates = {
761
+ prefix: await this.visitSpace(parentheses.prefix, p),
762
+ markers: await this.visitMarkers(parentheses.markers, p),
763
+ tree: await this.visitRightPadded(parentheses.tree, p)
764
+ };
765
+ return (0, util_1.updateIfChanged)(parentheses, updates);
766
+ }
767
+ async visitParenthesizedTypeTree(parTypeTree, p) {
768
+ const expression = await this.visitExpression(parTypeTree, p);
769
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.ParenthesizedTypeTree) {
770
+ return expression;
771
+ }
772
+ parTypeTree = expression;
773
+ const updates = {
774
+ prefix: await this.visitSpace(parTypeTree.prefix, p),
775
+ markers: await this.visitMarkers(parTypeTree.markers, p),
776
+ annotations: await (0, util_1.mapAsync)(parTypeTree.annotations, a => this.visitDefined(a, p)),
777
+ parenthesizedType: await this.visitDefined(parTypeTree.parenthesizedType, p)
778
+ };
779
+ return (0, util_1.updateIfChanged)(parTypeTree, updates);
780
+ }
781
+ async visitPrimitive(primitive, p) {
782
+ const expression = await this.visitExpression(primitive, p);
783
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Primitive) {
784
+ return expression;
785
+ }
786
+ primitive = expression;
787
+ const updates = {
788
+ prefix: await this.visitSpace(primitive.prefix, p),
789
+ markers: await this.visitMarkers(primitive.markers, p),
790
+ type: await this.visitType(primitive.type, p)
791
+ };
792
+ return (0, util_1.updateIfChanged)(primitive, updates);
793
+ }
794
+ async visitReturn(ret, p) {
795
+ const statement = await this.visitStatement(ret, p);
796
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Return) {
797
+ return statement;
798
+ }
799
+ ret = statement;
800
+ const updates = {
801
+ prefix: await this.visitSpace(ret.prefix, p),
802
+ markers: await this.visitMarkers(ret.markers, p)
803
+ };
804
+ if (ret.expression) {
805
+ updates.expression = await this.visitDefined(ret.expression, p);
806
+ }
807
+ return (0, util_1.updateIfChanged)(ret, updates);
808
+ }
809
+ async visitSwitch(aSwitch, p) {
810
+ const statement = await this.visitStatement(aSwitch, p);
811
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Switch) {
812
+ return statement;
813
+ }
814
+ aSwitch = statement;
815
+ const updates = {
816
+ prefix: await this.visitSpace(aSwitch.prefix, p),
817
+ markers: await this.visitMarkers(aSwitch.markers, p),
818
+ selector: await this.visitDefined(aSwitch.selector, p),
819
+ cases: await this.visitDefined(aSwitch.cases, p)
820
+ };
821
+ return (0, util_1.updateIfChanged)(aSwitch, updates);
822
+ }
823
+ async visitSwitchExpression(switchExpr, p) {
824
+ const expression = await this.visitExpression(switchExpr, p);
825
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.SwitchExpression) {
826
+ return expression;
827
+ }
828
+ switchExpr = expression;
829
+ const updates = {
830
+ prefix: await this.visitSpace(switchExpr.prefix, p),
831
+ markers: await this.visitMarkers(switchExpr.markers, p),
832
+ selector: await this.visitDefined(switchExpr.selector, p),
833
+ cases: await this.visitDefined(switchExpr.cases, p),
834
+ type: await this.visitType(switchExpr.type, p)
835
+ };
836
+ return (0, util_1.updateIfChanged)(switchExpr, updates);
837
+ }
838
+ async visitSynchronized(sync, p) {
839
+ const statement = await this.visitStatement(sync, p);
840
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Synchronized) {
841
+ return statement;
842
+ }
843
+ sync = statement;
844
+ const updates = {
845
+ prefix: await this.visitSpace(sync.prefix, p),
846
+ markers: await this.visitMarkers(sync.markers, p),
847
+ lock: await this.visitDefined(sync.lock, p),
848
+ body: await this.visitDefined(sync.body, p)
849
+ };
850
+ return (0, util_1.updateIfChanged)(sync, updates);
851
+ }
852
+ async visitTernary(ternary, p) {
853
+ const expression = await this.visitExpression(ternary, p);
854
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Ternary) {
855
+ return expression;
856
+ }
857
+ ternary = expression;
858
+ const statement = await this.visitStatement(ternary, p);
859
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Ternary) {
860
+ return statement;
861
+ }
862
+ ternary = statement;
863
+ const updates = {
864
+ prefix: await this.visitSpace(ternary.prefix, p),
865
+ markers: await this.visitMarkers(ternary.markers, p),
866
+ condition: await this.visitDefined(ternary.condition, p),
867
+ truePart: await this.visitLeftPadded(ternary.truePart, p),
868
+ falsePart: await this.visitLeftPadded(ternary.falsePart, p),
869
+ type: await this.visitType(ternary.type, p)
870
+ };
871
+ return (0, util_1.updateIfChanged)(ternary, updates);
872
+ }
873
+ async visitThrow(thrown, p) {
874
+ const statement = await this.visitStatement(thrown, p);
875
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Throw) {
876
+ return statement;
877
+ }
878
+ thrown = statement;
879
+ const updates = {
880
+ prefix: await this.visitSpace(thrown.prefix, p),
881
+ markers: await this.visitMarkers(thrown.markers, p),
882
+ exception: await this.visitDefined(thrown.exception, p)
883
+ };
884
+ return (0, util_1.updateIfChanged)(thrown, updates);
885
+ }
886
+ async visitTry(tryable, p) {
887
+ const statement = await this.visitStatement(tryable, p);
888
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Try) {
889
+ return statement;
890
+ }
891
+ tryable = statement;
892
+ const updates = {
893
+ prefix: await this.visitSpace(tryable.prefix, p),
894
+ markers: await this.visitMarkers(tryable.markers, p),
895
+ resources: await this.visitOptionalContainer(tryable.resources, p),
896
+ body: await this.visitDefined(tryable.body, p),
897
+ catches: await (0, util_1.mapAsync)(tryable.catches, c => this.visitDefined(c, p)),
898
+ finally: await this.visitOptionalLeftPadded(tryable.finally, p)
899
+ };
900
+ return (0, util_1.updateIfChanged)(tryable, updates);
901
+ }
902
+ async visitTryResource(resource, p) {
903
+ const updates = {
904
+ prefix: await this.visitSpace(resource.prefix, p),
905
+ markers: await this.visitMarkers(resource.markers, p),
906
+ variableDeclarations: await this.visitDefined(resource.variableDeclarations, p)
907
+ };
908
+ return (0, util_1.updateIfChanged)(resource, updates);
909
+ }
910
+ async visitTryCatch(tryCatch, p) {
911
+ const updates = {
912
+ prefix: await this.visitSpace(tryCatch.prefix, p),
913
+ markers: await this.visitMarkers(tryCatch.markers, p),
914
+ parameter: await this.visitDefined(tryCatch.parameter, p),
915
+ body: await this.visitDefined(tryCatch.body, p)
916
+ };
917
+ return (0, util_1.updateIfChanged)(tryCatch, updates);
918
+ }
919
+ async visitTypeCast(typeCast, p) {
920
+ const expression = await this.visitExpression(typeCast, p);
921
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.TypeCast) {
922
+ return expression;
923
+ }
924
+ typeCast = expression;
925
+ const updates = {
926
+ prefix: await this.visitSpace(typeCast.prefix, p),
927
+ markers: await this.visitMarkers(typeCast.markers, p),
928
+ class: await this.visitDefined(typeCast.class, p),
929
+ expression: await this.visitDefined(typeCast.expression, p)
930
+ };
931
+ return (0, util_1.updateIfChanged)(typeCast, updates);
932
+ }
933
+ async visitTypeParameter(typeParam, p) {
934
+ const updates = {
935
+ prefix: await this.visitSpace(typeParam.prefix, p),
936
+ markers: await this.visitMarkers(typeParam.markers, p),
937
+ annotations: await (0, util_1.mapAsync)(typeParam.annotations, a => this.visitDefined(a, p)),
938
+ modifiers: await (0, util_1.mapAsync)(typeParam.modifiers, m => this.visitDefined(m, p)),
939
+ name: await this.visitDefined(typeParam.name, p),
940
+ bounds: await this.visitOptionalContainer(typeParam.bounds, p)
941
+ };
942
+ return (0, util_1.updateIfChanged)(typeParam, updates);
943
+ }
944
+ async visitTypeParameters(typeParams, p) {
945
+ const updates = {
946
+ prefix: await this.visitSpace(typeParams.prefix, p),
947
+ markers: await this.visitMarkers(typeParams.markers, p),
948
+ annotations: await (0, util_1.mapAsync)(typeParams.annotations, a => this.visitDefined(a, p)),
949
+ typeParameters: await (0, util_1.mapAsync)(typeParams.typeParameters, tp => this.visitRightPadded(tp, p))
950
+ };
951
+ return (0, util_1.updateIfChanged)(typeParams, updates);
952
+ }
953
+ async visitUnary(unary, p) {
954
+ const expression = await this.visitExpression(unary, p);
955
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Unary) {
956
+ return expression;
957
+ }
958
+ unary = expression;
959
+ const statement = await this.visitStatement(unary, p);
960
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Unary) {
961
+ return statement;
962
+ }
963
+ unary = statement;
964
+ const updates = {
965
+ prefix: await this.visitSpace(unary.prefix, p),
966
+ markers: await this.visitMarkers(unary.markers, p),
967
+ operator: await this.visitLeftPadded(unary.operator, p),
968
+ expression: await this.visitDefined(unary.expression, p),
969
+ type: await this.visitType(unary.type, p)
970
+ };
971
+ return (0, util_1.updateIfChanged)(unary, updates);
972
+ }
973
+ async visitUnknown(unknown, p) {
974
+ const expression = await this.visitExpression(unknown, p);
975
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Unknown) {
976
+ return expression;
977
+ }
978
+ unknown = expression;
979
+ const statement = await this.visitStatement(unknown, p);
980
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Unknown) {
981
+ return statement;
982
+ }
983
+ unknown = statement;
984
+ const updates = {
985
+ prefix: await this.visitSpace(unknown.prefix, p),
986
+ markers: await this.visitMarkers(unknown.markers, p),
987
+ source: await this.visitDefined(unknown.source, p)
988
+ };
989
+ return (0, util_1.updateIfChanged)(unknown, updates);
990
+ }
991
+ async visitUnknownSource(source, p) {
992
+ const updates = {
993
+ prefix: await this.visitSpace(source.prefix, p),
994
+ markers: await this.visitMarkers(source.markers, p)
995
+ };
996
+ return (0, util_1.updateIfChanged)(source, updates);
997
+ }
998
+ async visitVariableDeclarations(varDecls, p) {
999
+ const statement = await this.visitStatement(varDecls, p);
1000
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.VariableDeclarations) {
1001
+ return statement;
1002
+ }
1003
+ varDecls = statement;
1004
+ const updates = {
1005
+ prefix: await this.visitSpace(varDecls.prefix, p),
1006
+ markers: await this.visitMarkers(varDecls.markers, p),
1007
+ leadingAnnotations: await (0, util_1.mapAsync)(varDecls.leadingAnnotations, a => this.visitDefined(a, p)),
1008
+ modifiers: await (0, util_1.mapAsync)(varDecls.modifiers, m => this.visitDefined(m, p)),
1009
+ variables: await (0, util_1.mapAsync)(varDecls.variables, v => this.visitRightPadded(v, p))
1010
+ };
1011
+ if (varDecls.typeExpression) {
1012
+ updates.typeExpression = await this.visitDefined(varDecls.typeExpression, p);
1013
+ }
1014
+ if (varDecls.varargs) {
1015
+ updates.varargs = await this.visitSpace(varDecls.varargs, p);
1016
+ }
1017
+ return (0, util_1.updateIfChanged)(varDecls, updates);
1018
+ }
1019
+ async visitVariable(variable, p) {
1020
+ const updates = {
1021
+ prefix: await this.visitSpace(variable.prefix, p),
1022
+ markers: await this.visitMarkers(variable.markers, p),
1023
+ name: await this.visitDefined(variable.name, p),
1024
+ dimensionsAfterName: await (0, util_1.mapAsync)(variable.dimensionsAfterName, dim => this.visitLeftPadded(dim, p)),
1025
+ initializer: await this.visitOptionalLeftPadded(variable.initializer, p),
1026
+ variableType: await this.visitType(variable.variableType, p)
1027
+ };
1028
+ return (0, util_1.updateIfChanged)(variable, updates);
1029
+ }
1030
+ async visitWhileLoop(whileLoop, p) {
1031
+ const statement = await this.visitStatement(whileLoop, p);
1032
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.WhileLoop) {
1033
+ return statement;
1034
+ }
1035
+ whileLoop = statement;
1036
+ const updates = {
1037
+ prefix: await this.visitSpace(whileLoop.prefix, p),
1038
+ markers: await this.visitMarkers(whileLoop.markers, p),
1039
+ condition: await this.visitDefined(whileLoop.condition, p),
1040
+ body: await this.visitRightPadded(whileLoop.body, p)
1041
+ };
1042
+ return (0, util_1.updateIfChanged)(whileLoop, updates);
1043
+ }
1044
+ async visitWildcard(wildcard, p) {
1045
+ const expression = await this.visitExpression(wildcard, p);
1046
+ if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.Wildcard) {
1047
+ return expression;
1048
+ }
1049
+ wildcard = expression;
1050
+ const updates = {
1051
+ prefix: await this.visitSpace(wildcard.prefix, p),
1052
+ markers: await this.visitMarkers(wildcard.markers, p),
1053
+ bound: await this.visitOptionalLeftPadded(wildcard.bound, p)
1054
+ };
1055
+ if (wildcard.boundedType) {
1056
+ updates.boundedType = await this.visitTypeName(wildcard.boundedType, p);
1057
+ }
1058
+ return (0, util_1.updateIfChanged)(wildcard, updates);
1059
+ }
1060
+ async visitYield(aYield, p) {
1061
+ const statement = await this.visitStatement(aYield, p);
1062
+ if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.Yield) {
1063
+ return statement;
1064
+ }
1065
+ aYield = statement;
1066
+ const updates = {
1067
+ prefix: await this.visitSpace(aYield.prefix, p),
1068
+ markers: await this.visitMarkers(aYield.markers, p),
1069
+ value: await this.visitDefined(aYield.value, p)
1070
+ };
1071
+ return (0, util_1.updateIfChanged)(aYield, updates);
1072
+ }
1073
+ async visitOptionalRightPadded(right, p) {
1074
+ return right ? this.visitRightPadded(right, p) : undefined;
1075
+ }
1076
+ async visitRightPadded(right, p) {
1077
+ this.cursor = new tree_1.Cursor(right, this.cursor);
1078
+ const element = (0, tree_1.isTree)(right.element) ? await this.visitDefined(right.element, p) : right.element;
1079
+ const after = await this.visitSpace(right.after, p);
1080
+ const markers = await this.visitMarkers(right.markers, p);
1081
+ this.cursor = this.cursor.parent;
1082
+ if (element === undefined) {
1083
+ return undefined;
1084
+ }
1085
+ return (0, util_1.updateIfChanged)(right, { element, after, markers });
1086
+ }
1087
+ async visitOptionalLeftPadded(left, p) {
1088
+ return left ? this.visitLeftPadded(left, p) : undefined;
1089
+ }
1090
+ async visitLeftPadded(left, p) {
1091
+ this.cursor = new tree_1.Cursor(left, this.cursor);
1092
+ const before = await this.visitSpace(left.before, p);
1093
+ let element = left.element;
1094
+ if ((0, tree_1.isTree)(left.element)) {
1095
+ element = await this.visitDefined(left.element, p);
1096
+ }
1097
+ else if ((0, tree_2.isSpace)(left.element)) {
1098
+ element = await this.visitSpace(left.element, p);
1099
+ }
1100
+ const markers = await this.visitMarkers(left.markers, p);
1101
+ this.cursor = this.cursor.parent;
1102
+ if (element === undefined) {
1103
+ return undefined;
1104
+ }
1105
+ return (0, util_1.updateIfChanged)(left, { before, element, markers });
1106
+ }
1107
+ async visitOptionalContainer(container, p) {
1108
+ return container ? this.visitContainer(container, p) : undefined;
1109
+ }
1110
+ async visitContainer(container, p) {
1111
+ this.cursor = new tree_1.Cursor(container, this.cursor);
1112
+ const before = await this.visitSpace(container.before, p);
1113
+ const elements = await (0, util_1.mapAsync)(container.elements, e => this.visitRightPadded(e, p));
1114
+ const markers = await this.visitMarkers(container.markers, p);
1115
+ this.cursor = this.cursor.parent;
1116
+ return (0, util_1.updateIfChanged)(container, { before, elements, markers });
1117
+ }
1118
+ async produceJava(before, p, recipe) {
1119
+ const [draft, finishDraft] = (0, mutative_1.create)(before);
1120
+ draft.prefix = await this.visitSpace(before.prefix, p);
1121
+ draft.markers = await this.visitMarkers(before.markers, p);
1122
+ if (recipe) {
1123
+ await recipe(draft);
1124
+ }
1125
+ return finishDraft();
1303
1126
  }
1304
1127
  accept(t, p) {
1305
1128
  switch (t.kind) {