@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
@@ -75,6 +75,24 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
75
75
  return nameTree;
76
76
  }
77
77
 
78
+ /**
79
+ * Visits the children of `tree` through `visit` under a cursor that holds it, where a visit made it of the tree
80
+ * on the cursor, and puts the given cursor back after with the messages they left.
81
+ */
82
+ protected visitChildrenOf<R>(tree: J, visit: () => Promise<R>): Promise<R> {
83
+ const given = this.cursor;
84
+ if (given.value === tree || given.value?.kind !== tree.kind) {
85
+ return visit();
86
+ }
87
+ this.cursor = new Cursor(tree, given.parent);
88
+ given.messages.forEach((value, key) => this.cursor.messages.set(key, value));
89
+ return visit().then(visited => {
90
+ this.cursor.messages.forEach((value, key) => given.messages.set(key, value));
91
+ this.cursor = given;
92
+ return visited;
93
+ });
94
+ }
95
+
78
96
  protected async visitAnnotatedType(annotatedType: J.AnnotatedType, p: P): Promise<J | undefined> {
79
97
  const expression = await this.visitExpression(annotatedType, p);
80
98
  if (!expression?.kind || expression.kind !== J.Kind.AnnotatedType) {
@@ -82,12 +100,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
82
100
  }
83
101
  annotatedType = expression as J.AnnotatedType;
84
102
 
85
- const updates = {
103
+ const updates = await this.visitChildrenOf(annotatedType, async () => ({
86
104
  prefix: await this.visitSpace(annotatedType.prefix, p),
87
105
  markers: await this.visitMarkers(annotatedType.markers, p),
88
106
  annotations: await mapAsync(annotatedType.annotations, a => this.visitDefined<J.Annotation>(a, p)),
89
107
  typeExpression: await this.visitDefined(annotatedType.typeExpression, p) as TypedTree
90
- };
108
+ }));
91
109
  return updateIfChanged(annotatedType, updates);
92
110
  }
93
111
 
@@ -98,12 +116,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
98
116
  }
99
117
  annotation = expression as J.Annotation;
100
118
 
101
- const updates = {
119
+ const updates = await this.visitChildrenOf(annotation, async () => ({
102
120
  prefix: await this.visitSpace(annotation.prefix, p),
103
121
  markers: await this.visitMarkers(annotation.markers, p),
104
122
  annotationType: await this.visitTypeName(annotation.annotationType, p),
105
123
  arguments: await this.visitOptionalContainer(annotation.arguments, p)
106
- };
124
+ }));
107
125
  return updateIfChanged(annotation, updates);
108
126
  }
109
127
 
@@ -114,12 +132,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
114
132
  }
115
133
  arrayAccess = expression as J.ArrayAccess;
116
134
 
117
- const updates = {
135
+ const updates = await this.visitChildrenOf(arrayAccess, async () => ({
118
136
  prefix: await this.visitSpace(arrayAccess.prefix, p),
119
137
  markers: await this.visitMarkers(arrayAccess.markers, p),
120
138
  indexed: await this.visitDefined(arrayAccess.indexed, p) as Expression,
121
139
  dimension: await this.visitDefined(arrayAccess.dimension, p) as J.ArrayDimension
122
- };
140
+ }));
123
141
  return updateIfChanged(arrayAccess, updates);
124
142
  }
125
143
 
@@ -140,17 +158,19 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
140
158
  }
141
159
  arrayType = expression as J.ArrayType;
142
160
 
143
- const updates: any = {
144
- prefix: await this.visitSpace(arrayType.prefix, p),
145
- markers: await this.visitMarkers(arrayType.markers, p),
146
- elementType: await this.visitDefined(arrayType.elementType, p) as TypedTree,
147
- dimension: await this.visitLeftPadded(arrayType.dimension, p),
148
- type: await this.visitType(arrayType.type, p)
149
- };
150
- if (arrayType.annotations) {
151
- updates.annotations = await mapAsync(arrayType.annotations, a => this.visitDefined<J.Annotation>(a, p));
152
- }
153
- return updateIfChanged(arrayType, updates);
161
+ return this.visitChildrenOf(arrayType, async () => {
162
+ const updates: any = {
163
+ prefix: await this.visitSpace(arrayType.prefix, p),
164
+ markers: await this.visitMarkers(arrayType.markers, p),
165
+ elementType: await this.visitDefined(arrayType.elementType, p) as TypedTree,
166
+ dimension: await this.visitLeftPadded(arrayType.dimension, p),
167
+ type: await this.visitType(arrayType.type, p)
168
+ };
169
+ if (arrayType.annotations) {
170
+ updates.annotations = await mapAsync(arrayType.annotations, a => this.visitDefined<J.Annotation>(a, p));
171
+ }
172
+ return updateIfChanged(arrayType, updates);
173
+ });
154
174
  }
155
175
 
156
176
  protected async visitAssert(anAssert: J.Assert, p: P): Promise<J | undefined> {
@@ -160,12 +180,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
160
180
  }
161
181
  anAssert = statement as J.Assert;
162
182
 
163
- const updates = {
183
+ const updates = await this.visitChildrenOf(anAssert, async () => ({
164
184
  prefix: await this.visitSpace(anAssert.prefix, p),
165
185
  markers: await this.visitMarkers(anAssert.markers, p),
166
186
  condition: await this.visitDefined(anAssert.condition, p) as Expression,
167
187
  detail: await this.visitOptionalLeftPadded(anAssert.detail, p)
168
- };
188
+ }));
169
189
  return updateIfChanged(anAssert, updates);
170
190
  }
171
191
 
@@ -182,13 +202,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
182
202
  }
183
203
  assignment = statement as J.Assignment;
184
204
 
