@openrewrite/rewrite 8.96.5 → 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 (30) hide show
  1. package/dist/java/tree.d.ts +2 -1
  2. package/dist/java/tree.d.ts.map +1 -1
  3. package/dist/java/tree.js.map +1 -1
  4. package/dist/java/visitor.d.ts +5 -0
  5. package/dist/java/visitor.d.ts.map +1 -1
  6. package/dist/java/visitor.js +264 -231
  7. package/dist/java/visitor.js.map +1 -1
  8. package/dist/javascript/dependency-workspace.d.ts +8 -2
  9. package/dist/javascript/dependency-workspace.d.ts.map +1 -1
  10. package/dist/javascript/dependency-workspace.js +36 -4
  11. package/dist/javascript/dependency-workspace.js.map +1 -1
  12. package/dist/javascript/templating/engine.d.ts +1 -0
  13. package/dist/javascript/templating/engine.d.ts.map +1 -1
  14. package/dist/javascript/templating/engine.js +28 -4
  15. package/dist/javascript/templating/engine.js.map +1 -1
  16. package/dist/javascript/templating/placeholder-replacement.d.ts +2 -0
  17. package/dist/javascript/templating/placeholder-replacement.d.ts.map +1 -1
  18. package/dist/javascript/templating/placeholder-replacement.js +24 -3
  19. package/dist/javascript/templating/placeholder-replacement.js.map +1 -1
  20. package/dist/javascript/visitor.d.ts.map +1 -1
  21. package/dist/javascript/visitor.js +135 -121
  22. package/dist/javascript/visitor.js.map +1 -1
  23. package/dist/rewrite-javascript-version.txt +1 -1
  24. package/package.json +1 -1
  25. package/src/java/tree.ts +2 -1
  26. package/src/java/visitor.ts +263 -230
  27. package/src/javascript/dependency-workspace.ts +35 -3
  28. package/src/javascript/templating/engine.ts +30 -3
  29. package/src/javascript/templating/placeholder-replacement.ts +24 -3
  30. package/src/javascript/visitor.ts +139 -121
@@ -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
 
@@ -221,27 +241,16 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
221
241
  if (!expression?.kind || expression.kind !== J.Kind.Binary) {
222
242
  return expression;
223
243
  }
224
- const given = this.cursor;
225
- if (expression !== binary && given.value === binary) {
226
- // the operands are visited under the binary that holds them, where a template reads their slots
227
- this.cursor = new Cursor(expression, given.parent);
228
- given.messages.forEach((value, key) => this.cursor.messages.set(key, value));
229
- }
230
244
  binary = expression as J.Binary;
231
245
 
232
- const updates = {
246
+ const updates = await this.visitChildrenOf(binary, async () => ({
233
247
  prefix: await this.visitSpace(binary.prefix, p),
234
248
  markers: await this.visitMarkers(binary.markers, p),
235
249
  left: await this.visitDefined(binary.left, p) as Expression,
236
250
  operator: await this.visitLeftPadded(binary.operator, p),
237
251
  right: await this.visitDefined(binary.right, p) as Expression,
238
252
  type: await this.visitType(binary.type, p)
239
- };
240
- if (this.cursor !== given) {
241
- // what follows reads the cursor of the binary it was given, as for every other tree
242
- this.cursor.messages.forEach((value, key) => given.messages.set(key, value));
243
- this.cursor = given;
244
- }
253
+ }));
245
254
  return updateIfChanged(binary, updates);
246
255
  }
247
256
 
@@ -252,13 +261,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
252
261
  }
253
262
  block = statement as J.Block;
254
263
 
255
- const updates = {
264
+ const updates = await this.visitChildrenOf(block, async () => ({
256
265
  prefix: await this.visitSpace(block.prefix, p),
257
266
  markers: await this.visitMarkers(block.markers, p),
258
267
  static: await this.visitRightPadded(block.static, p),
259
268
  statements: await mapAsync(block.statements, stmt => this.visitRightPadded(stmt, p)),
260
269
  end: await this.visitSpace(block.end, p)
261
- };
270
+ }));
262
271
  return updateIfChanged(block, updates);
263
272
  }
264
273
 
@@ -269,14 +278,16 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
269
278
  }
270
279
  breakStatement = statement as J.Break;
