@openrewrite/rewrite 8.70.0-20251222-160244 → 8.70.0-20251222-222208

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 (154) hide show
  1. package/dist/execution.d.ts.map +1 -1
  2. package/dist/execution.js +5 -2
  3. package/dist/execution.js.map +1 -1
  4. package/dist/index.js +8 -8
  5. package/dist/index.js.map +1 -1
  6. package/dist/java/formatting-utils.d.ts +1 -1
  7. package/dist/java/formatting-utils.js +4 -4
  8. package/dist/java/formatting-utils.js.map +1 -1
  9. package/dist/java/markers.js +8 -8
  10. package/dist/java/markers.js.map +1 -1
  11. package/dist/java/type-visitor.d.ts +0 -3
  12. package/dist/java/type-visitor.d.ts.map +1 -1
  13. package/dist/java/type-visitor.js +67 -68
  14. package/dist/java/type-visitor.js.map +1 -1
  15. package/dist/java/visitor.d.ts +3 -3
  16. package/dist/java/visitor.d.ts.map +1 -1
  17. package/dist/java/visitor.js +5 -5
  18. package/dist/java/visitor.js.map +1 -1
  19. package/dist/javascript/assertions.js +4 -3
  20. package/dist/javascript/assertions.js.map +1 -1
  21. package/dist/javascript/cleanup/use-object-property-shorthand.js +3 -3
  22. package/dist/javascript/cleanup/use-object-property-shorthand.js.map +1 -1
  23. package/dist/javascript/format/format.d.ts +28 -7
  24. package/dist/javascript/format/format.d.ts.map +1 -1
  25. package/dist/javascript/format/format.js +149 -158
  26. package/dist/javascript/format/format.js.map +1 -1
  27. package/dist/javascript/format/minimum-viable-spacing-visitor.js +23 -23
  28. package/dist/javascript/format/minimum-viable-spacing-visitor.js.map +1 -1
  29. package/dist/javascript/format/prettier-format.d.ts.map +1 -1
  30. package/dist/javascript/format/prettier-format.js +8 -11
  31. package/dist/javascript/format/prettier-format.js.map +1 -1
  32. package/dist/javascript/format/tabs-and-indents-visitor.js +7 -7
  33. package/dist/javascript/format/tabs-and-indents-visitor.js.map +1 -1
  34. package/dist/javascript/format/whitespace-reconciler.d.ts.map +1 -1
  35. package/dist/javascript/format/whitespace-reconciler.js +12 -11
  36. package/dist/javascript/format/whitespace-reconciler.js.map +1 -1
  37. package/dist/javascript/markers.d.ts.map +1 -1
  38. package/dist/javascript/markers.js +6 -5
  39. package/dist/javascript/markers.js.map +1 -1
  40. package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js +2 -2
  41. package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js.map +1 -1
  42. package/dist/javascript/migrate/es6/modernize-octal-literals.js +2 -2
  43. package/dist/javascript/migrate/es6/modernize-octal-literals.js.map +1 -1
  44. package/dist/javascript/migrate/es6/remove-duplicate-object-keys.js +2 -2
  45. package/dist/javascript/migrate/es6/remove-duplicate-object-keys.js.map +1 -1
  46. package/dist/javascript/migrate/typescript/export-assignment-to-export-default.js +2 -2
  47. package/dist/javascript/migrate/typescript/export-assignment-to-export-default.js.map +1 -1
  48. package/dist/javascript/node-resolution-result.js +3 -9
  49. package/dist/javascript/node-resolution-result.js.map +1 -1
  50. package/dist/javascript/parser.d.ts.map +1 -1
  51. package/dist/javascript/parser.js +35 -35
  52. package/dist/javascript/parser.js.map +1 -1
  53. package/dist/javascript/project-parser.d.ts.map +1 -1
  54. package/dist/javascript/project-parser.js +6 -5
  55. package/dist/javascript/project-parser.js.map +1 -1
  56. package/dist/javascript/recipes/auto-format.d.ts +7 -23
  57. package/dist/javascript/recipes/auto-format.d.ts.map +1 -1
  58. package/dist/javascript/recipes/auto-format.js +8 -54
  59. package/dist/javascript/recipes/auto-format.js.map +1 -1
  60. package/dist/javascript/recipes/change-import.js +8 -8
  61. package/dist/javascript/recipes/change-import.js.map +1 -1
  62. package/dist/javascript/recipes/order-imports.js +4 -4
  63. package/dist/javascript/recipes/order-imports.js.map +1 -1
  64. package/dist/javascript/templating/engine.js +2 -2
  65. package/dist/javascript/templating/engine.js.map +1 -1
  66. package/dist/javascript/templating/index.d.ts +1 -0
  67. package/dist/javascript/templating/index.d.ts.map +1 -1
  68. package/dist/javascript/templating/index.js +4 -1
  69. package/dist/javascript/templating/index.js.map +1 -1
  70. package/dist/javascript/templating/placeholder-replacement.js +16 -16
  71. package/dist/javascript/templating/placeholder-replacement.js.map +1 -1
  72. package/dist/javascript/type-mapping.d.ts.map +1 -1
  73. package/dist/javascript/type-mapping.js +49 -58
  74. package/dist/javascript/type-mapping.js.map +1 -1
  75. package/dist/javascript/visitor.d.ts +3 -3
  76. package/dist/javascript/visitor.d.ts.map +1 -1
  77. package/dist/javascript/visitor.js +3 -3
  78. package/dist/javascript/visitor.js.map +1 -1
  79. package/dist/json/rpc.js +48 -49
  80. package/dist/json/rpc.js.map +1 -1
  81. package/dist/json/visitor.d.ts +3 -3
  82. package/dist/json/visitor.d.ts.map +1 -1
  83. package/dist/json/visitor.js +3 -3
  84. package/dist/json/visitor.js.map +1 -1
  85. package/dist/parse-error.js +11 -11
  86. package/dist/parse-error.js.map +1 -1
  87. package/dist/reference.d.ts.map +1 -1
  88. package/dist/reference.js +0 -3
  89. package/dist/reference.js.map +1 -1
  90. package/dist/rpc/index.js +42 -42
  91. package/dist/rpc/index.js.map +1 -1
  92. package/dist/rpc/queue.d.ts +7 -0
  93. package/dist/rpc/queue.d.ts.map +1 -1
  94. package/dist/rpc/queue.js +10 -8
  95. package/dist/rpc/queue.js.map +1 -1
  96. package/dist/rpc/request/install-recipes.js +1 -1
  97. package/dist/rpc/request/install-recipes.js.map +1 -1
  98. package/dist/rpc/request/parse-project.d.ts.map +1 -1
  99. package/dist/rpc/request/parse-project.js +12 -32
  100. package/dist/rpc/request/parse-project.js.map +1 -1
  101. package/dist/rpc/request/parse.d.ts.map +1 -1
  102. package/dist/rpc/request/parse.js +1 -4
  103. package/dist/rpc/request/parse.js.map +1 -1
  104. package/dist/text/rpc.js +18 -18
  105. package/dist/text/rpc.js.map +1 -1
  106. package/dist/version.txt +1 -1
  107. package/dist/visitor.d.ts +6 -4
  108. package/dist/visitor.d.ts.map +1 -1
  109. package/dist/visitor.js +19 -17
  110. package/dist/visitor.js.map +1 -1
  111. package/dist/yaml/rpc.js +65 -65
  112. package/dist/yaml/rpc.js.map +1 -1
  113. package/package.json +2 -2
  114. package/src/execution.ts +6 -2
  115. package/src/index.ts +8 -8
  116. package/src/java/formatting-utils.ts +2 -2
  117. package/src/java/markers.ts +8 -8
  118. package/src/java/type-visitor.ts +59 -68
  119. package/src/java/visitor.ts +8 -8
  120. package/src/javascript/assertions.ts +3 -3
  121. package/src/javascript/cleanup/use-object-property-shorthand.ts +1 -1
  122. package/src/javascript/format/format.ts +109 -107
  123. package/src/javascript/format/minimum-viable-spacing-visitor.ts +1 -1
  124. package/src/javascript/format/prettier-format.ts +9 -12
  125. package/src/javascript/format/tabs-and-indents-visitor.ts +1 -1
  126. package/src/javascript/format/whitespace-reconciler.ts +12 -11
  127. package/src/javascript/markers.ts +6 -6
  128. package/src/javascript/migrate/es6/modernize-octal-escape-sequences.ts +1 -1
  129. package/src/javascript/migrate/es6/modernize-octal-literals.ts +1 -1
  130. package/src/javascript/migrate/es6/remove-duplicate-object-keys.ts +1 -1
  131. package/src/javascript/migrate/typescript/export-assignment-to-export-default.ts +1 -1
  132. package/src/javascript/node-resolution-result.ts +8 -14
  133. package/src/javascript/parser.ts +5 -4
  134. package/src/javascript/project-parser.ts +4 -4
  135. package/src/javascript/recipes/auto-format.ts +9 -71
  136. package/src/javascript/recipes/change-import.ts +4 -4
  137. package/src/javascript/recipes/order-imports.ts +1 -1
  138. package/src/javascript/templating/engine.ts +1 -1
  139. package/src/javascript/templating/index.ts +5 -0
  140. package/src/javascript/templating/placeholder-replacement.ts +2 -2
  141. package/src/javascript/type-mapping.ts +28 -34
  142. package/src/javascript/visitor.ts +6 -6
  143. package/src/json/rpc.ts +51 -52
  144. package/src/json/visitor.ts +6 -6
  145. package/src/parse-error.ts +11 -11
  146. package/src/reference.ts +0 -5
  147. package/src/rpc/index.ts +43 -43
  148. package/src/rpc/queue.ts +18 -8
  149. package/src/rpc/request/install-recipes.ts +1 -1
  150. package/src/rpc/request/parse-project.ts +20 -32
  151. package/src/rpc/request/parse.ts +1 -4
  152. package/src/text/rpc.ts +18 -18
  153. package/src/visitor.ts +29 -30
  154. package/src/yaml/rpc.ts +80 -81