185
- const updates = {
205
+ const updates = await this.visitChildrenOf(assignment, async () => ({
186
206
  prefix: await this.visitSpace(assignment.prefix, p),
187
207
  markers: await this.visitMarkers(assignment.markers, p),
188
208
  variable: await this.visitDefined(assignment.variable, p) as Expression,
189
209
  assignment: await this.visitLeftPadded(assignment.assignment, p),
190
210
  type: await this.visitType(assignment.type, p)
191
- };
211
+ }));
192
212
  return updateIfChanged(assignment, updates);
193
213
  }
194
214
 
@@ -205,14 +225,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
205
225
  }
206
226
  assignOp = statement as J.AssignmentOperation;
207
227
 
208
- const updates = {
228
+ const updates = await this.visitChildrenOf(assignOp, async () => ({
209
229
  prefix: await this.visitSpace(assignOp.prefix, p),
210
230
  markers: await this.visitMarkers(assignOp.markers, p),
211
231
  variable: await this.visitDefined(assignOp.variable, p) as Expression,
212
232
  operator: await this.visitLeftPadded(assignOp.operator, p),
213
233
  assignment: await this.visitDefined(assignOp.assignment, p) as Expression,
214
234
  type: await this.visitType(assignOp.type, p)
215
- };
235
+ }));
216
236
  return updateIfChanged(assignOp, updates);
217
237
  }
218
238
 
@@ -223,14 +243,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
223
243
  }
224
244
  binary = expression as J.Binary;
225
245
 
226
- const updates = {
246
+ const updates = await this.visitChildrenOf(binary, async () => ({
227
247
  prefix: await this.visitSpace(binary.prefix, p),
228
248
  markers: await this.visitMarkers(binary.markers, p),
229
249
  left: await this.visitDefined(binary.left, p) as Expression,
230
250
  operator: await this.visitLeftPadded(binary.operator, p),
231
251
  right: await this.visitDefined(binary.right, p) as Expression,
232
252
  type: await this.visitType(binary.type, p)
233
- };
253
+ }));
234
254
  return updateIfChanged(binary, updates);
235
255
  }
236
256
 
@@ -241,13 +261,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
241
261
  }
242
262
  block = statement as J.Block;
243
263
 
244
- const updates = {
264
+ const updates = await this.visitChildrenOf(block, async () => ({
245
265
  prefix: await this.visitSpace(block.prefix, p),
246
266
  markers: await this.visitMarkers(block.markers, p),
247
267
  static: await this.visitRightPadded(block.static, p),
248
268
  statements: await mapAsync(block.statements, stmt => this.visitRightPadded(stmt, p)),
249
269
  end: await this.visitSpace(block.end, p)
250
- };
270
+ }));
251
271
  return updateIfChanged(block, updates);
252
272
  }
253
273
 
@@ -258,14 +278,16 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
258
278
  }
259
279
  breakStatement = statement as J.Break;
260
280
 
261
- const updates: any = {
262
- prefix: await this.visitSpace(breakStatement.prefix, p),
263
- markers: await this.visitMarkers(breakStatement.markers, p)
264
- };
265
- if (breakStatement.label) {
266
- updates.label = await this.visitDefined(breakStatement.label, p) as J.Identifier;
267
- }
268
- return updateIfChanged(breakStatement, updates);
281
+ return this.visitChildrenOf(breakStatement, async () => {
282
+ const updates: any = {
283
+ prefix: await this.visitSpace(breakStatement.prefix, p),
284
+ markers: await this.visitMarkers(breakStatement.markers, p)
285
+ };
286
+ if (breakStatement.label) {
287
+ updates.label = await this.visitDefined(breakStatement.label, p) as J.Identifier;
288
+ }
289
+ return updateIfChanged(breakStatement, updates);
290
+ });
269
291
  }
270
292
 
271
293
  protected async visitCase(aCase: J.Case, p: P): Promise<J | undefined> {
@@ -275,17 +297,19 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
275
297
  }
276
298
  aCase = statement as J.Case;
277
299
 
278
- const updates: any = {
279
- prefix: await this.visitSpace(aCase.prefix, p),
280
- markers: await this.visitMarkers(aCase.markers, p),
281
- caseLabels: await this.visitContainer(aCase.caseLabels, p),
282
- statements: await this.visitContainer(aCase.statements, p),
283
- body: await this.visitOptionalRightPadded(aCase.body, p)
284
- };
285
- if (aCase.guard) {
286
- updates.guard = await this.visitDefined(aCase.guard, p) as Expression;
287
- }
288
- return updateIfChanged(aCase, updates);
300
+ return this.visitChildrenOf(aCase, async () => {
301
+ const updates: any = {
302
+ prefix: await this.visitSpace(aCase.prefix, p),
303
+ markers: await this.visitMarkers(aCase.markers, p),
304
+ caseLabels: await this.visitContainer(aCase.caseLabels, p),
305
+ statements: await this.visitContainer(aCase.statements, p),
306
+ body: await this.visitOptionalRightPadded(aCase.body, p)
307
+ };
308
+ if (aCase.guard) {
309
+ updates.guard = await this.visitDefined(aCase.guard, p) as Expression;
310
+ }
311
+ return updateIfChanged(aCase, updates);
312
+ });
289
313
  }
290
314
 
291
315
  protected async visitClassDeclaration(classDecl: J.ClassDeclaration, p: P): Promise<J | undefined> {
@@ -295,7 +319,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
295
319
  }
296
320
  classDecl = statement as J.ClassDeclaration;
297
321
 
298
- const updates: any = {
322
+ const updates: any = await this.visitChildrenOf(classDecl, async () => ({
299
323
  prefix: await this.visitSpace(classDecl.prefix, p),
300
324
  markers: await this.visitMarkers(classDecl.markers, p),
301
325
  leadingAnnotations: await mapAsync(classDecl.leadingAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
@@ -309,7 +333,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
309
333
  permitting: await this.visitOptionalContainer(classDecl.permitting, p),
310
334
  body: await this.visitDefined(classDecl.body, p) as J.Block,
311
335
  type: await this.visitType(classDecl.type, p) as Type.Class | undefined
312
- };
336
+ }));
313
337
  return updateIfChanged(classDecl, updates);
314
338
  }