271
280
 
272
- const updates: any = {
273
- prefix: await this.visitSpace(breakStatement.prefix, p),
274
- markers: await this.visitMarkers(breakStatement.markers, p)
275
- };
276
- if (breakStatement.label) {
277
- updates.label = await this.visitDefined(breakStatement.label, p) as J.Identifier;
278
- }
279
- 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
+ });
280
291
  }
281
292
 
282
293
  protected async visitCase(aCase: J.Case, p: P): Promise<J | undefined> {
@@ -286,17 +297,19 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
286
297
  }
287
298
  aCase = statement as J.Case;
288
299
 
289
- const updates: any = {
290
- prefix: await this.visitSpace(aCase.prefix, p),
291
- markers: await this.visitMarkers(aCase.markers, p),
292
- caseLabels: await this.visitContainer(aCase.caseLabels, p),
293
- statements: await this.visitContainer(aCase.statements, p),
294
- body: await this.visitOptionalRightPadded(aCase.body, p)
295
- };
296
- if (aCase.guard) {
297
- updates.guard = await this.visitDefined(aCase.guard, p) as Expression;
298
- }
299
- 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
+ });
300
313
  }
301
314
 
302
315
  protected async visitClassDeclaration(classDecl: J.ClassDeclaration, p: P): Promise<J | undefined> {
@@ -306,7 +319,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
306
319
  }
307
320
  classDecl = statement as J.ClassDeclaration;
308
321
 
309
- const updates: any = {
322
+ const updates: any = await this.visitChildrenOf(classDecl, async () => ({
310
323
  prefix: await this.visitSpace(classDecl.prefix, p),
311
324
  markers: await this.visitMarkers(classDecl.markers, p),
312
325
  leadingAnnotations: await mapAsync(classDecl.leadingAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
@@ -320,7 +333,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
320
333
  permitting: await this.visitOptionalContainer(classDecl.permitting, p),
321
334
  body: await this.visitDefined(classDecl.body, p) as J.Block,
322
335
  type: await this.visitType(classDecl.type, p) as Type.Class | undefined
323
- };
336
+ }));
324
337
  return updateIfChanged(classDecl, updates);
325
338
  }
326
339
 
@@ -352,14 +365,16 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
352
365
  }
353
366
  continueStatement = statement as J.Continue;
354
367
 
355
- const updates: any = {
356
- prefix: await this.visitSpace(continueStatement.prefix, p),
357
- markers: await this.visitMarkers(continueStatement.markers, p)
358
- };
359
- if (continueStatement.label) {
360
- updates.label = await this.visitDefined(continueStatement.label, p) as J.Identifier;
361
- }
362
- 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
+ });
363
378
  }
364
379
 
365
380
  protected async visitControlParentheses<T extends J>(controlParens: J.ControlParentheses<T>, p: P): Promise<J | undefined> {
@@ -369,11 +384,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
369
384
  }
370
385
  controlParens = expression as J.ControlParentheses<T>;
371
386
 
372
- const updates: any = {
387
+ const updates: any = await this.visitChildrenOf(controlParens, async () => ({
373
388
  prefix: await this.visitSpace(controlParens.prefix, p),
374
389
  markers: await this.visitMarkers(controlParens.markers, p),
375
390
  tree: await this.visitRightPadded(controlParens.tree, p)
376
- };
391
+ }));
377
392
  return updateIfChanged(controlParens, updates);
378
393
  }
379
394
 
@@ -395,12 +410,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
395
410
  }
396
411
  doWhileLoop = statement as J.DoWhileLoop;
397
412
 
398
- const updates: any = {
413
+ const updates: any = await this.visitChildrenOf(doWhileLoop, async () => ({
399
414
  prefix: await this.visitSpace(doWhileLoop.prefix, p),
400
415
  markers: await this.visitMarkers(doWhileLoop.markers, p),
401
416
  body: await this.visitRightPadded(doWhileLoop.body, p),
402
417
  whileCondition: await this.visitLeftPadded(doWhileLoop.whileCondition, p)
403
- };
418
+ }));
404
419
  return updateIfChanged(doWhileLoop, updates);
405
420
  }
406
421
 
@@ -444,11 +459,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
444
459
  }
