@openrewrite/rewrite 8.100.0 → 8.100.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 (158) hide show
  1. package/dist/java/rpc.d.ts.map +1 -1
  2. package/dist/java/rpc.js +6 -1
  3. package/dist/java/rpc.js.map +1 -1
  4. package/dist/javascript/add-import.d.ts.map +1 -1
  5. package/dist/javascript/add-import.js +3 -0
  6. package/dist/javascript/add-import.js.map +1 -1
  7. package/dist/javascript/binding.d.ts.map +1 -1
  8. package/dist/javascript/binding.js +8 -1
  9. package/dist/javascript/binding.js.map +1 -1
  10. package/dist/javascript/comparator.js +2 -1
  11. package/dist/javascript/comparator.js.map +1 -1
  12. package/dist/javascript/format/format.d.ts.map +1 -1
  13. package/dist/javascript/format/format.js +3 -2
  14. package/dist/javascript/format/format.js.map +1 -1
  15. package/dist/javascript/format/minimum-viable-spacing-visitor.js +3 -3
  16. package/dist/javascript/format/minimum-viable-spacing-visitor.js.map +1 -1
  17. package/dist/javascript/node-resolution-result.d.ts +4 -1
  18. package/dist/javascript/node-resolution-result.d.ts.map +1 -1
  19. package/dist/javascript/node-resolution-result.js +47 -16
  20. package/dist/javascript/node-resolution-result.js.map +1 -1
  21. package/dist/javascript/package-json-parser.d.ts.map +1 -1
  22. package/dist/javascript/package-json-parser.js +4 -2
  23. package/dist/javascript/package-json-parser.js.map +1 -1
  24. package/dist/javascript/package-manager.d.ts +2 -0
  25. package/dist/javascript/package-manager.d.ts.map +1 -1
  26. package/dist/javascript/package-manager.js +11 -4
  27. package/dist/javascript/package-manager.js.map +1 -1
  28. package/dist/javascript/parser.d.ts.map +1 -1
  29. package/dist/javascript/parser.js +11 -17
  30. package/dist/javascript/parser.js.map +1 -1
  31. package/dist/javascript/print.d.ts +4 -0
  32. package/dist/javascript/print.d.ts.map +1 -1
  33. package/dist/javascript/print.js +82 -20
  34. package/dist/javascript/print.js.map +1 -1
  35. package/dist/javascript/rpc.js +2 -0
  36. package/dist/javascript/rpc.js.map +1 -1
  37. package/dist/javascript/scope.d.ts.map +1 -1
  38. package/dist/javascript/scope.js +4 -1
  39. package/dist/javascript/scope.js.map +1 -1
  40. package/dist/javascript/templating/comparator.d.ts +9 -0
  41. package/dist/javascript/templating/comparator.d.ts.map +1 -1
  42. package/dist/javascript/templating/comparator.js +21 -0
  43. package/dist/javascript/templating/comparator.js.map +1 -1
  44. package/dist/javascript/templating/debug.d.ts.map +1 -1
  45. package/dist/javascript/templating/debug.js +2 -0
  46. package/dist/javascript/templating/debug.js.map +1 -1
  47. package/dist/javascript/templating/precedence.d.ts.map +1 -1
  48. package/dist/javascript/templating/precedence.js +36 -39
  49. package/dist/javascript/templating/precedence.js.map +1 -1
  50. package/dist/javascript/templating/types.d.ts +4 -4
  51. package/dist/javascript/tree-debug.d.ts.map +1 -1
  52. package/dist/javascript/tree-debug.js +6 -3
  53. package/dist/javascript/tree-debug.js.map +1 -1
  54. package/dist/javascript/tree.d.ts +4 -1
  55. package/dist/javascript/tree.d.ts.map +1 -1
  56. package/dist/javascript/tree.js +2 -0
  57. package/dist/javascript/tree.js.map +1 -1
  58. package/dist/javascript/type-mapping.d.ts +1 -0
  59. package/dist/javascript/type-mapping.d.ts.map +1 -1
  60. package/dist/javascript/type-mapping.js +12 -1
  61. package/dist/javascript/type-mapping.js.map +1 -1
  62. package/dist/json/edit.d.ts +150 -0
  63. package/dist/json/edit.d.ts.map +1 -0
  64. package/dist/json/edit.js +667 -0
  65. package/dist/json/edit.js.map +1 -0
  66. package/dist/json/index.d.ts +1 -0
  67. package/dist/json/index.d.ts.map +1 -1
  68. package/dist/json/index.js +1 -0
  69. package/dist/json/index.js.map +1 -1
  70. package/dist/json/parser.d.ts.map +1 -1
  71. package/dist/json/parser.js +8 -1
  72. package/dist/json/parser.js.map +1 -1
  73. package/dist/parser.d.ts +1 -1
  74. package/dist/parser.d.ts.map +1 -1
  75. package/dist/print.d.ts +16 -0
  76. package/dist/print.d.ts.map +1 -1
  77. package/dist/print.js +33 -0
  78. package/dist/print.js.map +1 -1
  79. package/dist/rewrite-javascript-version.txt +1 -1
  80. package/dist/rpc/request/get-languages.d.ts.map +1 -1
  81. package/dist/rpc/request/get-languages.js +1 -0
  82. package/dist/rpc/request/get-languages.js.map +1 -1
  83. package/dist/rpc/request/parse.d.ts.map +1 -1
  84. package/dist/rpc/request/parse.js +4 -0
  85. package/dist/rpc/request/parse.js.map +1 -1
  86. package/dist/rpc/server.d.ts +1 -0
  87. package/dist/rpc/server.d.ts.map +1 -1
  88. package/dist/rpc/server.js +1 -0
  89. package/dist/rpc/server.js.map +1 -1
  90. package/dist/xml/assertions.d.ts +4 -0
  91. package/dist/xml/assertions.d.ts.map +1 -0
  92. package/dist/xml/assertions.js +31 -0
  93. package/dist/xml/assertions.js.map +1 -0
  94. package/dist/xml/index.d.ts +8 -0
  95. package/dist/xml/index.d.ts.map +1 -0
  96. package/dist/xml/index.js +39 -0
  97. package/dist/xml/index.js.map +1 -0
  98. package/dist/xml/namespaces.d.ts +36 -0
  99. package/dist/xml/namespaces.d.ts.map +1 -0
  100. package/dist/xml/namespaces.js +98 -0
  101. package/dist/xml/namespaces.js.map +1 -0
  102. package/dist/xml/parser.d.ts +15 -0
  103. package/dist/xml/parser.d.ts.map +1 -0
  104. package/dist/xml/parser.js +677 -0
  105. package/dist/xml/parser.js.map +1 -0
  106. package/dist/xml/print.d.ts +2 -0
  107. package/dist/xml/print.d.ts.map +1 -0
  108. package/dist/xml/print.js +209 -0
  109. package/dist/xml/print.js.map +1 -0
  110. package/dist/xml/rpc.d.ts +2 -0
  111. package/dist/xml/rpc.d.ts.map +1 -0
  112. package/dist/xml/rpc.js +313 -0
  113. package/dist/xml/rpc.js.map +1 -0
  114. package/dist/xml/tree.d.ts +244 -0
  115. package/dist/xml/tree.d.ts.map +1 -0
  116. package/dist/xml/tree.js +265 -0
  117. package/dist/xml/tree.js.map +1 -0
  118. package/dist/xml/visitor.d.ts +35 -0
  119. package/dist/xml/visitor.d.ts.map +1 -0
  120. package/dist/xml/visitor.js +203 -0
  121. package/dist/xml/visitor.js.map +1 -0
  122. package/package.json +5 -1
  123. package/src/java/rpc.ts +6 -1
  124. package/src/javascript/add-import.ts +3 -0
  125. package/src/javascript/binding.ts +10 -1
  126. package/src/javascript/comparator.ts +2 -1
  127. package/src/javascript/format/format.ts +3 -2
  128. package/src/javascript/format/minimum-viable-spacing-visitor.ts +3 -3
  129. package/src/javascript/node-resolution-result.ts +49 -15
  130. package/src/javascript/package-json-parser.ts +4 -1
  131. package/src/javascript/package-manager.ts +11 -4
  132. package/src/javascript/parser.ts +12 -17
  133. package/src/javascript/print.ts +85 -23
  134. package/src/javascript/rpc.ts +2 -0
  135. package/src/javascript/scope.ts +4 -1
  136. package/src/javascript/templating/comparator.ts +23 -0
  137. package/src/javascript/templating/debug.ts +1 -0
  138. package/src/javascript/templating/precedence.ts +17 -20
  139. package/src/javascript/templating/types.ts +4 -4
  140. package/src/javascript/tree-debug.ts +7 -3
  141. package/src/javascript/tree.ts +4 -1
  142. package/src/javascript/type-mapping.ts +15 -1
  143. package/src/json/edit.ts +750 -0
  144. package/src/json/index.ts +1 -0
  145. package/src/json/parser.ts +9 -1
  146. package/src/parser.ts +1 -1
  147. package/src/print.ts +42 -0
  148. package/src/rpc/request/get-languages.ts +1 -0
  149. package/src/rpc/request/parse.ts +3 -0
  150. package/src/rpc/server.ts +1 -0
  151. package/src/xml/assertions.ts +28 -0
  152. package/src/xml/index.ts +23 -0
  153. package/src/xml/namespaces.ts +109 -0
  154. package/src/xml/parser.ts +692 -0
  155. package/src/xml/print.ts +225 -0
  156. package/src/xml/rpc.ts +370 -0
  157. package/src/xml/tree.ts +455 -0
  158. package/src/xml/visitor.ts +227 -0
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import {JS, JSX} from "./tree";
19
19
  import {JavaScriptVisitor} from "./visitor";