@@ -28,7 +28,7 @@ exports.prettierFormat = exports.BlankLinesVisitor = exports.WrappingAndBracesVi
28
28
  const tree_1 = require("../tree");
29
29
  const visitor_1 = require("../visitor");
30
30
  const java_1 = require("../../java");
31
- const immer_1 = require("immer");
31
+ const mutative_1 = require("mutative");
32
32
  const tree_2 = require("../../tree");
33
33
  const style_1 = require("../style");
34
34
  const visitor_2 = require("../../visitor");
@@ -132,7 +132,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
132
132
  });
133
133
  return __awaiter(this, void 0, void 0, function* () {
134
134
  const ret = yield _super.visitAlias.call(this, alias, p);
135
- return (0, immer_1.produce)(ret, draft => {
135
+ return (0, mutative_1.create)(ret, draft => {
136
136
  draft.propertyName.after.whitespace = " ";
137
137
  });
138
138
  });
@@ -143,7 +143,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
143
143
  });
144
144
  return __awaiter(this, void 0, void 0, function* () {
145
145
  const ret = yield _super.visitArrayAccess.call(this, arrayAccess, p);
146
- return (0, immer_1.produce)(ret, draft => {
146
+ return (0, mutative_1.create)(ret, draft => {
147
147
  // Preserve newlines - only modify if no newlines present
148
148
  if (!draft.dimension.index.element.prefix.whitespace.includes("\n")) {
149
149
  draft.dimension.index.element.prefix.whitespace = this.style.within.arrayBrackets ? " " : "";
@@ -160,7 +160,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
160
160
  });
161
161
  return __awaiter(this, void 0, void 0, function* () {
162
162
  const ret = yield _super.visitAssignment.call(this, assignment, p);
163
- return (0, immer_1.produce)(ret, draft => {
163
+ return (0, mutative_1.create)(ret, draft => {
164
164
  // Preserve newlines - only modify if no newlines present
165
165
  if (!draft.assignment.before.whitespace.includes("\n")) {
166
166
  draft.assignment.before.whitespace = this.style.aroundOperators.assignment ? " " : "";
@@ -215,7 +215,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
215
215
  default:
216
216
  throw new Error("Unsupported operator type " + ret.operator.element.valueOf());
217
217
  }
218
- return (0, immer_1.produce)(ret, draft => {
218
+ return (0, mutative_1.create)(ret, draft => {
219
219
  // Preserve newlines - only modify if no newlines present
220
220
  if (!draft.operator.before.whitespace.includes("\n")) {
221
221
  draft.operator.before.whitespace = property ? " " : "";
@@ -232,7 +232,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
232
232
  });
233
233
  return __awaiter(this, void 0, void 0, function* () {
234
234
  const ret = yield _super.visitCase.call(this, aCase, p);
235
- return ret && (0, immer_1.produce)(ret, draft => {
235
+ return ret && (0, mutative_1.create)(ret, draft => {
236
236
  if (draft.caseLabels.elements[0].element.kind != java_1.J.Kind.Identifier || draft.caseLabels.elements[0].element.simpleName != "default") {
237
237
  // Preserve newlines - only set to space if no newline exists
238
238
  if (!draft.caseLabels.before.whitespace.includes("\n")) {
@@ -250,7 +250,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
250
250
  const ret = yield _super.visitClassDeclaration.call(this, classDecl, p);
251
251
  // TODO typeParameters - IntelliJ doesn't seem to provide a setting for angleBrackets spacing for Typescript (while it does for Java),
252
252
  // thus we either introduce our own setting or just enforce the natural spacing with no setting
253
- return (0, immer_1.produce)(ret, draft => {
253
+ return (0, mutative_1.create)(ret, draft => {
254
254
  draft.body.prefix.whitespace = this.style.beforeLeftBrace.classInterfaceModuleLeftBrace ? " " : "";
255
255
  });
256
256
  });
@@ -261,7 +261,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
261
261
  });
262
262
  return __awaiter(this, void 0, void 0, function* () {
263
263
  const ret = yield _super.visitContainer.call(this, container, p);
264
- return (0, immer_1.produce)(ret, draft => {
264
+ return (0, mutative_1.create)(ret, draft => {
265
265
  var _a, _b, _c, _d;
266
266
  if (draft.elements.length > 0) {
267
267
  // Apply beforeComma rule to all elements except the last
@@ -297,7 +297,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
297
297
  });
298
298
  return __awaiter(this, void 0, void 0, function* () {
299
299
  const ret = yield _super.visitExportDeclaration.call(this, exportDeclaration, p);
300
- return (0, immer_1.produce)(ret, draft => {
300
+ return (0, mutative_1.create)(ret, draft => {
301
301
  if (draft.exportClause) {
302
302
  draft.exportClause.prefix.whitespace = " ";
303
303
  if (draft.exportClause.kind == tree_1.JS.Kind.NamedExports) {
@@ -345,18 +345,19 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
345
345
  }
346
346
  }
347
347
  oneInit.after.whitespace = "";
348
- return yield this.spaceBeforeRightPaddedElement(oneInit, index === 0 ? this.style.within.forParentheses : true);
348
+ this.spaceBeforeRightPaddedElementDraft(oneInit, index === 0 ? this.style.within.forParentheses : true);
349
+ return oneInit;
349
350
  })));
350
351
  if (draft.control.condition) {
351
352
  draft.control.condition.element.prefix.whitespace = " ";
352
353
  draft.control.condition.after.whitespace = this.style.other.beforeForSemicolon ? " " : "";
353
354
  }
354
- draft.control.update = yield Promise.all(draft.control.update.map((oneUpdate, index) => __awaiter(this, void 0, void 0, function* () {
355
+ draft.control.update.forEach((oneUpdate, index) => {
355
356
  oneUpdate.element.prefix.whitespace = " ";
356
357
  oneUpdate.after.whitespace = (index === draft.control.update.length - 1 ? this.style.within.forParentheses : this.style.other.beforeForSemicolon) ? " " : "";
357
- return oneUpdate;
358
- })));
359
- draft.body = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(ret.body, this.style.beforeLeftBrace.forLeftBrace), false);
358
+ });
359
+ this.spaceBeforeRightPaddedElementDraft(draft.body, this.style.beforeLeftBrace.forLeftBrace);
360
+ this.spaceAfterRightPaddedDraft(draft.body, false);
360
361
  }));
361
362
  });
362
363
  }
@@ -367,9 +368,11 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
367
368
  return __awaiter(this, void 0, void 0, function* () {
368
369
  const ret = yield _super.visitIf.call(this, iff, p);
369
370
  return (0, visitor_2.produceAsync)(ret, (draft) => __awaiter(this, void 0, void 0, function* () {
370
- draft.ifCondition = yield this.spaceBefore(draft.ifCondition, this.style.beforeParentheses.ifParentheses);
371
- draft.ifCondition.tree = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(draft.ifCondition.tree, this.style.within.ifParentheses), this.style.within.ifParentheses);
372
- draft.thenPart = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(ret.thenPart, this.style.beforeLeftBrace.ifLeftBrace), false);
371
+ this.spaceBeforeDraft(draft.ifCondition, this.style.beforeParentheses.ifParentheses);
372
+ this.spaceBeforeRightPaddedElementDraft(draft.ifCondition.tree, this.style.within.ifParentheses);
373
+ this.spaceAfterRightPaddedDraft(draft.ifCondition.tree, this.style.within.ifParentheses);
374
+ this.spaceBeforeRightPaddedElementDraft(draft.thenPart, this.style.beforeLeftBrace.ifLeftBrace);
375
+ this.spaceAfterRightPaddedDraft(draft.thenPart, false);
373
376
  }));
374
377
  });
375
378
  }
@@ -379,7 +382,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
379
382
  });
380
383
  return __awaiter(this, void 0, void 0, function* () {
381
384
  const ret = yield _super.visitImportDeclaration.call(this, jsImport, p);
382
- return (0, immer_1.produce)(ret, draft => {
385
+ return (0, mutative_1.create)(ret, draft => {
383
386
  if (draft.importClause) {
384
387
  // Space after 'import' keyword:
385
388
  // - If there's a default import (name), space goes in importClause.prefix
@@ -430,7 +433,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
430
433
  });
431
434
  return __awaiter(this, void 0, void 0, function* () {
432
435
  const ret = yield _super.visitIndexSignatureDeclaration.call(this, indexSignatureDeclaration, p);
433
- return (0, immer_1.produce)(ret, draft => {
436
+ return (0, mutative_1.create)(ret, draft => {
434
437
  draft.typeExpression.before.whitespace = this.style.other.beforeTypeReferenceColon ? " " : "";
435
438
  draft.typeExpression.element.prefix.whitespace = this.style.other.afterTypeReferenceColon ? " " : "";
436
439
  });
@@ -443,20 +446,22 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
443
446
  return __awaiter(this, void 0, void 0, function* () {
444
447
  const ret = yield _super.visitMethodDeclaration.call(this, methodDecl, p);
445
448
  return (0, visitor_2.produceAsync)(ret, (draft) => __awaiter(this, void 0, void 0, function* () {
446
- draft.body = ret.body && (yield this.spaceBefore(ret.body, this.style.beforeLeftBrace.functionLeftBrace));
449
+ if (draft.body) {
450
+ this.spaceBeforeDraft(draft.body, this.style.beforeLeftBrace.functionLeftBrace);
451
+ }
447
452
  if (draft.parameters.elements.length > 0 && draft.parameters.elements[0].element.kind != java_1.J.Kind.Empty) {
448
- draft.parameters.elements = yield Promise.all(draft.parameters.elements.map((param, index) => __awaiter(this, void 0, void 0, function* () {
449
- param = yield this.spaceAfterRightPadded(param, index === draft.parameters.elements.length - 1 ? this.style.within.functionDeclarationParentheses : this.style.other.beforeComma);
450
- param.element = yield this.spaceBefore(param.element, index === 0 ? this.style.within.functionDeclarationParentheses : this.style.other.afterComma);
453
+ draft.parameters.elements.forEach((param, index) => {
454
+ this.spaceAfterRightPaddedDraft(param, index === draft.parameters.elements.length - 1 ? this.style.within.functionDeclarationParentheses : this.style.other.beforeComma);
455
+ this.spaceBeforeDraft(param.element, index === 0 ? this.style.within.functionDeclarationParentheses : this.style.other.afterComma);
451
456
  param.element.variables[0].element.name.prefix.whitespace = "";
452
457
  param.element.variables[0].after.whitespace = "";
453
- return param;
454
- })));
458
+ });
455
459
  }
456
460
  else if (draft.parameters.elements.length == 1) {
457
- draft.parameters.elements[0] = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(draft.parameters.elements[0], this.style.within.functionDeclarationParentheses), false);
461
+ this.spaceBeforeRightPaddedElementDraft(draft.parameters.elements[0], this.style.within.functionDeclarationParentheses);
462
+ this.spaceAfterRightPaddedDraft(draft.parameters.elements[0], false);
458
463
  }
459
- draft.parameters = yield this.spaceBeforeContainer(draft.parameters, this.style.beforeParentheses.functionDeclarationParentheses);
464
+ this.spaceBeforeContainerDraft(draft.parameters, this.style.beforeParentheses.functionDeclarationParentheses);
460
465
  // Handle generator asterisk spacing
461
466
  // - space before * is in the Generator marker's prefix
462
467
  // - space after * is in the method name's prefix
@@ -478,17 +483,17 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
478
483
  const ret = yield _super.visitMethodInvocation.call(this, methodInv, p);
479
484
  return (0, visitor_2.produceAsync)(ret, (draft) => __awaiter(this, void 0, void 0, function* () {
480
485
  if (draft.select) {
481
- draft.arguments = yield this.spaceBeforeContainer(draft.arguments, this.style.beforeParentheses.functionCallParentheses);
486
+ this.spaceBeforeContainerDraft(draft.arguments, this.style.beforeParentheses.functionCallParentheses);
482
487
  }
483
488
  if (ret.arguments.elements.length > 0 && ret.arguments.elements[0].element.kind != java_1.J.Kind.Empty) {
484
- draft.arguments.elements = yield Promise.all(draft.arguments.elements.map((arg, index) => __awaiter(this, void 0, void 0, function* () {
485
- arg = yield this.spaceAfterRightPadded(arg, index === draft.arguments.elements.length - 1 ? this.style.within.functionCallParentheses : this.style.other.beforeComma);
486
- arg.element = yield this.spaceBefore(arg.element, index === 0 ? this.style.within.functionCallParentheses : this.style.other.afterComma);
487
- return arg;
488
- })));
489
+ draft.arguments.elements.forEach((arg, index) => {
490
+ this.spaceAfterRightPaddedDraft(arg, index === draft.arguments.elements.length - 1 ? this.style.within.functionCallParentheses : this.style.other.beforeComma);
491
+ this.spaceBeforeDraft(arg.element, index === 0 ? this.style.within.functionCallParentheses : this.style.other.afterComma);
492
+ });
489
493
  }
490
494
  else if (ret.arguments.elements.length == 1) {
491
- draft.arguments.elements[0] = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(draft.arguments.elements[0], this.style.within.functionCallParentheses), false);
495
+ this.spaceBeforeRightPaddedElementDraft(draft.arguments.elements[0], this.style.within.functionCallParentheses);
496
+ this.spaceAfterRightPaddedDraft(draft.arguments.elements[0], false);
492
497
  }
493
498
  // TODO typeParameters handling - see visitClassDeclaration
494
499
  }));
@@ -516,9 +521,10 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
516
521
  return __awaiter(this, void 0, void 0, function* () {
517
522
  const ret = yield _super.visitSwitch.call(this, switchNode, p);
518
523
  return (0, visitor_2.produceAsync)(ret, (draft) => __awaiter(this, void 0, void 0, function* () {
519
- draft.selector = yield this.spaceBefore(draft.selector, this.style.beforeParentheses.switchParentheses);
520
- draft.selector.tree = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(draft.selector.tree, this.style.within.switchParentheses), this.style.within.switchParentheses);
521
- draft.cases = yield this.spaceBefore(draft.cases, this.style.beforeLeftBrace.switchLeftBrace);
524
+ this.spaceBeforeDraft(draft.selector, this.style.beforeParentheses.switchParentheses);
525
+ this.spaceBeforeRightPaddedElementDraft(draft.selector.tree, this.style.within.switchParentheses);
526
+ this.spaceAfterRightPaddedDraft(draft.selector.tree, this.style.within.switchParentheses);
527
+ this.spaceBeforeDraft(draft.cases, this.style.beforeLeftBrace.switchLeftBrace);
522
528
  for (const case_ of draft.cases.statements) {
523
529
  if (case_.element.kind === java_1.J.Kind.Case) {
524
530
  case_.element.caseLabels.elements[0].after.whitespace = "";
@@ -534,8 +540,8 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
534
540
  return __awaiter(this, void 0, void 0, function* () {
535
541
  const ret = yield _super.visitTernary.call(this, ternary, p);
536
542
  return (0, visitor_2.produceAsync)(ret, (draft) => __awaiter(this, void 0, void 0, function* () {
537
- draft.truePart = yield this.spaceBeforeLeftPaddedElement(draft.truePart, this.style.ternaryOperator.beforeQuestionMark, this.style.ternaryOperator.afterQuestionMark);
538
- draft.falsePart = yield this.spaceBeforeLeftPaddedElement(draft.falsePart, this.style.ternaryOperator.beforeColon, this.style.ternaryOperator.afterColon);
543
+ this.spaceBeforeLeftPaddedElementDraft(draft.truePart, this.style.ternaryOperator.beforeQuestionMark, this.style.ternaryOperator.afterQuestionMark);
544
+ this.spaceBeforeLeftPaddedElementDraft(draft.falsePart, this.style.ternaryOperator.beforeColon, this.style.ternaryOperator.afterColon);
539
545
  }));
540
546
  });
541
547
  }
@@ -547,17 +553,19 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
547
553
  const ret = yield _super.visitTry.call(this, try_, p);
548
554
  return (0, visitor_2.produceAsync)(ret, (draft) => __awaiter(this, void 0, void 0, function* () {
549
555
  draft.body.prefix.whitespace = this.style.beforeLeftBrace.tryLeftBrace ? " " : "";
550
- draft.catches = yield Promise.all(draft.catches.map((catch_, index) => __awaiter(this, void 0, void 0, function* () {
551
- catch_ = yield this.spaceBefore(catch_, this.style.beforeKeywords.catchKeyword);
556
+ draft.catches.forEach(catch_ => {
557
+ this.spaceBeforeDraft(catch_, this.style.beforeKeywords.catchKeyword);
552
558
  catch_.parameter.prefix.whitespace = this.style.beforeParentheses.catchParentheses ? " " : "";
553
- catch_.parameter.tree = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(catch_.parameter.tree, this.style.within.catchParentheses), this.style.within.catchParentheses);
559
+ this.spaceBeforeRightPaddedElementDraft(catch_.parameter.tree, this.style.within.catchParentheses);
560
+ this.spaceAfterRightPaddedDraft(catch_.parameter.tree, this.style.within.catchParentheses);
554
561
  if (catch_.parameter.tree.element.variables.length > 0) {
555
562
  catch_.parameter.tree.element.variables[catch_.parameter.tree.element.variables.length - 1].after.whitespace = "";
556
563
  }
557
564
  catch_.body.prefix.whitespace = this.style.beforeLeftBrace.catchLeftBrace ? " " : "";
558
- return catch_;
559
- })));
560
- draft.finally = draft.finally && (yield this.spaceBeforeLeftPaddedElement(draft.finally, this.style.beforeKeywords.finallyKeyword, this.style.beforeLeftBrace.finallyLeftBrace));
565
+ });
566
+ if (draft.finally) {
567
+ this.spaceBeforeLeftPaddedElementDraft(draft.finally, this.style.beforeKeywords.finallyKeyword, this.style.beforeLeftBrace.finallyLeftBrace);
568
+ }
561
569
  }));
562
570
  });
563
571
  }
@@ -567,7 +575,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
567
575
  });
568
576
  return __awaiter(this, void 0, void 0, function* () {
569
577
  const ret = yield _super.visitTypeDeclaration.call(this, typeDeclaration, p);
570
- return (0, immer_1.produce)(ret, draft => {
578
+ return (0, mutative_1.create)(ret, draft => {
571
579
  if (draft.modifiers.length > 0) {
572
580
  draft.name.before.whitespace = " ";
573
581
  }
@@ -590,7 +598,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
590
598
  const ret = yield _super.visitTypeInfo.call(this, typeInfo, p);
591
599
  return (0, visitor_2.produceAsync)(ret, (draft) => __awaiter(this, void 0, void 0, function* () {
592
600
  draft.prefix.whitespace = this.style.other.beforeTypeReferenceColon ? " " : "";
593
- draft.typeIdentifier = yield this.spaceBefore(draft.typeIdentifier, this.style.other.afterTypeReferenceColon);
601
+ this.spaceBeforeDraft(draft.typeIdentifier, this.style.other.afterTypeReferenceColon);
594
602
  }));
595
603
  });
596
604
  }
@@ -606,7 +614,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
606
614
  const isSingleLine = !ret.members.end.whitespace.includes("\n") &&
607
615
  stmts.every(s => !s.element.prefix.whitespace.includes("\n"));
608
616
  if (isSingleLine) {
609
- return (0, immer_1.produce)(ret, draft => {
617
+ return (0, mutative_1.create)(ret, draft => {
610
618
  const space = this.style.within.objectLiteralTypeBraces ? " " : "";
611
619
  draft.members.statements[0].element.prefix.whitespace = space;
612
620
  // For type literals, the space before } is in members.end, not in last statement's after
@@ -623,7 +631,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
623
631
  });
624
632
  return __awaiter(this, void 0, void 0, function* () {
625
633
  const ret = yield _super.visitUnary.call(this, unary, p);
626
- return (0, immer_1.produce)(ret, draft => {
634
+ return (0, mutative_1.create)(ret, draft => {
627
635
  const spacing = this.style.aroundOperators.unary;
628
636
  switch (draft.operator.element) {
629
637
  case java_1.J.Unary.Type.Not:
@@ -675,9 +683,11 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
675
683
  return __awaiter(this, void 0, void 0, function* () {
676
684
  const ret = yield _super.visitWhileLoop.call(this, whileLoop, p);
677
685
  return (0, visitor_2.produceAsync)(ret, (draft) => __awaiter(this, void 0, void 0, function* () {
678
- draft.body = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(ret.body, this.style.beforeLeftBrace.whileLeftBrace), false);
679
- draft.condition = yield this.spaceBefore(draft.condition, this.style.beforeParentheses.whileParentheses);
680
- draft.condition.tree = yield this.spaceAfterRightPadded(yield this.spaceBeforeRightPaddedElement(draft.condition.tree, this.style.within.whileParentheses), this.style.within.whileParentheses);
686
+ this.spaceBeforeRightPaddedElementDraft(draft.body, this.style.beforeLeftBrace.whileLeftBrace);
687
+ this.spaceAfterRightPaddedDraft(draft.body, false);
688
+ this.spaceBeforeDraft(draft.condition, this.style.beforeParentheses.whileParentheses);
689
+ this.spaceBeforeRightPaddedElementDraft(draft.condition.tree, this.style.within.whileParentheses);
690
+ this.spaceAfterRightPaddedDraft(draft.condition.tree, this.style.within.whileParentheses);
681
691
  }));
682
692
  });
683
693
  }
@@ -687,7 +697,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
687
697
  });
688
698
  return __awaiter(this, void 0, void 0, function* () {
689
699
  const ret = yield _super.visitTypeParameter.call(this, typeParam, p);
690
- return (0, immer_1.produce)(ret, draft => {
700
+ return (0, mutative_1.create)(ret, draft => {
691
701
  if (draft.bounds && draft.bounds.elements.length >= 2) {
692
702
  const constraintType = draft.bounds.elements[0];
693
703
  const defaultType = draft.bounds.elements[1];
@@ -709,104 +719,85 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
709
719
  });
710
720
  });
711
721
  }
712
- spaceAfterRightPadded(right, spaceAfter) {
713
- return __awaiter(this, void 0, void 0, function* () {
714
- if (right.after.comments.length > 0) {
715
- // Perform the space rule for the suffix of the last comment only. Same as IntelliJ.
716
- const comments = SpacesVisitor.spaceLastCommentSuffix(right.after.comments, spaceAfter);
717
- return Object.assign(Object.assign({}, right), { after: Object.assign(Object.assign({}, right.after), { comments }) });
718
- }
719
- if (spaceAfter && SpacesVisitor.isNotSingleSpace(right.after.whitespace)) {
720
- return Object.assign(Object.assign({}, right), { after: Object.assign(Object.assign({}, right.after), { whitespace: " " }) });
721
- }
722
- else if (!spaceAfter && SpacesVisitor.isOnlySpacesAndNotEmpty(right.after.whitespace)) {
723
- return Object.assign(Object.assign({}, right), { after: Object.assign(Object.assign({}, right.after), { whitespace: "" }) });
724
- }
725
- else {
726
- return right;
727
- }
728
- });
729
- }
730
- spaceBeforeLeftPaddedElement(left, spaceBeforePadding, spaceBeforeElement) {
731
- return __awaiter(this, void 0, void 0, function* () {
732
- return (yield (0, visitor_2.produceAsync)(left, (draft) => __awaiter(this, void 0, void 0, function* () {
733
- if (draft.before.comments.length == 0) {
734
- // Preserve newlines - only modify if no newlines present
735
- if (!draft.before.whitespace.includes("\n")) {
736
- draft.before.whitespace = spaceBeforePadding ? " " : "";
737
- }
738
- }
739
- draft.element = (yield this.spaceBefore(left.element, spaceBeforeElement));
740
- })));
741
- });
742
- }
743
- spaceBeforeRightPaddedElement(right, spaceBefore) {
744
- return __awaiter(this, void 0, void 0, function* () {
745
- return (yield (0, visitor_2.produceAsync)(right, (draft) => __awaiter(this, void 0, void 0, function* () {
746
- draft.element = (yield this.spaceBefore(right.element, spaceBefore));
747
- })));
748
- });
722
+ /**
723
+ * Modifies the after space of a RightPadded draft in place.
724
+ */
725
+ spaceAfterRightPaddedDraft(draft, spaceAfter) {
726
+ if (draft.after.comments.length > 0) {
727
+ // Perform the space rule for the suffix of the last comment only. Same as IntelliJ.
728
+ SpacesVisitor.spaceLastCommentSuffixDraft(draft.after.comments, spaceAfter);
729
+ return;
730
+ }
731
+ if (spaceAfter && SpacesVisitor.isNotSingleSpace(draft.after.whitespace)) {
732
+ draft.after.whitespace = " ";
733
+ }
734
+ else if (!spaceAfter && SpacesVisitor.isOnlySpacesAndNotEmpty(draft.after.whitespace)) {
735
+ draft.after.whitespace = "";
736
+ }
749
737
  }
750
- spaceBefore(j, spaceBefore) {
751
- return __awaiter(this, void 0, void 0, function* () {
752
- if (j.prefix.comments.length > 0) {
753
- return j;
754
- }
755
- if (spaceBefore && SpacesVisitor.isNotSingleSpace(j.prefix.whitespace)) {
756
- return (0, immer_1.produce)(j, draft => {
757
- draft.prefix.whitespace = " ";
758
- });
759
- }
760
- else if (!spaceBefore && SpacesVisitor.isOnlySpacesAndNotEmpty(j.prefix.whitespace)) {
761
- return (0, immer_1.produce)(j, draft => {
762
- draft.prefix.whitespace = "";
763
- });
764
- }
765
- else {
766
- return j;
738
+ /**
739
+ * Modifies the before space of a LeftPadded draft and the element's prefix in place.
740
+ */
741
+ spaceBeforeLeftPaddedElementDraft(draft, spaceBeforePadding, spaceBeforeElement) {
742
+ if (draft.before.comments.length == 0) {
743
+ // Preserve newlines - only modify if no newlines present
744
+ if (!draft.before.whitespace.includes("\n")) {
745
+ draft.before.whitespace = spaceBeforePadding ? " " : "";
767
746
  }
768
- });
747
+ }
748
+ this.spaceBeforeDraft(draft.element, spaceBeforeElement);
769
749
  }
770
- spaceBeforeContainer(container, spaceBefore) {
771
- return __awaiter(this, void 0, void 0, function* () {
772
- if (container.before.comments.length > 0) {
773
- // Perform the space rule for the suffix of the last comment only. Same as IntelliJ.
774
- return (0, immer_1.produce)(container, draft => {
775
- draft.before.comments = SpacesVisitor.spaceLastCommentSuffix(container.before.comments, spaceBefore);
776
- });
777
- }
778
- if (spaceBefore && SpacesVisitor.isNotSingleSpace(container.before.whitespace)) {
779
- return (0, immer_1.produce)(container, draft => {
780
- draft.before.whitespace = " ";
781
- });
782
- }
783
- else if (!spaceBefore && SpacesVisitor.isOnlySpacesAndNotEmpty(container.before.whitespace)) {
784
- return (0, immer_1.produce)(container, draft => {
785
- draft.before.whitespace = "";
786
- });
787
- }
788
- else {
789
- return container;
790
- }
791
- });
750
+ /**
751
+ * Modifies the element's prefix of a RightPadded draft in place.
752
+ */
753
+ spaceBeforeRightPaddedElementDraft(draft, spaceBefore) {
754
+ this.spaceBeforeDraft(draft.element, spaceBefore);
792
755
  }
793
- static spaceLastCommentSuffix(comments, spaceSuffix) {
794
- comments[comments.length - 1] = this.spaceSuffix(comments[comments.length - 1], spaceSuffix);
795
- return comments;
756
+ /**
757
+ * Modifies the prefix whitespace of a J draft in place.
758
+ */
759
+ spaceBeforeDraft(draft, spaceBefore) {
760
+ if (draft.prefix.comments.length > 0) {
761
+ return;
762
+ }
763
+ if (spaceBefore && SpacesVisitor.isNotSingleSpace(draft.prefix.whitespace)) {
764
+ draft.prefix.whitespace = " ";
765
+ }
766
+ else if (!spaceBefore && SpacesVisitor.isOnlySpacesAndNotEmpty(draft.prefix.whitespace)) {
767
+ draft.prefix.whitespace = "";
768
+ }
796
769
  }
797
- static spaceSuffix(comment, spaceSuffix) {
798
- if (spaceSuffix && this.isNotSingleSpace(comment.suffix)) {
799
- return (0, immer_1.produce)(comment, draft => {
800
- draft.suffix = " ";
801
- });
770
+ /**
771
+ * Modifies the before space of a Container draft in place.
772
+ */
773
+ spaceBeforeContainerDraft(draft, spaceBefore) {
774
+ if (draft.before.comments.length > 0) {
775
+ // Perform the space rule for the suffix of the last comment only. Same as IntelliJ.
776
+ SpacesVisitor.spaceLastCommentSuffixDraft(draft.before.comments, spaceBefore);
777
+ return;
802
778
  }
803
- else if (!spaceSuffix && this.isOnlySpacesAndNotEmpty(comment.suffix)) {
804
- return (0, immer_1.produce)(comment, draft => {
805
- draft.suffix = "";
806
- });
779
+ if (spaceBefore && SpacesVisitor.isNotSingleSpace(draft.before.whitespace)) {
780
+ draft.before.whitespace = " ";
807
781
  }
808
- else {
809
- return comment;
782
+ else if (!spaceBefore && SpacesVisitor.isOnlySpacesAndNotEmpty(draft.before.whitespace)) {
783
+ draft.before.whitespace = "";
784
+ }
785
+ }
786
+ /**
787
+ * Modifies the suffix of the last comment in an array of draft comments in place.
788
+ */
789
+ static spaceLastCommentSuffixDraft(comments, spaceSuffix) {
790
+ this.spaceSuffixDraft(comments[comments.length - 1], spaceSuffix);
791
+ }
792
+ /**
793
+ * Modifies the suffix of a Comment draft in place.
794
+ */
795
+ static spaceSuffixDraft(draft, spaceSuffix) {
796
+ if (spaceSuffix && this.isNotSingleSpace(draft.suffix)) {
797
+ draft.suffix = " ";
798
+ }
799
+ else if (!spaceSuffix && this.isOnlySpacesAndNotEmpty(draft.suffix)) {
800
+ draft.suffix = "";
810
801
  }
811
802
  }
812
803
  static isOnlySpaces(str) {
@@ -830,7 +821,7 @@ class SpacesVisitor extends visitor_1.JavaScriptVisitor {
830
821
  }
831
822
  // Handle object literal brace spacing: { foo: 1 } vs {foo: 1}
832
823
  if (ret.body && ret.body.statements.length > 0) {
833
- return (0, immer_1.produce)(ret, draft => {
824
+ return (0, mutative_1.create)(ret, draft => {
834
825
  const stmts = draft.body.statements;
835
826
  // Check if this is a multi-line object literal
836
827
  const isMultiLine = stmts.some(s => s.element.prefix.whitespace.includes("\n")) ||
@@ -887,7 +878,7 @@ class WrappingAndBracesVisitor extends visitor_1.JavaScriptVisitor {
887
878
  const v = yield _super.visitVariableDeclarations.call(this, multiVariable, p);
888
879
  const parent = (_a = this.cursor.parentTree()) === null || _a === void 0 ? void 0 : _a.value;
889
880
  if ((parent === null || parent === void 0 ? void 0 : parent.kind) === java_1.J.Kind.Block) {
890
- return (0, immer_1.produce)(v, draft => {
881
+ return (0, mutative_1.create)(v, draft => {
891
882
  draft.leadingAnnotations = this.withNewlines(draft.leadingAnnotations);
892
883
  if (draft.leadingAnnotations.length > 0) {
893
884
  if (draft.modifiers.length > 0) {
@@ -908,7 +899,7 @@ class WrappingAndBracesVisitor extends visitor_1.JavaScriptVisitor {
908
899
  });
909
900
  return __awaiter(this, void 0, void 0, function* () {
910
901
  const m = yield _super.visitMethodDeclaration.call(this, method, p);
911
- return (0, immer_1.produce)(m, draft => {
902
+ return (0, mutative_1.create)(m, draft => {
912
903
  draft.leadingAnnotations = this.withNewlines(draft.leadingAnnotations);
913
904
  if (draft.leadingAnnotations.length > 0) {
914
905
  if (draft.modifiers.length > 0) {
@@ -934,7 +925,7 @@ class WrappingAndBracesVisitor extends visitor_1.JavaScriptVisitor {
934
925
  return __awaiter(this, void 0, void 0, function* () {
935
926
  const e = yield _super.visitElse.call(this, elsePart, p);
936
927
  const hasBody = e.body.element.kind === java_1.J.Kind.Block || e.body.element.kind === java_1.J.Kind.If;
937
- return (0, immer_1.produce)(e, draft => {
928
+ return (0, mutative_1.create)(e, draft => {
938
929
  if (hasBody) {
939
930
  const shouldHaveNewline = this.style.ifStatement.elseOnNewLine;
940
931
  const hasNewline = draft.prefix.whitespace.includes("\n");
@@ -954,7 +945,7 @@ class WrappingAndBracesVisitor extends visitor_1.JavaScriptVisitor {
954
945
  });
955
946
  return __awaiter(this, void 0, void 0, function* () {
956
947
  const j = yield _super.visitClassDeclaration.call(this, classDecl, p);
957
- return (0, immer_1.produce)(j, draft => {
948
+ return (0, mutative_1.create)(j, draft => {
958
949
  draft.leadingAnnotations = this.withNewlines(draft.leadingAnnotations);
959
950
  if (draft.leadingAnnotations.length > 0) {
960
951
  if (draft.modifiers.length > 0) {
@@ -976,7 +967,7 @@ class WrappingAndBracesVisitor extends visitor_1.JavaScriptVisitor {
976
967
  });
977
968
  return __awaiter(this, void 0, void 0, function* () {
978
969
  const b = yield _super.visitBlock.call(this, block, p);
979
- return (0, immer_1.produce)(b, draft => {
970
+ return (0, mutative_1.create)(b, draft => {
980
971
  var _a;
981
972
  const parentKind = (_a = this.cursor.parent) === null || _a === void 0 ? void 0 : _a.value.kind;
982
973
  // Check if this is a "simple" block (empty or contains only a single J.Empty)
@@ -1042,7 +1033,7 @@ class WrappingAndBracesVisitor extends visitor_1.JavaScriptVisitor {
1042
1033
  withNewlines(list) {
1043
1034
  return list.map((a, index) => {
1044
1035
  if (index > 0 && !a.prefix.whitespace.includes("\n")) {
1045
- return (0, immer_1.produce)(a, draft => {
1036
+ return (0, mutative_1.create)(a, draft => {
1046
1037
  draft.prefix.whitespace = "\n" + draft.prefix.whitespace;
1047
1038
  });
1048
1039
  }
@@ -1051,7 +1042,7 @@ class WrappingAndBracesVisitor extends visitor_1.JavaScriptVisitor {
1051
1042
  }
1052
1043
  withNewlineSpace(space) {
1053
1044
  if (space.comments.length === 0) {
1054
- space = (0, immer_1.produce)(space, draft => {
1045
+ space = (0, mutative_1.create)(space, draft => {
1055
1046
  draft.whitespace = "\n" + space.whitespace;
1056
1047
  });
1057
1048
  }
@@ -1068,7 +1059,7 @@ class WrappingAndBracesVisitor extends visitor_1.JavaScriptVisitor {
1068
1059
  const first = modifiers[0];
1069
1060
  if (!first.prefix.whitespace.includes("\n")) {
1070
1061
  return [
1071
- (0, immer_1.produce)(first, draft => {
1062
+ (0, mutative_1.create)(first, draft => {
1072
1063
  draft.prefix.whitespace = "\n" + draft.prefix.whitespace;
1073
1064
  }),
1074
1065
  ...modifiers.slice(1),
@@ -1092,7 +1083,7 @@ class BlankLinesVisitor extends visitor_1.JavaScriptVisitor {
1092
1083
  var _a, _b, _c;
1093
1084
  let ret = yield _super.preVisit.call(this, tree, p);
1094
1085
  if (ret.kind === tree_1.JS.Kind.CompilationUnit) {
1095
- ret = (0, immer_1.produce)(ret, draft => {
1086
+ ret = (0, mutative_1.create)(ret, draft => {
1096
1087
  if (draft.prefix.comments.length == 0) {
1097
1088
  draft.prefix.whitespace = "";
1098
1089
  }
@@ -1100,7 +1091,7 @@ class BlankLinesVisitor extends visitor_1.JavaScriptVisitor {
1100
1091
  }
1101
1092
  if (ret.kind === java_1.J.Kind.MethodDeclaration
1102
1093
  && ((_c = (_b = (_a = this.cursor.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.value.kind) === java_1.J.Kind.ClassDeclaration) {
1103
- ret = (0, immer_1.produce)(ret, draft => {
1094
+ ret = (0, mutative_1.create)(ret, draft => {
1104
1095
  this.ensurePrefixHasNewLine(draft);
1105
1096
  });
1106
1097
  }
@@ -1127,7 +1118,7 @@ class BlankLinesVisitor extends visitor_1.JavaScriptVisitor {
1127
1118
  let ret = yield _super.visitClassDeclaration.call(this, classDecl, p);
1128
1119
  if (!ret.body)
1129
1120
  return ret;
1130
- return (0, immer_1.produce)(ret, draft => {
1121
+ return (0, mutative_1.create)(ret, draft => {
1131
1122
  var _a, _b, _c;
1132
1123
  const statements = draft.body.statements;
1133
1124
  if (statements.length > 0) {
@@ -1176,7 +1167,7 @@ class BlankLinesVisitor extends visitor_1.JavaScriptVisitor {
1176
1167
  const ret = yield _super.visitStatement.call(this, statement, p);
1177
1168
  const parent = (_a = this.cursor.parentTree()) === null || _a === void 0 ? void 0 : _a.value;
1178
1169
  const grandparent = (_c = (_b = this.cursor.parentTree()) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.value;
1179
- return (0, immer_1.produce)(ret, draft => {
1170
+ return (0, mutative_1.create)(ret, draft => {
1180
1171
  var _a, _b;
1181
1172
  if ((grandparent === null || grandparent === void 0 ? void 0 : grandparent.kind) === java_1.J.Kind.ClassDeclaration && (parent === null || parent === void 0 ? void 0 : parent.kind) === java_1.J.Kind.Block) {
1182
1173
  const classDecl = grandparent;
@@ -1220,7 +1211,7 @@ class BlankLinesVisitor extends visitor_1.JavaScriptVisitor {
1220
1211
  });
1221
1212
  return __awaiter(this, void 0, void 0, function* () {
1222
1213
  const b = yield _super.visitBlock.call(this, block, p);
1223
- return (0, immer_1.produce)(b, draft => {
1214
+ return (0, mutative_1.create)(b, draft => {
1224
1215
  var _a;
1225
1216
  const parentKind = (_a = this.cursor.parent) === null || _a === void 0 ? void 0 : _a.value.kind;
1226
1217
  // Skip newline for object literals (NewClass) and type literals (TypeLiteral)