315
339
 
@@ -341,14 +365,16 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
341
365
  }
342
366
  continueStatement = statement as J.Continue;
343
367
 
344
- const updates: any = {
345
- prefix: await this.visitSpace(continueStatement.prefix, p),
346
- markers: await this.visitMarkers(continueStatement.markers, p)
347
- };
348
- if (continueStatement.label) {
349
- updates.label = await this.visitDefined(continueStatement.label, p) as J.Identifier;
350
- }
351
- return updateIfChanged(continueStatement, updates);
368
+ return this.visitChildrenOf(continueStatement, async () => {
369
+ const updates: any = {
370
+ prefix: await this.visitSpace(continueStatement.prefix, p),
371
+ markers: await this.visitMarkers(continueStatement.markers, p)
372
+ };
373
+ if (continueStatement.label) {
374
+ updates.label = await this.visitDefined(continueStatement.label, p) as J.Identifier;
375
+ }
376
+ return updateIfChanged(continueStatement, updates);
377
+ });
352
378
  }
353
379
 
354
380
  protected async visitControlParentheses<T extends J>(controlParens: J.ControlParentheses<T>, p: P): Promise<J | undefined> {
@@ -358,11 +384,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
358
384
  }
359
385
  controlParens = expression as J.ControlParentheses<T>;
360
386
 
361
- const updates: any = {
387
+ const updates: any = await this.visitChildrenOf(controlParens, async () => ({
362
388
  prefix: await this.visitSpace(controlParens.prefix, p),
363
389
  markers: await this.visitMarkers(controlParens.markers, p),
364
390
  tree: await this.visitRightPadded(controlParens.tree, p)
365
- };
391
+ }));
366
392
  return updateIfChanged(controlParens, updates);
367
393
  }
368
394
 
@@ -384,12 +410,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
384
410
  }
385
411
  doWhileLoop = statement as J.DoWhileLoop;
386
412
 
387
- const updates: any = {
413
+ const updates: any = await this.visitChildrenOf(doWhileLoop, async () => ({
388
414
  prefix: await this.visitSpace(doWhileLoop.prefix, p),
389
415
  markers: await this.visitMarkers(doWhileLoop.markers, p),
390
416
  body: await this.visitRightPadded(doWhileLoop.body, p),
391
417
  whileCondition: await this.visitLeftPadded(doWhileLoop.whileCondition, p)
392
- };
418
+ }));
393
419
  return updateIfChanged(doWhileLoop, updates);
394
420
  }
395
421
 
@@ -433,11 +459,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
433
459
  }
434
460
  enumValueSet = statement as J.EnumValueSet;
435
461
 
436
- const updates: any = {
462
+ const updates: any = await this.visitChildrenOf(enumValueSet, async () => ({
437
463
  prefix: await this.visitSpace(enumValueSet.prefix, p),
438
464
  markers: await this.visitMarkers(enumValueSet.markers, p),
439
465
  enums: await mapAsync(enumValueSet.enums, e => this.visitRightPadded(e, p))
440
- };
466
+ }));
441
467
  return updateIfChanged(enumValueSet, updates);
442
468
  }
443
469
 
@@ -474,13 +500,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
474
500
  }
475
501
  fieldAccess = statement as J.FieldAccess;
476
502
 
477
- const updates: any = {
503
+ const updates: any = await this.visitChildrenOf(fieldAccess, async () => ({
478
504
  prefix: await this.visitSpace(fieldAccess.prefix, p),
479
505
  markers: await this.visitMarkers(fieldAccess.markers, p),
480
506
  target: await this.visitDefined(fieldAccess.target, p) as Expression,
481
507
  name: await this.visitLeftPadded(fieldAccess.name, p),
482
508
  type: await this.visitType(fieldAccess.type, p)
483
- };
509
+ }));
484
510
  return updateIfChanged(fieldAccess, updates);
485
511
  }
486
512
 
@@ -491,12 +517,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
491
517
  }
492
518
  forLoop = statement as J.ForEachLoop;
493
519
 
494
- const updates: any = {
520
+ const updates: any = await this.visitChildrenOf(forLoop, async () => ({
495
521
  prefix: await this.visitSpace(forLoop.prefix, p),
496
522
  markers: await this.visitMarkers(forLoop.markers, p),
497
523
  control: await this.visitDefined(forLoop.control, p) as J.ForEachLoop.Control,
498
524
  body: await this.visitRightPadded(forLoop.body, p)
499
- };
525
+ }));
500
526
  return updateIfChanged(forLoop, updates);
501
527
  }
502
528
 
@@ -517,12 +543,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
517
543
  }
518
544
  forLoop = statement as J.ForLoop;
519
545
 
520
- const updates: any = {
546
+ const updates: any = await this.visitChildrenOf(forLoop, async () => ({
521
547
  prefix: await this.visitSpace(forLoop.prefix, p),
522
548
  markers: await this.visitMarkers(forLoop.markers, p),
523
549
  control: await this.visitDefined(forLoop.control, p) as J.ForLoop.Control,
524
550
  body: await this.visitRightPadded(forLoop.body, p)
525
- };
551
+ }));
526
552
  return updateIfChanged(forLoop, updates);
527
553
  }
528
554
 
@@ -561,16 +587,18 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
561
587
  }
562
588
  iff = statement as J.If;
563
589
 
