@openrewrite/rewrite 8.63.0 → 8.63.2

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 (134) hide show
  1. package/dist/java/index.d.ts +1 -0
  2. package/dist/java/index.d.ts.map +1 -1
  3. package/dist/java/index.js +1 -0
  4. package/dist/java/index.js.map +1 -1
  5. package/dist/java/rpc.d.ts +2 -0
  6. package/dist/java/rpc.d.ts.map +1 -1
  7. package/dist/java/rpc.js +749 -410
  8. package/dist/java/rpc.js.map +1 -1
  9. package/dist/java/tree.d.ts +1 -1
  10. package/dist/java/tree.d.ts.map +1 -1
  11. package/dist/java/type-visitor.d.ts +48 -0
  12. package/dist/java/type-visitor.d.ts.map +1 -0
  13. package/dist/java/type-visitor.js +260 -0
  14. package/dist/java/type-visitor.js.map +1 -0
  15. package/dist/java/type.d.ts +2 -0
  16. package/dist/java/type.d.ts.map +1 -1
  17. package/dist/java/type.js +0 -317
  18. package/dist/java/type.js.map +1 -1
  19. package/dist/java/visitor.d.ts.map +1 -1
  20. package/dist/java/visitor.js +579 -363
  21. package/dist/java/visitor.js.map +1 -1
  22. package/dist/javascript/preconditions.d.ts +1 -1
  23. package/dist/javascript/preconditions.d.ts.map +1 -1
  24. package/dist/javascript/preconditions.js +7 -6
  25. package/dist/javascript/preconditions.js.map +1 -1
  26. package/dist/javascript/rpc.js +430 -350
  27. package/dist/javascript/rpc.js.map +1 -1
  28. package/dist/javascript/tree.d.ts +1 -1
  29. package/dist/javascript/tree.d.ts.map +1 -1
  30. package/dist/javascript/type-mapping.d.ts.map +1 -1
  31. package/dist/javascript/type-mapping.js +7 -0
  32. package/dist/javascript/type-mapping.js.map +1 -1
  33. package/dist/javascript/visitor.d.ts.map +1 -1
  34. package/dist/javascript/visitor.js +504 -309
  35. package/dist/javascript/visitor.js.map +1 -1
  36. package/dist/json/visitor.d.ts.map +1 -1
  37. package/dist/json/visitor.js +46 -21
  38. package/dist/json/visitor.js.map +1 -1
  39. package/dist/rpc/queue.d.ts +7 -4
  40. package/dist/rpc/queue.d.ts.map +1 -1
  41. package/dist/rpc/queue.js +22 -32
  42. package/dist/rpc/queue.js.map +1 -1
  43. package/dist/rpc/request/generate.d.ts.map +1 -1
  44. package/dist/rpc/request/generate.js +2 -3
  45. package/dist/rpc/request/generate.js.map +1 -1
  46. package/dist/rpc/request/get-languages.d.ts.map +1 -1
  47. package/dist/rpc/request/get-languages.js +4 -3
  48. package/dist/rpc/request/get-languages.js.map +1 -1
  49. package/dist/rpc/request/get-object.d.ts +1 -1
  50. package/dist/rpc/request/get-object.d.ts.map +1 -1
  51. package/dist/rpc/request/get-object.js +8 -7
  52. package/dist/rpc/request/get-object.js.map +1 -1
  53. package/dist/rpc/request/get-recipes.d.ts.map +1 -1
  54. package/dist/rpc/request/get-recipes.js +2 -2
  55. package/dist/rpc/request/get-recipes.js.map +1 -1
  56. package/dist/rpc/request/index.d.ts +1 -0
  57. package/dist/rpc/request/index.d.ts.map +1 -1
  58. package/dist/rpc/request/index.js +1 -0
  59. package/dist/rpc/request/index.js.map +1 -1
  60. package/dist/rpc/request/install-recipes.d.ts.map +1 -1
  61. package/dist/rpc/request/install-recipes.js +30 -21
  62. package/dist/rpc/request/install-recipes.js.map +1 -1
  63. package/dist/rpc/request/metrics.d.ts +10 -10
  64. package/dist/rpc/request/metrics.d.ts.map +1 -1
  65. package/dist/rpc/request/metrics.js +38 -31
  66. package/dist/rpc/request/metrics.js.map +1 -1
  67. package/dist/rpc/request/parse.d.ts.map +1 -1
  68. package/dist/rpc/request/parse.js +10 -12
  69. package/dist/rpc/request/parse.js.map +1 -1
  70. package/dist/rpc/request/prepare-recipe.d.ts.map +1 -1
  71. package/dist/rpc/request/prepare-recipe.js +4 -4
  72. package/dist/rpc/request/prepare-recipe.js.map +1 -1
  73. package/dist/rpc/request/print.d.ts +1 -1
  74. package/dist/rpc/request/print.d.ts.map +1 -1
  75. package/dist/rpc/request/print.js +10 -6
  76. package/dist/rpc/request/print.js.map +1 -1
  77. package/dist/rpc/request/trace-get-object.d.ts +5 -0
  78. package/dist/rpc/request/trace-get-object.d.ts.map +1 -0
  79. package/dist/rpc/request/trace-get-object.js +3 -0
  80. package/dist/rpc/request/trace-get-object.js.map +1 -0
  81. package/dist/rpc/request/visit.d.ts.map +1 -1
  82. package/dist/rpc/request/visit.js +2 -3
  83. package/dist/rpc/request/visit.js.map +1 -1
  84. package/dist/rpc/rewrite-rpc.d.ts +2 -3
  85. package/dist/rpc/rewrite-rpc.d.ts.map +1 -1
  86. package/dist/rpc/rewrite-rpc.js +14 -5
  87. package/dist/rpc/rewrite-rpc.js.map +1 -1
  88. package/dist/rpc/server.d.ts.map +1 -1
  89. package/dist/rpc/server.js +15 -44
  90. package/dist/rpc/server.js.map +1 -1
  91. package/dist/rpc/trace.d.ts +1 -1
  92. package/dist/rpc/trace.d.ts.map +1 -1
  93. package/dist/rpc/trace.js +3 -3
  94. package/dist/rpc/trace.js.map +1 -1
  95. package/dist/util.d.ts +6 -0
  96. package/dist/util.d.ts.map +1 -1
  97. package/dist/util.js +14 -0
  98. package/dist/util.js.map +1 -1
  99. package/dist/version.txt +1 -1
  100. package/package.json +1 -1
  101. package/src/java/index.ts +1 -0
  102. package/src/java/rpc.ts +726 -537
  103. package/src/java/tree.ts +1 -1
  104. package/src/java/type-visitor.ts +241 -0
  105. package/src/java/type.ts +13 -277
  106. package/src/java/visitor.ts +581 -378
  107. package/src/javascript/preconditions.ts +7 -6
  108. package/src/javascript/rpc.ts +431 -360
  109. package/src/javascript/tree.ts +1 -1
  110. package/src/javascript/type-mapping.ts +7 -0
  111. package/src/javascript/visitor.ts +505 -310
  112. package/src/json/visitor.ts +47 -22
  113. package/src/rpc/queue.ts +20 -17
  114. package/src/rpc/request/generate.ts +31 -25
  115. package/src/rpc/request/get-languages.ts +18 -10
  116. package/src/rpc/request/get-object.ts +42 -34
  117. package/src/rpc/request/get-recipes.ts +15 -8
  118. package/src/rpc/request/index.ts +1 -0
  119. package/src/rpc/request/install-recipes.ts +96 -79
  120. package/src/rpc/request/metrics.ts +54 -48
  121. package/src/rpc/request/parse.ts +31 -25
  122. package/src/rpc/request/prepare-recipe.ts +31 -23
  123. package/src/rpc/request/print.ts +28 -14
  124. package/src/rpc/request/trace-get-object.ts +4 -0
  125. package/src/rpc/request/visit.ts +22 -16
  126. package/src/rpc/rewrite-rpc.ts +23 -10
  127. package/src/rpc/server.ts +17 -52
  128. package/src/rpc/trace.ts +3 -3
  129. package/src/util.ts +14 -0
  130. package/dist/rpc/chrome-profiler.d.ts +0 -25
  131. package/dist/rpc/chrome-profiler.d.ts.map +0 -1
  132. package/dist/rpc/chrome-profiler.js +0 -405
  133. package/dist/rpc/chrome-profiler.js.map +0 -1
  134. package/src/rpc/chrome-profiler.ts +0 -373
@@ -15,7 +15,7 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- import {mapAsync} from "../util";
18
+ import {mapAsync, updateIfChanged} from "../util";
19
19
  import {SourceFile} from "../tree";
20
20
  import {ValidImmerRecipeReturnType} from "../visitor";
21
21
  import {Expression, J, Type, JavaVisitor, NameTree, Statement, TypedTree} from "../java";
@@ -77,10 +77,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
77
77
  }
78
78
  alias = expression as JS.Alias;
79
79
 
80
- return this.produceJavaScript<JS.Alias>(alias, p, async draft => {
81
- draft.propertyName = await this.visitRightPadded(alias.propertyName, p);
82
- draft.alias = await this.visitDefined<Expression>(alias.alias, p);
83
- });
80
+ const updates: any = {
81
+ prefix: await this.visitSpace(alias.prefix, p),
82
+ markers: await this.visitMarkers(alias.markers, p),
83
+ propertyName: await this.visitRightPadded(alias.propertyName, p),
84
+ alias: await this.visitDefined<Expression>(alias.alias, p)
85
+ };
86
+ return updateIfChanged(alias, updates);
84
87
  }
85
88
 
86
89
  protected async visitArrowFunction(arrowFunction: JS.ArrowFunction, p: P): Promise<J | undefined> {
@@ -96,21 +99,27 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
96
99
  }
97
100
  arrowFunction = statement as JS.ArrowFunction;
98
101
 