445
460
  enumValueSet = statement as J.EnumValueSet;
446
461
 
447
- const updates: any = {
462
+ const updates: any = await this.visitChildrenOf(enumValueSet, async () => ({
448
463
  prefix: await this.visitSpace(enumValueSet.prefix, p),
449
464
  markers: await this.visitMarkers(enumValueSet.markers, p),
450
465
  enums: await mapAsync(enumValueSet.enums, e => this.visitRightPadded(e, p))
451
- };
466
+ }));
452
467
  return updateIfChanged(enumValueSet, updates);
453
468
  }
454
469
 
@@ -485,13 +500,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
485
500
  }
486
501
  fieldAccess = statement as J.FieldAccess;
487
502
 
488
- const updates: any = {
503
+ const updates: any = await this.visitChildrenOf(fieldAccess, async () => ({
489
504
  prefix: await this.visitSpace(fieldAccess.prefix, p),
490
505
  markers: await this.visitMarkers(fieldAccess.markers, p),
491
506
  target: await this.visitDefined(fieldAccess.target, p) as Expression,
492
507
  name: await this.visitLeftPadded(fieldAccess.name, p),
493
508
  type: await this.visitType(fieldAccess.type, p)
494
- };
509
+ }));
495
510
  return updateIfChanged(fieldAccess, updates);
496
511
  }
497
512
 
@@ -502,12 +517,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
502
517
  }
503
518
  forLoop = statement as J.ForEachLoop;
504
519
 
505
- const updates: any = {
520
+ const updates: any = await this.visitChildrenOf(forLoop, async () => ({
506
521
  prefix: await this.visitSpace(forLoop.prefix, p),
507
522
  markers: await this.visitMarkers(forLoop.markers, p),
508
523
  control: await this.visitDefined(forLoop.control, p) as J.ForEachLoop.Control,
509
524
  body: await this.visitRightPadded(forLoop.body, p)
510
- };
525
+ }));
511
526
  return updateIfChanged(forLoop, updates);
512
527
  }
513
528
 
@@ -528,12 +543,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
528
543
  }
529
544
  forLoop = statement as J.ForLoop;
530
545
 
531
- const updates: any = {
546
+ const updates: any = await this.visitChildrenOf(forLoop, async () => ({
532
547
  prefix: await this.visitSpace(forLoop.prefix, p),
533
548
  markers: await this.visitMarkers(forLoop.markers, p),
534
549
  control: await this.visitDefined(forLoop.control, p) as J.ForLoop.Control,
535
550
  body: await this.visitRightPadded(forLoop.body, p)
536
- };
551
+ }));
537
552
  return updateIfChanged(forLoop, updates);
538
553
  }
539
554
 
@@ -572,16 +587,18 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
572
587
  }
573
588
  iff = statement as J.If;
574
589
 
575
- const updates: any = {
576
- prefix: await this.visitSpace(iff.prefix, p),
577
- markers: await this.visitMarkers(iff.markers, p),
578
- ifCondition: await this.visitDefined(iff.ifCondition, p) as J.ControlParentheses<Expression>,
579
- thenPart: await this.visitRightPadded(iff.thenPart, p)
580
- };
581
- if (iff.elsePart) {
582
- updates.elsePart = await this.visitDefined(iff.elsePart, p) as J.If.Else;
583
- }
584
- 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
+ });
585
602
  }
586
603
 
587
604
  protected async visitElse(anElse: J.If.Else, p: P): Promise<J | undefined> {
@@ -611,20 +628,22 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
611
628
  }
612
629
  instanceOf = expression as J.InstanceOf;
613
630
 
614
- const updates: any = {
615
- prefix: await this.visitSpace(instanceOf.prefix, p),
616
- markers: await this.visitMarkers(instanceOf.markers, p),
617
- expression: await this.visitRightPadded(instanceOf.expression, p),
618
- class: await this.visitDefined(instanceOf.class, p) as J,
619
- type: await this.visitType(instanceOf.type, p)
620
- };
621
- if (instanceOf.pattern) {
622
- updates.pattern = await this.visitDefined(instanceOf.pattern, p) as J;
623
- }
624
- if (instanceOf.modifier) {
625
- updates.modifier = await this.visitDefined(instanceOf.modifier, p) as J.Modifier;
626
- }
627
- 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
+ });
628
647
  }