564
- const updates: any = {
565
- prefix: await this.visitSpace(iff.prefix, p),
566
- markers: await this.visitMarkers(iff.markers, p),
567
- ifCondition: await this.visitDefined(iff.ifCondition, p) as J.ControlParentheses<Expression>,
568
- thenPart: await this.visitRightPadded(iff.thenPart, p)
569
- };
570
- if (iff.elsePart) {
571
- updates.elsePart = await this.visitDefined(iff.elsePart, p) as J.If.Else;
572
- }
573
- return updateIfChanged(iff, updates);
590
+ return this.visitChildrenOf(iff, async () => {
591
+ const updates: any = {
592
+ prefix: await this.visitSpace(iff.prefix, p),
593
+ markers: await this.visitMarkers(iff.markers, p),
594
+ ifCondition: await this.visitDefined(iff.ifCondition, p) as J.ControlParentheses<Expression>,
595
+ thenPart: await this.visitRightPadded(iff.thenPart, p)
596
+ };
597
+ if (iff.elsePart) {
598
+ updates.elsePart = await this.visitDefined(iff.elsePart, p) as J.If.Else;
599
+ }
600
+ return updateIfChanged(iff, updates);
601
+ });
574
602
  }
575
603
 
576
604
  protected async visitElse(anElse: J.If.Else, p: P): Promise<J | undefined> {
@@ -600,20 +628,22 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
600
628
  }
601
629
  instanceOf = expression as J.InstanceOf;
602
630
 
603
- const updates: any = {
604
- prefix: await this.visitSpace(instanceOf.prefix, p),
605
- markers: await this.visitMarkers(instanceOf.markers, p),
606
- expression: await this.visitRightPadded(instanceOf.expression, p),
607
- class: await this.visitDefined(instanceOf.class, p) as J,
608
- type: await this.visitType(instanceOf.type, p)
609
- };
610
- if (instanceOf.pattern) {
611
- updates.pattern = await this.visitDefined(instanceOf.pattern, p) as J;
612
- }
613
- if (instanceOf.modifier) {
614
- updates.modifier = await this.visitDefined(instanceOf.modifier, p) as J.Modifier;
615
- }
616
- return updateIfChanged(instanceOf, updates);
631
+ return this.visitChildrenOf(instanceOf, async () => {
632
+ const updates: any = {
633
+ prefix: await this.visitSpace(instanceOf.prefix, p),
634
+ markers: await this.visitMarkers(instanceOf.markers, p),
635
+ expression: await this.visitRightPadded(instanceOf.expression, p),
636
+ class: await this.visitDefined(instanceOf.class, p) as J,
637
+ type: await this.visitType(instanceOf.type, p)
638
+ };
639
+ if (instanceOf.pattern) {
640
+ updates.pattern = await this.visitDefined(instanceOf.pattern, p) as J;
641
+ }
642
+ if (instanceOf.modifier) {
643
+ updates.modifier = await this.visitDefined(instanceOf.modifier, p) as J.Modifier;
644
+ }
645
+ return updateIfChanged(instanceOf, updates);
646
+ });
617
647
  }
618
648
 
619
649
  protected async visitIntersectionType(intersectionType: J.IntersectionType, p: P): Promise<J | undefined> {
@@ -623,11 +653,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
623
653
  }
624
654
  intersectionType = expression as J.IntersectionType;
625
655
 
626
- const updates: any = {
656
+ const updates: any = await this.visitChildrenOf(intersectionType, async () => ({
627
657
  prefix: await this.visitSpace(intersectionType.prefix, p),
628
658
  markers: await this.visitMarkers(intersectionType.markers, p),
629
659
  bounds: await this.visitContainer(intersectionType.bounds, p)
630
- };
660
+ }));
631
661
  return updateIfChanged(intersectionType, updates);
632
662
  }
633
663
 
@@ -638,12 +668,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
638
668
  }
639
669
  label = statement as J.Label;
640
670
 
641
- const updates: any = {
671
+ const updates: any = await this.visitChildrenOf(label, async () => ({
642
672
  prefix: await this.visitSpace(label.prefix, p),
643
673
  markers: await this.visitMarkers(label.markers, p),
644
674
  label: await this.visitRightPadded(label.label, p),
645
675
  statement: await this.visitDefined(label.statement, p) as Statement
646
- };
676
+ }));
647
677
  return updateIfChanged(label, updates);
648
678
  }
649
679
 
@@ -660,14 +690,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
660
690
  }
661
691
  lambda = statement as J.Lambda;
662
692
 
663
- const updates: any = {
693
+ const updates: any = await this.visitChildrenOf(lambda, async () => ({
664
694
  prefix: await this.visitSpace(lambda.prefix, p),
665
695
  markers: await this.visitMarkers(lambda.markers, p),
666
696
  parameters: await this.visitDefined(lambda.parameters, p) as J.Lambda.Parameters,
667
697
  arrow: await this.visitSpace(lambda.arrow, p),
668
698
  body: await this.visitDefined(lambda.body, p) as Statement | Expression,
669
699
  type: await this.visitType(lambda.type, p)
670
- };
700
+ }));
671
701
  return updateIfChanged(lambda, updates);
672
702
  }
673
703
 
@@ -702,7 +732,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
702
732
  }
703
733
  memberRef = expression as J.MemberReference;
704
734
 
705
- const updates: any = {
735
+ const updates: any = await this.visitChildrenOf(memberRef, async () => ({
706
736
  prefix: await this.visitSpace(memberRef.prefix, p),
707
737
  markers: await this.visitMarkers(memberRef.markers, p),
708
738
  containing: await this.visitRightPadded(memberRef.containing, p),
@@ -711,7 +741,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
711
741
  type: await this.visitType(memberRef.type, p),
712
742
  methodType: await this.visitType(memberRef.methodType, p) as Type.Method | undefined,
713
743
  variableType: await this.visitType(memberRef.variableType, p) as Type.Variable | undefined
714
- };
744
+ }));
715
745
  return updateIfChanged(memberRef, updates);
716
746
  }
717
747
 
@@ -722,27 +752,29 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
722
752
  }
723
753
  method = statement as J.MethodDeclaration;
724
754
 