99
- return this.produceJavaScript<JS.ArrowFunction>(arrowFunction, p, async draft => {
100
- draft.leadingAnnotations = await mapAsync(arrowFunction.leadingAnnotations, item => this.visitDefined<J.Annotation>(item, p));
101
- draft.modifiers = await mapAsync(arrowFunction.modifiers, item => this.visitDefined<J.Modifier>(item, p));
102
- draft.typeParameters = arrowFunction.typeParameters && await this.visitDefined<J.TypeParameters>(arrowFunction.typeParameters, p);
103
- draft.lambda = await this.visitDefined<J.Lambda>(arrowFunction.lambda, p);
104
- draft.returnTypeExpression = arrowFunction.returnTypeExpression && await this.visitDefined<TypedTree>(arrowFunction.returnTypeExpression, p);
105
- });
102
+ const updates: any = {
103
+ prefix: await this.visitSpace(arrowFunction.prefix, p),
104
+ markers: await this.visitMarkers(arrowFunction.markers, p),
105
+ leadingAnnotations: await mapAsync(arrowFunction.leadingAnnotations, item => this.visitDefined<J.Annotation>(item, p)),
106
+ modifiers: await mapAsync(arrowFunction.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
107
+ typeParameters: arrowFunction.typeParameters && await this.visitDefined<J.TypeParameters>(arrowFunction.typeParameters, p),
108
+ lambda: await this.visitDefined<J.Lambda>(arrowFunction.lambda, p),
109
+ returnTypeExpression: arrowFunction.returnTypeExpression && await this.visitDefined<TypedTree>(arrowFunction.returnTypeExpression, p)
110
+ };
111
+ return updateIfChanged(arrowFunction, updates);
106
112
  }
107
113
 
108
114
  protected async visitAs(as_: JS.As, p: P): Promise<J | undefined> {
109
- return this.produceJavaScript<JS.As>(as_, p, async draft => {
110
- draft.left = await this.visitRightPadded<Expression>(as_.left, p);
111
- draft.right = await this.visitDefined<Expression>(as_.right, p);
112
- draft.type = as_.type && await this.visitType(as_.type, p);
113
- });
115
+ const updates: any = {
116
+ prefix: await this.visitSpace(as_.prefix, p),
117
+ markers: await this.visitMarkers(as_.markers, p),
118
+ left: await this.visitRightPadded<Expression>(as_.left, p),
119
+ right: await this.visitDefined<Expression>(as_.right, p),
120
+ type: as_.type && await this.visitType(as_.type, p)
121
+ };
122
+ return updateIfChanged(as_, updates);
114
123
  }
115
124
 
116
125
  protected async visitAwait(await_: JS.Await, p: P): Promise<J | undefined> {
@@ -120,57 +129,78 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
120
129
  }
121
130
  await_ = expression as JS.Await;
122
131
 
123
- return this.produceJavaScript<JS.Await>(await_, p, async draft => {
124
- draft.expression = await this.visitDefined<Expression>(await_.expression, p);
125
- draft.type = await_.type && await this.visitType(await_.type, p);
126
- });
132
+ const updates: any = {
133
+ prefix: await this.visitSpace(await_.prefix, p),
134
+ markers: await this.visitMarkers(await_.markers, p),
135
+ expression: await this.visitDefined<Expression>(await_.expression, p),
136
+ type: await_.type && await this.visitType(await_.type, p)
137
+ };
138
+ return updateIfChanged(await_, updates);
127
139
  }
128
140
 
129
141
  protected async visitJsxTag(element: JSX.Tag, p: P): Promise<J | undefined> {
130
- return this.produceJavaScript<JSX.Tag>(element, p, async draft => {
131
- draft.openName = await this.visitLeftPadded(element.openName, p);
132
- draft.typeArguments = element.typeArguments && await this.visitContainer(element.typeArguments, p);
133
- draft.afterName = await this.visitSpace(element.afterName, p);
134
- draft.attributes = await mapAsync(element.attributes, attr => this.visitRightPadded(attr, p));
135
- draft.selfClosing = element.selfClosing && await this.visitSpace(element.selfClosing, p);
136
- draft.children = element.children && await mapAsync(element.children, child => this.visit(child, p));
137
- draft.closingName = element.closingName && await this.visitLeftPadded(element.closingName, p);
138
- draft.afterClosingName = element.afterClosingName && await this.visitSpace(element.afterClosingName, p);
139
- });
142
+ const updates: any = {
143
+ prefix: await this.visitSpace(element.prefix, p),
144
+ markers: await this.visitMarkers(element.markers, p),
145
+ openName: await this.visitLeftPadded(element.openName, p),
146
+ typeArguments: element.typeArguments && await this.visitContainer(element.typeArguments, p),
147
+ afterName: await this.visitSpace(element.afterName, p),
148
+ attributes: await mapAsync(element.attributes, attr => this.visitRightPadded(attr, p)),
149
+ selfClosing: element.selfClosing && await this.visitSpace(element.selfClosing, p),
150
+ children: element.children && await mapAsync(element.children, child => this.visit(child, p)),
151
+ closingName: element.closingName && await this.visitLeftPadded(element.closingName, p),
152
+ afterClosingName: element.afterClosingName && await this.visitSpace(element.afterClosingName, p)
153
+ };
154
+ return updateIfChanged(element, updates);
140
155
  }
141
156
 
142
157
  protected async visitJsxAttribute(attribute: JSX.Attribute, p: P): Promise<J | undefined> {
143
- return this.produceJavaScript<JSX.Attribute>(attribute, p, async draft => {
144
- draft.key = await this.visitDefined<J.Identifier | JSX.NamespacedName>(attribute.key, p);
145
- draft.value = attribute.value && await this.visitLeftPadded(attribute.value, p);
146
- });
158
+ const updates: any = {
159
+ prefix: await this.visitSpace(attribute.prefix, p),
160
+ markers: await this.visitMarkers(attribute.markers, p),
161
+ key: await this.visitDefined<J.Identifier | JSX.NamespacedName>(attribute.key, p),
162
+ value: attribute.value && await this.visitLeftPadded(attribute.value, p)
163
+ };
164
+ return updateIfChanged(attribute, updates);
147
165
  }
148
166
 
149
167
  protected async visitJsxSpreadAttribute(spread: JSX.SpreadAttribute, p: P): Promise<J | undefined> {
150
- return this.produceJavaScript<JSX.SpreadAttribute>(spread, p, async draft => {
151
- draft.dots = await this.visitSpace(spread.dots, p);
152
- draft.expression = await this.visitRightPadded(spread.expression, p);
153
- });
168
+ const updates: any = {
169
+ prefix: await this.visitSpace(spread.prefix, p),
170
+ markers: await this.visitMarkers(spread.markers, p),
171
+ dots: await this.visitSpace(spread.dots, p),
172
+ expression: await this.visitRightPadded(spread.expression, p)
173
+ };
174
+ return updateIfChanged(spread, updates);
154
175
  }
155
176
 
156
177
  protected async visitJsxEmbeddedExpression(expr: JSX.EmbeddedExpression, p: P): Promise<J | undefined> {
157
- return this.produceJavaScript<JSX.EmbeddedExpression>(expr, p, async draft => {
158
- draft.expression = await this.visitRightPadded(expr.expression, p);
159
- });
178
+ const updates: any = {
179
+ prefix: await this.visitSpace(expr.prefix, p),
180
+ markers: await this.visitMarkers(expr.markers, p),
181
+ expression: await this.visitRightPadded(expr.expression, p)
182
+ };
183
+ return updateIfChanged(expr, updates);
160
184
  }
161
185
 
162
186
  protected async visitJsxNamespacedName(ns: JSX.NamespacedName, p: P): Promise<J | undefined> {
163
- return this.produceJavaScript<JSX.NamespacedName>(ns, p, async draft => {
164
- draft.namespace = await this.visitDefined<J.Identifier>(ns.namespace, p);
165
- draft.name = await this.visitLeftPadded(ns.name, p);
166
- });
187
+ const updates: any = {
188
+ prefix: await this.visitSpace(ns.prefix, p),
189
+ markers: await this.visitMarkers(ns.markers, p),
190
+ namespace: await this.visitDefined<J.Identifier>(ns.namespace, p),
191
+ name: await this.visitLeftPadded(ns.name, p)
192
+ };
193
+ return updateIfChanged(ns, updates);
167
194
  }
168
195
 
169
196
  protected async visitJsCompilationUnit(compilationUnit: JS.CompilationUnit, p: P): Promise<J | undefined> {
170
- return this.produceJavaScript<JS.CompilationUnit>(compilationUnit, p, async draft => {
171
- draft.statements = await mapAsync(compilationUnit.statements, stmt => this.visitRightPadded(stmt, p));
172
- draft.eof = await this.visitSpace(compilationUnit.eof, p);
173
- });
197
+ const updates: any = {
198
+ prefix: await this.visitSpace(compilationUnit.prefix, p),
199
+ markers: await this.visitMarkers(compilationUnit.markers, p),
200
+ statements: await mapAsync(compilationUnit.statements, stmt => this.visitRightPadded(stmt, p)),
201
+ eof: await this.visitSpace(compilationUnit.eof, p)
202
+ };
203
+ return updateIfChanged(compilationUnit, updates);
174
204
  }
175
205
 
176
206
  protected async visitConditionalType(conditionalType: JS.ConditionalType, p: P): Promise<J | undefined> {
@@ -180,11 +210,14 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
180
210
  }
181
211
  conditionalType = expression as JS.ConditionalType;
182
212
 
183
- return this.produceJavaScript<JS.ConditionalType>(conditionalType, p, async draft => {
184
- draft.checkType = await this.visitDefined<Expression>(conditionalType.checkType, p);
185
- draft.condition = await this.visitLeftPadded(conditionalType.condition, p);
186
- draft.type = conditionalType.type && await this.visitType(conditionalType.type, p);
187
- });
213
+ const updates: any = {
214
+ prefix: await this.visitSpace(conditionalType.prefix, p),
215
+ markers: await this.visitMarkers(conditionalType.markers, p),
216
+ checkType: await this.visitDefined<Expression>(conditionalType.checkType, p),
217
+ condition: await this.visitLeftPadded(conditionalType.condition, p),
218
+ type: conditionalType.type && await this.visitType(conditionalType.type, p)
219
+ };
220
+ return updateIfChanged(conditionalType, updates);
188
221
  }
189
222
 
190
223
  protected async visitDelete(delete_: JS.Delete, p: P): Promise<J | undefined> {
@@ -200,9 +233,12 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
200
233
  }
201
234
  delete_ = statement as JS.Delete;
202
235
 
