@openrewrite/rewrite 8.96.4 → 8.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/execution.d.ts +2 -0
  2. package/dist/execution.d.ts.map +1 -1
  3. package/dist/execution.js +4 -0
  4. package/dist/execution.js.map +1 -1
  5. package/dist/heavyweight.d.ts +8 -0
  6. package/dist/heavyweight.d.ts.map +1 -0
  7. package/dist/heavyweight.js +45 -0
  8. package/dist/heavyweight.js.map +1 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/java/tree.d.ts +2 -1
  14. package/dist/java/tree.d.ts.map +1 -1
  15. package/dist/java/tree.js.map +1 -1
  16. package/dist/java/visitor.d.ts +5 -0
  17. package/dist/java/visitor.d.ts.map +1 -1
  18. package/dist/java/visitor.js +264 -217
  19. package/dist/java/visitor.js.map +1 -1
  20. package/dist/javascript/add-import.d.ts +2 -1
  21. package/dist/javascript/add-import.d.ts.map +1 -1
  22. package/dist/javascript/add-import.js +14 -2
  23. package/dist/javascript/add-import.js.map +1 -1
  24. package/dist/javascript/amd.d.ts.map +1 -1
  25. package/dist/javascript/amd.js +2 -1
  26. package/dist/javascript/amd.js.map +1 -1
  27. package/dist/javascript/cleanup/add-parse-int-radix.js +1 -1
  28. package/dist/javascript/cleanup/add-parse-int-radix.js.map +1 -1
  29. package/dist/javascript/dependency-workspace.d.ts +8 -2
  30. package/dist/javascript/dependency-workspace.d.ts.map +1 -1
  31. package/dist/javascript/dependency-workspace.js +36 -4
  32. package/dist/javascript/dependency-workspace.js.map +1 -1
  33. package/dist/javascript/format/format.d.ts +10 -0
  34. package/dist/javascript/format/format.d.ts.map +1 -1
  35. package/dist/javascript/format/format.js +10 -2
  36. package/dist/javascript/format/format.js.map +1 -1
  37. package/dist/javascript/format/tabs-and-indents-visitor.d.ts.map +1 -1
  38. package/dist/javascript/format/tabs-and-indents-visitor.js +4 -0
  39. package/dist/javascript/format/tabs-and-indents-visitor.js.map +1 -1
  40. package/dist/javascript/format/whitespace-reconciler.d.ts.map +1 -1
  41. package/dist/javascript/format/whitespace-reconciler.js +4 -0
  42. package/dist/javascript/format/whitespace-reconciler.js.map +1 -1
  43. package/dist/javascript/node-resolution-result.d.ts.map +1 -1
  44. package/dist/javascript/node-resolution-result.js +2 -0
  45. package/dist/javascript/node-resolution-result.js.map +1 -1
  46. package/dist/javascript/parser-utils.d.ts.map +1 -1
  47. package/dist/javascript/parser-utils.js +9 -6
  48. package/dist/javascript/parser-utils.js.map +1 -1
  49. package/dist/javascript/templating/engine.d.ts +1 -0
  50. package/dist/javascript/templating/engine.d.ts.map +1 -1
  51. package/dist/javascript/templating/engine.js +39 -10
  52. package/dist/javascript/templating/engine.js.map +1 -1
  53. package/dist/javascript/templating/pattern.d.ts.map +1 -1
  54. package/dist/javascript/templating/pattern.js +8 -0
  55. package/dist/javascript/templating/pattern.js.map +1 -1
  56. package/dist/javascript/templating/placeholder-replacement.d.ts +2 -0
  57. package/dist/javascript/templating/placeholder-replacement.d.ts.map +1 -1
  58. package/dist/javascript/templating/placeholder-replacement.js +37 -1
  59. package/dist/javascript/templating/placeholder-replacement.js.map +1 -1
  60. package/dist/javascript/visitor.d.ts.map +1 -1
  61. package/dist/javascript/visitor.js +153 -118
  62. package/dist/javascript/visitor.js.map +1 -1
  63. package/dist/recipe.d.ts +5 -0
  64. package/dist/recipe.d.ts.map +1 -1
  65. package/dist/recipe.js +5 -0
  66. package/dist/recipe.js.map +1 -1
  67. package/dist/rewrite-javascript-version.txt +1 -1
  68. package/dist/run.d.ts +7 -1
  69. package/dist/run.d.ts.map +1 -1
  70. package/dist/run.js +40 -2
  71. package/dist/run.js.map +1 -1
  72. package/dist/test/accumulator-contents.d.ts +15 -0
  73. package/dist/test/accumulator-contents.d.ts.map +1 -0
  74. package/dist/test/accumulator-contents.js +185 -0
  75. package/dist/test/accumulator-contents.js.map +1 -0
  76. package/dist/test/empty-sources.d.ts +14 -0
  77. package/dist/test/empty-sources.d.ts.map +1 -0
  78. package/dist/test/empty-sources.js +98 -0
  79. package/dist/test/empty-sources.js.map +1 -0
  80. package/dist/test/formatting-scope.d.ts +18 -0
  81. package/dist/test/formatting-scope.d.ts.map +1 -0
  82. package/dist/test/formatting-scope.js +244 -0
  83. package/dist/test/formatting-scope.js.map +1 -0
  84. package/dist/test/probes.d.ts +25 -0
  85. package/dist/test/probes.d.ts.map +1 -0
  86. package/dist/test/probes.js +189 -0
  87. package/dist/test/probes.js.map +1 -0
  88. package/dist/test/rewrite-test.d.ts +27 -0
  89. package/dist/test/rewrite-test.d.ts.map +1 -1
  90. package/dist/test/rewrite-test.js +191 -21
  91. package/dist/test/rewrite-test.js.map +1 -1
  92. package/dist/test/tree-shapes.d.ts +15 -0
  93. package/dist/test/tree-shapes.d.ts.map +1 -0
  94. package/dist/test/tree-shapes.js +288 -0
  95. package/dist/test/tree-shapes.js.map +1 -0
  96. package/dist/test/unparsed-sources.d.ts +17 -0
  97. package/dist/test/unparsed-sources.d.ts.map +1 -0
  98. package/dist/test/unparsed-sources.js +113 -0
  99. package/dist/test/unparsed-sources.js.map +1 -0
  100. package/dist/tree.d.ts.map +1 -1
  101. package/dist/tree.js +2 -0
  102. package/dist/tree.js.map +1 -1
  103. package/dist/visitor.d.ts.map +1 -1
  104. package/dist/visitor.js +2 -0
  105. package/dist/visitor.js.map +1 -1
  106. package/package.json +1 -1
  107. package/src/execution.ts +6 -0
  108. package/src/heavyweight.ts +42 -0
  109. package/src/index.ts +1 -0
  110. package/src/java/tree.ts +2 -1
  111. package/src/java/visitor.ts +263 -216
  112. package/src/javascript/add-import.ts +11 -2
  113. package/src/javascript/amd.ts +4 -2
  114. package/src/javascript/cleanup/add-parse-int-radix.ts +2 -2
  115. package/src/javascript/dependency-workspace.ts +35 -3
  116. package/src/javascript/format/format.ts +18 -0
  117. package/src/javascript/format/tabs-and-indents-visitor.ts +4 -0
  118. package/src/javascript/format/whitespace-reconciler.ts +4 -0
  119. package/src/javascript/node-resolution-result.ts +3 -0
  120. package/src/javascript/parser-utils.ts +10 -6
  121. package/src/javascript/templating/engine.ts +41 -9
  122. package/src/javascript/templating/pattern.ts +10 -0
  123. package/src/javascript/templating/placeholder-replacement.ts +38 -1
  124. package/src/javascript/visitor.ts +166 -118
  125. package/src/recipe.ts +5 -0
  126. package/src/run.ts +30 -2
  127. package/src/test/accumulator-contents.ts +194 -0
  128. package/src/test/empty-sources.ts +99 -0
  129. package/src/test/formatting-scope.ts +231 -0
  130. package/src/test/probes.ts +156 -0
  131. package/src/test/rewrite-test.ts +177 -24
  132. package/src/test/tree-shapes.ts +332 -0
  133. package/src/test/unparsed-sources.ts +138 -0
  134. package/src/tree.ts +3 -0
  135. package/src/visitor.ts +3 -0