725
- const updates: any = {
726
- prefix: await this.visitSpace(method.prefix, p),
727
- markers: await this.visitMarkers(method.markers, p),
728
- leadingAnnotations: await mapAsync(method.leadingAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
729
- modifiers: await mapAsync(method.modifiers, m => this.visitDefined<J.Modifier>(m, p)),
730
- nameAnnotations: await mapAsync(method.nameAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
731
- name: await this.visitDefined(method.name, p),
732
- parameters: await this.visitContainer(method.parameters, p),
733
- dimensionsAfterName: await mapAsync(method.dimensionsAfterName ?? [], dim => this.visitLeftPadded(dim, p)),
734
- throws: method.throws && await this.visitContainer(method.throws, p),
735
- body: method.body && await this.visitDefined(method.body, p) as J.Block,
736
- defaultValue: await this.visitOptionalLeftPadded(method.defaultValue, p),
737
- methodType: await this.visitType(method.methodType, p) as Type.Method | undefined
738
- };
739
- if (method.typeParameters) {
740
- updates.typeParameters = await this.visitDefined(method.typeParameters, p) as J.TypeParameters;
741
- }
742
- if (method.returnTypeExpression) {
743
- updates.returnTypeExpression = await this.visitDefined(method.returnTypeExpression, p) as TypedTree;
744
- }
745
- return updateIfChanged(method, updates);
755
+ return this.visitChildrenOf(method, async () => {
756
+ const updates: any = {
757
+ prefix: await this.visitSpace(method.prefix, p),
758
+ markers: await this.visitMarkers(method.markers, p),
759
+ leadingAnnotations: await mapAsync(method.leadingAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
760
+ modifiers: await mapAsync(method.modifiers, m => this.visitDefined<J.Modifier>(m, p)),
761
+ nameAnnotations: await mapAsync(method.nameAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
762
+ name: await this.visitDefined(method.name, p),
763
+ parameters: await this.visitContainer(method.parameters, p),
764
+ dimensionsAfterName: await mapAsync(method.dimensionsAfterName ?? [], dim => this.visitLeftPadded(dim, p)),
765
+ throws: method.throws && await this.visitContainer(method.throws, p),
766
+ body: method.body && await this.visitDefined(method.body, p) as J.Block,
767
+ defaultValue: await this.visitOptionalLeftPadded(method.defaultValue, p),
768
+ methodType: await this.visitType(method.methodType, p) as Type.Method | undefined
769
+ };
770
+ if (method.typeParameters) {
771
+ updates.typeParameters = await this.visitDefined(method.typeParameters, p) as J.TypeParameters;
772
+ }
773
+ if (method.returnTypeExpression) {
774
+ updates.returnTypeExpression = await this.visitDefined(method.returnTypeExpression, p) as TypedTree;
775
+ }
776
+ return updateIfChanged(method, updates);
777
+ });
746
778
  }
747
779
 
748
780
  protected async visitMethodInvocation(method: J.MethodInvocation, p: P): Promise<J | undefined> {
@@ -758,7 +790,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
758
790
  }
759
791
  method = statement as J.MethodInvocation;
760
792
 
761
- const updates: any = {
793
+ const updates: any = await this.visitChildrenOf(method, async () => ({
762
794
  prefix: await this.visitSpace(method.prefix, p),
763
795
  markers: await this.visitMarkers(method.markers, p),
764
796
  select: await this.visitOptionalRightPadded(method.select, p),
@@ -766,7 +798,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
766
798
  name: await this.visitDefined(method.name, p) as J.Identifier,
767
799
  arguments: await this.visitContainer(method.arguments, p),
768
800
  methodType: await this.visitType(method.methodType, p) as Type.Method | undefined
769
- };
801
+ }));
770
802
  return updateIfChanged(method, updates);
771
803
  }
772
804
 
@@ -795,17 +827,19 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
795
827
  }
796
828
  newArray = expression as J.NewArray;
797
829
 
798
- const updates: any = {
799
- prefix: await this.visitSpace(newArray.prefix, p),
800
- markers: await this.visitMarkers(newArray.markers, p),
801
- dimensions: await mapAsync(newArray.dimensions, dim => this.visitDefined<J.ArrayDimension>(dim, p)),
802
- initializer: await this.visitOptionalContainer(newArray.initializer, p),
803
- type: await this.visitType(newArray.type, p)
804
- };
805
- if (newArray.typeExpression) {
806
- updates.typeExpression = await this.visitDefined(newArray.typeExpression, p) as TypedTree;
807
- }
808
- return updateIfChanged(newArray, updates);
830
+ return this.visitChildrenOf(newArray, async () => {
831
+ const updates: any = {
832
+ prefix: await this.visitSpace(newArray.prefix, p),
833
+ markers: await this.visitMarkers(newArray.markers, p),
834
+ dimensions: await mapAsync(newArray.dimensions, dim => this.visitDefined<J.ArrayDimension>(dim, p)),
835
+ initializer: await this.visitOptionalContainer(newArray.initializer, p),
836
+ type: await this.visitType(newArray.type, p)
837
+ };
838
+ if (newArray.typeExpression) {
839
+ updates.typeExpression = await this.visitDefined(newArray.typeExpression, p) as TypedTree;
840
+ }
841
+ return updateIfChanged(newArray, updates);
842
+ });
809
843
  }
810
844
 
811
845
  protected async visitNewClass(newClass: J.NewClass, p: P): Promise<J | undefined> {
@@ -821,23 +855,25 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
821
855
  }
822
856
  newClass = statement as J.NewClass;
823
857
 