203
- return this.produceJavaScript<JS.Delete>(delete_, p, async draft => {
204
- draft.expression = await this.visitDefined<Expression>(delete_.expression, p);
205
- });
236
+ const updates: any = {
237
+ prefix: await this.visitSpace(delete_.prefix, p),
238
+ markers: await this.visitMarkers(delete_.markers, p),
239
+ expression: await this.visitDefined<Expression>(delete_.expression, p)
240
+ };
241
+ return updateIfChanged(delete_, updates);
206
242
  }
207
243
 
208
244
  protected async visitExpressionStatement(expressionStatement: JS.ExpressionStatement, p: P): Promise<J | undefined> {
@@ -218,9 +254,12 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
218
254
  }
219
255
  expressionStatement = statement as JS.ExpressionStatement;
220
256
 
221
- return this.produceJavaScript<JS.ExpressionStatement>(expressionStatement, p, async draft => {
222
- draft.expression = await this.visitDefined<Expression>(expressionStatement.expression, p);
223
- });
257
+ const updates: any = {
258
+ prefix: await this.visitSpace(expressionStatement.prefix, p),
259
+ markers: await this.visitMarkers(expressionStatement.markers, p),
260
+ expression: await this.visitDefined<Expression>(expressionStatement.expression, p)
261
+ };
262
+ return updateIfChanged(expressionStatement, updates);
224
263
  }
225
264
 
226
265
  protected async visitExpressionWithTypeArguments(expressionWithTypeArguments: JS.ExpressionWithTypeArguments, p: P): Promise<J | undefined> {
@@ -230,11 +269,14 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
230
269
  }
231
270
  expressionWithTypeArguments = expression as JS.ExpressionWithTypeArguments;
232
271
 
233
- return this.produceJavaScript<JS.ExpressionWithTypeArguments>(expressionWithTypeArguments, p, async draft => {
234
- draft.clazz = await this.visitDefined<J>(expressionWithTypeArguments.clazz, p);
235
- draft.typeArguments = expressionWithTypeArguments.typeArguments && await this.visitContainer(expressionWithTypeArguments.typeArguments, p);
236
- draft.type = expressionWithTypeArguments.type && await this.visitType(expressionWithTypeArguments.type, p);
237
- });
272
+ const updates: any = {
273
+ prefix: await this.visitSpace(expressionWithTypeArguments.prefix, p),
274
+ markers: await this.visitMarkers(expressionWithTypeArguments.markers, p),
275
+ clazz: await this.visitDefined<J>(expressionWithTypeArguments.clazz, p),
276
+ typeArguments: expressionWithTypeArguments.typeArguments && await this.visitContainer(expressionWithTypeArguments.typeArguments, p),
277
+ type: expressionWithTypeArguments.type && await this.visitType(expressionWithTypeArguments.type, p)
278
+ };
279
+ return updateIfChanged(expressionWithTypeArguments, updates);
238
280
  }
239
281
 
240
282
  protected async visitFunctionCall(functionCall: JS.FunctionCall, p: P): Promise<J | undefined> {
@@ -265,12 +307,15 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
265
307
  }
266
308
  functionType = expression as JS.FunctionType;
267
309
 
268
- return this.produceJavaScript<JS.FunctionType>(functionType, p, async draft => {
269
- draft.constructorType = await this.visitLeftPadded(functionType.constructorType, p);
270
- draft.typeParameters = functionType.typeParameters && await this.visitDefined<J.TypeParameters>(functionType.typeParameters, p);
271
- draft.parameters = await this.visitContainer(functionType.parameters, p);
272
- draft.returnType = await this.visitLeftPadded(functionType.returnType, p);
273
- });
310
+ const updates: any = {
311
+ prefix: await this.visitSpace(functionType.prefix, p),
312
+ markers: await this.visitMarkers(functionType.markers, p),
313
+ constructorType: await this.visitLeftPadded(functionType.constructorType, p),
314
+ typeParameters: functionType.typeParameters && await this.visitDefined<J.TypeParameters>(functionType.typeParameters, p),
315
+ parameters: await this.visitContainer(functionType.parameters, p),
316
+ returnType: await this.visitLeftPadded(functionType.returnType, p)
317
+ };
318
+ return updateIfChanged(functionType, updates);
274
319
  }
275
320
 
276
321
  protected async visitInferType(inferType: JS.InferType, p: P): Promise<J | undefined> {
@@ -280,10 +325,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
280
325
  }
281
326
  inferType = expression as JS.InferType;
282
327
 
283
- return this.produceJavaScript<JS.InferType>(inferType, p, async draft => {
284
- draft.typeParameter = await this.visitLeftPadded(inferType.typeParameter, p);
285
- draft.type = inferType.type && await this.visitType(inferType.type, p);
286
- });
328
+ const updates: any = {
329
+ prefix: await this.visitSpace(inferType.prefix, p),
330
+ markers: await this.visitMarkers(inferType.markers, p),
331
+ typeParameter: await this.visitLeftPadded(inferType.typeParameter, p),
332
+ type: inferType.type && await this.visitType(inferType.type, p)
333
+ };
334
+ return updateIfChanged(inferType, updates);
287
335
  }
288
336
 
289
337
  protected async visitImportType(importType: JS.ImportType, p: P): Promise<J | undefined> {
@@ -293,13 +341,16 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
293
341
  }
294
342
  importType = expression as JS.ImportType;
295
343
 
296
- return this.produceJavaScript<JS.ImportType>(importType, p, async draft => {
297
- draft.hasTypeof = await this.visitRightPadded(importType.hasTypeof, p);
298
- draft.argumentAndAttributes = await this.visitContainer(importType.argumentAndAttributes, p);
299
- draft.qualifier = importType.qualifier && await this.visitLeftPadded(importType.qualifier, p);
300
- draft.typeArguments = importType.typeArguments && await this.visitContainer(importType.typeArguments, p);
301
- draft.type = importType.type && await this.visitType(importType.type, p);
302
- });
344
+ const updates: any = {
345
+ prefix: await this.visitSpace(importType.prefix, p),
346
+ markers: await this.visitMarkers(importType.markers, p),
347
+ hasTypeof: await this.visitRightPadded(importType.hasTypeof, p),
348
+ argumentAndAttributes: await this.visitContainer(importType.argumentAndAttributes, p),
349
+ qualifier: importType.qualifier && await this.visitLeftPadded(importType.qualifier, p),
350
+ typeArguments: importType.typeArguments && await this.visitContainer(importType.typeArguments, p),
351
+ type: importType.type && await this.visitType(importType.type, p)
352
+ };
353
+ return updateIfChanged(importType, updates);
303
354
  }
304
355
 
305
356
  protected async visitImportDeclaration(jsImport: JS.Import, p: P): Promise<J | undefined> {
@@ -309,20 +360,26 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
309
360
  }
310
361
  jsImport = statement as JS.Import;
311
362
 
312
- return this.produceJavaScript<JS.Import>(jsImport, p, async draft => {
313
- draft.modifiers = await mapAsync(jsImport.modifiers, item => this.visitDefined<J.Modifier>(item, p));
314
- draft.importClause = jsImport.importClause && await this.visitDefined<JS.ImportClause>(jsImport.importClause, p);
315
- draft.moduleSpecifier = jsImport.moduleSpecifier && await this.visitLeftPadded(jsImport.moduleSpecifier, p);
316
- draft.attributes = jsImport.attributes && await this.visitDefined<JS.ImportAttributes>(jsImport.attributes, p);
317
- draft.initializer = jsImport.initializer && await this.visitLeftPadded(jsImport.initializer, p);
318
- });
363
+ const updates: any = {
364
+ prefix: await this.visitSpace(jsImport.prefix, p),
365
+ markers: await this.visitMarkers(jsImport.markers, p),
366
+ modifiers: await mapAsync(jsImport.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
367
+ importClause: jsImport.importClause && await this.visitDefined<JS.ImportClause>(jsImport.importClause, p),
368
+ moduleSpecifier: jsImport.moduleSpecifier && await this.visitLeftPadded(jsImport.moduleSpecifier, p),
369
+ attributes: jsImport.attributes && await this.visitDefined<JS.ImportAttributes>(jsImport.attributes, p),
370
+ initializer: jsImport.initializer && await this.visitLeftPadded(jsImport.initializer, p)
371
+ };
372
+ return updateIfChanged(jsImport, updates);
319
373
  }
320
374
 
321
375
  protected async visitImportClause(importClause: JS.ImportClause, p: P): Promise<J | undefined> {
322
- return this.produceJavaScript<JS.ImportClause>(importClause, p, async draft => {
323
- draft.name = importClause.name && await this.visitRightPadded(importClause.name, p);
324
- draft.namedBindings = importClause.namedBindings && await this.visitDefined<Expression>(importClause.namedBindings, p);
325
- });
376
+ const updates: any = {
377
+ prefix: await this.visitSpace(importClause.prefix, p),
378
+ markers: await this.visitMarkers(importClause.markers, p),
379
+ name: importClause.name && await this.visitRightPadded(importClause.name, p),
380
+ namedBindings: importClause.namedBindings && await this.visitDefined<Expression>(importClause.namedBindings, p)
381
+ };
382
+ return updateIfChanged(importClause, updates);
326
383
  }
327
384
 
328
385
  protected async visitNamedImports(namedImports: JS.NamedImports, p: P): Promise<J | undefined> {
@@ -332,10 +389,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
332
389
  }
333
390
  namedImports = expression as JS.NamedImports;
334
391
 
335
- return this.produceJavaScript<JS.NamedImports>(namedImports, p, async draft => {
336
- draft.elements = await this.visitContainer(namedImports.elements, p);
337
- draft.type = namedImports.type && await this.visitType(namedImports.type, p);
338
- });
392
+ const updates: any = {
393
+ prefix: await this.visitSpace(namedImports.prefix, p),
394
+ markers: await this.visitMarkers(namedImports.markers, p),
395
+ elements: await this.visitContainer(namedImports.elements, p),
396
+ type: namedImports.type && await this.visitType(namedImports.type, p)
397
+ };
398
+ return updateIfChanged(namedImports, updates);
339
399
  }
340
400
 
341
401
  protected async visitImportSpecifier(importSpecifier: JS.ImportSpecifier, p: P): Promise<J | undefined> {
@@ -345,25 +405,34 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
345
405
  }
346
406
  importSpecifier = expression as JS.ImportSpecifier;
347
407
 