@@ -64,18 +64,36 @@ class JavaVisitor extends visitor_1.TreeVisitor {
64
64
  async visitTypeName(nameTree, p) {
65
65
  return nameTree;
66
66
  }
67
+ /**
68
+ * Visits the children of `tree` through `visit` under a cursor that holds it, where a visit made it of the tree
69
+ * on the cursor, and puts the given cursor back after with the messages they left.
70
+ */
71
+ visitChildrenOf(tree, visit) {
72
+ var _a;
73
+ const given = this.cursor;
74
+ if (given.value === tree || ((_a = given.value) === null || _a === void 0 ? void 0 : _a.kind) !== tree.kind) {
75
+ return visit();
76
+ }
77
+ this.cursor = new tree_1.Cursor(tree, given.parent);
78
+ given.messages.forEach((value, key) => this.cursor.messages.set(key, value));
79
+ return visit().then(visited => {
80
+ this.cursor.messages.forEach((value, key) => given.messages.set(key, value));
81
+ this.cursor = given;
82
+ return visited;
83
+ });
84
+ }
67
85
  async visitAnnotatedType(annotatedType, p) {
68
86
  const expression = await this.visitExpression(annotatedType, p);
69
87
  if (!(expression === null || expression === void 0 ? void 0 : expression.kind) || expression.kind !== tree_2.J.Kind.AnnotatedType) {
70
88
  return expression;
71
89
  }
72
90
  annotatedType = expression;
73
- const updates = {
91
+ const updates = await this.visitChildrenOf(annotatedType, async () => ({
74
92
  prefix: await this.visitSpace(annotatedType.prefix, p),
75
93
  markers: await this.visitMarkers(annotatedType.markers, p),
76
94
  annotations: await (0, util_1.mapAsync)(annotatedType.annotations, a => this.visitDefined(a, p)),
77
95
  typeExpression: await this.visitDefined(annotatedType.typeExpression, p)
78
- };
96
+ }));
79
97
  return (0, util_1.updateIfChanged)(annotatedType, updates);
80
98
  }
81
99
  async visitAnnotation(annotation, p) {
@@ -84,12 +102,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
84
102
  return expression;
85
103
  }
86
104
  annotation = expression;
87
- const updates = {
105
+ const updates = await this.visitChildrenOf(annotation, async () => ({
88
106
  prefix: await this.visitSpace(annotation.prefix, p),
89
107
  markers: await this.visitMarkers(annotation.markers, p),
90
108
  annotationType: await this.visitTypeName(annotation.annotationType, p),
91
109
  arguments: await this.visitOptionalContainer(annotation.arguments, p)
92
- };
110
+ }));
93
111
  return (0, util_1.updateIfChanged)(annotation, updates);
94
112
  }
95
113
  async visitArrayAccess(arrayAccess, p) {
@@ -98,12 +116,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
98
116
  return expression;
99
117
  }
100
118
  arrayAccess = expression;
101
- const updates = {
119
+ const updates = await this.visitChildrenOf(arrayAccess, async () => ({
102
120
  prefix: await this.visitSpace(arrayAccess.prefix, p),
103
121
  markers: await this.visitMarkers(arrayAccess.markers, p),
104
122
  indexed: await this.visitDefined(arrayAccess.indexed, p),
105
123
  dimension: await this.visitDefined(arrayAccess.dimension, p)
106
- };
124
+ }));
107
125
  return (0, util_1.updateIfChanged)(arrayAccess, updates);
108
126
  }
109
127
  async visitArrayDimension(arrayDimension, p) {
@@ -120,17 +138,19 @@ class JavaVisitor extends visitor_1.TreeVisitor {
120
138
  return expression;
121
139
  }
122
140
  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);
141
+ return this.visitChildrenOf(arrayType, async () => {
142
+ const updates = {
143
+ prefix: await this.visitSpace(arrayType.prefix, p),
144
+ markers: await this.visitMarkers(arrayType.markers, p),
145
+ elementType: await this.visitDefined(arrayType.elementType, p),
146
+ dimension: await this.visitLeftPadded(arrayType.dimension, p),
147
+ type: await this.visitType(arrayType.type, p)
148
+ };
149
+ if (arrayType.annotations) {
150
+ updates.annotations = await (0, util_1.mapAsync)(arrayType.annotations, a => this.visitDefined(a, p));
151
+ }
152
+ return (0, util_1.updateIfChanged)(arrayType, updates);
153
+ });
134
154
  }
135
155
  async visitAssert(anAssert, p) {
136
156
  const statement = await this.visitStatement(anAssert, p);
@@ -138,12 +158,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
138
158
  return statement;
139
159
  }
140
160
  anAssert = statement;
141
- const updates = {
161
+ const updates = await this.visitChildrenOf(anAssert, async () => ({
142
162
  prefix: await this.visitSpace(anAssert.prefix, p),
143
163
  markers: await this.visitMarkers(anAssert.markers, p),
144
164
  condition: await this.visitDefined(anAssert.condition, p),
145
165
  detail: await this.visitOptionalLeftPadded(anAssert.detail, p)
146
- };
166
+ }));
147
167
  return (0, util_1.updateIfChanged)(anAssert, updates);
148
168
  }
149
169
  async visitAssignment(assignment, p) {
@@ -157,13 +177,13 @@ class JavaVisitor extends visitor_1.TreeVisitor {
157
177
  return statement;
158
178
  }
159
179
  assignment = statement;
160
- const updates = {
180
+ const updates = await this.visitChildrenOf(assignment, async () => ({
161
181
  prefix: await this.visitSpace(assignment.prefix, p),
162
182
  markers: await this.visitMarkers(assignment.markers, p),
163
183
  variable: await this.visitDefined(assignment.variable, p),
164
184
  assignment: await this.visitLeftPadded(assignment.assignment, p),
165
185
  type: await this.visitType(assignment.type, p)
166
- };
186
+ }));
167
187
  return (0, util_1.updateIfChanged)(assignment, updates);
168
188
  }