629
648
 
630
649
  protected async visitIntersectionType(intersectionType: J.IntersectionType, p: P): Promise<J | undefined> {
@@ -634,11 +653,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
634
653
  }
635
654
  intersectionType = expression as J.IntersectionType;
636
655
 
637
- const updates: any = {
656
+ const updates: any = await this.visitChildrenOf(intersectionType, async () => ({
638
657
  prefix: await this.visitSpace(intersectionType.prefix, p),
639
658
  markers: await this.visitMarkers(intersectionType.markers, p),
640
659
  bounds: await this.visitContainer(intersectionType.bounds, p)
641
- };
660
+ }));
642
661
  return updateIfChanged(intersectionType, updates);
643
662
  }
644
663
 
@@ -649,12 +668,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
649
668
  }
650
669
  label = statement as J.Label;
651
670
 
652
- const updates: any = {
671
+ const updates: any = await this.visitChildrenOf(label, async () => ({
653
672
  prefix: await this.visitSpace(label.prefix, p),
654
673
  markers: await this.visitMarkers(label.markers, p),
655
674
  label: await this.visitRightPadded(label.label, p),
656
675
  statement: await this.visitDefined(label.statement, p) as Statement
657
- };
676
+ }));
658
677
  return updateIfChanged(label, updates);
659
678
  }
660
679
 
@@ -671,14 +690,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
671
690
  }
672
691
  lambda = statement as J.Lambda;
673
692
 
674
- const updates: any = {
693
+ const updates: any = await this.visitChildrenOf(lambda, async () => ({
675
694
  prefix: await this.visitSpace(lambda.prefix, p),
676
695
  markers: await this.visitMarkers(lambda.markers, p),
677
696
  parameters: await this.visitDefined(lambda.parameters, p) as J.Lambda.Parameters,
678
697
  arrow: await this.visitSpace(lambda.arrow, p),
679
698
  body: await this.visitDefined(lambda.body, p) as Statement | Expression,
680
699
  type: await this.visitType(lambda.type, p)
681
- };
700
+ }));
682
701
  return updateIfChanged(lambda, updates);
683
702
  }
684
703
 
@@ -713,7 +732,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
713
732
  }
714
733
  memberRef = expression as J.MemberReference;
715
734
 
716
- const updates: any = {
735
+ const updates: any = await this.visitChildrenOf(memberRef, async () => ({
717
736
  prefix: await this.visitSpace(memberRef.prefix, p),
718
737
  markers: await this.visitMarkers(memberRef.markers, p),
719
738
  containing: await this.visitRightPadded(memberRef.containing, p),
@@ -722,7 +741,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
722
741
  type: await this.visitType(memberRef.type, p),
723
742
  methodType: await this.visitType(memberRef.methodType, p) as Type.Method | undefined,
724
743
  variableType: await this.visitType(memberRef.variableType, p) as Type.Variable | undefined
725
- };
744
+ }));
726
745
  return updateIfChanged(memberRef, updates);
727
746
  }
728
747
 
@@ -733,27 +752,29 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
733
752
  }
734
753
  method = statement as J.MethodDeclaration;
735
754
 
736
- const updates: any = {
737
- prefix: await this.visitSpace(method.prefix, p),
738
- markers: await this.visitMarkers(method.markers, p),
739
- leadingAnnotations: await mapAsync(method.leadingAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
740
- modifiers: await mapAsync(method.modifiers, m => this.visitDefined<J.Modifier>(m, p)),
741
- nameAnnotations: await mapAsync(method.nameAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
742
- name: await this.visitDefined(method.name, p),
743
- parameters: await this.visitContainer(method.parameters, p),
744
- dimensionsAfterName: await mapAsync(method.dimensionsAfterName ?? [], dim => this.visitLeftPadded(dim, p)),
745
- throws: method.throws && await this.visitContainer(method.throws, p),
746
- body: method.body && await this.visitDefined(method.body, p) as J.Block,
747
- defaultValue: await this.visitOptionalLeftPadded(method.defaultValue, p),
748
- methodType: await this.visitType(method.methodType, p) as Type.Method | undefined
749
- };
750
- if (method.typeParameters) {
751
- updates.typeParameters = await this.visitDefined(method.typeParameters, p) as J.TypeParameters;
752
- }
753
- if (method.returnTypeExpression) {
754
- updates.returnTypeExpression = await this.visitDefined(method.returnTypeExpression, p) as TypedTree;
755
- }
756
- 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
+ });
757
778
  }