20
- import {PrintOutputCapture, TreePrinters} from "../print";
20
+ import {PrintMark, PrintOutputCapture, TreePrinters} from "../print";
21
21
  import {Cursor, isTree, Tree} from "../tree";
22
22
  import {Comment, emptySpace, J, Statement, TextComment, TrailingComma, TypedTree} from "../java";
23
23
  import {findMarker, Marker, Markers} from "../markers";
@@ -49,7 +49,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
49
49
  override async visitAwait(awaitExpr: JS.Await, p: PrintOutputCapture): Promise<J | undefined> {
50
50
  await this.beforeSyntax(awaitExpr, p);
51
51
  p.append("await");
52
- await this.visit(awaitExpr.expression, p);
52
+ await this.visitAfterKeyword(awaitExpr.expression, p);
53
53
  await this.afterSyntax(awaitExpr, p);
54
54
  return awaitExpr;
55
55
  }
@@ -69,7 +69,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
69
69
  override async visitDelete(del: JS.Delete, p: PrintOutputCapture): Promise<J | undefined> {
70
70
  await this.beforeSyntax(del, p);
71
71
  p.append("delete");
72
- await this.visit(del.expression, p);
72
+ await this.visitAfterKeyword(del.expression, p);
73
73
  await this.afterSyntax(del, p);
74
74
  return del;
75
75
  }