169
189
  async visitAssignmentOperation(assignOp, p) {
@@ -177,14 +197,14 @@ class JavaVisitor extends visitor_1.TreeVisitor {
177
197
  return statement;
178
198
  }
179
199
  assignOp = statement;
180
- const updates = {
200
+ const updates = await this.visitChildrenOf(assignOp, async () => ({
181
201
  prefix: await this.visitSpace(assignOp.prefix, p),
182
202
  markers: await this.visitMarkers(assignOp.markers, p),
183
203
  variable: await this.visitDefined(assignOp.variable, p),
184
204
  operator: await this.visitLeftPadded(assignOp.operator, p),
185
205
  assignment: await this.visitDefined(assignOp.assignment, p),
186
206
  type: await this.visitType(assignOp.type, p)
187
- };
207
+ }));
188
208
  return (0, util_1.updateIfChanged)(assignOp, updates);
189
209
  }
190
210
  async visitBinary(binary, p) {
@@ -193,14 +213,14 @@ class JavaVisitor extends visitor_1.TreeVisitor {
193
213
  return expression;
194
214
  }
195
215
  binary = expression;
196
- const updates = {
216
+ const updates = await this.visitChildrenOf(binary, async () => ({
197
217
  prefix: await this.visitSpace(binary.prefix, p),
198
218
  markers: await this.visitMarkers(binary.markers, p),
199
219
  left: await this.visitDefined(binary.left, p),
200
220
  operator: await this.visitLeftPadded(binary.operator, p),
201
221
  right: await this.visitDefined(binary.right, p),
202
222
  type: await this.visitType(binary.type, p)
203
- };
223
+ }));
204
224
  return (0, util_1.updateIfChanged)(binary, updates);
205
225
  }
206
226
  async visitBlock(block, p) {
@@ -209,13 +229,13 @@ class JavaVisitor extends visitor_1.TreeVisitor {
209
229
  return statement;
210
230
  }
211
231
  block = statement;
212
- const updates = {
232
+ const updates = await this.visitChildrenOf(block, async () => ({
213
233
  prefix: await this.visitSpace(block.prefix, p),
214
234
  markers: await this.visitMarkers(block.markers, p),
215
235
  static: await this.visitRightPadded(block.static, p),
216
236
  statements: await (0, util_1.mapAsync)(block.statements, stmt => this.visitRightPadded(stmt, p)),
217
237
  end: await this.visitSpace(block.end, p)
218
- };
238
+ }));
219
239
  return (0, util_1.updateIfChanged)(block, updates);
220
240
  }
221
241
  async visitBreak(breakStatement, p) {
@@ -224,14 +244,16 @@ class JavaVisitor extends visitor_1.TreeVisitor {
224
244
  return statement;
225
245
  }
226
246
  breakStatement = statement;
227
- const updates = {
228
- prefix: await this.visitSpace(breakStatement.prefix, p),
229
- markers: await this.visitMarkers(breakStatement.markers, p)
230
- };
231
- if (breakStatement.label) {
232
- updates.label = await this.visitDefined(breakStatement.label, p);
233
- }
234
- return (0, util_1.updateIfChanged)(breakStatement, updates);
247
+ return this.visitChildrenOf(breakStatement, async () => {
248
+ const updates = {
249
+ prefix: await this.visitSpace(breakStatement.prefix, p),
250
+ markers: await this.visitMarkers(breakStatement.markers, p)
251
+ };
252
+ if (breakStatement.label) {
253
+ updates.label = await this.visitDefined(breakStatement.label, p);
254
+ }
255
+ return (0, util_1.updateIfChanged)(breakStatement, updates);
256
+ });
235
257
  }
236
258
  async visitCase(aCase, p) {
237
259
  const statement = await this.visitStatement(aCase, p);
@@ -239,17 +261,19 @@ class JavaVisitor extends visitor_1.TreeVisitor {
239
261
  return statement;
240
262
  }
241
263
  aCase = statement;
242
- const updates = {
243
- prefix: await this.visitSpace(aCase.prefix, p),
244
- markers: await this.visitMarkers(aCase.markers, p),
245
- caseLabels: await this.visitContainer(aCase.caseLabels, p),
246
- statements: await this.visitContainer(aCase.statements, p),
247
- body: await this.visitOptionalRightPadded(aCase.body, p)
248
- };
249
- if (aCase.guard) {
250
- updates.guard = await this.visitDefined(aCase.guard, p);
251
- }
252
- return (0, util_1.updateIfChanged)(aCase, updates);
264
+ return this.visitChildrenOf(aCase, async () => {
265
+ const updates = {
266
+ prefix: await this.visitSpace(aCase.prefix, p),
267
+ markers: await this.visitMarkers(aCase.markers, p),
268
+ caseLabels: await this.visitContainer(aCase.caseLabels, p),
269
+ statements: await this.visitContainer(aCase.statements, p),
270
+ body: await this.visitOptionalRightPadded(aCase.body, p)
271
+ };
272
+ if (aCase.guard) {
273
+ updates.guard = await this.visitDefined(aCase.guard, p);
274
+ }
275
+ return (0, util_1.updateIfChanged)(aCase, updates);
276
+ });
253
277
  }
254
278
  async visitClassDeclaration(classDecl, p) {
255
279
  const statement = await this.visitStatement(classDecl, p);
@@ -257,7 +281,7 @@ class JavaVisitor extends visitor_1.TreeVisitor {
257
281
  return statement;
258
282
  }
259
283
  classDecl = statement;
260
- const updates = {
284
+ const updates = await this.visitChildrenOf(classDecl, async () => ({
261
285
  prefix: await this.visitSpace(classDecl.prefix, p),
262
286
  markers: await this.visitMarkers(classDecl.markers, p),
263
287
  leadingAnnotations: await (0, util_1.mapAsync)(classDecl.leadingAnnotations, a => this.visitDefined(a, p)),
@@ -271,7 +295,7 @@ class JavaVisitor extends visitor_1.TreeVisitor {
271
295
  permitting: await this.visitOptionalContainer(classDecl.permitting, p),
272
296
  body: await this.visitDefined(classDecl.body, p),
273
297
  type: await this.visitType(classDecl.type, p)
274
- };
298
+ }));
275
299
  return (0, util_1.updateIfChanged)(classDecl, updates);
276
300
  }
277
301
  async visitClassDeclarationKind(kind, p) {
@@ -299,14 +323,16 @@ class JavaVisitor extends visitor_1.TreeVisitor {
299
323
  return statement;
300
324
  }
301
325
  continueStatement = statement;
302
- const updates = {
303
- prefix: await this.visitSpace(continueStatement.prefix, p),
304
- markers: await this.visitMarkers(continueStatement.markers, p)
305
- };
306
- if (continueStatement.label) {
307
- updates.label = await this.visitDefined(continueStatement.label, p);
308
- }
309
- return (0, util_1.updateIfChanged)(continueStatement, updates);
326
+ return this.visitChildrenOf(continueStatement, async () => {
327
+ const updates = {
328
+ prefix: await this.visitSpace(continueStatement.prefix, p),
329
+ markers: await this.visitMarkers(continueStatement.markers, p)
330
+ };
331
+ if (continueStatement.label) {
332
+ updates.label = await this.visitDefined(continueStatement.label, p);
333
+ }
334
+ return (0, util_1.updateIfChanged)(continueStatement, updates);
335
+ });
310
336
  }
311
337
  async visitControlParentheses(controlParens, p) {
312
338
  const expression = await this.visitExpression(controlParens, p);
@@ -314,11 +340,11 @@ class JavaVisitor extends visitor_1.TreeVisitor {
314
340
  return expression;
315
341
  }
316
342
  controlParens = expression;
317
- const updates = {
343
+ const updates = await this.visitChildrenOf(controlParens, async () => ({
318
344
  prefix: await this.visitSpace(controlParens.prefix, p),
319
345
  markers: await this.visitMarkers(controlParens.markers, p),
320
346
  tree: await this.visitRightPadded(controlParens.tree, p)
321
- };
347
+ }));
322
348
  return (0, util_1.updateIfChanged)(controlParens, updates);
323
349
  }
324
350
  async visitDeconstructionPattern(pattern, p) {
@@ -337,12 +363,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
337
363
  return statement;
338
364
  }
339
365
  doWhileLoop = statement;
340
- const updates = {
366
+ const updates = await this.visitChildrenOf(doWhileLoop, async () => ({
341
367
  prefix: await this.visitSpace(doWhileLoop.prefix, p),
342
368
  markers: await this.visitMarkers(doWhileLoop.markers, p),
343
369
  body: await this.visitRightPadded(doWhileLoop.body, p),
344
370
  whileCondition: await this.visitLeftPadded(doWhileLoop.whileCondition, p)
345
- };
371
+ }));
346
372
  return (0, util_1.updateIfChanged)(doWhileLoop, updates);
347
373
  }
