@openrewrite/rewrite 8.97.0 → 8.97.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 (152) hide show
  1. package/README.md +42 -0
  2. package/dist/java/visitor.d.ts +2 -0
  3. package/dist/java/visitor.d.ts.map +1 -1
  4. package/dist/java/visitor.js +7 -3
  5. package/dist/java/visitor.js.map +1 -1
  6. package/dist/javascript/add-import.d.ts +1 -6
  7. package/dist/javascript/add-import.d.ts.map +1 -1
  8. package/dist/javascript/add-import.js +90 -58
  9. package/dist/javascript/add-import.js.map +1 -1
  10. package/dist/javascript/comparator.d.ts +16 -10
  11. package/dist/javascript/comparator.d.ts.map +1 -1
  12. package/dist/javascript/comparator.js +10 -8
  13. package/dist/javascript/comparator.js.map +1 -1
  14. package/dist/javascript/package-json-parser.d.ts +2 -0
  15. package/dist/javascript/package-json-parser.d.ts.map +1 -1
  16. package/dist/javascript/package-json-parser.js +27 -15
  17. package/dist/javascript/package-json-parser.js.map +1 -1
  18. package/dist/javascript/package-manager.d.ts +13 -4
  19. package/dist/javascript/package-manager.d.ts.map +1 -1
  20. package/dist/javascript/package-manager.js +134 -17
  21. package/dist/javascript/package-manager.js.map +1 -1
  22. package/dist/javascript/parser.d.ts +2 -0
  23. package/dist/javascript/parser.d.ts.map +1 -1
  24. package/dist/javascript/parser.js +23 -58
  25. package/dist/javascript/parser.js.map +1 -1
  26. package/dist/javascript/print.d.ts.map +1 -1
  27. package/dist/javascript/print.js +1 -1
  28. package/dist/javascript/print.js.map +1 -1
  29. package/dist/javascript/recipes/change-method-target-to-import.d.ts +4 -0
  30. package/dist/javascript/recipes/change-method-target-to-import.d.ts.map +1 -1
  31. package/dist/javascript/recipes/change-method-target-to-import.js +20 -2
  32. package/dist/javascript/recipes/change-method-target-to-import.js.map +1 -1
  33. package/dist/javascript/recipes/dependencies.d.ts +19 -0
  34. package/dist/javascript/recipes/dependencies.d.ts.map +1 -1
  35. package/dist/javascript/recipes/dependencies.js +8 -0
  36. package/dist/javascript/recipes/dependencies.js.map +1 -1
  37. package/dist/javascript/recipes/order-imports.js +3 -3
  38. package/dist/javascript/recipes/order-imports.js.map +1 -1
  39. package/dist/javascript/remove-import.d.ts.map +1 -1
  40. package/dist/javascript/remove-import.js +115 -33
  41. package/dist/javascript/remove-import.js.map +1 -1
  42. package/dist/javascript/scope.d.ts +7 -0
  43. package/dist/javascript/scope.d.ts.map +1 -1
  44. package/dist/javascript/scope.js +23 -0
  45. package/dist/javascript/scope.js.map +1 -1
  46. package/dist/javascript/templating/bindings.d.ts.map +1 -1
  47. package/dist/javascript/templating/bindings.js +0 -4
  48. package/dist/javascript/templating/bindings.js.map +1 -1
  49. package/dist/javascript/templating/comparator.d.ts +32 -79
  50. package/dist/javascript/templating/comparator.d.ts.map +1 -1
  51. package/dist/javascript/templating/comparator.js +35 -628
  52. package/dist/javascript/templating/comparator.js.map +1 -1
  53. package/dist/javascript/templating/debug.d.ts +143 -0
  54. package/dist/javascript/templating/debug.d.ts.map +1 -0
  55. package/dist/javascript/templating/debug.js +769 -0
  56. package/dist/javascript/templating/debug.js.map +1 -0
  57. package/dist/javascript/templating/engine.d.ts +12 -3
  58. package/dist/javascript/templating/engine.d.ts.map +1 -1
  59. package/dist/javascript/templating/engine.js +135 -76
  60. package/dist/javascript/templating/engine.js.map +1 -1
  61. package/dist/javascript/templating/index.d.ts +1 -1
  62. package/dist/javascript/templating/index.d.ts.map +1 -1
  63. package/dist/javascript/templating/index.js.map +1 -1
  64. package/dist/javascript/templating/pattern.d.ts +44 -35
  65. package/dist/javascript/templating/pattern.d.ts.map +1 -1
  66. package/dist/javascript/templating/pattern.js +224 -238
  67. package/dist/javascript/templating/pattern.js.map +1 -1
  68. package/dist/javascript/templating/rewrite.d.ts +4 -0
  69. package/dist/javascript/templating/rewrite.d.ts.map +1 -1
  70. package/dist/javascript/templating/rewrite.js +5 -1
  71. package/dist/javascript/templating/rewrite.js.map +1 -1
  72. package/dist/javascript/templating/template.js +1 -1
  73. package/dist/javascript/templating/template.js.map +1 -1
  74. package/dist/javascript/templating/types.d.ts +38 -35
  75. package/dist/javascript/templating/types.d.ts.map +1 -1
  76. package/dist/javascript/templating/utils.d.ts.map +1 -1
  77. package/dist/javascript/templating/utils.js +18 -9
  78. package/dist/javascript/templating/utils.js.map +1 -1
  79. package/dist/javascript/tree.d.ts +3 -1
  80. package/dist/javascript/tree.d.ts.map +1 -1
  81. package/dist/javascript/tree.js +5 -0
  82. package/dist/javascript/tree.js.map +1 -1
  83. package/dist/json/tree.d.ts +1 -2
  84. package/dist/json/tree.d.ts.map +1 -1
  85. package/dist/json/tree.js +10 -7
  86. package/dist/json/tree.js.map +1 -1
  87. package/dist/rewrite-javascript-version.txt +1 -1
  88. package/dist/rpc/request/get-object.d.ts.map +1 -1
  89. package/dist/rpc/request/get-object.js +5 -3
  90. package/dist/rpc/request/get-object.js.map +1 -1
  91. package/dist/rpc/request/install-recipes.d.ts +10 -0
  92. package/dist/rpc/request/install-recipes.d.ts.map +1 -1
  93. package/dist/rpc/request/install-recipes.js +125 -51
  94. package/dist/rpc/request/install-recipes.js.map +1 -1
  95. package/dist/rpc/request/prepare-recipe.d.ts +1 -0
  96. package/dist/rpc/request/prepare-recipe.d.ts.map +1 -1
  97. package/dist/rpc/request/prepare-recipe.js +13 -6
  98. package/dist/rpc/request/prepare-recipe.js.map +1 -1
  99. package/dist/rpc/rewrite-rpc.d.ts +1 -1
  100. package/dist/rpc/rewrite-rpc.d.ts.map +1 -1
  101. package/dist/rpc/rewrite-rpc.js +2 -3
  102. package/dist/rpc/rewrite-rpc.js.map +1 -1
  103. package/dist/rpc/worker-transport.d.ts +7 -3
  104. package/dist/rpc/worker-transport.d.ts.map +1 -1
  105. package/dist/rpc/worker-transport.js +54 -41
  106. package/dist/rpc/worker-transport.js.map +1 -1
  107. package/dist/test/rewrite-test.d.ts +1 -16
  108. package/dist/test/rewrite-test.d.ts.map +1 -1
  109. package/dist/test/rewrite-test.js +7 -58
  110. package/dist/test/rewrite-test.js.map +1 -1
  111. package/dist/util.d.ts +16 -0
  112. package/dist/util.d.ts.map +1 -1
  113. package/dist/util.js +53 -0
  114. package/dist/util.js.map +1 -1
  115. package/dist/yaml/parser.js +8 -5
  116. package/dist/yaml/parser.js.map +1 -1
  117. package/dist/yaml/print.js +9 -3
  118. package/dist/yaml/print.js.map +1 -1
  119. package/package.json +1 -1
  120. package/src/java/visitor.ts +8 -3
  121. package/src/javascript/add-import.ts +98 -64
  122. package/src/javascript/comparator.ts +66 -53
  123. package/src/javascript/package-json-parser.ts +25 -16
  124. package/src/javascript/package-manager.ts +121 -15
  125. package/src/javascript/parser.ts +29 -81
  126. package/src/javascript/print.ts +1 -2
  127. package/src/javascript/recipes/change-method-target-to-import.ts +23 -3
  128. package/src/javascript/recipes/dependencies.ts +23 -0
  129. package/src/javascript/recipes/order-imports.ts +5 -5
  130. package/src/javascript/remove-import.ts +113 -41
  131. package/src/javascript/scope.ts +23 -0
  132. package/src/javascript/templating/bindings.ts +1 -6
  133. package/src/javascript/templating/comparator.ts +76 -766
  134. package/src/javascript/templating/debug.ts +806 -0
  135. package/src/javascript/templating/engine.ts +138 -77
  136. package/src/javascript/templating/index.ts +1 -0
  137. package/src/javascript/templating/pattern.ts +267 -270
  138. package/src/javascript/templating/rewrite.ts +5 -1
  139. package/src/javascript/templating/template.ts +1 -1
  140. package/src/javascript/templating/types.ts +40 -37
  141. package/src/javascript/templating/utils.ts +4 -12
  142. package/src/javascript/tree.ts +6 -1
  143. package/src/json/tree.ts +9 -7
  144. package/src/rpc/request/get-object.ts +34 -28
  145. package/src/rpc/request/install-recipes.ts +128 -52
  146. package/src/rpc/request/prepare-recipe.ts +18 -15
  147. package/src/rpc/rewrite-rpc.ts +2 -4
  148. package/src/rpc/worker-transport.ts +63 -43
  149. package/src/test/rewrite-test.ts +2 -59
  150. package/src/util.ts +58 -0
  151. package/src/yaml/parser.ts +9 -5
  152. package/src/yaml/print.ts +9 -3