348
- return this.produceJavaScript<JS.ImportSpecifier>(importSpecifier, p, async draft => {
349
- draft.importType = await this.visitLeftPadded(importSpecifier.importType, p);
350
- draft.specifier = await this.visitDefined<JS.Alias | J.Identifier>(importSpecifier.specifier, p);
351
- draft.type = importSpecifier.type && await this.visitType(importSpecifier.type, p);
352
- });
408
+ const updates: any = {
409
+ prefix: await this.visitSpace(importSpecifier.prefix, p),
410
+ markers: await this.visitMarkers(importSpecifier.markers, p),
411
+ importType: await this.visitLeftPadded(importSpecifier.importType, p),
412
+ specifier: await this.visitDefined<JS.Alias | J.Identifier>(importSpecifier.specifier, p),
413
+ type: importSpecifier.type && await this.visitType(importSpecifier.type, p)
414
+ };
415
+ return updateIfChanged(importSpecifier, updates);
353
416
  }
354
417
 
355
418
  protected async visitImportAttributes(importAttributes: JS.ImportAttributes, p: P): Promise<J | undefined> {
356
- return this.produceJavaScript<JS.ImportAttributes>(importAttributes, p, async draft => {
357
- draft.elements = await this.visitContainer(importAttributes.elements, p);
358
- });
419
+ const updates: any = {
420
+ prefix: await this.visitSpace(importAttributes.prefix, p),
421
+ markers: await this.visitMarkers(importAttributes.markers, p),
422
+ elements: await this.visitContainer(importAttributes.elements, p)
423
+ };
424
+ return updateIfChanged(importAttributes, updates);
359
425
  }
360
426
 
361
427
  protected async visitImportTypeAttributes(importTypeAttributes: JS.ImportTypeAttributes, p: P): Promise<J | undefined> {
362
- return this.produceJavaScript<JS.ImportTypeAttributes>(importTypeAttributes, p, async draft => {
363
- draft.token = await this.visitRightPadded(importTypeAttributes.token, p);
364
- draft.elements = await this.visitContainer(importTypeAttributes.elements, p);
365
- draft.end = await this.visitSpace(importTypeAttributes.end, p);
366
- });
428
+ const updates: any = {
429
+ prefix: await this.visitSpace(importTypeAttributes.prefix, p),
430
+ markers: await this.visitMarkers(importTypeAttributes.markers, p),
431
+ token: await this.visitRightPadded(importTypeAttributes.token, p),
432
+ elements: await this.visitContainer(importTypeAttributes.elements, p),
433
+ end: await this.visitSpace(importTypeAttributes.end, p)
434
+ };
435
+ return updateIfChanged(importTypeAttributes, updates);
367
436
  }
368
437
 
369
438
  protected async visitImportAttribute(importAttribute: JS.ImportAttribute, p: P): Promise<J | undefined> {
@@ -373,19 +442,25 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
373
442
  }
374
443
  importAttribute = statement as JS.ImportAttribute;
375
444
 
376
- return this.produceJavaScript<JS.ImportAttribute>(importAttribute, p, async draft => {
377
- draft.name = await this.visitDefined<Expression>(importAttribute.name, p);
378
- draft.value = await this.visitLeftPadded(importAttribute.value, p);
379
- });
445
+ const updates: any = {
446
+ prefix: await this.visitSpace(importAttribute.prefix, p),
447
+ markers: await this.visitMarkers(importAttribute.markers, p),
448
+ name: await this.visitDefined<Expression>(importAttribute.name, p),
449
+ value: await this.visitLeftPadded(importAttribute.value, p)
450
+ };
451
+ return updateIfChanged(importAttribute, updates);
380
452
  }
381
453
 
382
454
  protected async visitBinaryExtensions(jsBinary: JS.Binary, p: P): Promise<J | undefined> {
383
- return this.produceJavaScript<JS.Binary>(jsBinary, p, async draft => {
384
- draft.left = await this.visitDefined<Expression>(jsBinary.left, p);
385
- draft.operator = await this.visitLeftPadded(jsBinary.operator, p);
386
- draft.right = await this.visitDefined<Expression>(jsBinary.right, p);
387
- draft.type = jsBinary.type && await this.visitType(jsBinary.type, p);
388
- });
455
+ const updates: any = {
456
+ prefix: await this.visitSpace(jsBinary.prefix, p),
457
+ markers: await this.visitMarkers(jsBinary.markers, p),
458
+ left: await this.visitDefined<Expression>(jsBinary.left, p),
459
+ operator: await this.visitLeftPadded(jsBinary.operator, p),
460
+ right: await this.visitDefined<Expression>(jsBinary.right, p),
461
+ type: jsBinary.type && await this.visitType(jsBinary.type, p)
462
+ };
463
+ return updateIfChanged(jsBinary, updates);
389
464
  }
390
465
 
391
466
  protected async visitLiteralType(literalType: JS.LiteralType, p: P): Promise<J | undefined> {
@@ -395,10 +470,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
395
470
  }
396
471
  literalType = expression as JS.LiteralType;
397
472
 
398
- return this.produceJavaScript<JS.LiteralType>(literalType, p, async draft => {
399
- draft.literal = await this.visitDefined<Expression>(literalType.literal, p);
400
- draft.type = (await this.visitType(literalType.type, p))!;
401
- });
473
+ const updates: any = {
474
+ prefix: await this.visitSpace(literalType.prefix, p),
475
+ markers: await this.visitMarkers(literalType.markers, p),
476
+ literal: await this.visitDefined<Expression>(literalType.literal, p),
477
+ type: (await this.visitType(literalType.type, p))!
478
+ };
479
+ return updateIfChanged(literalType, updates);
402
480
  }
403
481
 
404
482
  protected async visitMappedType(mappedType: JS.MappedType, p: P): Promise<J | undefined> {
@@ -408,29 +486,38 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
408
486
  }
409
487
  mappedType = expression as JS.MappedType;
410
488
 
411
- return this.produceJavaScript<JS.MappedType>(mappedType, p, async draft => {
412
- draft.prefixToken = mappedType.prefixToken && await this.visitLeftPadded(mappedType.prefixToken, p);
413
- draft.hasReadonly = await this.visitLeftPadded(mappedType.hasReadonly, p);
414
- draft.keysRemapping = await this.visitDefined<JS.MappedType.KeysRemapping>(mappedType.keysRemapping, p);
415
- draft.suffixToken = mappedType.suffixToken && await this.visitLeftPadded(mappedType.suffixToken, p);
416
- draft.hasQuestionToken = await this.visitLeftPadded(mappedType.hasQuestionToken, p);
417
- draft.valueType = await this.visitContainer(mappedType.valueType, p);
418
- draft.type = mappedType.type && await this.visitType(mappedType.type, p);
419
- });
489
+ const updates: any = {
490
+ prefix: await this.visitSpace(mappedType.prefix, p),
491
+ markers: await this.visitMarkers(mappedType.markers, p),
492
+ prefixToken: mappedType.prefixToken && await this.visitLeftPadded(mappedType.prefixToken, p),
493
+ hasReadonly: await this.visitLeftPadded(mappedType.hasReadonly, p),
494
+ keysRemapping: await this.visitDefined<JS.MappedType.KeysRemapping>(mappedType.keysRemapping, p),
495
+ suffixToken: mappedType.suffixToken && await this.visitLeftPadded(mappedType.suffixToken, p),
496
+ hasQuestionToken: await this.visitLeftPadded(mappedType.hasQuestionToken, p),
497
+ valueType: await this.visitContainer(mappedType.valueType, p),
498
+ type: mappedType.type && await this.visitType(mappedType.type, p)
499
+ };
500
+ return updateIfChanged(mappedType, updates);
420
501
  }
421
502
 
422
503
  protected async visitMappedTypeKeysRemapping(keysRemapping: JS.MappedType.KeysRemapping, p: P): Promise<J | undefined> {
423
- return this.produceJavaScript<JS.MappedType.KeysRemapping>(keysRemapping, p, async draft => {
424
- draft.typeParameter = await this.visitRightPadded(keysRemapping.typeParameter, p);
425
- draft.nameType = keysRemapping.nameType && await this.visitRightPadded(keysRemapping.nameType, p);
426
- });
504
+ const updates: any = {
505
+ prefix: await this.visitSpace(keysRemapping.prefix, p),
506
+ markers: await this.visitMarkers(keysRemapping.markers, p),
507
+ typeParameter: await this.visitRightPadded(keysRemapping.typeParameter, p),
508
+ nameType: keysRemapping.nameType && await this.visitRightPadded(keysRemapping.nameType, p)
509
+ };
510
+ return updateIfChanged(keysRemapping, updates);
427
511
  }
428
512
 
429
513
  protected async visitMappedTypeParameter(mappedTypeParameter: JS.MappedType.Parameter, p: P): Promise<J | undefined> {
430
- return this.produceJavaScript<JS.MappedType.Parameter>(mappedTypeParameter, p, async draft => {
431
- draft.name = await this.visitDefined<Expression>(mappedTypeParameter.name, p);
432
- draft.iterateType = await this.visitLeftPadded(mappedTypeParameter.iterateType, p);
433
- });
514
+ const updates: any = {
515
+ prefix: await this.visitSpace(mappedTypeParameter.prefix, p),
516
+ markers: await this.visitMarkers(mappedTypeParameter.markers, p),
517
+ name: await this.visitDefined<Expression>(mappedTypeParameter.name, p),
518
+ iterateType: await this.visitLeftPadded(mappedTypeParameter.iterateType, p)
519
+ };
520
+ return updateIfChanged(mappedTypeParameter, updates);
434
521
  }
435
522
 
436
523
  protected async visitObjectBindingPattern(objectBindingPattern: JS.ObjectBindingPattern, p: P): Promise<J | undefined> {
@@ -440,13 +527,16 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
440
527
  }
441
528
  objectBindingPattern = expression as JS.ObjectBindingPattern;
442
529
 