348
374
  async visitEmpty(empty, p) {
@@ -380,11 +406,11 @@ class JavaVisitor extends visitor_1.TreeVisitor {
380
406
  return statement;
381
407
  }
382
408
  enumValueSet = statement;
383
- const updates = {
409
+ const updates = await this.visitChildrenOf(enumValueSet, async () => ({
384
410
  prefix: await this.visitSpace(enumValueSet.prefix, p),
385
411
  markers: await this.visitMarkers(enumValueSet.markers, p),
386
412
  enums: await (0, util_1.mapAsync)(enumValueSet.enums, e => this.visitRightPadded(e, p))
387
- };
413
+ }));
388
414
  return (0, util_1.updateIfChanged)(enumValueSet, updates);
389
415
  }
390
416
  async visitErroneous(erroneous, p) {
@@ -415,13 +441,13 @@ class JavaVisitor extends visitor_1.TreeVisitor {
415
441
  return statement;
416
442
  }
417
443
  fieldAccess = statement;
418
- const updates = {
444
+ const updates = await this.visitChildrenOf(fieldAccess, async () => ({
419
445
  prefix: await this.visitSpace(fieldAccess.prefix, p),
420
446
  markers: await this.visitMarkers(fieldAccess.markers, p),
421
447
  target: await this.visitDefined(fieldAccess.target, p),
422
448
  name: await this.visitLeftPadded(fieldAccess.name, p),
423
449
  type: await this.visitType(fieldAccess.type, p)
424
- };
450
+ }));
425
451
  return (0, util_1.updateIfChanged)(fieldAccess, updates);
426
452
  }
427
453
  async visitForEachLoop(forLoop, p) {
@@ -430,12 +456,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
430
456
  return statement;
431
457
  }
432
458
  forLoop = statement;
433
- const updates = {
459
+ const updates = await this.visitChildrenOf(forLoop, async () => ({
434
460
  prefix: await this.visitSpace(forLoop.prefix, p),
435
461
  markers: await this.visitMarkers(forLoop.markers, p),
436
462
  control: await this.visitDefined(forLoop.control, p),
437
463
  body: await this.visitRightPadded(forLoop.body, p)
438
- };
464
+ }));
439
465
  return (0, util_1.updateIfChanged)(forLoop, updates);
440
466
  }
441
467
  async visitForEachLoopControl(control, p) {
@@ -453,12 +479,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
453
479
  return statement;
454
480
  }
455
481
  forLoop = statement;
456
- const updates = {
482
+ const updates = await this.visitChildrenOf(forLoop, async () => ({
457
483
  prefix: await this.visitSpace(forLoop.prefix, p),
458
484
  markers: await this.visitMarkers(forLoop.markers, p),
459
485
  control: await this.visitDefined(forLoop.control, p),
460
486
  body: await this.visitRightPadded(forLoop.body, p)
461
- };
487
+ }));
462
488
  return (0, util_1.updateIfChanged)(forLoop, updates);
463
489
  }
464
490
  async visitForLoopControl(control, p) {
@@ -492,16 +518,18 @@ class JavaVisitor extends visitor_1.TreeVisitor {
492
518
  return statement;
493
519
  }
494
520
  iff = statement;
495
- const updates = {
496
- prefix: await this.visitSpace(iff.prefix, p),
497
- markers: await this.visitMarkers(iff.markers, p),
498
- ifCondition: await this.visitDefined(iff.ifCondition, p),
499
- thenPart: await this.visitRightPadded(iff.thenPart, p)
500
- };
501
- if (iff.elsePart) {
502
- updates.elsePart = await this.visitDefined(iff.elsePart, p);
503
- }
504
- return (0, util_1.updateIfChanged)(iff, updates);
521
+ return this.visitChildrenOf(iff, async () => {
522
+ const updates = {
523
+ prefix: await this.visitSpace(iff.prefix, p),
524
+ markers: await this.visitMarkers(iff.markers, p),
525
+ ifCondition: await this.visitDefined(iff.ifCondition, p),
526
+ thenPart: await this.visitRightPadded(iff.thenPart, p)
527
+ };
528
+ if (iff.elsePart) {
529
+ updates.elsePart = await this.visitDefined(iff.elsePart, p);
530
+ }
531
+ return (0, util_1.updateIfChanged)(iff, updates);
532
+ });
505
533
  }