@@ -205,6 +205,8 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
205
205
 
206
206
  if (jsImportClause.typeOnly) {
207
207
  p.append("type");
208
+ } else if (jsImportClause.deferred) {
209
+ p.append("defer");
208
210
  }
209
211
 
210
212
  if (jsImportClause.name) {
@@ -260,7 +262,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
260
262
  override async visitSatisfiesExpression(satisfiesExpression: JS.SatisfiesExpression, p: PrintOutputCapture): Promise<J | undefined> {
261
263
  await this.beforeSyntax(satisfiesExpression, p);
262
264
  await this.visit(satisfiesExpression.expression, p);
263
- await this.visitLeftPaddedLocal("satisfies", satisfiesExpression.satisfiesType, p);
265
+ await this.visitLeftPaddedKeyword("satisfies", satisfiesExpression.satisfiesType, p);
264
266
  await this.afterSyntax(satisfiesExpression, p);
265
267
  return satisfiesExpression;
266
268
  }
@@ -268,7 +270,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
268
270
  override async visitVoid(aVoid: JS.Void, p: PrintOutputCapture): Promise<J | undefined> {
269
271
  await this.beforeSyntax(aVoid, p);
270
272
  p.append("void");
271
- await this.visit(aVoid.expression, p);
273
+ await this.visitAfterKeyword(aVoid.expression, p);
272
274
  await this.afterSyntax(aVoid, p);
273
275
  return aVoid;
274
276
  }
@@ -282,10 +284,11 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
282
284
  if (delegated) {
283
285
  await this.visitSpace(delegated.prefix, p);
284
286
  p.append("*");
287
+ aYield.value && await this.visit(aYield.value, p);
288
+ } else {
289
+ await this.visitAfterKeyword(aYield.value, p);
285
290
  }
286
291
 
287
- aYield.value && await this.visit(aYield.value, p);
288
-
289
292
  await this.afterSyntax(aYield, p);
290
293
  return aYield;
291
294
  }
@@ -377,7 +380,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
377
380
  override async visitThrow(thrown: J.Throw, p: PrintOutputCapture): Promise<J | undefined> {
378
381
  await this.beforeSyntax(thrown, p);
379
382
  p.append("throw");
380
- await this.visit(thrown.exception, p);
383
+ await this.visitAfterKeyword(thrown.exception, p);
381
384
  await this.afterSyntax(thrown, p);
382
385
  return thrown;
383
386
  }
@@ -395,7 +398,9 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
395
398
  override async visitElse(else_: J.If.Else, p: PrintOutputCapture): Promise<J | undefined> {
396
399
  await this.beforeSyntax(else_, p);
397
400
  p.append("else");
401
+ const body = p.mark();
398
402
  await this.visitStatementLocal(else_.body, p);
403
+ this.separateFromKeyword(body, p);
399
404
  await this.afterSyntax(else_, p);
400
405
  return else_;
401
406
  }