758
779
 
759
780
  protected async visitMethodInvocation(method: J.MethodInvocation, p: P): Promise<J | undefined> {
@@ -769,7 +790,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
769
790
  }
770
791
  method = statement as J.MethodInvocation;
771
792
 
772
- const updates: any = {
793
+ const updates: any = await this.visitChildrenOf(method, async () => ({
773
794
  prefix: await this.visitSpace(method.prefix, p),
774
795
  markers: await this.visitMarkers(method.markers, p),
775
796
  select: await this.visitOptionalRightPadded(method.select, p),
@@ -777,7 +798,7 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
777
798
  name: await this.visitDefined(method.name, p) as J.Identifier,
778
799
  arguments: await this.visitContainer(method.arguments, p),
779
800
  methodType: await this.visitType(method.methodType, p) as Type.Method | undefined
780
- };
801
+ }));
781
802
  return updateIfChanged(method, updates);
782
803
  }
783
804
 
@@ -806,17 +827,19 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
806
827
  }
807
828
  newArray = expression as J.NewArray;
808
829
 
809
- const updates: any = {
810
- prefix: await this.visitSpace(newArray.prefix, p),
811
- markers: await this.visitMarkers(newArray.markers, p),
812
- dimensions: await mapAsync(newArray.dimensions, dim => this.visitDefined<J.ArrayDimension>(dim, p)),
813
- initializer: await this.visitOptionalContainer(newArray.initializer, p),
814
- type: await this.visitType(newArray.type, p)
815
- };
816
- if (newArray.typeExpression) {
817
- updates.typeExpression = await this.visitDefined(newArray.typeExpression, p) as TypedTree;
818
- }
819
- 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
+ });
820
843
  }
821
844
 
822
845
  protected async visitNewClass(newClass: J.NewClass, p: P): Promise<J | undefined> {
@@ -832,23 +855,25 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
832
855
  }
833
856
  newClass = statement as J.NewClass;
834
857
 
835
- const updates: any = {
836
- prefix: await this.visitSpace(newClass.prefix, p),
837
- markers: await this.visitMarkers(newClass.markers, p),
838
- new: await this.visitSpace(newClass.new, p),
839
- arguments: await this.visitContainer(newClass.arguments, p),
840
- constructorType: await this.visitType(newClass.constructorType, p) as Type.Method | undefined
841
- };
842
- if (newClass.enclosing) {
843
- updates.enclosing = await this.visitRightPadded(newClass.enclosing, p);
844
- }
845
- if (newClass.class) {
846
- updates.class = await this.visitDefined(newClass.class, p) as TypedTree;
847
- }
848
- if (newClass.body) {
849
- updates.body = await this.visitDefined(newClass.body, p) as J.Block;
850
- }
851
- 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
+ });
852
877
  }
853
878
 
854
879
  protected async visitNullableType(nullableType: J.NullableType, p: P): Promise<J | undefined> {
@@ -858,12 +883,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
858
883
  }
859
884
  nullableType = expression as J.NullableType;
860
885
 
861
- const updates: any = {
886
+ const updates: any = await this.visitChildrenOf(nullableType, async () => ({
862
887
  prefix: await this.visitSpace(nullableType.prefix, p),
863
888
  markers: await this.visitMarkers(nullableType.markers, p),
864
889
  annotations: await mapAsync(nullableType.annotations, a => this.visitDefined<J.Annotation>(a, p)),
865
890
  typeTree: await this.visitRightPadded(nullableType.typeTree, p)
866
- };
891
+ }));
867
892
  return updateIfChanged(nullableType, updates);
868
893
  }
869
894
 
@@ -886,13 +911,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
886
911
  }
887
912
  parameterizedType = expression as J.ParameterizedType;
888
913
 