824
- const updates: any = {
825
- prefix: await this.visitSpace(newClass.prefix, p),
826
- markers: await this.visitMarkers(newClass.markers, p),
827
- new: await this.visitSpace(newClass.new, p),
828
- arguments: await this.visitContainer(newClass.arguments, p),
829
- constructorType: await this.visitType(newClass.constructorType, p) as Type.Method | undefined
830
- };
831
- if (newClass.enclosing) {
832
- updates.enclosing = await this.visitRightPadded(newClass.enclosing, p);
833
- }
834
- if (newClass.class) {
835
- updates.class = await this.visitDefined(newClass.class, p) as TypedTree;
836
- }
837
- if (newClass.body) {
838
- updates.body = await this.visitDefined(newClass.body, p) as J.Block;
839
- }
840
- return updateIfChanged(newClass, updates);
858
+ return this.visitChildrenOf(newClass, async () => {
859
+ const updates: any = {
860
+ prefix: await this.visitSpace(newClass.prefix, p),
861
+ markers: await this.visitMarkers(newClass.markers, p),
862
+ new: await this.visitSpace(newClass.new, p),
863
+ arguments: await this.visitContainer(newClass.arguments, p),
864
+ constructorType: await this.visitType(newClass.constructorType, p) as Type.Method | undefined
865
+ };
866
+ if (newClass.enclosing) {
867
+ updates.enclosing = await this.visitRightPadded(newClass.enclosing, p);
868
+ }
869
+ if (newClass.class) {
870
+ updates.class = await this.visitDefined(newClass.class, p) as TypedTree;
871
+ }
872
+ if (newClass.body) {
873
+ updates.body = await this.visitDefined(newClass.body, p) as J.Block;
874
+ }
875
+ return updateIfChanged(newClass, updates);
876
+ });
841
877
  }
842
878
 
843
879
  protected async visitNullableType(nullableType: J.NullableType, p: P): Promise<J | undefined> {
@@ -847,12 +883,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
847
883
  }
848
884
  nullableType = expression as J.NullableType;
849
885
 
850
- const updates: any = {
886
+ const updates: any = await this.visitChildrenOf(nullableType, async () => ({
851
887
  prefix: await this.visitSpace(nullableType.prefix, p),
852
888
  markers: await this.visitMarkers(nullableType.markers, p),
853
889
  annotations: await mapAsync(nullableType.annotations, a => this.visitDefined<J.Annotation>(a, p)),
854
890
  typeTree: await this.visitRightPadded(nullableType.typeTree, p)
855
- };
891
+ }));
856
892
  return updateIfChanged(nullableType, updates);
857
893
  }
858
894
 
@@ -875,13 +911,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
875
911
  }
876
912
  parameterizedType = expression as J.ParameterizedType;
877
913
 
878
- const updates: any = {
914
+ const updates: any = await this.visitChildrenOf(parameterizedType, async () => ({
879
915
  prefix: await this.visitSpace(parameterizedType.prefix, p),
880
916
  markers: await this.visitMarkers(parameterizedType.markers, p),
881
917
  class: await this.visitTypeName(parameterizedType.class, p),
882
918
  typeParameters: await this.visitOptionalContainer(parameterizedType.typeParameters, p),
883
919
  type: await this.visitType(parameterizedType.type, p)
884
- };
920
+ }));
885
921
  return updateIfChanged(parameterizedType, updates);
886
922
  }
887
923
 
@@ -892,11 +928,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
892
928
  }
893
929
  parentheses = expression as J.Parentheses<T>;
894
930
 
895
- const updates: any = {
931
+ const updates: any = await this.visitChildrenOf(parentheses, async () => ({
896
932
  prefix: await this.visitSpace(parentheses.prefix, p),
897
933
  markers: await this.visitMarkers(parentheses.markers, p),
898
934
  tree: await this.visitRightPadded(parentheses.tree, p)
899
- };
935
+ }));
900
936
  return updateIfChanged(parentheses, updates);
901
937
  }
902
938
 
@@ -907,12 +943,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
907
943
  }
908
944
  parTypeTree = expression as J.ParenthesizedTypeTree;
909
945
 
910
- const updates: any = {
946
+ const updates: any = await this.visitChildrenOf(parTypeTree, async () => ({
911
947
  prefix: await this.visitSpace(parTypeTree.prefix, p),
912
948
  markers: await this.visitMarkers(parTypeTree.markers, p),
913
949
  annotations: await mapAsync(parTypeTree.annotations, a => this.visitDefined<J.Annotation>(a, p)),
914
950
  parenthesizedType: await this.visitDefined(parTypeTree.parenthesizedType, p) as J.Parentheses<TypeTree>
915
- };
951
+ }));
916
952
  return updateIfChanged(parTypeTree, updates);
917
953
  }
918
954
 
@@ -938,14 +974,16 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
938
974
  }
939
975
  ret = statement as J.Return;
940
976
 
941
- const updates: any = {
942
- prefix: await this.visitSpace(ret.prefix, p),
943
- markers: await this.visitMarkers(ret.markers, p)
944
- };
945
- if (ret.expression) {
946
- updates.expression = await this.visitDefined(ret.expression, p) as Expression;
947
- }
948
- return updateIfChanged(ret, updates);
977
+ return this.visitChildrenOf(ret, async () => {
978
+ const updates: any = {
979
+ prefix: await this.visitSpace(ret.prefix, p),
980
+ markers: await this.visitMarkers(ret.markers, p)
981
+ };
982
+ if (ret.expression) {
983
+ updates.expression = await this.visitDefined(ret.expression, p) as Expression;
984
+ }
985
+ return updateIfChanged(ret, updates);
986
+ });
949
987
  }
950
988
 
951
989
  protected async visitSwitch(aSwitch: J.Switch, p: P): Promise<J | undefined> {
@@ -955,12 +993,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
955
993
  }
956
994
  aSwitch = statement as J.Switch;
957
995
 
958
- const updates: any = {
996
+ const updates: any = await this.visitChildrenOf(aSwitch, async () => ({
959
997
  prefix: await this.visitSpace(aSwitch.prefix, p),
960
998
  markers: await this.visitMarkers(aSwitch.markers, p),
961
999
  selector: await this.visitDefined(aSwitch.selector, p) as J.ControlParentheses<Expression>,
962
1000
  cases: await this.visitDefined(aSwitch.cases, p) as J.Block
963
- };
1001
+ }));
964
1002
  return updateIfChanged(aSwitch, updates);