506
534
  async visitElse(anElse, p) {
507
535
  const updates = {
@@ -527,20 +555,22 @@ class JavaVisitor extends visitor_1.TreeVisitor {
527
555
  return expression;
528
556
  }
529
557
  instanceOf = expression;
530
- const updates = {
531
- prefix: await this.visitSpace(instanceOf.prefix, p),
532
- markers: await this.visitMarkers(instanceOf.markers, p),
533
- expression: await this.visitRightPadded(instanceOf.expression, p),
534
- class: await this.visitDefined(instanceOf.class, p),
535
- type: await this.visitType(instanceOf.type, p)
536
- };
537
- if (instanceOf.pattern) {
538
- updates.pattern = await this.visitDefined(instanceOf.pattern, p);
539
- }
540
- if (instanceOf.modifier) {
541
- updates.modifier = await this.visitDefined(instanceOf.modifier, p);
542
- }
543
- return (0, util_1.updateIfChanged)(instanceOf, updates);
558
+ return this.visitChildrenOf(instanceOf, async () => {
559
+ const updates = {
560
+ prefix: await this.visitSpace(instanceOf.prefix, p),
561
+ markers: await this.visitMarkers(instanceOf.markers, p),
562
+ expression: await this.visitRightPadded(instanceOf.expression, p),
563
+ class: await this.visitDefined(instanceOf.class, p),
564
+ type: await this.visitType(instanceOf.type, p)
565
+ };
566
+ if (instanceOf.pattern) {
567
+ updates.pattern = await this.visitDefined(instanceOf.pattern, p);
568
+ }
569
+ if (instanceOf.modifier) {
570
+ updates.modifier = await this.visitDefined(instanceOf.modifier, p);
571
+ }
572
+ return (0, util_1.updateIfChanged)(instanceOf, updates);
573
+ });
544
574
  }
545
575
  async visitIntersectionType(intersectionType, p) {
546
576
  const expression = await this.visitExpression(intersectionType, p);
@@ -548,11 +578,11 @@ class JavaVisitor extends visitor_1.TreeVisitor {
548
578
  return expression;
549
579
  }
550
580
  intersectionType = expression;
551
- const updates = {
581
+ const updates = await this.visitChildrenOf(intersectionType, async () => ({
552
582
  prefix: await this.visitSpace(intersectionType.prefix, p),
553
583
  markers: await this.visitMarkers(intersectionType.markers, p),
554
584
  bounds: await this.visitContainer(intersectionType.bounds, p)
555
- };
585
+ }));
556
586
  return (0, util_1.updateIfChanged)(intersectionType, updates);
557
587
  }
558
588
  async visitLabel(label, p) {
@@ -561,12 +591,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
561
591
  return statement;
562
592
  }
563
593
  label = statement;
564
- const updates = {
594
+ const updates = await this.visitChildrenOf(label, async () => ({
565
595
  prefix: await this.visitSpace(label.prefix, p),
566
596
  markers: await this.visitMarkers(label.markers, p),
567
597
  label: await this.visitRightPadded(label.label, p),
568
598
  statement: await this.visitDefined(label.statement, p)
569
- };
599
+ }));
570
600
  return (0, util_1.updateIfChanged)(label, updates);
571
601
  }
572
602
  async visitLambda(lambda, p) {
@@ -580,14 +610,14 @@ class JavaVisitor extends visitor_1.TreeVisitor {
580
610
  return statement;
581
611
  }
582
612
  lambda = statement;
583
- const updates = {
613
+ const updates = await this.visitChildrenOf(lambda, async () => ({
584
614
  prefix: await this.visitSpace(lambda.prefix, p),
585
615
  markers: await this.visitMarkers(lambda.markers, p),
586
616
  parameters: await this.visitDefined(lambda.parameters, p),
587
617
  arrow: await this.visitSpace(lambda.arrow, p),
588
618
  body: await this.visitDefined(lambda.body, p),
589
619
  type: await this.visitType(lambda.type, p)
590
- };
620
+ }));
591
621
  return (0, util_1.updateIfChanged)(lambda, updates);
592
622
  }