889
- const updates: any = {
914
+ const updates: any = await this.visitChildrenOf(parameterizedType, async () => ({
890
915
  prefix: await this.visitSpace(parameterizedType.prefix, p),
891
916
  markers: await this.visitMarkers(parameterizedType.markers, p),
892
917
  class: await this.visitTypeName(parameterizedType.class, p),
893
918
  typeParameters: await this.visitOptionalContainer(parameterizedType.typeParameters, p),
894
919
  type: await this.visitType(parameterizedType.type, p)
895
- };
920
+ }));
896
921
  return updateIfChanged(parameterizedType, updates);
897
922
  }
898
923
 
@@ -903,11 +928,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
903
928
  }
904
929
  parentheses = expression as J.Parentheses<T>;
905
930
 
906
- const updates: any = {
931
+ const updates: any = await this.visitChildrenOf(parentheses, async () => ({
907
932
  prefix: await this.visitSpace(parentheses.prefix, p),
908
933
  markers: await this.visitMarkers(parentheses.markers, p),
909
934
  tree: await this.visitRightPadded(parentheses.tree, p)
910
- };
935
+ }));
911
936
  return updateIfChanged(parentheses, updates);
912
937
  }
913
938
 
@@ -918,12 +943,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
918
943
  }
919
944
  parTypeTree = expression as J.ParenthesizedTypeTree;
920
945
 
921
- const updates: any = {
946
+ const updates: any = await this.visitChildrenOf(parTypeTree, async () => ({
922
947
  prefix: await this.visitSpace(parTypeTree.prefix, p),
923
948
  markers: await this.visitMarkers(parTypeTree.markers, p),
924
949
  annotations: await mapAsync(parTypeTree.annotations, a => this.visitDefined<J.Annotation>(a, p)),
925
950
  parenthesizedType: await this.visitDefined(parTypeTree.parenthesizedType, p) as J.Parentheses<TypeTree>
926
- };
951
+ }));
927
952
  return updateIfChanged(parTypeTree, updates);
928
953
  }
929
954
 
@@ -949,14 +974,16 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
949
974
  }
950
975
  ret = statement as J.Return;
951
976
 
952
- const updates: any = {
953
- prefix: await this.visitSpace(ret.prefix, p),
954
- markers: await this.visitMarkers(ret.markers, p)
955
- };
956
- if (ret.expression) {
957
- updates.expression = await this.visitDefined(ret.expression, p) as Expression;
958
- }
959
- 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
+ });
960
987
  }
961
988
 
962
989
  protected async visitSwitch(aSwitch: J.Switch, p: P): Promise<J | undefined> {
@@ -966,12 +993,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
966
993
  }
967
994
  aSwitch = statement as J.Switch;
968
995
 
969
- const updates: any = {
996
+ const updates: any = await this.visitChildrenOf(aSwitch, async () => ({
970
997
  prefix: await this.visitSpace(aSwitch.prefix, p),
971
998
  markers: await this.visitMarkers(aSwitch.markers, p),
972
999
  selector: await this.visitDefined(aSwitch.selector, p) as J.ControlParentheses<Expression>,
973
1000
  cases: await this.visitDefined(aSwitch.cases, p) as J.Block
974
- };
1001
+ }));
975
1002
  return updateIfChanged(aSwitch, updates);
976
1003
  }
977
1004
 
@@ -982,13 +1009,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
982
1009
  }
983
1010
  switchExpr = expression as J.SwitchExpression;
984
1011
 
985
- const updates: any = {
1012
+ const updates: any = await this.visitChildrenOf(switchExpr, async () => ({
986
1013
  prefix: await this.visitSpace(switchExpr.prefix, p),
987
1014
  markers: await this.visitMarkers(switchExpr.markers, p),
988
1015
  selector: await this.visitDefined(switchExpr.selector, p) as J.ControlParentheses<Expression>,
989
1016
  cases: await this.visitDefined(switchExpr.cases, p) as J.Block,
990
1017
  type: await this.visitType(switchExpr.type, p)
991
- };
1018
+ }));
992
1019
  return updateIfChanged(switchExpr, updates);
993
1020
  }
994
1021
 
@@ -999,12 +1026,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
999
1026
  }
1000
1027
  sync = statement as J.Synchronized;
1001
1028
 