443
- return this.produceJavaScript<JS.ObjectBindingPattern>(objectBindingPattern, p, async draft => {
444
- draft.leadingAnnotations = await mapAsync(objectBindingPattern.leadingAnnotations, item => this.visitDefined<J.Annotation>(item, p));
445
- draft.modifiers = await mapAsync(objectBindingPattern.modifiers, item => this.visitDefined<J.Modifier>(item, p));
446
- draft.typeExpression = objectBindingPattern.typeExpression && await this.visitDefined<TypedTree>(objectBindingPattern.typeExpression, p);
447
- draft.bindings = await this.visitContainer(objectBindingPattern.bindings, p);
448
- draft.initializer = objectBindingPattern.initializer && await this.visitLeftPadded(objectBindingPattern.initializer, p);
449
- });
530
+ const updates: any = {
531
+ prefix: await this.visitSpace(objectBindingPattern.prefix, p),
532
+ markers: await this.visitMarkers(objectBindingPattern.markers, p),
533
+ leadingAnnotations: await mapAsync(objectBindingPattern.leadingAnnotations, item => this.visitDefined<J.Annotation>(item, p)),
534
+ modifiers: await mapAsync(objectBindingPattern.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
535
+ typeExpression: objectBindingPattern.typeExpression && await this.visitDefined<TypedTree>(objectBindingPattern.typeExpression, p),
536
+ bindings: await this.visitContainer(objectBindingPattern.bindings, p),
537
+ initializer: objectBindingPattern.initializer && await this.visitLeftPadded(objectBindingPattern.initializer, p)
538
+ };
539
+ return updateIfChanged(objectBindingPattern, updates);
450
540
  }
451
541
 
452
542
  protected async visitPropertyAssignment(propertyAssignment: JS.PropertyAssignment, p: P): Promise<J | undefined> {
@@ -456,10 +546,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
456
546
  }
457
547
  propertyAssignment = statement as JS.PropertyAssignment;
458
548
 
459
- return this.produceJavaScript<JS.PropertyAssignment>(propertyAssignment, p, async draft => {
460
- draft.name = await this.visitRightPadded(propertyAssignment.name, p);
461
- draft.initializer = propertyAssignment.initializer && await this.visitDefined<Expression>(propertyAssignment.initializer, p);
462
- });
549
+ const updates: any = {
550
+ prefix: await this.visitSpace(propertyAssignment.prefix, p),
551
+ markers: await this.visitMarkers(propertyAssignment.markers, p),
552
+ name: await this.visitRightPadded(propertyAssignment.name, p),
553
+ initializer: propertyAssignment.initializer && await this.visitDefined<Expression>(propertyAssignment.initializer, p)
554
+ };
555
+ return updateIfChanged(propertyAssignment, updates);
463
556
  }
464
557
 
465
558
  protected async visitSatisfiesExpression(satisfiesExpression: JS.SatisfiesExpression, p: P): Promise<J | undefined> {
@@ -469,11 +562,14 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
469
562
  }
470
563
  satisfiesExpression = expression as JS.SatisfiesExpression;
471
564
 
472
- return this.produceJavaScript<JS.SatisfiesExpression>(satisfiesExpression, p, async draft => {
473
- draft.expression = await this.visitDefined<J>(satisfiesExpression.expression, p);
474
- draft.satisfiesType = await this.visitLeftPadded(satisfiesExpression.satisfiesType, p);
475
- draft.type = satisfiesExpression.type && await this.visitType(satisfiesExpression.type, p);
476
- });
565
+ const updates: any = {
566
+ prefix: await this.visitSpace(satisfiesExpression.prefix, p),
567
+ markers: await this.visitMarkers(satisfiesExpression.markers, p),
568
+ expression: await this.visitDefined<J>(satisfiesExpression.expression, p),
569
+ satisfiesType: await this.visitLeftPadded(satisfiesExpression.satisfiesType, p),
570
+ type: satisfiesExpression.type && await this.visitType(satisfiesExpression.type, p)
571
+ };
572
+ return updateIfChanged(satisfiesExpression, updates);
477
573
  }
478
574
 
479
575
  protected async visitScopedVariableDeclarations(scopedVariableDeclarations: JS.ScopedVariableDeclarations, p: P): Promise<J | undefined> {
@@ -483,10 +579,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
483
579
  }
484
580
  scopedVariableDeclarations = statement as JS.ScopedVariableDeclarations;
485
581
 
486
- return this.produceJavaScript<JS.ScopedVariableDeclarations>(scopedVariableDeclarations, p, async draft => {
487
- draft.modifiers = await mapAsync(scopedVariableDeclarations.modifiers, item => this.visitDefined<J.Modifier>(item, p));
488
- draft.variables = await mapAsync(scopedVariableDeclarations.variables, item => this.visitRightPadded(item, p));
489
- });
582
+ const updates: any = {
583
+ prefix: await this.visitSpace(scopedVariableDeclarations.prefix, p),
584
+ markers: await this.visitMarkers(scopedVariableDeclarations.markers, p),
585
+ modifiers: await mapAsync(scopedVariableDeclarations.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
586
+ variables: await mapAsync(scopedVariableDeclarations.variables, item => this.visitRightPadded(item, p))
587
+ };
588
+ return updateIfChanged(scopedVariableDeclarations, updates);
490
589
  }
491
590
 
492
591
  protected async visitStatementExpression(statementExpression: JS.StatementExpression, p: P): Promise<J | undefined> {
@@ -502,9 +601,12 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
502
601
  }
503
602
  statementExpression = statement as JS.StatementExpression;
504
603
 
505
- return this.produceJavaScript<JS.StatementExpression>(statementExpression, p, async draft => {
506
- draft.statement = await this.visitDefined<Statement>(statementExpression.statement, p);
507
- });
604
+ const updates: any = {
605
+ prefix: await this.visitSpace(statementExpression.prefix, p),
606
+ markers: await this.visitMarkers(statementExpression.markers, p),
607
+ statement: await this.visitDefined<Statement>(statementExpression.statement, p)
608
+ };
609
+ return updateIfChanged(statementExpression, updates);
508
610
  }
509
611
 
510
612
  protected async visitTaggedTemplateExpression(taggedTemplateExpression: JS.TaggedTemplateExpression, p: P): Promise<J | undefined> {
@@ -520,12 +622,15 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
520
622
  }
521
623
  taggedTemplateExpression = statement as JS.TaggedTemplateExpression;
522
624
 
523
- return this.produceJavaScript<JS.TaggedTemplateExpression>(taggedTemplateExpression, p, async draft => {
524
- draft.tag = taggedTemplateExpression.tag && await this.visitRightPadded(taggedTemplateExpression.tag, p);
525
- draft.typeArguments = taggedTemplateExpression.typeArguments && await this.visitContainer(taggedTemplateExpression.typeArguments, p);
526
- draft.templateExpression = await this.visitDefined<Expression>(taggedTemplateExpression.templateExpression, p);
527
- draft.type = taggedTemplateExpression.type && await this.visitType(taggedTemplateExpression.type, p);
528
- });
625
+ const updates: any = {
626
+ prefix: await this.visitSpace(taggedTemplateExpression.prefix, p),
627
+ markers: await this.visitMarkers(taggedTemplateExpression.markers, p),
628
+ tag: taggedTemplateExpression.tag && await this.visitRightPadded(taggedTemplateExpression.tag, p),
629
+ typeArguments: taggedTemplateExpression.typeArguments && await this.visitContainer(taggedTemplateExpression.typeArguments, p),
630
+ templateExpression: await this.visitDefined<Expression>(taggedTemplateExpression.templateExpression, p),
631
+ type: taggedTemplateExpression.type && await this.visitType(taggedTemplateExpression.type, p)
632
+ };
633
+ return updateIfChanged(taggedTemplateExpression, updates);
529
634
  }
530
635
 
531
636
  protected async visitTemplateExpression(templateExpression: JS.TemplateExpression, p: P): Promise<J | undefined> {
@@ -541,18 +646,24 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
541
646
  }
542
647
  templateExpression = statement as JS.TemplateExpression;
543
648
 
544
- return this.produceJavaScript<JS.TemplateExpression>(templateExpression, p, async draft => {
545
- draft.head = await this.visitDefined<J.Literal>(templateExpression.head, p);
546
- draft.spans = await mapAsync(templateExpression.spans, item => this.visitRightPadded(item, p));
547
- draft.type = templateExpression.type && await this.visitType(templateExpression.type, p);
548
- });
649
+ const updates: any = {
650
+ prefix: await this.visitSpace(templateExpression.prefix, p),
651
+ markers: await this.visitMarkers(templateExpression.markers, p),
652
+ head: await this.visitDefined<J.Literal>(templateExpression.head, p),
653
+ spans: await mapAsync(templateExpression.spans, item => this.visitRightPadded(item, p)),
654
+ type: templateExpression.type && await this.visitType(templateExpression.type, p)
655
+ };
656
+ return updateIfChanged(templateExpression, updates);
549
657
  }
550
658
 
551
659
  protected async visitTemplateExpressionSpan(span: JS.TemplateExpression.Span, p: P): Promise<J | undefined> {
552
- return this.produceJavaScript<JS.TemplateExpression.Span>(span, p, async draft => {
553
- draft.expression = await this.visitDefined<J>(span.expression, p);
554
- draft.tail = await this.visitDefined<J.Literal>(span.tail, p);
555
- });
660
+ const updates: any = {
661
+ prefix: await this.visitSpace(span.prefix, p),
662
+ markers: await this.visitMarkers(span.markers, p),
663
+ expression: await this.visitDefined<J>(span.expression, p),
664
+ tail: await this.visitDefined<J.Literal>(span.tail, p)
665
+ };
666
+ return updateIfChanged(span, updates);
556
667
  }
557
668
 
558
669
  protected async visitTuple(tuple: JS.Tuple, p: P): Promise<J | undefined> {
@@ -562,10 +673,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
562
673
  }
563
674
  tuple = expression as JS.Tuple;
564
675
 
565
- return this.produceJavaScript<JS.Tuple>(tuple, p, async draft => {
566
- draft.elements = await this.visitContainer(tuple.elements, p);
567
- draft.type = tuple.type && await this.visitType(tuple.type, p);
568
- });
676
+ const updates: any = {
677
+ prefix: await this.visitSpace(tuple.prefix, p),
678
+ markers: await this.visitMarkers(tuple.markers, p),
679
+ elements: await this.visitContainer(tuple.elements, p),
680
+ type: tuple.type && await this.visitType(tuple.type, p)
681
+ };
682
+ return updateIfChanged(tuple, updates);
569
683
  }
570
684
 
571
685
  protected async visitTypeDeclaration(typeDeclaration: JS.TypeDeclaration, p: P): Promise<J | undefined> {
@@ -575,13 +689,16 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
575
689
  }
576
690
  typeDeclaration = statement as JS.TypeDeclaration;
577
691
 