593
623
  async visitLambdaParameters(params, p) {
@@ -617,7 +647,7 @@ class JavaVisitor extends visitor_1.TreeVisitor {
617
647
  return expression;
618
648
  }
619
649
  memberRef = expression;
620
- const updates = {
650
+ const updates = await this.visitChildrenOf(memberRef, async () => ({
621
651
  prefix: await this.visitSpace(memberRef.prefix, p),
622
652
  markers: await this.visitMarkers(memberRef.markers, p),
623
653
  containing: await this.visitRightPadded(memberRef.containing, p),
@@ -626,37 +656,39 @@ class JavaVisitor extends visitor_1.TreeVisitor {
626
656
  type: await this.visitType(memberRef.type, p),
627
657
  methodType: await this.visitType(memberRef.methodType, p),
628
658
  variableType: await this.visitType(memberRef.variableType, p)
629
- };
659
+ }));
630
660
  return (0, util_1.updateIfChanged)(memberRef, updates);
631
661
  }
632
662
  async visitMethodDeclaration(method, p) {
633
- var _a;
634
663
  const statement = await this.visitStatement(method, p);
635
664
  if (!(statement === null || statement === void 0 ? void 0 : statement.kind) || statement.kind !== tree_2.J.Kind.MethodDeclaration) {
636
665
  return statement;
637
666
  }
638
667
  method = statement;
639
- const updates = {
640
- prefix: await this.visitSpace(method.prefix, p),
641
- markers: await this.visitMarkers(method.markers, p),
642
- leadingAnnotations: await (0, util_1.mapAsync)(method.leadingAnnotations, a => this.visitDefined(a, p)),
643
- modifiers: await (0, util_1.mapAsync)(method.modifiers, m => this.visitDefined(m, p)),
644
- nameAnnotations: await (0, util_1.mapAsync)(method.nameAnnotations, a => this.visitDefined(a, p)),
645
- name: await this.visitDefined(method.name, p),
646
- parameters: await this.visitContainer(method.parameters, p),
647
- dimensionsAfterName: await (0, util_1.mapAsync)((_a = method.dimensionsAfterName) !== null && _a !== void 0 ? _a : [], dim => this.visitLeftPadded(dim, p)),
648
- throws: method.throws && await this.visitContainer(method.throws, p),
649
- body: method.body && await this.visitDefined(method.body, p),
650
- defaultValue: await this.visitOptionalLeftPadded(method.defaultValue, p),
651
- methodType: await this.visitType(method.methodType, p)
652
- };
653
- if (method.typeParameters) {
654
- updates.typeParameters = await this.visitDefined(method.typeParameters, p);
655
- }
656
- if (method.returnTypeExpression) {
657
- updates.returnTypeExpression = await this.visitDefined(method.returnTypeExpression, p);
658
- }
659
- return (0, util_1.updateIfChanged)(method, updates);
668
+ return this.visitChildrenOf(method, async () => {
669
+ var _a;
670
+ const updates = {
671
+ prefix: await this.visitSpace(method.prefix, p),
672
+ markers: await this.visitMarkers(method.markers, p),
673
+ leadingAnnotations: await (0, util_1.mapAsync)(method.leadingAnnotations, a => this.visitDefined(a, p)),
674
+ modifiers: await (0, util_1.mapAsync)(method.modifiers, m => this.visitDefined(m, p)),
675
+ nameAnnotations: await (0, util_1.mapAsync)(method.nameAnnotations, a => this.visitDefined(a, p)),
676
+ name: await this.visitDefined(method.name, p),
677
+ parameters: await this.visitContainer(method.parameters, p),
678
+ dimensionsAfterName: await (0, util_1.mapAsync)((_a = method.dimensionsAfterName) !== null && _a !== void 0 ? _a : [], dim => this.visitLeftPadded(dim, p)),
679
+ throws: method.throws && await this.visitContainer(method.throws, p),
680
+ body: method.body && await this.visitDefined(method.body, p),
681
+ defaultValue: await this.visitOptionalLeftPadded(method.defaultValue, p),
682
+ methodType: await this.visitType(method.methodType, p)
683
+ };
684
+ if (method.typeParameters) {
685
+ updates.typeParameters = await this.visitDefined(method.typeParameters, p);
686
+ }
687
+ if (method.returnTypeExpression) {
688
+ updates.returnTypeExpression = await this.visitDefined(method.returnTypeExpression, p);
689
+ }
690
+ return (0, util_1.updateIfChanged)(method, updates);
691
+ });
660
692
  }
661
693
  async visitMethodInvocation(method, p) {
662
694
  const expression = await this.visitExpression(method, p);
@@ -669,7 +701,7 @@ class JavaVisitor extends visitor_1.TreeVisitor {
669
701
  return statement;
670
702
  }
671
703
  method = statement;
672
- const updates = {
704
+ const updates = await this.visitChildrenOf(method, async () => ({
673
705
  prefix: await this.visitSpace(method.prefix, p),
674
706
  markers: await this.visitMarkers(method.markers, p),
675
707
  select: await this.visitOptionalRightPadded(method.select, p),
@@ -677,7 +709,7 @@ class JavaVisitor extends visitor_1.TreeVisitor {
677
709
  name: await this.visitDefined(method.name, p),
678
710
  arguments: await this.visitContainer(method.arguments, p),
679
711
  methodType: await this.visitType(method.methodType, p)
680
- };
712
+ }));
681
713
  return (0, util_1.updateIfChanged)(method, updates);
682
714
  }
683
715
  async visitModifier(modifier, p) {
@@ -702,17 +734,19 @@ class JavaVisitor extends visitor_1.TreeVisitor {
702
734
  return expression;
703
735
  }
704
736
  newArray = expression;
705
- const updates = {
706
- prefix: await this.visitSpace(newArray.prefix, p),
707
- markers: await this.visitMarkers(newArray.markers, p),
708
- dimensions: await (0, util_1.mapAsync)(newArray.dimensions, dim => this.visitDefined(dim, p)),
709
- initializer: await this.visitOptionalContainer(newArray.initializer, p),
710
- type: await this.visitType(newArray.type, p)
711
- };
712
- if (newArray.typeExpression) {
713
- updates.typeExpression = await this.visitDefined(newArray.typeExpression, p);
714
- }
715
- return (0, util_1.updateIfChanged)(newArray, updates);
737
+ return this.visitChildrenOf(newArray, async () => {
738
+ const updates = {
739
+ prefix: await this.visitSpace(newArray.prefix, p),
740
+ markers: await this.visitMarkers(newArray.markers, p),
741
+ dimensions: await (0, util_1.mapAsync)(newArray.dimensions, dim => this.visitDefined(dim, p)),
742
+ initializer: await this.visitOptionalContainer(newArray.initializer, p),
743
+ type: await this.visitType(newArray.type, p)
744
+ };
745
+ if (newArray.typeExpression) {
746
+ updates.typeExpression = await this.visitDefined(newArray.typeExpression, p);
747
+ }
748
+ return (0, util_1.updateIfChanged)(newArray, updates);
749
+ });
716
750
  }
717
751
  async visitNewClass(newClass, p) {
718
752
  const expression = await this.visitExpression(newClass, p);
@@ -725,23 +759,25 @@ class JavaVisitor extends visitor_1.TreeVisitor {
725
759
  return statement;
726
760
  }
727
761
  newClass = statement;
728
- const updates = {
729
- prefix: await this.visitSpace(newClass.prefix, p),
730
- markers: await this.visitMarkers(newClass.markers, p),
731
- new: await this.visitSpace(newClass.new, p),
732
- arguments: await this.visitContainer(newClass.arguments, p),
733
- constructorType: await this.visitType(newClass.constructorType, p)
734
- };
735
- if (newClass.enclosing) {
736
- updates.enclosing = await this.visitRightPadded(newClass.enclosing, p);
737
- }
738
- if (newClass.class) {
739
- updates.class = await this.visitDefined(newClass.class, p);
740
- }
741
- if (newClass.body) {
742
- updates.body = await this.visitDefined(newClass.body, p);
743
- }
744
- return (0, util_1.updateIfChanged)(newClass, updates);
762
+ return this.visitChildrenOf(newClass, async () => {
763
+ const updates = {
764
+ prefix: await this.visitSpace(newClass.prefix, p),
765
+ markers: await this.visitMarkers(newClass.markers, p),
766
+ new: await this.visitSpace(newClass.new, p),
767
+ arguments: await this.visitContainer(newClass.arguments, p),
768
+ constructorType: await this.visitType(newClass.constructorType, p)
769
+ };
770
+ if (newClass.enclosing) {
771
+ updates.enclosing = await this.visitRightPadded(newClass.enclosing, p);
772
+ }
773
+ if (newClass.class) {
774
+ updates.class = await this.visitDefined(newClass.class, p);
775
+ }
776
+ if (newClass.body) {
777
+ updates.body = await this.visitDefined(newClass.body, p);
778
+ }
779
+ return (0, util_1.updateIfChanged)(newClass, updates);
780
+ });
745
781
  }
746
782
  async visitNullableType(nullableType, p) {
747
783
  const expression = await this.visitExpression(nullableType, p);
@@ -749,12 +785,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
749
785
  return expression;
750
786
  }
751
787
  nullableType = expression;
752
- const updates = {
788
+ const updates = await this.visitChildrenOf(nullableType, async () => ({
753
789
  prefix: await this.visitSpace(nullableType.prefix, p),
754
790
  markers: await this.visitMarkers(nullableType.markers, p),
755
791
  annotations: await (0, util_1.mapAsync)(nullableType.annotations, a => this.visitDefined(a, p)),
756
792
  typeTree: await this.visitRightPadded(nullableType.typeTree, p)
757
- };
793
+ }));
758
794
  return (0, util_1.updateIfChanged)(nullableType, updates);
759
795
  }
760
796
  async visitPackage(aPackage, p) {
@@ -774,13 +810,13 @@ class JavaVisitor extends visitor_1.TreeVisitor {
774
810
  return expression;
775
811
  }
776
812
  parameterizedType = expression;
777
- const updates = {
813
+ const updates = await this.visitChildrenOf(parameterizedType, async () => ({
778
814
  prefix: await this.visitSpace(parameterizedType.prefix, p),
779
815
  markers: await this.visitMarkers(parameterizedType.markers, p),
780
816
  class: await this.visitTypeName(parameterizedType.class, p),
781
817
  typeParameters: await this.visitOptionalContainer(parameterizedType.typeParameters, p),
782
818
  type: await this.visitType(parameterizedType.type, p)
783
- };
819
+ }));
784
820
  return (0, util_1.updateIfChanged)(parameterizedType, updates);
785
821
  }
786
822
  async visitParentheses(parentheses, p) {
@@ -789,11 +825,11 @@ class JavaVisitor extends visitor_1.TreeVisitor {
789
825
  return expression;
790
826
  }
791
827
  parentheses = expression;
792
- const updates = {
828
+ const updates = await this.visitChildrenOf(parentheses, async () => ({
793
829
  prefix: await this.visitSpace(parentheses.prefix, p),
794
830
  markers: await this.visitMarkers(parentheses.markers, p),
795
831
  tree: await this.visitRightPadded(parentheses.tree, p)
796
- };
832
+ }));
797
833
  return (0, util_1.updateIfChanged)(parentheses, updates);
798
834
  }
799
835
  async visitParenthesizedTypeTree(parTypeTree, p) {
@@ -802,12 +838,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
802
838
  return expression;
803
839
  }
804
840
  parTypeTree = expression;
805
- const updates = {
841
+ const updates = await this.visitChildrenOf(parTypeTree, async () => ({
806
842
  prefix: await this.visitSpace(parTypeTree.prefix, p),
807
843
  markers: await this.visitMarkers(parTypeTree.markers, p),
808
844
  annotations: await (0, util_1.mapAsync)(parTypeTree.annotations, a => this.visitDefined(a, p)),
809
845
  parenthesizedType: await this.visitDefined(parTypeTree.parenthesizedType, p)
810
- };
846
+ }));
811
847
  return (0, util_1.updateIfChanged)(parTypeTree, updates);
812
848
  }