@@ -403,7 +408,9 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
403
408
  override async visitDoWhileLoop(doWhileLoop: J.DoWhileLoop, p: PrintOutputCapture): Promise<J | undefined> {
404
409
  await this.beforeSyntax(doWhileLoop, p);
405
410
  p.append("do");
411
+ const body = p.mark();
406
412
  await this.visitStatementLocal(doWhileLoop.body, p);
413
+ this.separateFromKeyword(body, p);
407
414
  await this.visitLeftPaddedLocal("while", doWhileLoop.whileCondition, p);
408
415
  await this.afterSyntax(doWhileLoop, p);
409
416
  return doWhileLoop;
@@ -420,8 +427,9 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
420
427
 
421
428
  override async visitInstanceOf(instanceOf: J.InstanceOf, p: PrintOutputCapture): Promise<J | undefined> {
422
429
  await this.beforeSyntax(instanceOf, p);
423
- await this.visitRightPaddedLocalSingle(instanceOf.expression, "instanceof", p);
424
- await this.visit(instanceOf.class, p);
430
+ await this.visitRightPadded(instanceOf.expression, p);
431
+ this.appendKeyword("instanceof", p);
432
+ await this.visitAfterKeyword(instanceOf.class, p);
425
433
  instanceOf.pattern && await this.visit(instanceOf.pattern, p);
426
434
  await this.afterSyntax(instanceOf, p);
427
435
  return instanceOf;
@@ -573,7 +581,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
573
581
  override async visitReturn(return_: J.Return, p: PrintOutputCapture): Promise<J | undefined> {
574
582
  await this.beforeSyntax(return_, p);
575
583
  p.append("return");
576
- return_.expression && await this.visit(return_.expression, p);
584
+ await this.visitAfterKeyword(return_.expression, p);
577
585
  await this.afterSyntax(return_, p);
578
586
  return return_;
579
587
  }
@@ -879,7 +887,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
879
887
  override async visitConditionalType(conditionalType: JS.ConditionalType, p: PrintOutputCapture): Promise<J | undefined> {
880
888
  await this.beforeSyntax(conditionalType, p);
881
889
  await this.visit(conditionalType.checkType, p);
882
- await this.visitLeftPaddedLocal("extends", conditionalType.condition, p);
890
+ await this.visitLeftPaddedKeyword("extends", conditionalType.condition, p);
883
891
  await this.afterSyntax(conditionalType, p);
884
892
  return conditionalType;
885
893
  }
@@ -982,7 +990,11 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
982
990
  override async visitExportAssignment(es: JS.ExportAssignment, p: PrintOutputCapture): Promise<J | undefined> {
983
991
  await this.beforeSyntax(es, p);
984
992
  p.append("export");
985
- await this.visitLeftPaddedLocal(es.exportEquals ? "=" : "default", es.expression, p);
993
+ if (es.exportEquals) {
994
+ await this.visitLeftPaddedLocal("=", es.expression, p);
995
+ } else {
996
+ await this.visitLeftPaddedKeyword("default", es.expression, p);
997
+ }
986
998
  await this.afterSyntax(es, p);
987
999
  return es;
988
1000
  }
@@ -1190,7 +1202,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1190
1202
  override async visitTypeOf(typeOf: JS.TypeOf, p: PrintOutputCapture): Promise<J | undefined> {
1191
1203
  await this.beforeSyntax(typeOf, p);
1192
1204
  p.append("typeof");
1193
- await this.visit(typeOf.expression, p);
1205
+ await this.visitAfterKeyword(typeOf.expression, p);
1194
1206
  await this.afterSyntax(typeOf, p);
1195
1207
  return typeOf;
1196
1208
  }
@@ -1217,7 +1229,9 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1217
1229
 
1218
1230
  p.append(keyword);
1219
1231
 
1232
+ const operand = p.mark();
1220
1233
  await this.visitLeftPadded(typeOperator.expression, p);
1234
+ this.separateFromKeyword(operand, p);
1221
1235
 
1222
1236
  await this.afterSyntax(typeOperator, p);
1223
1237
  return typeOperator;
@@ -1277,7 +1291,7 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1277
1291
 
1278
1292
  if (newClass.class) {
1279
1293
  p.append("new");
1280
- await this.visit(newClass.class, p);
1294
+ await this.visitAfterKeyword(newClass.class, p);
1281
1295
 
1282
1296
  if (!newClass.arguments.markers.markers.find(m => m.kind === J.Markers.OmitParentheses)) {
1283
1297
  await this.visitContainerLocal("(", newClass.arguments, ",", ")", p);
@@ -1302,11 +1316,16 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1302
1316
  await this.beforeSyntax(case_, p);
1303
1317
 
1304
1318
  const elem = case_.caseLabels.elements[0].element;
1305
- if (elem.kind !== J.Kind.Identifier || (elem as J.Identifier).simpleName !== "default") {
1319
+ const keyword = elem.kind !== J.Kind.Identifier || (elem as J.Identifier).simpleName !== "default";
1320
+ if (keyword) {
1306
1321
  p.append("case");
1307
1322
  }
1308
1323
 
1324
+ const labels = p.mark();
1309
1325
  await this.visitContainerLocal("", case_.caseLabels, ",", "", p);
1326
+ if (keyword) {
1327
+ this.separateFromKeyword(labels, p);
1328
+ }
1310
1329
 
1311
1330
  await this.visitSpace(case_.statements.before, p);
1312
1331
  p.append(case_.type === J.Case.Type.Statement ? ":" : "->");
@@ -1378,8 +1397,8 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1378
1397
  override async visitAs(as_: JS.As, p: PrintOutputCapture): Promise<J | undefined> {
1379
1398
  await this.beforeSyntax(as_, p);
1380
1399
  await this.visitRightPadded(as_.left, p);
1381
- p.append("as");
1382
- await this.visit(as_.right, p);
1400
+ this.appendKeyword("as", p);
1401
+ await this.visitAfterKeyword(as_.right, p);
1383
1402
  await this.afterSyntax(as_, p);
1384
1403
 
1385
1404
  return as_;
@@ -1624,12 +1643,19 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1624
1643
  case JS.Binary.Type.Comma:
1625
1644
  keyword = ",";
1626
1645
  break;
1646
+ case JS.Binary.Type.Exponentiation:
1647
+ keyword = "**";
1648
+ break;
1627
1649
  }
1628
1650
 
1629
1651
  await this.visitSpace(binary.operator.before, p);
1630
- p.append(keyword);
1631
-
1632
- await this.visit(binary.right, p);
1652
+ if (binary.operator.element === JS.Binary.Type.In) {
1653
+ this.appendKeyword(keyword, p);
1654
+ await this.visitAfterKeyword(binary.right, p);
1655
+ } else {
1656
+ p.append(keyword);
1657
+ await this.visit(binary.right, p);
1658
+ }
1633
1659
 
1634
1660
  await this.afterSyntax(binary, p);
1635
1661
  return binary;
@@ -1725,8 +1751,10 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1725
1751
  await this.beforeSyntax(control, p);
1726
1752
  p.append('(');
1727
1753
  await this.visitRightPadded(control.variable, p);
1728
- p.append("of");
1754
+ this.appendKeyword("of", p);
1755
+ const iterable = p.mark();
1729
1756
  await this.visitRightPadded(control.iterable, p);
1757
+ this.separateFromKeyword(iterable, p);
1730
1758
  p.append(')');
1731
1759
  await this.afterSyntax(control, p);
1732
1760
  await this.visitRightPadded(loop.loop.body, p);
@@ -1743,8 +1771,10 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1743
1771
  await this.beforeSyntax(control, p);
1744
1772
  p.append('(');
1745
1773
  await this.visitRightPadded(control.variable, p);
1746
- p.append("in");
1774
+ this.appendKeyword("in", p);
1775
+ const iterable = p.mark();
1747
1776
  await this.visitRightPadded(control.iterable, p);
1777
+ this.separateFromKeyword(iterable, p);
1748
1778
  p.append(')');
1749
1779
  await this.afterSyntax(control, p);
1750
1780
  await this.visitRightPadded(loop.body, p);
@@ -1931,6 +1961,32 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
1931
1961
  }
1932
1962
  }
1933
1963
 
1964
+ private appendKeyword(keyword: string, p: PrintOutputCapture) {
1965
+ if (isWordChar(p.lastChar)) {
1966
+ p.append(" ");
1967
+ }
1968
+ p.append(keyword);
1969
+ }
1970
+
1971
+ private async visitAfterKeyword(tree: J | undefined, p: PrintOutputCapture) {
1972
+ const printed = p.mark();
1973
+ tree && await this.visit(tree, p);
1974
+ this.separateFromKeyword(printed, p);
1975
+ }
1976
+
1977
+ private separateFromKeyword(printed: PrintMark, p: PrintOutputCapture) {
1978
+ if (isWordChar(printed.firstChar)) {
1979
+ p.insert(printed.offset, " ");
1980
+ }
1981
+ }
1982
+
1983
+ private async visitLeftPaddedKeyword(keyword: string, leftPadded: J.LeftPadded<J>, p: PrintOutputCapture) {
1984
+ await this.beforeSyntaxExt(leftPadded.before, leftPadded.markers, p);
1985
+ this.appendKeyword(keyword, p);
1986
+ await this.visitAfterKeyword(leftPadded.element, p);
1987
+ await this.afterSyntaxMarkers(leftPadded.markers, p);
1988
+ }
1989
+
1934
1990
  private async visitLeftPaddedLocal(prefix: string | undefined, leftPadded: J.LeftPadded<J> | J.LeftPadded<boolean> | J.LeftPadded<string> | undefined, p: PrintOutputCapture) {
1935
1991
  if (leftPadded) {
1936
1992
  await this.beforeSyntaxExt(leftPadded.before, leftPadded.markers, p);
@@ -2038,3 +2094,9 @@ export class JavaScriptPrinter extends JavaScriptVisitor<PrintOutputCapture> {
2038
2094
  }
2039
2095
 
2040
2096
  TreePrinters.register(JS.Kind.CompilationUnit, () => new JavaScriptPrinter());
2097
+
2098
+ const WORD_CHAR = /^[\p{ID_Continue}$\u200C\u200D\\]$/u;
2099
+
2100
+ function isWordChar(char: string): boolean {
2101
+ return WORD_CHAR.test(char);
2102
+ }
@@ -386,6 +386,7 @@ class JavaScriptSender extends JavaScriptRpcVisitor<RpcSendQueue> {
386
386
 
387
387
  override visitImportClause(jsImportClause: JS.ImportClause, q: RpcSendQueue): J | undefined {
388
388
  q.getAndSend(jsImportClause, el => el.typeOnly);
389
+ q.getAndSend(jsImportClause, el => el.deferred);
389
390
  q.getAndSend(jsImportClause, el => el.name, el => this.visitRightPadded(el, q));
390
391
  q.getAndSend(jsImportClause, el => el.namedBindings, el => this.visit(el, q));
391
392
  return jsImportClause;
@@ -950,6 +951,7 @@ class JavaScriptReceiver extends JavaScriptRpcVisitor<RpcReceiveQueue> {
950
951
  override visitImportClause(jsImportClause: JS.ImportClause, q: RpcReceiveQueue): J | undefined {
951
952
  const updates = {
952
953
  typeOnly: q.receive(jsImportClause.typeOnly),
954
+ deferred: q.receive(jsImportClause.deferred),
953
955
  name: q.receive(jsImportClause.name, el => this.visitRightPadded(el, q)),
954
956
  namedBindings: q.receive(jsImportClause.namedBindings, el => this.visitDefined<Expression>(el, q))
955
957
  };
@@ -411,8 +411,11 @@ function writes(node: Tree, key: string): boolean {
411
411
  switch (node.kind) {
412
412
  case J.Kind.Assignment:
413
413
  case J.Kind.AssignmentOperation:
414
- case JS.Kind.AssignmentOperation:
415
414
  return key === 'variable';
415
+ case JS.Kind.AssignmentOperation:
416
+ // `a ** b` as parsed before it was a JS.Binary assigns nothing
417
+ return key === 'variable' &&
418
+ (node as JS.AssignmentOperation).operator.element !== JS.AssignmentOperation.Type.Power;
416
419
  case J.Kind.Unary:
417
420
  return key === 'expression' && incrementing.has((node as J.Unary).operator.element);
418
421
  case J.Kind.ForEachLoopControl:
@@ -128,6 +128,29 @@ export class PatternMatchingComparator extends JavaScriptSemanticComparatorVisit
128
128
  super(lenientTypeMatching);
129
129
  }
130
130
 
131
+ /**
132
+ * Lenient matching lets the code have a type annotation that the pattern leaves out, but not the
133
+ * other way round: `const ${x}: number = ${v}` must not match `const a = 1`. The check is here,
134
+ * not in the parent class, because the parent also compares the two places a repeated capture
135
+ * binds. Neither of those is the pattern, so there both sides are treated alike.
136
+ */
137
+ override async visitVariableDeclarations(pattern: J.VariableDeclarations, other: J): Promise<J | undefined> {
138
+ if (pattern.typeExpression && other.kind === J.Kind.VariableDeclarations &&
139
+ !(other as J.VariableDeclarations).typeExpression) {
140
+ return this.structuralMismatch<J>('typeExpression');
141
+ }
142
+ return super.visitVariableDeclarations(pattern, other);
143
+ }
144
+
145
+ /** The same for a return type: `function ${f}(): string {…}` must not match `function a() {…}`. */
146
+ override async visitMethodDeclaration(pattern: J.MethodDeclaration, other: J): Promise<J | undefined> {
147
+ if (pattern.returnTypeExpression && other.kind === J.Kind.MethodDeclaration &&
148
+ !(other as J.MethodDeclaration).returnTypeExpression) {
149
+ return this.typeMismatch('returnTypeExpression');
150
+ }
151
+ return super.visitMethodDeclaration(pattern, other);
152
+ }
153
+
131
154
  /**
132
155
  * Builds the constraint context with the cursor and current captures.
133
156
  * @param cursor The cursor to include in the context
@@ -581,6 +581,7 @@ export class DebugPatternMatchingComparator extends PatternMatchingComparator {
581
581
  if (value === undefined) return 'undefined';
582
582
  if (typeof value === 'string') return `"${value}"`;
583
583
  if (typeof value === 'number' || typeof value === 'boolean') return String(value);
584
+ if (typeof value === 'bigint') return `${value}n`;
584
585
 
585
586
  if (Type.isType(value)) {
586
587
  return Type.isFullyQualified(value) ?
@@ -95,9 +95,7 @@ export function precedenceOf(expression: J): number {
95
95
  case JS.Kind.SatisfiesExpression:
96
96
  return Precedence.Relational;
97
97
  case JS.Kind.AssignmentOperation:
98
- // `**` is the odd one out: every other JS.AssignmentOperation is a compound assignment
99
- return (expression as JS.AssignmentOperation).operator.element === JS.AssignmentOperation.Type.Power ?
100
- Precedence.Exponentiation : Precedence.Assignment;
98
+ return isLegacyPower(expression as JS.AssignmentOperation) ? Precedence.Exponentiation : Precedence.Assignment;
101
99
  case J.Kind.Ternary:
102
100
  case J.Kind.Assignment:
103
101
  case J.Kind.AssignmentOperation:
@@ -160,10 +158,12 @@ function slotConstraints(parent: J, childId: string): SlotConstraints | undefine
160
158
  if (precedence === undefined) {
161
159
  return undefined;
162
160
  }
161
+ // Right-associative, and `-a ** b` is a syntax error
162
+ const exponentiation = binary.operator.element === JS.Binary.Type.Exponentiation;
163
163
  if (binary.left?.id === childId) {
164
- return {precedence};
164
+ return {precedence: exponentiation ? Precedence.Postfix : precedence};
165
165
  }
166
- return binary.right?.id === childId ? {precedence: precedence + 1} : undefined;
166
+ return binary.right?.id === childId ? {precedence: exponentiation ? precedence : precedence + 1} : undefined;
167
167
  }
168
168
 
169
169
  case J.Kind.Unary: {
@@ -195,25 +195,15 @@ function slotConstraints(parent: J, childId: string): SlotConstraints | undefine
195
195
  return assignment.assignment?.element?.id === childId ? {precedence: Precedence.Assignment} : undefined;
196
196
  }
197
197
 
198
- case J.Kind.AssignmentOperation: {
199
- const assignment = parent as J.AssignmentOperation;
200
- if (assignment.variable?.id === childId) {
201
- return {precedence: Precedence.Call};
202
- }
203
- return assignment.assignment?.id === childId ? {precedence: Precedence.Assignment} : undefined;
204
- }
205
-
198
+ case J.Kind.AssignmentOperation:
206
199
  case JS.Kind.AssignmentOperation: {
207
- const assignment = parent as JS.AssignmentOperation;
208
- const power = assignment.operator.element === JS.AssignmentOperation.Type.Power;
200
+ const assignment = parent as J.AssignmentOperation;
201
+ const power = parent.kind === JS.Kind.AssignmentOperation && isLegacyPower(parent as JS.AssignmentOperation);
209
202
  if (assignment.variable?.id === childId) {
210
- // `-a ** b` is a syntax error, and `**` is right-associative besides
211
203
  return {precedence: power ? Precedence.Postfix : Precedence.Call};
212
204
  }
213
- if (assignment.assignment?.id === childId) {
214
- return {precedence: power ? Precedence.Exponentiation : Precedence.Assignment};
215
- }
216
- return undefined;
205
+ return assignment.assignment?.id === childId ?
206
+ {precedence: power ? Precedence.Exponentiation : Precedence.Assignment} : undefined;
217
207
  }
218
208
 
219
209
  case J.Kind.FieldAccess: {
@@ -468,11 +458,18 @@ function jsBinaryPrecedence(operator: JS.Binary.Type): number | undefined {
468
458
  return Precedence.LogicalOr;
469
459
  case JS.Binary.Type.Comma:
470
460
  return Precedence.Comma;
461
+ case JS.Binary.Type.Exponentiation:
462
+ return Precedence.Exponentiation;
471
463
  default:
472
464
  return undefined;
473
465
  }
474
466
  }
475
467
 
468
+ /** `a ** b` as parsed before it was a {@link JS.Binary}, which trees from an older parser still hold. */
469
+ function isLegacyPower(assignment: JS.AssignmentOperation): boolean {
470
+ return assignment.operator.element === JS.AssignmentOperation.Type.Power;
471
+ }
472
+
476
473
  function isUpdateOperator(operator: J.Unary.Type): boolean {
477
474
  return operator === J.Unary.Type.PreIncrement || operator === J.Unary.Type.PreDecrement ||
478
475
  isPostfixOperator(operator);
@@ -356,10 +356,10 @@ export interface PatternOptions {
356
356
  types?: string[];
357
357
 
358
358
  /**
359
- * When true, allows patterns without type annotations to match code with type annotations.
360
- * This enables more flexible pattern matching during development or when full type attribution
361
- * is not needed. When false, enforces strict type matching where both pattern and target must
362
- * have matching type annotations.
359
+ * When true, a pattern without a type annotation matches code with or without one, so
360
+ * `const ${x} = ${v}` matches `const a: number = 1`, while an annotation the pattern spells out
361
+ * must be matched by the code's. Type attribution missing on either side is not a mismatch.
362
+ * When false, the pattern and the code must both have each annotation, or both lack it.
363
363
  *
364
364
  * @default true (lenient matching enabled for backward compatibility)
365
365
  */
@@ -423,6 +423,10 @@ function escapeString(str: string): string {
423
423
  /**
424
424
  * Format a literal value for inline display.
425
425
  */
426
+ function formatScalar(value: unknown): string {
427
+ return typeof value === 'bigint' ? `${value}n` : JSON.stringify(value);
428
+ }
429
+
426
430
  function formatLiteralValue(lit: J.Literal): string {
427
431
  let value: string;
428
432
  if (lit.valueSource !== undefined) {
@@ -749,7 +753,7 @@ export class LstDebugPrinter {
749
753
 
750
754
  // Primitive or unknown type
751
755
  if (typeof node !== 'object') {
752
- this.outputLines.push(`${this.indent(depth)}${JSON.stringify(node)}`);
756
+ this.outputLines.push(`${this.indent(depth)}${formatScalar(node)}`);
753
757
  return;
754
758
  }
755
759
 
@@ -851,7 +855,7 @@ export class LstDebugPrinter {
851
855
  // Skip complex objects that aren't J nodes
852
856
  this.outputLines.push(`${this.indent(depth)}${key}: <object>`);
853
857
  } else {
854
- this.outputLines.push(`${this.indent(depth)}${key}: ${JSON.stringify(value)}`);
858
+ this.outputLines.push(`${this.indent(depth)}${key}: ${formatScalar(value)}`);
855
859
  }
856
860
  }
857
861
  }
@@ -934,7 +938,7 @@ export class LstDebugPrinter {
934
938
  if (typeof value === 'object' && value !== null) {
935
939
  this.outputLines.push(`${this.indent(depth + 1)}${key}: <object>`);
936
940
  } else {
937
- this.outputLines.push(`${this.indent(depth + 1)}${key}: ${JSON.stringify(value)}`);
941
+ this.outputLines.push(`${this.indent(depth + 1)}${key}: ${formatScalar(value)}`);
938
942
  }
939
943
  }
940
944
  this.outputLines.push(`${this.indent(depth)}}`);
@@ -264,6 +264,7 @@ export namespace JS {
264
264
  export interface ImportClause extends JS {
265
265
  readonly kind: typeof Kind.ImportClause;
266
266
  readonly typeOnly: boolean;
267
+ readonly deferred: boolean;
267
268
  readonly name?: J.RightPadded<J.Identifier>;
268
269
  readonly namedBindings?: Expression;
269
270
  }
@@ -346,7 +347,8 @@ export namespace JS {
346
347
  IdentityNotEquals = "IdentityNotEquals",
347
348
  In = "In",
348
349
  QuestionQuestion = "QuestionQuestion",
349
- Comma = "Comma"
350
+ Comma = "Comma",
351
+ Exponentiation = "Exponentiation"
350
352
  }
351
353
  }
352
354
 
@@ -580,6 +582,7 @@ export namespace JS {
580
582
  QuestionQuestion = "QuestionQuestion",
581
583
  And = "And",
582
584
  Or = "Or",
585
+ /** @deprecated `a ** b` is a {@link JS.Binary} of type {@link JS.Binary.Type.Exponentiation}. */
583
586
  Power = "Power",
584
587
  Exp = "Exp"
585
588
  }
@@ -116,6 +116,11 @@ export class JavaScriptTypeMapping {
116
116
  // Fall through to regular type checking if not a variable
117
117
  }
118
118
 
119
+ // The checker asserts when asked for the type of the `import.defer` in `import.defer(...)`
120
+ if (this.isImportDefer(node)) {
121
+ return undefined;
122
+ }
123
+
119
124
  // TypeNode needs getTypeFromTypeNode (resolves the annotation itself).
120
125
  // Everything else — expressions, declarations, specifiers, bindings, etc. —
121
126
  // uses getTypeAtLocation which works for virtually all node kinds.
@@ -707,13 +712,18 @@ export class JavaScriptTypeMapping {
707
712
  node = this.unparenthesized(node);
708
713
  if (ts.isAwaitExpression(node)) {
709
714
  const call = this.unparenthesized(node.expression);
710
- return ts.isCallExpression(call) && call.expression.kind === ts.SyntaxKind.ImportKeyword ?
715
+ return ts.isCallExpression(call) &&
716
+ (call.expression.kind === ts.SyntaxKind.ImportKeyword || this.isImportDefer(call.expression)) ?
711
717
  this.moduleSpecifierArgument(call) : undefined;
712
718
  }
713
719
  return ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'require' ?
714
720
  this.moduleSpecifierArgument(node) : undefined;
715
721
  }
716
722
 
723
+ private isImportDefer(node: ts.Node): boolean {
724
+ return ts.isMetaProperty(node) && node.keywordToken === ts.SyntaxKind.ImportKeyword && node.name.text === 'defer';
725
+ }
726
+
717
727
  private unparenthesized(node: ts.Expression): ts.Expression {
718
728
  while (ts.isParenthesizedExpression(node)) {
719
729
  node = node.expression;
@@ -1048,6 +1058,10 @@ export class JavaScriptTypeMapping {
1048
1058
  let declaringType: Type.FullyQualified;
1049
1059
  let declaredFormalTypeNames: string[] = [];
1050
1060
 
1061
+ if (ts.isCallExpression(node) && this.isImportDefer(node.expression)) {
1062
+ return undefined;
1063
+ }
1064
+
1051
1065
  // Handle different kinds of nodes that represent methods or method invocations
1052
1066
  if (ts.isCallOrNewExpression(node)) {
1053
1067
  // For method invocations (e.g., _.map(...))