578
- return this.produceJavaScript<JS.TypeDeclaration>(typeDeclaration, p, async draft => {
579
- draft.modifiers = await mapAsync(typeDeclaration.modifiers, item => this.visitDefined<J.Modifier>(item, p));
580
- draft.name = await this.visitLeftPadded(typeDeclaration.name, p);
581
- draft.typeParameters = typeDeclaration.typeParameters && await this.visitDefined<J.TypeParameters>(typeDeclaration.typeParameters, p);
582
- draft.initializer = await this.visitLeftPadded(typeDeclaration.initializer, p);
583
- draft.type = typeDeclaration.type && await this.visitType(typeDeclaration.type, p);
584
- });
692
+ const updates: any = {
693
+ prefix: await this.visitSpace(typeDeclaration.prefix, p),
694
+ markers: await this.visitMarkers(typeDeclaration.markers, p),
695
+ modifiers: await mapAsync(typeDeclaration.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
696
+ name: await this.visitLeftPadded(typeDeclaration.name, p),
697
+ typeParameters: typeDeclaration.typeParameters && await this.visitDefined<J.TypeParameters>(typeDeclaration.typeParameters, p),
698
+ initializer: await this.visitLeftPadded(typeDeclaration.initializer, p),
699
+ type: typeDeclaration.type && await this.visitType(typeDeclaration.type, p)
700
+ };
701
+ return updateIfChanged(typeDeclaration, updates);
585
702
  }
586
703
 
587
704
  protected async visitTypeOf(typeOf: JS.TypeOf, p: P): Promise<J | undefined> {
@@ -591,10 +708,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
591
708
  }
592
709
  typeOf = expression as JS.TypeOf;
593
710
 
594
- return this.produceJavaScript<JS.TypeOf>(typeOf, p, async draft => {
595
- draft.expression = await this.visitDefined<Expression>(typeOf.expression, p);
596
- draft.type = typeOf.type && await this.visitType(typeOf.type, p);
597
- });
711
+ const updates: any = {
712
+ prefix: await this.visitSpace(typeOf.prefix, p),
713
+ markers: await this.visitMarkers(typeOf.markers, p),
714
+ expression: await this.visitDefined<Expression>(typeOf.expression, p),
715
+ type: typeOf.type && await this.visitType(typeOf.type, p)
716
+ };
717
+ return updateIfChanged(typeOf, updates);
598
718
  }
599
719
 
600
720
  protected async visitTypeTreeExpression(typeTreeExpression: JS.TypeTreeExpression, p: P): Promise<J | undefined> {
@@ -604,18 +724,24 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
604
724
  }
605
725
  typeTreeExpression = expression as JS.TypeTreeExpression;
606
726
 
607
- return this.produceJavaScript<JS.TypeTreeExpression>(typeTreeExpression, p, async draft => {
608
- draft.expression = await this.visitDefined<Expression>(typeTreeExpression.expression, p);
609
- });
727
+ const updates: any = {
728
+ prefix: await this.visitSpace(typeTreeExpression.prefix, p),
729
+ markers: await this.visitMarkers(typeTreeExpression.markers, p),
730
+ expression: await this.visitDefined<Expression>(typeTreeExpression.expression, p)
731
+ };
732
+ return updateIfChanged(typeTreeExpression, updates);
610
733
  }
611
734
 
612
735
  protected async visitAssignmentOperationExtensions(assignmentOperation: JS.AssignmentOperation, p: P): Promise<J | undefined> {
613
- return this.produceJavaScript<JS.AssignmentOperation>(assignmentOperation, p, async draft => {
614
- draft.variable = await this.visitDefined<Expression>(assignmentOperation.variable, p);
615
- draft.operator = await this.visitLeftPadded(assignmentOperation.operator, p);
616
- draft.assignment = await this.visitDefined<Expression>(assignmentOperation.assignment, p);
617
- draft.type = assignmentOperation.type && await this.visitType(assignmentOperation.type, p);
618
- });
736
+ const updates: any = {
737
+ prefix: await this.visitSpace(assignmentOperation.prefix, p),
738
+ markers: await this.visitMarkers(assignmentOperation.markers, p),
739
+ variable: await this.visitDefined<Expression>(assignmentOperation.variable, p),
740
+ operator: await this.visitLeftPadded(assignmentOperation.operator, p),
741
+ assignment: await this.visitDefined<Expression>(assignmentOperation.assignment, p),
742
+ type: assignmentOperation.type && await this.visitType(assignmentOperation.type, p)
743
+ };
744
+ return updateIfChanged(assignmentOperation, updates);
619
745
  }
620
746
 
621
747
  protected async visitIndexedAccessType(indexedAccessType: JS.IndexedAccessType, p: P): Promise<J | undefined> {
@@ -625,18 +751,24 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
625
751
  }
626
752
  indexedAccessType = expression as JS.IndexedAccessType;
627
753
 
628
- return this.produceJavaScript<JS.IndexedAccessType>(indexedAccessType, p, async draft => {
629
- draft.objectType = await this.visitDefined<TypedTree>(indexedAccessType.objectType, p);
630
- draft.indexType = await this.visitDefined<TypedTree>(indexedAccessType.indexType, p);
631
- draft.type = indexedAccessType.type && await this.visitType(indexedAccessType.type, p);
632
- });
754
+ const updates: any = {
755
+ prefix: await this.visitSpace(indexedAccessType.prefix, p),
756
+ markers: await this.visitMarkers(indexedAccessType.markers, p),
757
+ objectType: await this.visitDefined<TypedTree>(indexedAccessType.objectType, p),
758
+ indexType: await this.visitDefined<TypedTree>(indexedAccessType.indexType, p),
759
+ type: indexedAccessType.type && await this.visitType(indexedAccessType.type, p)
760
+ };
761
+ return updateIfChanged(indexedAccessType, updates);
633
762
  }
634
763
 
635
764
  protected async visitIndexedAccessTypeIndexType(indexType: JS.IndexedAccessType.IndexType, p: P): Promise<J | undefined> {
636
- return this.produceJavaScript<JS.IndexedAccessType.IndexType>(indexType, p, async draft => {
637
- draft.element = await this.visitRightPadded(indexType.element, p);
638
- draft.type = indexType.type && await this.visitType(indexType.type, p);
639
- });
765
+ const updates: any = {
766
+ prefix: await this.visitSpace(indexType.prefix, p),
767
+ markers: await this.visitMarkers(indexType.markers, p),
768
+ element: await this.visitRightPadded(indexType.element, p),
769
+ type: indexType.type && await this.visitType(indexType.type, p)
770
+ };
771
+ return updateIfChanged(indexType, updates);
640
772
  }
641
773
 
642
774
  protected async visitTypeQuery(typeQuery: JS.TypeQuery, p: P): Promise<J | undefined> {
@@ -646,11 +778,14 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
646
778
  }
647
779
  typeQuery = expression as JS.TypeQuery;
648
780
 
649
- return this.produceJavaScript<JS.TypeQuery>(typeQuery, p, async draft => {
650
- draft.typeExpression = await this.visitDefined<TypedTree>(typeQuery.typeExpression, p);
651
- draft.typeArguments = typeQuery.typeArguments && await this.visitContainer(typeQuery.typeArguments, p);
652
- draft.type = typeQuery.type && await this.visitType(typeQuery.type, p);
653
- });
781
+ const updates: any = {
782
+ prefix: await this.visitSpace(typeQuery.prefix, p),
783
+ markers: await this.visitMarkers(typeQuery.markers, p),
784
+ typeExpression: await this.visitDefined<TypedTree>(typeQuery.typeExpression, p),
785
+ typeArguments: typeQuery.typeArguments && await this.visitContainer(typeQuery.typeArguments, p),
786
+ type: typeQuery.type && await this.visitType(typeQuery.type, p)
787
+ };
788
+ return updateIfChanged(typeQuery, updates);
654
789
  }
655
790
 
656
791
  protected async visitTypeInfo(typeInfo: JS.TypeInfo, p: P): Promise<J | undefined> {
@@ -660,9 +795,12 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
660
795
  }
661
796
  typeInfo = expression as JS.TypeInfo;
662
797
 
663
- return this.produceJavaScript<JS.TypeInfo>(typeInfo, p, async draft => {
664
- draft.typeIdentifier = await this.visitDefined<TypedTree>(typeInfo.typeIdentifier, p);
665
- });
798
+ const updates: any = {
799
+ prefix: await this.visitSpace(typeInfo.prefix, p),
800
+ markers: await this.visitMarkers(typeInfo.markers, p),
801
+ typeIdentifier: await this.visitDefined<TypedTree>(typeInfo.typeIdentifier, p)
802
+ };
803
+ return updateIfChanged(typeInfo, updates);
666
804
  }
667
805
 
668
806
  protected async visitComputedPropertyName(computedPropertyName: JS.ComputedPropertyName, p: P): Promise<J | undefined> {
@@ -672,9 +810,12 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
672
810
  }
673
811
  computedPropertyName = expression as JS.ComputedPropertyName;
674
812
 
675
- return this.produceJavaScript<JS.ComputedPropertyName>(computedPropertyName, p, async draft => {
676
- draft.expression = await this.visitRightPadded(computedPropertyName.expression, p);
677
- });
813
+ const updates: any = {
814
+ prefix: await this.visitSpace(computedPropertyName.prefix, p),
815
+ markers: await this.visitMarkers(computedPropertyName.markers, p),
816
+ expression: await this.visitRightPadded(computedPropertyName.expression, p)
817
+ };
818
+ return updateIfChanged(computedPropertyName, updates);
678
819
  }
679
820
 
680
821
  protected async visitTypeOperator(typeOperator: JS.TypeOperator, p: P): Promise<J | undefined> {
@@ -684,9 +825,12 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
684
825
  }
685
826
  typeOperator = expression as JS.TypeOperator;
686
827
 
687
- return this.produceJavaScript<JS.TypeOperator>(typeOperator, p, async draft => {
688
- draft.expression = await this.visitLeftPadded(typeOperator.expression, p);
689
- });
828
+ const updates: any = {
829
+ prefix: await this.visitSpace(typeOperator.prefix, p),
830
+ markers: await this.visitMarkers(typeOperator.markers, p),
831
+ expression: await this.visitLeftPadded(typeOperator.expression, p)
832
+ };
833
+ return updateIfChanged(typeOperator, updates);
690
834
  }
691
835
 