813
849
  async visitPrimitive(primitive, p) {
@@ -829,14 +865,16 @@ class JavaVisitor extends visitor_1.TreeVisitor {
829
865
  return statement;
830
866
  }
831
867
  ret = statement;
832
- const updates = {
833
- prefix: await this.visitSpace(ret.prefix, p),
834
- markers: await this.visitMarkers(ret.markers, p)
835
- };
836
- if (ret.expression) {
837
- updates.expression = await this.visitDefined(ret.expression, p);
838
- }
839
- return (0, util_1.updateIfChanged)(ret, updates);
868
+ return this.visitChildrenOf(ret, async () => {
869
+ const updates = {
870
+ prefix: await this.visitSpace(ret.prefix, p),
871
+ markers: await this.visitMarkers(ret.markers, p)
872
+ };
873
+ if (ret.expression) {
874
+ updates.expression = await this.visitDefined(ret.expression, p);
875
+ }
876
+ return (0, util_1.updateIfChanged)(ret, updates);
877
+ });
840
878
  }
841
879
  async visitSwitch(aSwitch, p) {
842
880
  const statement = await this.visitStatement(aSwitch, p);
@@ -844,12 +882,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
844
882
  return statement;
845
883
  }
846
884
  aSwitch = statement;
847
- const updates = {
885
+ const updates = await this.visitChildrenOf(aSwitch, async () => ({
848
886
  prefix: await this.visitSpace(aSwitch.prefix, p),
849
887
  markers: await this.visitMarkers(aSwitch.markers, p),
850
888
  selector: await this.visitDefined(aSwitch.selector, p),
851
889
  cases: await this.visitDefined(aSwitch.cases, p)
852
- };
890
+ }));
853
891
  return (0, util_1.updateIfChanged)(aSwitch, updates);
854
892
  }
855
893
  async visitSwitchExpression(switchExpr, p) {
@@ -858,13 +896,13 @@ class JavaVisitor extends visitor_1.TreeVisitor {
858
896
  return expression;
859
897
  }
860
898
  switchExpr = expression;
861
- const updates = {
899
+ const updates = await this.visitChildrenOf(switchExpr, async () => ({
862
900
  prefix: await this.visitSpace(switchExpr.prefix, p),
863
901
  markers: await this.visitMarkers(switchExpr.markers, p),
864
902
  selector: await this.visitDefined(switchExpr.selector, p),
865
903
  cases: await this.visitDefined(switchExpr.cases, p),
866
904
  type: await this.visitType(switchExpr.type, p)
867
- };
905
+ }));
868
906
  return (0, util_1.updateIfChanged)(switchExpr, updates);
869
907
  }
870
908
  async visitSynchronized(sync, p) {
@@ -873,12 +911,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
873
911
  return statement;
874
912
  }
875
913
  sync = statement;
876
- const updates = {
914
+ const updates = await this.visitChildrenOf(sync, async () => ({
877
915
  prefix: await this.visitSpace(sync.prefix, p),
878
916
  markers: await this.visitMarkers(sync.markers, p),
879
917
  lock: await this.visitDefined(sync.lock, p),
880
918
  body: await this.visitDefined(sync.body, p)
881
- };
919
+ }));
882
920
  return (0, util_1.updateIfChanged)(sync, updates);
883
921
  }
884
922
  async visitTernary(ternary, p) {
@@ -892,14 +930,14 @@ class JavaVisitor extends visitor_1.TreeVisitor {
892
930
  return statement;
893
931
  }
894
932
  ternary = statement;
895
- const updates = {
933
+ const updates = await this.visitChildrenOf(ternary, async () => ({
896
934
  prefix: await this.visitSpace(ternary.prefix, p),
897
935
  markers: await this.visitMarkers(ternary.markers, p),
898
936
  condition: await this.visitDefined(ternary.condition, p),
899
937
  truePart: await this.visitLeftPadded(ternary.truePart, p),
900
938
  falsePart: await this.visitLeftPadded(ternary.falsePart, p),
901
939
  type: await this.visitType(ternary.type, p)
902
- };
940
+ }));
903
941
  return (0, util_1.updateIfChanged)(ternary, updates);
904
942
  }
905
943
  async visitThrow(thrown, p) {
@@ -908,11 +946,11 @@ class JavaVisitor extends visitor_1.TreeVisitor {
908
946
  return statement;
909
947
  }
910
948
  thrown = statement;
911
- const updates = {
949
+ const updates = await this.visitChildrenOf(thrown, async () => ({
912
950
  prefix: await this.visitSpace(thrown.prefix, p),
913
951
  markers: await this.visitMarkers(thrown.markers, p),
914
952
  exception: await this.visitDefined(thrown.exception, p)
915
- };
953
+ }));
916
954
  return (0, util_1.updateIfChanged)(thrown, updates);
917
955
  }
918
956
  async visitTry(tryable, p) {
@@ -921,14 +959,14 @@ class JavaVisitor extends visitor_1.TreeVisitor {
921
959
  return statement;
922
960
  }
923
961
  tryable = statement;
924
- const updates = {
962
+ const updates = await this.visitChildrenOf(tryable, async () => ({
925
963
  prefix: await this.visitSpace(tryable.prefix, p),
926
964
  markers: await this.visitMarkers(tryable.markers, p),
927
965
  resources: await this.visitOptionalContainer(tryable.resources, p),
928
966
  body: await this.visitDefined(tryable.body, p),
929
967
  catches: await (0, util_1.mapAsync)(tryable.catches, c => this.visitDefined(c, p)),
930
968
  finally: await this.visitOptionalLeftPadded(tryable.finally, p)
931
- };
969
+ }));
932
970
  return (0, util_1.updateIfChanged)(tryable, updates);
933
971
  }
934
972
  async visitTryResource(resource, p) {
@@ -954,12 +992,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
954
992
  return expression;
955
993
  }
956
994
  typeCast = expression;
957
- const updates = {
995
+ const updates = await this.visitChildrenOf(typeCast, async () => ({
958
996
  prefix: await this.visitSpace(typeCast.prefix, p),
959
997
  markers: await this.visitMarkers(typeCast.markers, p),
960
998
  class: await this.visitDefined(typeCast.class, p),
961
999
  expression: await this.visitDefined(typeCast.expression, p)
962
- };
1000
+ }));
963
1001
  return (0, util_1.updateIfChanged)(typeCast, updates);
964
1002
  }