1002
- const updates: any = {
1029
+ const updates: any = await this.visitChildrenOf(sync, async () => ({
1003
1030
  prefix: await this.visitSpace(sync.prefix, p),
1004
1031
  markers: await this.visitMarkers(sync.markers, p),
1005
1032
  lock: await this.visitDefined(sync.lock, p) as J.ControlParentheses<Expression>,
1006
1033
  body: await this.visitDefined(sync.body, p) as J.Block
1007
- };
1034
+ }));
1008
1035
  return updateIfChanged(sync, updates);
1009
1036
  }
1010
1037
 
@@ -1021,14 +1048,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1021
1048
  }
1022
1049
  ternary = statement as J.Ternary;
1023
1050
 
1024
- const updates: any = {
1051
+ const updates: any = await this.visitChildrenOf(ternary, async () => ({
1025
1052
  prefix: await this.visitSpace(ternary.prefix, p),
1026
1053
  markers: await this.visitMarkers(ternary.markers, p),
1027
1054
  condition: await this.visitDefined(ternary.condition, p) as Expression,
1028
1055
  truePart: await this.visitLeftPadded(ternary.truePart, p),
1029
1056
  falsePart: await this.visitLeftPadded(ternary.falsePart, p),
1030
1057
  type: await this.visitType(ternary.type, p)
1031
- };
1058
+ }));
1032
1059
  return updateIfChanged(ternary, updates);
1033
1060
  }
1034
1061
 
@@ -1039,11 +1066,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1039
1066
  }
1040
1067
  thrown = statement as J.Throw;
1041
1068
 
1042
- const updates: any = {
1069
+ const updates: any = await this.visitChildrenOf(thrown, async () => ({
1043
1070
  prefix: await this.visitSpace(thrown.prefix, p),
1044
1071
  markers: await this.visitMarkers(thrown.markers, p),
1045
1072
  exception: await this.visitDefined(thrown.exception, p) as Expression
1046
- };
1073
+ }));
1047
1074
  return updateIfChanged(thrown, updates);
1048
1075
  }
1049
1076
 
@@ -1054,14 +1081,14 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1054
1081
  }
1055
1082
  tryable = statement as J.Try;
1056
1083
 
1057
- const updates: any = {
1084
+ const updates: any = await this.visitChildrenOf(tryable, async () => ({
1058
1085
  prefix: await this.visitSpace(tryable.prefix, p),
1059
1086
  markers: await this.visitMarkers(tryable.markers, p),
1060
1087
  resources: await this.visitOptionalContainer(tryable.resources, p),
1061
1088
  body: await this.visitDefined(tryable.body, p) as J.Block,
1062
1089
  catches: await mapAsync(tryable.catches, c => this.visitDefined<J.Try.Catch>(c, p)),
1063
1090
  finally: await this.visitOptionalLeftPadded(tryable.finally, p)
1064
- };
1091
+ }));
1065
1092
  return updateIfChanged(tryable, updates);
1066
1093
  }
1067
1094
 
@@ -1091,12 +1118,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1091
1118
  }
1092
1119
  typeCast = expression as J.TypeCast;
1093
1120
 
1094
- const updates: any = {
1121
+ const updates: any = await this.visitChildrenOf(typeCast, async () => ({
1095
1122
  prefix: await this.visitSpace(typeCast.prefix, p),
1096
1123
  markers: await this.visitMarkers(typeCast.markers, p),
1097
1124
  class: await this.visitDefined(typeCast.class, p) as J.ControlParentheses<TypedTree>,
1098
1125
  expression: await this.visitDefined(typeCast.expression, p) as Expression
1099
- };
1126
+ }));
1100
1127
  return updateIfChanged(typeCast, updates);
1101
1128
  }
1102
1129
 
@@ -1135,13 +1162,13 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1135
1162
  }
1136
1163
  unary = statement as J.Unary;
1137
1164
 
1138
- const updates: any = {
1165
+ const updates: any = await this.visitChildrenOf(unary, async () => ({
1139
1166
  prefix: await this.visitSpace(unary.prefix, p),
1140
1167
  markers: await this.visitMarkers(unary.markers, p),
1141
1168
  operator: await this.visitLeftPadded(unary.operator, p),
1142
1169
  expression: await this.visitDefined(unary.expression, p) as Expression,
1143
1170
  type: await this.visitType(unary.type, p)
1144
- };
1171
+ }));
1145
1172
  return updateIfChanged(unary, updates);