@@ -253,6 +253,25 @@ function readModuleSyntax(cu) {
253
253
  });
254
254
  return esm ? "esm" : commonJs ? "commonjs" : "none";
255
255
  }
256
+ /**
257
+ * `cu` without an empty `export {};`, which only marks a file without imports as a module, as
258
+ * `RemoveImport` leaves one. An import makes it redundant. One carrying a comment is kept.
259
+ */
260
+ function withoutModuleMarker(cu) {
261
+ const statements = cu.statements.filter(({ element }) => !isModuleMarker(element));
262
+ return statements.length === cu.statements.length ? cu : Object.assign(Object.assign({}, cu), { statements });
263
+ }
264
+ function isModuleMarker(element) {
265
+ var _a;
266
+ if ((element === null || element === void 0 ? void 0 : element.kind) !== tree_1.JS.Kind.ExportDeclaration) {
267
+ return false;
268
+ }
269
+ const declaration = element;
270
+ return declaration.prefix.comments.length === 0 && declaration.modifiers.length === 0 &&
271
+ !declaration.typeOnly.element && declaration.moduleSpecifier === undefined &&
272
+ ((_a = declaration.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === tree_1.JS.Kind.NamedExports &&
273
+ declaration.exportClause.elements.elements.every(e => e.element.kind === java_1.J.Kind.Empty);
274
+ }
256
275
  /** An import or any export form. */
257
276
  function isEsmStatement(element) {
258
277
  var _a;
@@ -398,7 +417,7 @@ function isEmptyPlaceholder(element) {
398
417
  }
399
418
  /** The member a specifier imports and the name it binds it under, which are the same absent an alias. */
400
419
  function specifierBinding(specifier) {
401
- var _a, _b, _c, _d, _e;
420
+ var _a, _b, _c, _d;
402
421
  if (((_a = specifier.specifier) === null || _a === void 0 ? void 0 : _a.kind) === java_1.J.Kind.Identifier) {
403
422
  const name = specifier.specifier.simpleName;
404
423
  return { name, member: name };
@@ -407,8 +426,8 @@ function specifierBinding(specifier) {
407
426
  return undefined;
408
427
  }
409
428
  const alias = specifier.specifier;
410
- return ((_d = (_c = alias.propertyName) === null || _c === void 0 ? void 0 : _c.element) === null || _d === void 0 ? void 0 : _d.kind) === java_1.J.Kind.Identifier && ((_e = alias.alias) === null || _e === void 0 ? void 0 : _e.kind) === java_1.J.Kind.Identifier
411
- ? { name: alias.alias.simpleName, member: alias.propertyName.element.simpleName }
429
+ return ((_c = alias.propertyName) === null || _c === void 0 ? void 0 : _c.element) && ((_d = alias.alias) === null || _d === void 0 ? void 0 : _d.kind) === java_1.J.Kind.Identifier
430
+ ? { name: alias.alias.simpleName, member: (0, tree_1.moduleExportName)(alias.propertyName.element) }
412
431
  : undefined;
413
432
  }
414
433
  function importBindings(jsImport) {
@@ -777,19 +796,16 @@ class AddImport extends visitor_1.JavaScriptVisitor {
777
796
  const semicolonMarkers = detectSemi(compilationUnit)
778
797
  ? (0, markers_1.markers)({ kind: java_1.J.Markers.Semicolon, id: (0, uuid_1.randomId)() })
779
798
  : markers_1.emptyMarkers;
780
- if (insertionIndex === 0) {
781
- // Insert at the beginning
799
+ if (insertionIndex === prologueLength(compilationUnit)) {
782
800
  // The `after` space should be empty since any semicolon is printed after it
783
- // The spacing comes from updating the next statement's prefix
784
- const updatedStatements = compilationUnit.statements.length > 0
785
- ? [
786
- (0, java_1.rightPadded)(newImport, java_1.emptySpace, semicolonMarkers),
787
- Object.assign(Object.assign({}, compilationUnit.statements[0]), { element: compilationUnit.statements[0].element
788
- ? Object.assign(Object.assign({}, compilationUnit.statements[0].element), { prefix: (0, java_1.space)("\n\n") }) : undefined }),
789
- ...compilationUnit.statements.slice(1)
790
- ]
791
- : [(0, java_1.rightPadded)(newImport, java_1.emptySpace, semicolonMarkers)];
792
- draft.statements = updatedStatements;
801
+ const next = compilationUnit.statements[insertionIndex];
802
+ draft.statements = [
803
+ ...compilationUnit.statements.slice(0, insertionIndex),
804
+ (0, java_1.rightPadded)(newImport, java_1.emptySpace, semicolonMarkers),
805
+ ...(next ? [Object.assign(Object.assign({}, next), { element: next.element
806
+ ? Object.assign(Object.assign({}, next.element), { prefix: splitAtBodyStart(next.element.prefix).behind }) : undefined })] : []),
807
+ ...compilationUnit.statements.slice(insertionIndex + 1)
808
+ ];
793
809
  }
794
810
  else {
795
811
  // Insert after existing imports
@@ -817,7 +833,7 @@ class AddImport extends visitor_1.JavaScriptVisitor {
817
833
  }
818
834
  }
819
835
  });
820
- return formatImport(withImport, newImport.id, p, detectBraceSpacing(compilationUnit));
836
+ return formatImport(withoutModuleMarker(withImport), newImport.id, p, detectBraceSpacing(compilationUnit));
821
837
  }
822
838
  /**
823
839
  * Try to merge the new member into an existing import from the same module
@@ -1498,19 +1514,9 @@ class AddImport extends visitor_1.JavaScriptVisitor {
1498
1514
  */
1499
1515
  determineImportPrefix(compilationUnit, insertionIndex) {
1500
1516
  var _a;
1501
- // If inserting at the beginning (index 0), use the prefix of the first statement
1502
- // but only the whitespace part (preserve comments on the original first statement)
1503
- if (insertionIndex === 0 && compilationUnit.statements.length > 0) {
1504
- const firstPrefix = (_a = compilationUnit.statements[0].element) === null || _a === void 0 ? void 0 : _a.prefix;
1505
- if (firstPrefix) {
1506
- // Keep only whitespace, not comments
1507
- return {
1508
- kind: java_1.J.Kind.Space,
1509
- comments: [],
1510
- whitespace: firstPrefix.whitespace
1511
- };
1512
- }
1513
- return java_1.emptySpace;
1517
+ if (insertionIndex === prologueLength(compilationUnit) && insertionIndex < compilationUnit.statements.length) {
1518
+ const nextPrefix = (_a = compilationUnit.statements[insertionIndex].element) === null || _a === void 0 ? void 0 : _a.prefix;
1519
+ return nextPrefix ? splitAtBodyStart(nextPrefix).ahead : java_1.emptySpace;
1514
1520
  }
1515
1521
  // If inserting after other statements, ensure we have at least one newline
1516
1522
  // to separate from the previous statement
@@ -1535,8 +1541,7 @@ class AddImport extends visitor_1.JavaScriptVisitor {
1535
1541
  if (lastImportIndex >= 0) {
1536
1542
  return lastImportIndex + 1;
1537
1543
  }
1538
- // No imports found, insert at the beginning
1539
- return 0;
1544
+ return prologueLength(compilationUnit);
1540
1545
  }
1541
1546
  }
1542
1547
  exports.AddImport = AddImport;
@@ -1576,13 +1581,47 @@ function newIdentifier(name) {
1576
1581
  fieldType: undefined
1577
1582
  };
1578
1583
  }
1579
- function isUseStrict(statement) {
1584
+ function isDirective(statement) {
1580
1585
  const expression = (statement === null || statement === void 0 ? void 0 : statement.kind) === tree_1.JS.Kind.ExpressionStatement ? statement.expression : statement;
1581
- return (expression === null || expression === void 0 ? void 0 : expression.kind) === java_1.J.Kind.Literal && expression.value === 'use strict';
1586
+ return quoteOf(expression) !== undefined;
1587
+ }
1588
+ function prologueLength(cu) {
1589
+ var _a;
1590
+ const statements = cu.statements;
1591
+ let length = 0;
1592
+ while (length < statements.length &&
1593
+ (((_a = statements[length].element) === null || _a === void 0 ? void 0 : _a.kind) === tree_1.JS.Kind.Shebang || isDirective(statements[length].element))) {
1594
+ length++;
1595
+ }
1596
+ return length;
1597
+ }
1598
+ // Keep comments through the last triple-slash directive ahead of the import.
1599
+ function splitAtBodyStart(prefix) {
1600
+ let ahead = prefix.comments.length;
1601
+ while (ahead > 0 && !isTripleSlashDirective(prefix.comments[ahead - 1])) {
1602
+ ahead--;
1603
+ }
1604
+ return {
1605
+ ahead: { kind: java_1.J.Kind.Space, whitespace: prefix.whitespace, comments: prefix.comments.slice(0, ahead) },
1606
+ behind: Object.assign(Object.assign({}, prefix), { whitespace: "\n\n", comments: prefix.comments.slice(ahead) })
1607
+ };
1608
+ }
1609
+ const TRIPLE_SLASH_DIRECTIVES = ['<reference', '<amd-module', '<amd-dependency'];
1610
+ function isTripleSlashDirective(comment) {
1611
+ if (comment.kind !== java_1.J.Kind.TextComment || comment.multiline) {
1612
+ return false;
1613
+ }
1614
+ // TextComment.text excludes the leading //.
1615
+ const text = comment.text;
1616
+ if (!text.startsWith('/')) {
1617
+ return false;
1618
+ }
1619
+ const rest = text.slice(1).trimStart();
1620
+ return TRIPLE_SLASH_DIRECTIVES.some(directive => rest.startsWith(directive));
1582
1621
  }
1583
1622
  /**
1584
1623
  * `cu` with `statement` after its last top-level `require`. A file with none takes it first,
1585
- * after a `'use strict'` directive, which has to open the file to apply.
1624
+ * after a shebang and any directives, which have to open the file to apply.
1586
1625
  */
1587
1626
  function withRequireStatement(cu, statement) {
1588
1627
  var _a;
@@ -1600,11 +1639,11 @@ function withRequireStatement(cu, statement) {
1600
1639
  if (next === undefined) {
1601
1640
  return Object.assign(Object.assign({}, cu), { statements: [...statements, Object.assign(Object.assign({}, padded), { element: Object.assign(Object.assign({}, statement), { prefix: (0, java_1.space)(at === 0 ? "" : "\n\n") }) })] });
1602
1641
  }
1603
- // The new statement takes the place of the one it goes before, which gets a blank line of its own.
1642
+ const { ahead, behind } = splitAtBodyStart(next.prefix);
1604
1643
  return Object.assign(Object.assign({}, cu), { statements: [
1605
1644
  ...statements.slice(0, at),
1606
- Object.assign(Object.assign({}, padded), { element: Object.assign(Object.assign({}, statement), { prefix: (0, java_1.space)(next.prefix.whitespace) }) }),
1607
- Object.assign(Object.assign({}, statements[at]), { element: Object.assign(Object.assign({}, next), { prefix: Object.assign(Object.assign({}, next.prefix), { whitespace: "\n\n" }) }) }),
1645
+ Object.assign(Object.assign({}, padded), { element: Object.assign(Object.assign({}, statement), { prefix: ahead }) }),
1646
+ Object.assign(Object.assign({}, statements[at]), { element: Object.assign(Object.assign({}, next), { prefix: behind }) }),
1608
1647
  ...statements.slice(at + 1)
1609
1648
  ] });
1610
1649
  }
@@ -1638,17 +1677,12 @@ function requireBinds(declaration, module, member) {
1638
1677
  return (_a = requireBindings(pattern, required).find(b => b.member === key)) === null || _a === void 0 ? void 0 : _a.name;
1639
1678
  }
1640
1679
  /**
1641
- * Where the file's leading requires start, after a shebang and `'use strict'`, and end. Every
1680
+ * Where the file's leading requires start, after a shebang and any directives, and end. Every
1642
1681
  * top-level statement after them runs once they are initialised, so a binding placed there is read after it.
1643
1682
  */
1644
1683
  function leadingRequires(cu) {
1645
- var _a;
1646
1684
  const statements = cu.statements;
1647
- let start = 0;
1648
- while (start < statements.length &&
1649
- (((_a = statements[start].element) === null || _a === void 0 ? void 0 : _a.kind) === tree_1.JS.Kind.Shebang || isUseStrict(statements[start].element))) {
1650
- start++;
1651
- }
1685
+ const start = prologueLength(cu);
1652
1686
  let end = start;
1653
1687
  while (end < statements.length && isRequireStatement(statements[end].element)) {
1654
1688
  end++;
@@ -1732,8 +1766,7 @@ function namedSpecifierImports(specifier, key) {
1732
1766
  return specifier.simpleName === key;
1733
1767
  }
1734
1768
  if (specifier.kind === tree_1.JS.Kind.Alias) {
1735
- const propertyName = specifier.propertyName.element;
1736
- return (0, java_1.isIdentifier)(propertyName) && propertyName.simpleName === key;
1769
+ return (0, tree_1.moduleExportName)(specifier.propertyName.element) === key;
1737
1770
  }
1738
1771
  return false;
1739
1772
  }
@@ -2106,13 +2139,6 @@ class RebindImport extends visitor_1.JavaScriptVisitor {
2106
2139
  async visitType(javaType, p) {
2107
2140
  return this.movedTypes.visit(javaType, undefined);
2108
2141
  }
2109
- /**
2110
- * A decorator and the other type-name positions reach the tree through this hook, which the
2111
- * base visitor holds closed; a reference in one of them is a reference like any other.
2112
- */
2113
- async visitTypeName(nameTree, p) {
2114
- return await this.visit(nameTree, p);
2115
- }
2116
2142
  /**
2117
2143
  * An export specifier's own name is the module's public surface, which its consumers read and
2118
2144
  * the rename leaves alone. See CLAUDE.md: Which name a rebind binds.
@@ -2190,12 +2216,12 @@ class RebindImport extends visitor_1.JavaScriptVisitor {
2190
2216
  }
2191
2217
  }
2192
2218
  exports.RebindImport = RebindImport;
2193
- /** Points `literal` at `module`, keeping its quotes. */
2194
- function respecify(literal, module) {
2219
+ /** Points `literal` at `name`, keeping its quotes. */
2220
+ function respecify(literal, name) {
2195
2221
  var _a;
2196
2222
  const quoteChar = ((_a = literal.valueSource) !== null && _a !== void 0 ? _a : '"').startsWith("'") ? "'" : '"';
2197
- literal.value = module;
2198
- literal.valueSource = `${quoteChar}${module}${quoteChar}`;
2223
+ literal.value = name;
2224
+ literal.valueSource = `${quoteChar}${name.replace(/\\/g, '\\\\').split(quoteChar).join(`\\${quoteChar}`)}${quoteChar}`;
2199
2225
  literal.unicodeEscapes = undefined;
2200
2226
  }
2201
2227
  function withPattern(declaration, pattern) {
@@ -2457,7 +2483,13 @@ function rewriteNamedSpecifier(importClause, key, member, boundName) {
2457
2483
  specifier.specifier = Object.assign(Object.assign({}, local), { prefix: (alias !== null && alias !== void 0 ? alias : local).prefix, simpleName: member });
2458
2484
  }
2459
2485
  else if (alias) {
2460
- alias.propertyName.element.simpleName = member;
2486
+ const propertyName = alias.propertyName.element;
2487
+ if (propertyName.kind === java_1.J.Kind.Literal) {
2488
+ respecify(propertyName, member);
2489
+ }
2490
+ else {
2491
+ propertyName.simpleName = member;
2492
+ }
2461
2493
  local.simpleName = boundName;
2462
2494
  }
2463
2495
  else {