965
1003
  async visitTypeParameter(typeParam, p) {
@@ -993,13 +1031,13 @@ class JavaVisitor extends visitor_1.TreeVisitor {
993
1031
  return statement;
994
1032
  }
995
1033
  unary = statement;
996
- const updates = {
1034
+ const updates = await this.visitChildrenOf(unary, async () => ({
997
1035
  prefix: await this.visitSpace(unary.prefix, p),
998
1036
  markers: await this.visitMarkers(unary.markers, p),
999
1037
  operator: await this.visitLeftPadded(unary.operator, p),
1000
1038
  expression: await this.visitDefined(unary.expression, p),
1001
1039
  type: await this.visitType(unary.type, p)
1002
- };
1040
+ }));
1003
1041
  return (0, util_1.updateIfChanged)(unary, updates);
1004
1042
  }
1005
1043
  async visitUnknown(unknown, p) {
@@ -1013,11 +1051,11 @@ class JavaVisitor extends visitor_1.TreeVisitor {
1013
1051
  return statement;
1014
1052
  }
1015
1053
  unknown = statement;
1016
- const updates = {
1054
+ const updates = await this.visitChildrenOf(unknown, async () => ({
1017
1055
  prefix: await this.visitSpace(unknown.prefix, p),
1018
1056
  markers: await this.visitMarkers(unknown.markers, p),
1019
1057
  source: await this.visitDefined(unknown.source, p)
1020
- };
1058
+ }));
1021
1059
  return (0, util_1.updateIfChanged)(unknown, updates);
1022
1060
  }
1023
1061
  async visitUnknownSource(source, p) {
@@ -1033,20 +1071,22 @@ class JavaVisitor extends visitor_1.TreeVisitor {
1033
1071
  return statement;
1034
1072
  }
1035
1073
  varDecls = statement;
1036
- const updates = {
1037
- prefix: await this.visitSpace(varDecls.prefix, p),
1038
- markers: await this.visitMarkers(varDecls.markers, p),
1039
- leadingAnnotations: await (0, util_1.mapAsync)(varDecls.leadingAnnotations, a => this.visitDefined(a, p)),
1040
- modifiers: await (0, util_1.mapAsync)(varDecls.modifiers, m => this.visitDefined(m, p)),
1041
- variables: await (0, util_1.mapAsync)(varDecls.variables, v => this.visitRightPadded(v, p))
1042
- };
1043
- if (varDecls.typeExpression) {
1044
- updates.typeExpression = await this.visitDefined(varDecls.typeExpression, p);
1045
- }
1046
- if (varDecls.varargs) {
1047
- updates.varargs = await this.visitSpace(varDecls.varargs, p);
1048
- }
1049
- return (0, util_1.updateIfChanged)(varDecls, updates);
1074
+ return this.visitChildrenOf(varDecls, async () => {
1075
+ const updates = {
1076
+ prefix: await this.visitSpace(varDecls.prefix, p),
1077
+ markers: await this.visitMarkers(varDecls.markers, p),
1078
+ leadingAnnotations: await (0, util_1.mapAsync)(varDecls.leadingAnnotations, a => this.visitDefined(a, p)),
1079
+ modifiers: await (0, util_1.mapAsync)(varDecls.modifiers, m => this.visitDefined(m, p)),
1080
+ variables: await (0, util_1.mapAsync)(varDecls.variables, v => this.visitRightPadded(v, p))
1081
+ };
1082
+ if (varDecls.typeExpression) {
1083
+ updates.typeExpression = await this.visitDefined(varDecls.typeExpression, p);
1084
+ }
1085
+ if (varDecls.varargs) {
1086
+ updates.varargs = await this.visitSpace(varDecls.varargs, p);
1087
+ }
1088
+ return (0, util_1.updateIfChanged)(varDecls, updates);
1089
+ });
1050
1090
  }
1051
1091
  async visitVariable(variable, p) {
1052
1092
  const updates = {
@@ -1065,12 +1105,12 @@ class JavaVisitor extends visitor_1.TreeVisitor {
1065
1105
  return statement;
1066
1106
  }
1067
1107
  whileLoop = statement;
1068
- const updates = {
1108
+ const updates = await this.visitChildrenOf(whileLoop, async () => ({
1069
1109
  prefix: await this.visitSpace(whileLoop.prefix, p),
1070
1110
  markers: await this.visitMarkers(whileLoop.markers, p),
1071
1111
  condition: await this.visitDefined(whileLoop.condition, p),
1072
1112
  body: await this.visitRightPadded(whileLoop.body, p)
1073
- };
1113
+ }));
1074
1114
  return (0, util_1.updateIfChanged)(whileLoop, updates);
1075
1115
  }
1076
1116
  async visitWildcard(wildcard, p) {
@@ -1079,15 +1119,17 @@ class JavaVisitor extends visitor_1.TreeVisitor {
1079
1119
  return expression;
1080
1120
  }
1081
1121
  wildcard = expression;
1082
- const updates = {
1083
- prefix: await this.visitSpace(wildcard.prefix, p),
1084
- markers: await this.visitMarkers(wildcard.markers, p),
1085
- bound: await this.visitOptionalLeftPadded(wildcard.bound, p)
1086
- };
1087
- if (wildcard.boundedType) {
1088
- updates.boundedType = await this.visitTypeName(wildcard.boundedType, p);
1089
- }
1090
- return (0, util_1.updateIfChanged)(wildcard, updates);
1122
+ return this.visitChildrenOf(wildcard, async () => {
1123
+ const updates = {
1124
+ prefix: await this.visitSpace(wildcard.prefix, p),
1125
+ markers: await this.visitMarkers(wildcard.markers, p),
1126
+ bound: await this.visitOptionalLeftPadded(wildcard.bound, p)
1127
+ };
1128
+ if (wildcard.boundedType) {
1129
+ updates.boundedType = await this.visitTypeName(wildcard.boundedType, p);
1130
+ }
1131
+ return (0, util_1.updateIfChanged)(wildcard, updates);
1132
+ });
1091
1133
  }
1092
1134
  async visitYield(aYield, p) {
1093
1135
  const statement = await this.visitStatement(aYield, p);
@@ -1095,12 +1137,17 @@ class JavaVisitor extends visitor_1.TreeVisitor {
1095
1137
  return statement;
1096
1138
  }
1097
1139
  aYield = statement;
1098
- const updates = {
1099
- prefix: await this.visitSpace(aYield.prefix, p),
1100
- markers: await this.visitMarkers(aYield.markers, p),
1101
- value: await this.visitDefined(aYield.value, p)
1102
- };
1103
- return (0, util_1.updateIfChanged)(aYield, updates);
1140
+ return this.visitChildrenOf(aYield, async () => {
1141
+ const updates = {
1142
+ prefix: await this.visitSpace(aYield.prefix, p),
1143
+ markers: await this.visitMarkers(aYield.markers, p)
1144
+ };
1145
+ // a bare `yield` has no value
1146
+ if (aYield.value) {
1147
+ updates.value = await this.visitDefined(aYield.value, p);
1148
+ }
1149
+ return (0, util_1.updateIfChanged)(aYield, updates);
1150
+ });
1104
1151
  }
1105
1152
  async visitOptionalRightPadded(right, p) {
1106
1153
  return right ? this.visitRightPadded(right, p) : undefined;