965
1003
  }
966
1004
 
@@ -971,13 +1009,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
971
1009
  }
972
1010
  switchExpr = expression as J.SwitchExpression;
973
1011
 
974
- const updates: any = {
1012
+ const updates: any = await this.visitChildrenOf(switchExpr, async () => ({
975
1013
  prefix: await this.visitSpace(switchExpr.prefix, p),
976
1014
  markers: await this.visitMarkers(switchExpr.markers, p),
977
1015
  selector: await this.visitDefined(switchExpr.selector, p) as J.ControlParentheses<Expression>,
978
1016
  cases: await this.visitDefined(switchExpr.cases, p) as J.Block,
979
1017
  type: await this.visitType(switchExpr.type, p)
980
- };
1018
+ }));
981
1019
  return updateIfChanged(switchExpr, updates);
982
1020
  }
983
1021
 
@@ -988,12 +1026,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
988
1026
  }
989
1027
  sync = statement as J.Synchronized;
990
1028
 
991
- const updates: any = {
1029
+ const updates: any = await this.visitChildrenOf(sync, async () => ({
992
1030
  prefix: await this.visitSpace(sync.prefix, p),
993
1031
  markers: await this.visitMarkers(sync.markers, p),
994
1032
  lock: await this.visitDefined(sync.lock, p) as J.ControlParentheses<Expression>,
995
1033
  body: await this.visitDefined(sync.body, p) as J.Block
996
- };
1034
+ }));
997
1035
  return updateIfChanged(sync, updates);
998
1036
  }
999
1037
 
@@ -1010,14 +1048,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1010
1048
  }
1011
1049
  ternary = statement as J.Ternary;
1012
1050
 
1013
- const updates: any = {
1051
+ const updates: any = await this.visitChildrenOf(ternary, async () => ({
1014
1052
  prefix: await this.visitSpace(ternary.prefix, p),
1015
1053
  markers: await this.visitMarkers(ternary.markers, p),
1016
1054
  condition: await this.visitDefined(ternary.condition, p) as Expression,
1017
1055
  truePart: await this.visitLeftPadded(ternary.truePart, p),
1018
1056
  falsePart: await this.visitLeftPadded(ternary.falsePart, p),
1019
1057
  type: await this.visitType(ternary.type, p)
1020
- };
1058
+ }));
1021
1059
  return updateIfChanged(ternary, updates);
1022
1060
  }
1023
1061
 
@@ -1028,11 +1066,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1028
1066
  }
1029
1067
  thrown = statement as J.Throw;
1030
1068
 
1031
- const updates: any = {
1069
+ const updates: any = await this.visitChildrenOf(thrown, async () => ({
1032
1070
  prefix: await this.visitSpace(thrown.prefix, p),
1033
1071
  markers: await this.visitMarkers(thrown.markers, p),
1034
1072
  exception: await this.visitDefined(thrown.exception, p) as Expression
1035
- };
1073
+ }));
1036
1074
  return updateIfChanged(thrown, updates);
1037
1075
  }
1038
1076
 
@@ -1043,14 +1081,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1043
1081
  }
1044
1082
  tryable = statement as J.Try;
1045
1083
 
1046
- const updates: any = {
1084
+ const updates: any = await this.visitChildrenOf(tryable, async () => ({
1047
1085
  prefix: await this.visitSpace(tryable.prefix, p),
1048
1086
  markers: await this.visitMarkers(tryable.markers, p),
1049
1087
  resources: await this.visitOptionalContainer(tryable.resources, p),
1050
1088
  body: await this.visitDefined(tryable.body, p) as J.Block,
1051
1089
  catches: await mapAsync(tryable.catches, c => this.visitDefined<J.Try.Catch>(c, p)),
1052
1090
  finally: await this.visitOptionalLeftPadded(tryable.finally, p)
1053
- };
1091
+ }));
1054
1092
  return updateIfChanged(tryable, updates);
1055
1093
  }
1056
1094
 
@@ -1080,12 +1118,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1080
1118
  }
1081
1119
  typeCast = expression as J.TypeCast;
1082
1120
 
1083
- const updates: any = {
1121
+ const updates: any = await this.visitChildrenOf(typeCast, async () => ({
1084
1122
  prefix: await this.visitSpace(typeCast.prefix, p),
1085
1123
  markers: await this.visitMarkers(typeCast.markers, p),
1086
1124
  class: await this.visitDefined(typeCast.class, p) as J.ControlParentheses<TypedTree>,
1087
1125
  expression: await this.visitDefined(typeCast.expression, p) as Expression
1088
- };
1126
+ }));
1089
1127
  return updateIfChanged(typeCast, updates);
1090
1128
  }
1091
1129
 
@@ -1124,13 +1162,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1124
1162
  }
1125
1163
  unary = statement as J.Unary;
1126
1164
 
1127
- const updates: any = {
1165
+ const updates: any = await this.visitChildrenOf(unary, async () => ({
1128
1166
  prefix: await this.visitSpace(unary.prefix, p),
1129
1167
  markers: await this.visitMarkers(unary.markers, p),
1130
1168
  operator: await this.visitLeftPadded(unary.operator, p),
1131
1169
  expression: await this.visitDefined(unary.expression, p) as Expression,
1132
1170
  type: await this.visitType(unary.type, p)
1133
- };
1171
+ }));
1134
1172
  return updateIfChanged(unary, updates);
1135
1173
  }
1136
1174
 
@@ -1147,11 +1185,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1147
1185
  }
1148
1186
  unknown = statement as J.Unknown;
1149
1187
 