1146
1173
  }
1147
1174
 
@@ -1158,11 +1185,11 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1158
1185
  }
1159
1186
  unknown = statement as J.Unknown;
1160
1187
 
1161
- const updates: any = {
1188
+ const updates: any = await this.visitChildrenOf(unknown, async () => ({
1162
1189
  prefix: await this.visitSpace(unknown.prefix, p),
1163
1190
  markers: await this.visitMarkers(unknown.markers, p),
1164
1191
  source: await this.visitDefined(unknown.source, p) as J.UnknownSource
1165
- };
1192
+ }));
1166
1193
  return updateIfChanged(unknown, updates);
1167
1194
  }
1168
1195
 
@@ -1181,20 +1208,22 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1181
1208
  }
1182
1209
  varDecls = statement as J.VariableDeclarations;
1183
1210
 
1184
- const updates: any = {
1185
- prefix: await this.visitSpace(varDecls.prefix, p),
1186
- markers: await this.visitMarkers(varDecls.markers, p),
1187
- leadingAnnotations: await mapAsync(varDecls.leadingAnnotations, a => this.visitDefined<J.Annotation>(a, p)),
1188
- modifiers: await mapAsync(varDecls.modifiers, m => this.visitDefined<J.Modifier>(m, p)),
1189
- variables: await mapAsync(varDecls.variables, v => this.visitRightPadded(v, p))
1190
- };
1191
- if (varDecls.typeExpression) {
1192
- updates.typeExpression = await this.visitDefined(varDecls.typeExpression, p) as TypedTree;
1193
- }
1194
- if (varDecls.varargs) {
1195
- updates.varargs = await this.visitSpace(varDecls.varargs, p);
1196
- }
1197
- 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
+ });
1198
1227
  }
1199
1228
 
1200
1229
  protected async visitVariable(variable: J.VariableDeclarations.NamedVariable, p: P): Promise<J | undefined> {
@@ -1216,12 +1245,12 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1216
1245
  }
1217
1246
  whileLoop = statement as J.WhileLoop;
1218
1247
 
1219
- const updates: any = {
1248
+ const updates: any = await this.visitChildrenOf(whileLoop, async () => ({
1220
1249
  prefix: await this.visitSpace(whileLoop.prefix, p),
1221
1250
  markers: await this.visitMarkers(whileLoop.markers, p),
1222
1251
  condition: await this.visitDefined(whileLoop.condition, p) as J.ControlParentheses<Expression>,
1223
1252
  body: await this.visitRightPadded(whileLoop.body, p)
1224
- };
1253
+ }));
1225
1254
  return updateIfChanged(whileLoop, updates);
1226
1255
  }
1227
1256
 
@@ -1232,15 +1261,17 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1232
1261
  }
1233
1262
  wildcard = expression as J.Wildcard;
1234
1263
 
1235
- const updates: any = {
1236
- prefix: await this.visitSpace(wildcard.prefix, p),
1237
- markers: await this.visitMarkers(wildcard.markers, p),
1238
- bound: await this.visitOptionalLeftPadded(wildcard.bound, p)
1239
- };
1240
- if (wildcard.boundedType) {
1241
- updates.boundedType = await this.visitTypeName(wildcard.boundedType, p);
1242
- }
1243
- 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
+ });
1244
1275
  }
1245
1276
 
1246
1277
  protected async visitYield(aYield: J.Yield, p: P): Promise<J | undefined> {
@@ -1250,15 +1281,17 @@ export class JavaVisitor<P> extends TreeVisitor<J, P> {
1250
1281
  }
1251
1282
  aYield = statement as J.Yield;
1252
1283
 
1253
- const updates: any = {
1254
- prefix: await this.visitSpace(aYield.prefix, p),
1255
- markers: await this.visitMarkers(aYield.markers, p)
1256
- };
1257
- // a bare `yield` has no value
1258
- if (aYield.value) {
1259
- updates.value = await this.visitDefined(aYield.value, p) as Expression;
1260
- }
1261
- 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
+ });
1262
1295
  }
1263
1296
 
1264
1297
  protected async visitOptionalRightPadded<T extends J | boolean>(right: J.RightPadded<T> | undefined, p: P): Promise<J.RightPadded<T> | undefined> {