692
836
  protected async visitTypePredicate(typePredicate: JS.TypePredicate, p: P): Promise<J | undefined> {
@@ -696,12 +840,15 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
696
840
  }
697
841
  typePredicate = expression as JS.TypePredicate;
698
842
 
699
- return this.produceJavaScript<JS.TypePredicate>(typePredicate, p, async draft => {
700
- draft.asserts = await this.visitLeftPadded(typePredicate.asserts, p);
701
- draft.parameterName = await this.visitDefined<J.Identifier>(typePredicate.parameterName, p);
702
- draft.expression = typePredicate.expression && await this.visitLeftPadded(typePredicate.expression, p);
703
- draft.type = typePredicate.type && await this.visitType(typePredicate.type, p);
704
- });
843
+ const updates: any = {
844
+ prefix: await this.visitSpace(typePredicate.prefix, p),
845
+ markers: await this.visitMarkers(typePredicate.markers, p),
846
+ asserts: await this.visitLeftPadded(typePredicate.asserts, p),
847
+ parameterName: await this.visitDefined<J.Identifier>(typePredicate.parameterName, p),
848
+ expression: typePredicate.expression && await this.visitLeftPadded(typePredicate.expression, p),
849
+ type: typePredicate.type && await this.visitType(typePredicate.type, p)
850
+ };
851
+ return updateIfChanged(typePredicate, updates);
705
852
  }
706
853
 
707
854
  protected async visitUnion(union: JS.Union, p: P): Promise<J | undefined> {
@@ -711,10 +858,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
711
858
  }
712
859
  union = expression as JS.Union;
713
860
 
714
- return this.produceJavaScript<JS.Union>(union, p, async draft => {
715
- draft.types = await mapAsync(union.types, item => this.visitRightPadded(item, p));
716
- draft.type = union.type && await this.visitType(union.type, p);
717
- });
861
+ const updates: any = {
862
+ prefix: await this.visitSpace(union.prefix, p),
863
+ markers: await this.visitMarkers(union.markers, p),
864
+ types: await mapAsync(union.types, item => this.visitRightPadded(item, p)),
865
+ type: union.type && await this.visitType(union.type, p)
866
+ };
867
+ return updateIfChanged(union, updates);
718
868
  }
719
869
 
720
870
  protected async visitIntersection(intersection: JS.Intersection, p: P): Promise<J | undefined> {
@@ -724,10 +874,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
724
874
  }
725
875
  intersection = expression as JS.Intersection;
726
876
 
727
- return this.produceJavaScript<JS.Intersection>(intersection, p, async draft => {
728
- draft.types = await mapAsync(intersection.types, item => this.visitRightPadded(item, p));
729
- draft.type = intersection.type && await this.visitType(intersection.type, p);
730
- });
877
+ const updates: any = {
878
+ prefix: await this.visitSpace(intersection.prefix, p),
879
+ markers: await this.visitMarkers(intersection.markers, p),
880
+ types: await mapAsync(intersection.types, item => this.visitRightPadded(item, p)),
881
+ type: intersection.type && await this.visitType(intersection.type, p)
882
+ };
883
+ return updateIfChanged(intersection, updates);
731
884
  }
732
885
 
733
886
  protected async visitVoid(void_: JS.Void, p: P): Promise<J | undefined> {
@@ -737,9 +890,12 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
737
890
  }
738
891
  void_ = expression as JS.Void;
739
892
 
740
- return this.produceJavaScript<JS.Void>(void_, p, async draft => {
741
- draft.expression = await this.visitDefined<Expression>(void_.expression, p);
742
- });
893
+ const updates: any = {
894
+ prefix: await this.visitSpace(void_.prefix, p),
895
+ markers: await this.visitMarkers(void_.markers, p),
896
+ expression: await this.visitDefined<Expression>(void_.expression, p)
897
+ };
898
+ return updateIfChanged(void_, updates);
743
899
  }
744
900
 
745
901
  protected async visitWithStatement(withStatement: JS.WithStatement, p: P): Promise<J | undefined> {
@@ -749,10 +905,13 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
749
905
  }
750
906
  withStatement = statement as JS.WithStatement;
751
907
 
752
- return this.produceJavaScript<JS.WithStatement>(withStatement, p, async draft => {
753
- draft.expression = await this.visitDefined<J.ControlParentheses<Expression>>(withStatement.expression, p);
754
- draft.body = await this.visitRightPadded(withStatement.body, p);
755
- });
908
+ const updates: any = {
909
+ prefix: await this.visitSpace(withStatement.prefix, p),
910
+ markers: await this.visitMarkers(withStatement.markers, p),
911
+ expression: await this.visitDefined<J.ControlParentheses<Expression>>(withStatement.expression, p),
912
+ body: await this.visitRightPadded(withStatement.body, p)
913
+ };
914
+ return updateIfChanged(withStatement, updates);
756
915
  }
757
916
 
758
917
  protected async visitIndexSignatureDeclaration(indexSignatureDeclaration: JS.IndexSignatureDeclaration, p: P): Promise<J | undefined> {
@@ -762,12 +921,15 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
762
921
  }
763
922
  indexSignatureDeclaration = statement as JS.IndexSignatureDeclaration;
764
923
 
765
- return this.produceJavaScript<JS.IndexSignatureDeclaration>(indexSignatureDeclaration, p, async draft => {
766
- draft.modifiers = await mapAsync(indexSignatureDeclaration.modifiers, item => this.visitDefined<J.Modifier>(item, p));
767
- draft.parameters = await this.visitContainer(indexSignatureDeclaration.parameters, p);
768
- draft.typeExpression = await this.visitLeftPadded(indexSignatureDeclaration.typeExpression, p);
769
- draft.type = indexSignatureDeclaration.type && await this.visitType(indexSignatureDeclaration.type, p);
770
- });
924
+ const updates: any = {
925
+ prefix: await this.visitSpace(indexSignatureDeclaration.prefix, p),
926
+ markers: await this.visitMarkers(indexSignatureDeclaration.markers, p),
927
+ modifiers: await mapAsync(indexSignatureDeclaration.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
928
+ parameters: await this.visitContainer(indexSignatureDeclaration.parameters, p),
929
+ typeExpression: await this.visitLeftPadded(indexSignatureDeclaration.typeExpression, p),
930
+ type: indexSignatureDeclaration.type && await this.visitType(indexSignatureDeclaration.type, p)
931
+ };
932
+ return updateIfChanged(indexSignatureDeclaration, updates);
771
933
  }
772
934
 
773
935
  protected async visitComputedPropertyMethodDeclaration(computedPropMethod: JS.ComputedPropertyMethodDeclaration, p: P): Promise<J | undefined> {
@@ -777,29 +939,38 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
777
939
  }
778
940
  computedPropMethod = statement as JS.ComputedPropertyMethodDeclaration;
779
941
 
780
- return this.produceJavaScript<JS.ComputedPropertyMethodDeclaration>(computedPropMethod, p, async draft => {
781
- draft.leadingAnnotations = await mapAsync(computedPropMethod.leadingAnnotations, item => this.visitDefined<J.Annotation>(item, p));
782
- draft.modifiers = await mapAsync(computedPropMethod.modifiers, item => this.visitDefined<J.Modifier>(item, p));
783
- draft.typeParameters = computedPropMethod.typeParameters && await this.visitDefined<J.TypeParameters>(computedPropMethod.typeParameters, p);
784
- draft.returnTypeExpression = computedPropMethod.returnTypeExpression && await this.visitDefined<TypedTree>(computedPropMethod.returnTypeExpression, p);
785
- draft.name = await this.visitDefined<ComputedPropertyName>(computedPropMethod.name, p);
786
- draft.parameters = await this.visitContainer(computedPropMethod.parameters, p);
787
- draft.body = computedPropMethod.body && await this.visitDefined<J.Block>(computedPropMethod.body, p);
788
- draft.methodType = computedPropMethod.methodType && (await this.visitType(computedPropMethod.methodType, p) as Type.Method);
789
- });
942
+ const updates: any = {
943
+ prefix: await this.visitSpace(computedPropMethod.prefix, p),
944
+ markers: await this.visitMarkers(computedPropMethod.markers, p),
945
+ leadingAnnotations: await mapAsync(computedPropMethod.leadingAnnotations, item => this.visitDefined<J.Annotation>(item, p)),
946
+ modifiers: await mapAsync(computedPropMethod.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
947
+ typeParameters: computedPropMethod.typeParameters && await this.visitDefined<J.TypeParameters>(computedPropMethod.typeParameters, p),
948
+ returnTypeExpression: computedPropMethod.returnTypeExpression && await this.visitDefined<TypedTree>(computedPropMethod.returnTypeExpression, p),
949
+ name: await this.visitDefined<ComputedPropertyName>(computedPropMethod.name, p),
950
+ parameters: await this.visitContainer(computedPropMethod.parameters, p),
951
+ body: computedPropMethod.body && await this.visitDefined<J.Block>(computedPropMethod.body, p),
952
+ methodType: computedPropMethod.methodType && (await this.visitType(computedPropMethod.methodType, p) as Type.Method)
953
+ };
954
+ return updateIfChanged(computedPropMethod, updates);
790
955
  }
791
956
 
792
957
  protected async visitForOfLoop(forOfLoop: JS.ForOfLoop, p: P): Promise<J | undefined> {
793
- return this.produceJavaScript<JS.ForOfLoop>(forOfLoop, p, async draft => {
794
- draft.loop = await this.visitDefined<J.ForEachLoop>(forOfLoop.loop, p);
795
- });
958
+ const updates: any = {
959
+ prefix: await this.visitSpace(forOfLoop.prefix, p),
960
+ markers: await this.visitMarkers(forOfLoop.markers, p),
961
+ loop: await this.visitDefined<J.ForEachLoop>(forOfLoop.loop, p)
962
+ };
963
+ return updateIfChanged(forOfLoop, updates);
796
964
  }
797
965
 
798
966
  protected async visitForInLoop(forInLoop: JS.ForInLoop, p: P): Promise<J | undefined> {
799
- return this.produceJavaScript<JS.ForInLoop>(forInLoop, p, async draft => {
800
- draft.control = await this.visitDefined<JS.ForInLoop.Control>(forInLoop.control, p);
801
- draft.body = await this.visitRightPadded(forInLoop.body, p);
802
- });
967
+ const updates: any = {
968
+ prefix: await this.visitSpace(forInLoop.prefix, p),
969
+ markers: await this.visitMarkers(forInLoop.markers, p),
970
+ control: await this.visitDefined<JS.ForInLoop.Control>(forInLoop.control, p),
971
+ body: await this.visitRightPadded(forInLoop.body, p)
972
+ };
973
+ return updateIfChanged(forInLoop, updates);
803
974
  }