1150
- const updates: any = {
1188
+ const updates: any = await this.visitChildrenOf(unknown, async () => ({
1151
1189
  prefix: await this.visitSpace(unknown.prefix, p),
1152
1190
  markers: await this.visitMarkers(unknown.markers, p),
1153
1191
  source: await this.visitDefined(unknown.source, p) as J.UnknownSource
1154
- };
1192
+ }));
1155
1193
  return updateIfChanged(unknown, updates);
1156
1194
  }
1157
1195
 
@@ -1170,20 +1208,22 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1170
1208
  }
1171
1209
  varDecls = statement as J.VariableDeclarations;
1172
1210
 
1173
- const updates: any = {
1174
- prefix: await this.visitSpace(varDecls.prefix, p),
1175
- markers: await this.visitMarkers(varDecls.markers, p),
1176
- leadingAnnotations: await mapAsync(varDecls.leadingAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
1177
- modifiers: await mapAsync(varDecls.modifiers, m => this.visitDefined<J.Modifier>(m, p)),
1178
- variables: await mapAsync(varDecls.variables, v => this.visitRightPadded(v, p))
1179
- };
1180
- if (varDecls.typeExpression) {
1181
- updates.typeExpression = await this.visitDefined(varDecls.typeExpression, p) as TypedTree;
1182
- }
1183
- if (varDecls.varargs) {
1184
- updates.varargs = await this.visitSpace(varDecls.varargs, p);
1185
- }
1186
- return updateIfChanged(varDecls, updates);
1211
+ return this.visitChildrenOf(varDecls, async () => {
1212
+ const updates: any = {
1213
+ prefix: await this.visitSpace(varDecls.prefix, p),
1214
+ markers: await this.visitMarkers(varDecls.markers, p),
1215
+ leadingAnnotations: await mapAsync(varDecls.leadingAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
1216
+ modifiers: await mapAsync(varDecls.modifiers, m => this.visitDefined<J.Modifier>(m, p)),
1217
+ variables: await mapAsync(varDecls.variables, v => this.visitRightPadded(v, p))
1218
+ };
1219
+ if (varDecls.typeExpression) {
1220
+ updates.typeExpression = await this.visitDefined(varDecls.typeExpression, p) as TypedTree;
1221
+ }
1222
+ if (varDecls.varargs) {
1223
+ updates.varargs = await this.visitSpace(varDecls.varargs, p);
1224
+ }
1225
+ return updateIfChanged(varDecls, updates);
1226
+ });
1187
1227
  }
1188
1228
 
1189
1229
  protected async visitVariable(variable: J.VariableDeclarations.NamedVariable, p: P): Promise<J | undefined> {
@@ -1205,12 +1245,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1205
1245
  }
1206
1246
  whileLoop = statement as J.WhileLoop;
1207
1247
 
1208
- const updates: any = {
1248
+ const updates: any = await this.visitChildrenOf(whileLoop, async () => ({
1209
1249
  prefix: await this.visitSpace(whileLoop.prefix, p),
1210
1250
  markers: await this.visitMarkers(whileLoop.markers, p),
1211
1251
  condition: await this.visitDefined(whileLoop.condition, p) as J.ControlParentheses<Expression>,
1212
1252
  body: await this.visitRightPadded(whileLoop.body, p)
1213
- };
1253
+ }));
1214
1254
  return updateIfChanged(whileLoop, updates);
1215
1255
  }
1216
1256
 
@@ -1221,15 +1261,17 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1221
1261
  }
1222
1262
  wildcard = expression as J.Wildcard;
1223
1263
 
1224
- const updates: any = {
1225
- prefix: await this.visitSpace(wildcard.prefix, p),
1226
- markers: await this.visitMarkers(wildcard.markers, p),
1227
- bound: await this.visitOptionalLeftPadded(wildcard.bound, p)
1228
- };
1229
- if (wildcard.boundedType) {
1230
- updates.boundedType = await this.visitTypeName(wildcard.boundedType, p);
1231
- }
1232
- return updateIfChanged(wildcard, updates);
1264
+ return this.visitChildrenOf(wildcard, async () => {
1265
+ const updates: any = {
1266
+ prefix: await this.visitSpace(wildcard.prefix, p),
1267
+ markers: await this.visitMarkers(wildcard.markers, p),
1268
+ bound: await this.visitOptionalLeftPadded(wildcard.bound, p)
1269
+ };
1270
+ if (wildcard.boundedType) {
1271
+ updates.boundedType = await this.visitTypeName(wildcard.boundedType, p);
1272
+ }
1273
+ return updateIfChanged(wildcard, updates);
1274
+ });
1233
1275
  }
1234
1276
 
1235
1277
  protected async visitYield(aYield: J.Yield, p: P): Promise<J | undefined> {
@@ -1239,12 +1281,17 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1239
1281
  }
1240
1282
  aYield = statement as J.Yield;
1241
1283
 
1242
- const updates: any = {
1243
- prefix: await this.visitSpace(aYield.prefix, p),
1244
- markers: await this.visitMarkers(aYield.markers, p),
1245
- value: await this.visitDefined(aYield.value, p) as Expression
1246
- };
1247
- return updateIfChanged(aYield, updates);
1284
+ return this.visitChildrenOf(aYield, async () => {
1285
+ const updates: any = {
1286
+ prefix: await this.visitSpace(aYield.prefix, p),
1287
+ markers: await this.visitMarkers(aYield.markers, p)
1288
+ };
1289
+ // a bare `yield` has no value
1290
+ if (aYield.value) {
1291
+ updates.value = await this.visitDefined(aYield.value, p) as Expression;
1292
+ }
1293
+ return updateIfChanged(aYield, updates);
1294
+ });
1248
1295
  }
1249
1296
 
1250
1297
  protected async visitOptionalRightPadded<T extends J | boolean>(right: J.RightPadded<T> | undefined, p: P): Promise<J.RightPadded<T> | undefined> {