804
975
 
805
976
  protected async visitNamespaceDeclaration(namespaceDeclaration: JS.NamespaceDeclaration, p: P): Promise<J | undefined> {
@@ -809,26 +980,35 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
809
980
  }
810
981
  namespaceDeclaration = statement as JS.NamespaceDeclaration;
811
982
 
812
- return this.produceJavaScript<JS.NamespaceDeclaration>(namespaceDeclaration, p, async draft => {
813
- draft.modifiers = await mapAsync(namespaceDeclaration.modifiers, item => this.visitDefined<J.Modifier>(item, p));
814
- draft.keywordType = await this.visitLeftPadded(namespaceDeclaration.keywordType, p);
815
- draft.name = await this.visitRightPadded(namespaceDeclaration.name, p);
816
- draft.body = namespaceDeclaration.body && await this.visitDefined<J.Block>(namespaceDeclaration.body, p);
817
- });
983
+ const updates: any = {
984
+ prefix: await this.visitSpace(namespaceDeclaration.prefix, p),
985
+ markers: await this.visitMarkers(namespaceDeclaration.markers, p),
986
+ modifiers: await mapAsync(namespaceDeclaration.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
987
+ keywordType: await this.visitLeftPadded(namespaceDeclaration.keywordType, p),
988
+ name: await this.visitRightPadded(namespaceDeclaration.name, p),
989
+ body: namespaceDeclaration.body && await this.visitDefined<J.Block>(namespaceDeclaration.body, p)
990
+ };
991
+ return updateIfChanged(namespaceDeclaration, updates);
818
992
  }
819
993
 
820
994
  protected async visitTypeLiteral(typeLiteral: JS.TypeLiteral, p: P): Promise<J | undefined> {
821
- return this.produceJavaScript<JS.TypeLiteral>(typeLiteral, p, async draft => {
822
- draft.members = await this.visitDefined<J.Block>(typeLiteral.members, p);
823
- draft.type = typeLiteral.type && await this.visitType(typeLiteral.type, p);
824
- });
995
+ const updates: any = {
996
+ prefix: await this.visitSpace(typeLiteral.prefix, p),
997
+ markers: await this.visitMarkers(typeLiteral.markers, p),
998
+ members: await this.visitDefined<J.Block>(typeLiteral.members, p),
999
+ type: typeLiteral.type && await this.visitType(typeLiteral.type, p)
1000
+ };
1001
+ return updateIfChanged(typeLiteral, updates);
825
1002
  }
826
1003
 
827
1004
  protected async visitArrayBindingPattern(arrayBindingPattern: JS.ArrayBindingPattern, p: P): Promise<J | undefined> {
828
- return this.produceJavaScript<JS.ArrayBindingPattern>(arrayBindingPattern, p, async draft => {
829
- draft.elements = await this.visitContainer(arrayBindingPattern.elements, p);
830
- draft.type = arrayBindingPattern.type && await this.visitType(arrayBindingPattern.type, p);
831
- });
1005
+ const updates: any = {
1006
+ prefix: await this.visitSpace(arrayBindingPattern.prefix, p),
1007
+ markers: await this.visitMarkers(arrayBindingPattern.markers, p),
1008
+ elements: await this.visitContainer(arrayBindingPattern.elements, p),
1009
+ type: arrayBindingPattern.type && await this.visitType(arrayBindingPattern.type, p)
1010
+ };
1011
+ return updateIfChanged(arrayBindingPattern, updates);
832
1012
  }
833
1013
 
834
1014
  protected async visitBindingElement(bindingElement: JS.BindingElement, p: P): Promise<J | undefined> {
@@ -838,12 +1018,15 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
838
1018
  }
839
1019
  bindingElement = statement as JS.BindingElement;
840
1020
 
841
- return this.produceJavaScript<JS.BindingElement>(bindingElement, p, async draft => {
842
- draft.propertyName = bindingElement.propertyName && await this.visitRightPadded(bindingElement.propertyName, p);
843
- draft.name = await this.visitDefined<TypedTree>(bindingElement.name, p);
844
- draft.initializer = bindingElement.initializer && await this.visitLeftPadded(bindingElement.initializer, p);
845
- draft.variableType = bindingElement.variableType && (await this.visitType(bindingElement.variableType, p) as Type.Variable);
846
- });
1021
+ const updates: any = {
1022
+ prefix: await this.visitSpace(bindingElement.prefix, p),
1023
+ markers: await this.visitMarkers(bindingElement.markers, p),
1024
+ propertyName: bindingElement.propertyName && await this.visitRightPadded(bindingElement.propertyName, p),
1025
+ name: await this.visitDefined<TypedTree>(bindingElement.name, p),
1026
+ initializer: bindingElement.initializer && await this.visitLeftPadded(bindingElement.initializer, p),
1027
+ variableType: bindingElement.variableType && (await this.visitType(bindingElement.variableType, p) as Type.Variable)
1028
+ };
1029
+ return updateIfChanged(bindingElement, updates);
847
1030
  }
848
1031
 
849
1032
  protected async visitExportDeclaration(exportDeclaration: JS.ExportDeclaration, p: P): Promise<J | undefined> {
@@ -853,13 +1036,16 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
853
1036
  }
854
1037
  exportDeclaration = statement as JS.ExportDeclaration;
855
1038
 
856
- return this.produceJavaScript<JS.ExportDeclaration>(exportDeclaration, p, async draft => {
857
- draft.modifiers = await mapAsync(exportDeclaration.modifiers, item => this.visitDefined<J.Modifier>(item, p));
858
- draft.typeOnly = await this.visitLeftPadded(exportDeclaration.typeOnly, p);
859
- draft.exportClause = exportDeclaration.exportClause && await this.visitDefined<Expression>(exportDeclaration.exportClause, p);
860
- draft.moduleSpecifier = exportDeclaration.moduleSpecifier && await this.visitLeftPadded(exportDeclaration.moduleSpecifier, p);
861
- draft.attributes = exportDeclaration.attributes && await this.visitDefined<JS.ImportAttributes>(exportDeclaration.attributes, p);
862
- });
1039
+ const updates: any = {
1040
+ prefix: await this.visitSpace(exportDeclaration.prefix, p),
1041
+ markers: await this.visitMarkers(exportDeclaration.markers, p),
1042
+ modifiers: await mapAsync(exportDeclaration.modifiers, item => this.visitDefined<J.Modifier>(item, p)),
1043
+ typeOnly: await this.visitLeftPadded(exportDeclaration.typeOnly, p),
1044
+ exportClause: exportDeclaration.exportClause && await this.visitDefined<Expression>(exportDeclaration.exportClause, p),
1045
+ moduleSpecifier: exportDeclaration.moduleSpecifier && await this.visitLeftPadded(exportDeclaration.moduleSpecifier, p),
1046
+ attributes: exportDeclaration.attributes && await this.visitDefined<JS.ImportAttributes>(exportDeclaration.attributes, p)
1047
+ };
1048
+ return updateIfChanged(exportDeclaration, updates);
863
1049
  }
864
1050
 
865
1051
  protected async visitExportAssignment(exportAssignment: JS.ExportAssignment, p: P): Promise<J | undefined> {
@@ -869,24 +1055,33 @@ export class JavaScriptVisitor<P> extends JavaVisitor<P> {
869
1055
  }
870
1056
  exportAssignment = statement as JS.ExportAssignment;
871
1057
 
872
- return this.produceJavaScript<JS.ExportAssignment>(exportAssignment, p, async draft => {
873
- draft.expression = await this.visitLeftPadded<Expression>(exportAssignment.expression, p);
874
- });
1058
+ const updates: any = {
1059
+ prefix: await this.visitSpace(exportAssignment.prefix, p),
1060
+ markers: await this.visitMarkers(exportAssignment.markers, p),
1061
+ expression: await this.visitLeftPadded<Expression>(exportAssignment.expression, p)
1062
+ };
1063
+ return updateIfChanged(exportAssignment, updates);
875
1064
  }
876
1065
 
877
1066
  protected async visitNamedExports(namedExports: JS.NamedExports, p: P): Promise<J | undefined> {
878
- return this.produceJavaScript<JS.NamedExports>(namedExports, p, async draft => {
879
- draft.elements = await this.visitContainer(namedExports.elements, p);
880
- draft.type = namedExports.type && await this.visitType(namedExports.type, p);
881
- });
1067
+ const updates: any = {
1068
+ prefix: await this.visitSpace(namedExports.prefix, p),
1069
+ markers: await this.visitMarkers(namedExports.markers, p),
1070
+ elements: await this.visitContainer(namedExports.elements, p),
1071
+ type: namedExports.type && await this.visitType(namedExports.type, p)
1072
+ };
1073
+ return updateIfChanged(namedExports, updates);
882
1074
  }
883
1075
 
884
1076
  protected async visitExportSpecifier(exportSpecifier: JS.ExportSpecifier, p: P): Promise<J | undefined> {
885
- return this.produceJavaScript<JS.ExportSpecifier>(exportSpecifier, p, async draft => {
886
- draft.typeOnly = await this.visitLeftPadded(exportSpecifier.typeOnly, p);
887
- draft.specifier = await this.visitDefined<Expression>(exportSpecifier.specifier, p);
888
- draft.type = exportSpecifier.type && await this.visitType(exportSpecifier.type, p);
889
- });
1077
+ const updates: any = {
1078
+ prefix: await this.visitSpace(exportSpecifier.prefix, p),
1079
+ markers: await this.visitMarkers(exportSpecifier.markers, p),
1080
+ typeOnly: await this.visitLeftPadded(exportSpecifier.typeOnly, p),
1081
+ specifier: await this.visitDefined<Expression>(exportSpecifier.specifier, p),
1082
+ type: exportSpecifier.type && await this.visitType(exportSpecifier.type, p)
1083
+ };
1084
+ return updateIfChanged(exportSpecifier, updates);
890
1085
  }
891
1086
 
892
1087
  override async accept<J2 extends J, P2 extends P>(j: J2, p: P2): Promise<J | undefined> {