@openrewrite/rewrite 8.92.15 → 8.92.17
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.
- package/dist/javascript/add-import.d.ts.map +1 -1
- package/dist/javascript/add-import.js +3 -2
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/amd.d.ts.map +1 -1
- package/dist/javascript/amd.js +3 -2
- package/dist/javascript/amd.js.map +1 -1
- package/dist/javascript/binding.js +3 -3
- package/dist/javascript/binding.js.map +1 -1
- package/dist/javascript/comparator.d.ts.map +1 -1
- package/dist/javascript/comparator.js +4 -0
- package/dist/javascript/comparator.js.map +1 -1
- package/dist/javascript/format/tabs-and-indents-visitor.d.ts.map +1 -1
- package/dist/javascript/format/tabs-and-indents-visitor.js +31 -4
- package/dist/javascript/format/tabs-and-indents-visitor.js.map +1 -1
- package/dist/javascript/index.d.ts +3 -0
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +3 -0
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/markers.d.ts +12 -0
- package/dist/javascript/markers.d.ts.map +1 -1
- package/dist/javascript/markers.js +17 -2
- package/dist/javascript/markers.js.map +1 -1
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.d.ts.map +1 -1
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js +28 -32
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js.map +1 -1
- package/dist/javascript/node-resolution-result.js +3 -2
- package/dist/javascript/node-resolution-result.js.map +1 -1
- package/dist/javascript/parser.d.ts +9 -0
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +185 -88
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/preconditions.d.ts +11 -0
- package/dist/javascript/preconditions.d.ts.map +1 -1
- package/dist/javascript/preconditions.js +14 -0
- package/dist/javascript/preconditions.js.map +1 -1
- package/dist/javascript/print.d.ts +10 -1
- package/dist/javascript/print.d.ts.map +1 -1
- package/dist/javascript/print.js +120 -77
- package/dist/javascript/print.js.map +1 -1
- package/dist/javascript/search/index.d.ts +1 -0
- package/dist/javascript/search/index.d.ts.map +1 -1
- package/dist/javascript/search/index.js +1 -0
- package/dist/javascript/search/index.js.map +1 -1
- package/dist/javascript/search/is-vendored-or-bundled.d.ts +13 -0
- package/dist/javascript/search/is-vendored-or-bundled.d.ts.map +1 -0
- package/dist/javascript/search/is-vendored-or-bundled.js +93 -0
- package/dist/javascript/search/is-vendored-or-bundled.js.map +1 -0
- package/dist/javascript/templating/engine.d.ts.map +1 -1
- package/dist/javascript/templating/engine.js +8 -3
- package/dist/javascript/templating/engine.js.map +1 -1
- package/dist/javascript/type-mapping.d.ts +1 -0
- package/dist/javascript/type-mapping.d.ts.map +1 -1
- package/dist/javascript/type-mapping.js +18 -3
- package/dist/javascript/type-mapping.js.map +1 -1
- package/dist/print.d.ts +6 -1
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +21 -7
- package/dist/print.js.map +1 -1
- package/dist/rewrite-javascript-version.txt +1 -1
- package/dist/rpc/java-rpc-client.d.ts +2 -0
- package/dist/rpc/java-rpc-client.d.ts.map +1 -1
- package/dist/rpc/java-rpc-client.js +1 -0
- package/dist/rpc/java-rpc-client.js.map +1 -1
- package/dist/rpc/queue.d.ts +8 -0
- package/dist/rpc/queue.d.ts.map +1 -1
- package/dist/rpc/queue.js +45 -3
- package/dist/rpc/queue.js.map +1 -1
- package/dist/rpc/request/get-object.d.ts +4 -0
- package/dist/rpc/request/get-object.d.ts.map +1 -1
- package/dist/rpc/request/get-object.js +23 -1
- package/dist/rpc/request/get-object.js.map +1 -1
- package/dist/rpc/request/parse.d.ts.map +1 -1
- package/dist/rpc/request/parse.js +3 -1
- package/dist/rpc/request/parse.js.map +1 -1
- package/dist/rpc/request/print.d.ts +8 -2
- package/dist/rpc/request/print.d.ts.map +1 -1
- package/dist/rpc/request/print.js +12 -9
- package/dist/rpc/request/print.js.map +1 -1
- package/dist/rpc/rewrite-rpc.d.ts +3 -2
- package/dist/rpc/rewrite-rpc.d.ts.map +1 -1
- package/dist/rpc/rewrite-rpc.js +9 -3
- package/dist/rpc/rewrite-rpc.js.map +1 -1
- package/dist/rpc/server.d.ts.map +1 -1
- package/dist/rpc/server.js +19 -5
- package/dist/rpc/server.js.map +1 -1
- package/dist/test/java-rpc.d.ts.map +1 -1
- package/dist/test/java-rpc.js +3 -0
- package/dist/test/java-rpc.js.map +1 -1
- package/package.json +1 -1
- package/src/javascript/add-import.ts +3 -2
- package/src/javascript/amd.ts +3 -2
- package/src/javascript/binding.ts +3 -3
- package/src/javascript/comparator.ts +10 -0
- package/src/javascript/format/tabs-and-indents-visitor.ts +30 -3
- package/src/javascript/index.ts +3 -0
- package/src/javascript/markers.ts +34 -4
- package/src/javascript/migrate/es6/modernize-octal-escape-sequences.ts +28 -36
- package/src/javascript/node-resolution-result.ts +3 -2
- package/src/javascript/parser.ts +200 -91
- package/src/javascript/preconditions.ts +19 -1
- package/src/javascript/print.ts +123 -76
- package/src/javascript/search/index.ts +1 -0
- package/src/javascript/search/is-vendored-or-bundled.ts +59 -0
- package/src/javascript/templating/engine.ts +7 -2
- package/src/javascript/type-mapping.ts +19 -3
- package/src/print.ts +23 -8
- package/src/rpc/java-rpc-client.ts +3 -0
- package/src/rpc/queue.ts +37 -3
- package/src/rpc/request/get-object.ts +24 -0
- package/src/rpc/request/parse.ts +4 -1
- package/src/rpc/request/print.ts +12 -8
- package/src/rpc/rewrite-rpc.ts +16 -5
- package/src/rpc/server.ts +18 -6
- package/src/test/java-rpc.ts +3 -0
package/dist/rpc/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/rpc/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;;;;;;;;;;;;;GAcG;AACH,yDAA2C;AAC3C,+CAAyC;AACzC,uDAAqD;AACrD,uDAAqD;A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AC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,CAAC;KAAM,CAAC;IACJ,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"java-rpc.d.ts","sourceRoot":"","sources":["../../src/test/java-rpc.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAW,KAAK,QAAQ,EAAe,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAoB,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"java-rpc.d.ts","sourceRoot":"","sources":["../../src/test/java-rpc.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAW,KAAK,QAAQ,EAAe,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAoB,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAG5E,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AAC5E,YAAY,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAkB3D;;;GAGG;AACH,eAAO,MAAM,WAAW;;;EAkBtB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,QAC6C,CAAC"}
|
package/dist/test/java-rpc.js
CHANGED
|
@@ -42,6 +42,7 @@ exports.describeJavaRpc = exports.testJavaRpc = exports.JavaRpcTestServer = expo
|
|
|
42
42
|
*/
|
|
43
43
|
const vitest_1 = require("vitest");
|
|
44
44
|
const java_rpc_client_1 = require("../rpc/java-rpc-client");
|
|
45
|
+
const rewrite_rpc_1 = require("../rpc/rewrite-rpc");
|
|
45
46
|
var java_rpc_client_2 = require("../rpc/java-rpc-client");
|
|
46
47
|
Object.defineProperty(exports, "findTestClasspath", { enumerable: true, get: function () { return java_rpc_client_2.findTestClasspath; } });
|
|
47
48
|
Object.defineProperty(exports, "JavaRpcTestServer", { enumerable: true, get: function () { return java_rpc_client_2.JavaRpcTestServer; } });
|
|
@@ -63,6 +64,8 @@ exports.testJavaRpc = vitest_1.test.extend({
|
|
|
63
64
|
{ scope: "worker" },
|
|
64
65
|
],
|
|
65
66
|
javaRpc: async ({ _javaRpcServer }, use) => {
|
|
67
|
+
// any RewriteRpc constructed in this worker since has replaced it as the active connection
|
|
68
|
+
rewrite_rpc_1.RewriteRpc.set(_javaRpcServer.rpc);
|
|
66
69
|
await _javaRpcServer.reset();
|
|
67
70
|
await use(_javaRpcServer);
|
|
68
71
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"java-rpc.js","sourceRoot":"","sources":["../../src/test/java-rpc.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,mCAA6D;AAC7D,4DAA4E;
|
|
1
|
+
{"version":3,"file":"java-rpc.js","sourceRoot":"","sources":["../../src/test/java-rpc.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,mCAA6D;AAC7D,4DAA4E;AAC5E,oDAA8C;AAE9C,0DAA4E;AAApE,oHAAA,iBAAiB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAmB5C;;;GAGG;AACU,QAAA,WAAW,GAAG,aAAI,CAAC,MAAM,CAAkB;IACpD,cAAc,EAAE;QACZ,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;YACd,MAAM,MAAM,GAAG,MAAM,mCAAiB,CAAC,KAAK,EAAE,CAAC;YAC/C,IAAI,CAAC;gBACD,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;YACtB,CAAC;oBAAS,CAAC;gBACP,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;QACL,CAAC;QACD,EAAC,KAAK,EAAE,QAAQ,EAAC;KACpB;IACD,OAAO,EAAE,KAAK,EAAE,EAAC,cAAc,EAAC,EAAE,GAAG,EAAE,EAAE;QACrC,2FAA2F;QAC3F,wBAAU,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,GAAG,CAAC,cAAc,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAC,CAAC;AAEH;;;;;;;GAOG;AACU,QAAA,eAAe,GACxB,IAAA,mCAAiB,GAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC,CAAC,CAAE,iBAAQ,CAAC,IAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -438,7 +438,7 @@ export function moduleNameOf(module: string | J.Literal): string {
|
|
|
438
438
|
}
|
|
439
439
|
restored += source.slice(cut);
|
|
440
440
|
const quote = restored.charAt(0);
|
|
441
|
-
return (quote === "'" || quote === '"') && restored.endsWith(quote) && restored.length > 1
|
|
441
|
+
return (quote === "'" || quote === '"' || quote === '`') && restored.endsWith(quote) && restored.length > 1
|
|
442
442
|
? restored.slice(1, -1)
|
|
443
443
|
: restored;
|
|
444
444
|
}
|
|
@@ -1747,7 +1747,7 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
1747
1747
|
*/
|
|
1748
1748
|
function importBinds(jsImport: JS.Import, module: string, member: string | undefined): string | undefined {
|
|
1749
1749
|
const specifier = jsImport.moduleSpecifier?.element;
|
|
1750
|
-
if (specifier?.kind !== J.Kind.Literal || (specifier as J.Literal)
|
|
1750
|
+
if (specifier?.kind !== J.Kind.Literal || moduleNameOf(specifier as J.Literal) !== module) {
|
|
1751
1751
|
return undefined;
|
|
1752
1752
|
}
|
|
1753
1753
|
const importClause = jsImport.importClause;
|
|
@@ -2029,6 +2029,7 @@ export class RebindImport<P> extends JavaScriptVisitor<P> {
|
|
|
2029
2029
|
const originalSource = literal.valueSource || `"${this.from.module}"`;
|
|
2030
2030
|
const quoteChar = originalSource.startsWith("'") ? "'" : '"';
|
|
2031
2031
|
literal.valueSource = `${quoteChar}${this.to.module}${quoteChar}`;
|
|
2032
|
+
literal.unicodeEscapes = undefined;
|
|
2032
2033
|
|
|
2033
2034
|
// A default or namespace import carries its local name on the clause itself; a named
|
|
2034
2035
|
// one states the member alongside it, in the specifier.
|
package/src/javascript/amd.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
TrailingComma
|
|
30
30
|
} from "../java";
|
|
31
31
|
import {JS} from "./tree";
|
|
32
|
+
import {moduleNameOf} from "./add-import";
|
|
32
33
|
import {cursorOf, deconflict, namesDeclaredWithin, scopeOf} from "./scope";
|
|
33
34
|
import {Cursor} from "../tree";
|
|
34
35
|
import {JavaScriptVisitor} from "./visitor";
|
|
@@ -183,7 +184,7 @@ function foldDeclarationTrailingSpace(entry: J.RightPadded<J>): J.RightPadded<J>
|
|
|
183
184
|
export function dependencyNames(block: AmdBlock): string[] {
|
|
184
185
|
return elementsOf(block).map(padded => {
|
|
185
186
|
const element = padded.element;
|
|
186
|
-
return isLiteral(element) && typeof element.value === "string" ? element
|
|
187
|
+
return isLiteral(element) && typeof element.value === "string" ? moduleNameOf(element) : "";
|
|
187
188
|
});
|
|
188
189
|
}
|
|
189
190
|
|
|
@@ -519,7 +520,7 @@ export function withDependencyModuleAt(
|
|
|
519
520
|
const elements = [...elementsOf(block)];
|
|
520
521
|
const entry = elements[index];
|
|
521
522
|
const literal = entry.element as J.Literal;
|
|
522
|
-
const updated: J.Literal = {...literal, value: module, valueSource: `${quote}${module}${quote}
|
|
523
|
+
const updated: J.Literal = {...literal, value: module, valueSource: `${quote}${module}${quote}`, unicodeEscapes: undefined};
|
|
523
524
|
elements[index] = {...entry, element: updated};
|
|
524
525
|
const dependencies = withElements(block.dependencies, elements);
|
|
525
526
|
return withParts(call, block, dependencies, block.factory);
|
|
@@ -164,7 +164,7 @@ function dynamicallyImportedModule(declaration: J.VariableDeclarations): string
|
|
|
164
164
|
}
|
|
165
165
|
const argument = call.arguments.elements[0]?.element;
|
|
166
166
|
return argument?.kind === J.Kind.Literal && typeof (argument as J.Literal).value === "string"
|
|
167
|
-
? (argument as J.Literal)
|
|
167
|
+
? moduleNameOf(argument as J.Literal)
|
|
168
168
|
: undefined;
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -200,10 +200,10 @@ function moduleObjectBindings(cu: JS.CompilationUnit): ModuleObjectBinding[] {
|
|
|
200
200
|
if (specifier?.kind !== J.Kind.Literal) {
|
|
201
201
|
continue;
|
|
202
202
|
}
|
|
203
|
-
|
|
204
|
-
if (typeof module !== "string") {
|
|
203
|
+
if (typeof (specifier as J.Literal).value !== "string") {
|
|
205
204
|
continue;
|
|
206
205
|
}
|
|
206
|
+
const module = moduleNameOf(specifier as J.Literal);
|
|
207
207
|
const clause = jsImport.importClause;
|
|
208
208
|
const typeOnly = clause?.typeOnly ?? false;
|
|
209
209
|
if (clause?.name?.element?.kind === J.Kind.Identifier) {
|
|
@@ -2634,6 +2634,16 @@ export class JavaScriptSemanticComparatorVisitor extends JavaScriptComparatorVis
|
|
|
2634
2634
|
);
|
|
2635
2635
|
if (!this.match) return methodDeclaration;
|
|
2636
2636
|
|
|
2637
|
+
// Visit name annotations
|
|
2638
|
+
await this.visitArrayProperty(
|
|
2639
|
+
methodDeclaration,
|
|
2640
|
+
'nameAnnotations',
|
|
2641
|
+
methodDeclaration.nameAnnotations,
|
|
2642
|
+
otherMethodDeclaration.nameAnnotations,
|
|
2643
|
+
async (ann1, ann2) => { await this.visit(ann1, ann2); }
|
|
2644
|
+
);
|
|
2645
|
+
if (!this.match) return methodDeclaration;
|
|
2646
|
+
|
|
2637
2647
|
// Visit type parameters if present
|
|
2638
2648
|
if (!!methodDeclaration.typeParameters !== !!otherMethodDeclaration.typeParameters) {
|
|
2639
2649
|
return this.structuralMismatch('typeParameters');
|
|
@@ -179,15 +179,42 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
179
179
|
// TemplateExpressionSpan: reset indent context - template literal content determines its own indentation
|
|
180
180
|
// The expression inside ${...} should be indented based on where it appears in the template, not outer code
|
|
181
181
|
if (tree.kind === JS.Kind.TemplateExpressionSpan) {
|
|
182
|
-
//
|
|
182
|
+
// Whitespace after ${ belongs to the span, not its child expression.
|
|
183
183
|
const span = tree as JS.TemplateExpression.Span;
|
|
184
|
-
const prefix = span.
|
|
184
|
+
const prefix = lastWhitespace(span.prefix);
|
|
185
185
|
const lastNewline = prefix.lastIndexOf("\n");
|
|
186
186
|
if (lastNewline >= 0) {
|
|
187
|
-
return prefix.
|
|
187
|
+
return this.indentWidth(prefix.substring(lastNewline + 1));
|
|
188
|
+
}
|
|
189
|
+
const template = this.cursor.parentTree()?.value as JS.TemplateExpression | undefined;
|
|
190
|
+
if (template?.kind === JS.Kind.TemplateExpression) {
|
|
191
|
+
const index = template.spans.findIndex(s => s.element.id === span.id);
|
|
192
|
+
const preceding = index > 0 ? template.spans[index - 1].element.tail : template.head;
|
|
193
|
+
const text = preceding.valueSource ?? "";
|
|
194
|
+
const newline = text.lastIndexOf("\n");
|
|
195
|
+
if (newline >= 0) {
|
|
196
|
+
// A span on a literal's own line is anchored to that line's indentation.
|
|
197
|
+
const indent = text.substring(newline + 1).match(/^[ \t]*/)?.[0] ?? "";
|
|
198
|
+
return this.indentWidth(indent);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// An inline interpolation continues the surrounding code line, not column zero.
|
|
202
|
+
for (let c = this.cursor.parent; c; c = c.parent) {
|
|
203
|
+
const parent = c.value as J;
|
|
204
|
+
if (parent?.prefix && spaceContainsNewline(parent.prefix)) {
|
|
205
|
+
return (c.messages.get("indentContext") as IndentContext | undefined)?.[0] ?? parentMyIndent;
|
|
206
|
+
}
|
|
188
207
|
}
|
|
189
208
|
return 0;
|
|
190
209
|
}
|
|
210
|
+
// The tail prefix is the whitespace before }, not another continuation of the expression.
|
|
211
|
+
const parentTree = this.cursor.parentTree()?.value;
|
|
212
|
+
if (parentTree?.kind === JS.Kind.TemplateExpressionSpan &&
|
|
213
|
+
(parentTree as JS.TemplateExpression.Span).tail === tree) {
|
|
214
|
+
const prefix = lastWhitespace(tree.prefix);
|
|
215
|
+
const newline = prefix.lastIndexOf("\n");
|
|
216
|
+
return newline < 0 ? parentMyIndent : this.indentWidth(prefix.substring(newline + 1));
|
|
217
|
+
}
|
|
191
218
|
if (tree.kind === J.Kind.IfElse || parentIndentKind === 'align') {
|
|
192
219
|
return parentMyIndent;
|
|
193
220
|
}
|
package/src/javascript/index.ts
CHANGED
|
@@ -54,6 +54,9 @@ export * from "./remove-import";
|
|
|
54
54
|
export * from "./cleanup/index";
|
|
55
55
|
export * from "./recipes/index";
|
|
56
56
|
export * from "./search/index";
|
|
57
|
+
export * from "./migrate/index";
|
|
58
|
+
export * from "./migrate/es6/index";
|
|
59
|
+
export * from "./migrate/typescript/index";
|
|
57
60
|
|
|
58
61
|
import "./print";
|
|
59
62
|
import "./rpc";
|
|
@@ -24,9 +24,10 @@ import {
|
|
|
24
24
|
StyleKind,
|
|
25
25
|
TabsAndIndentsStyle,
|
|
26
26
|
WrappingAndBracesStyle,
|
|
27
|
-
WrappingAndBracesStyleDetailKind
|
|
27
|
+
WrappingAndBracesStyleDetailKind,
|
|
28
|
+
prettierStyle
|
|
28
29
|
} from "./style";
|
|
29
|
-
import {Autodetect} from "./autodetect";
|
|
30
|
+
import {Autodetect, autodetect} from "./autodetect";
|
|
30
31
|
import {updateIfChanged} from "../util";
|
|
31
32
|
|
|
32
33
|
declare module "./tree" {
|
|
@@ -37,6 +38,7 @@ declare module "./tree" {
|
|
|
37
38
|
readonly NonNullAssertion: "org.openrewrite.javascript.marker.NonNullAssertion";
|
|
38
39
|
readonly DelegatedYield: "org.openrewrite.javascript.marker.DelegatedYield";
|
|
39
40
|
readonly FunctionDeclaration: "org.openrewrite.javascript.marker.FunctionDeclaration";
|
|
41
|
+
readonly Computed: "org.openrewrite.javascript.marker.Computed";
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
}
|
|
@@ -48,6 +50,7 @@ declare module "./tree" {
|
|
|
48
50
|
Optional: "org.openrewrite.javascript.marker.Optional",
|
|
49
51
|
NonNullAssertion: "org.openrewrite.javascript.marker.NonNullAssertion",
|
|
50
52
|
FunctionDeclaration: "org.openrewrite.javascript.marker.FunctionDeclaration",
|
|
53
|
+
Computed: "org.openrewrite.javascript.marker.Computed",
|
|
51
54
|
} as const;
|
|
52
55
|
|
|
53
56
|
/**
|
|
@@ -80,6 +83,18 @@ export interface FunctionDeclaration extends Marker {
|
|
|
80
83
|
readonly prefix: J.Space;
|
|
81
84
|
}
|
|
82
85
|
|
|
86
|
+
/**
|
|
87
|
+
* A name written in brackets where the model has room for an identifier only, as the
|
|
88
|
+
* member of `enum A { ['b'] }` is. The identifier holds the bracketed literal.
|
|
89
|
+
*/
|
|
90
|
+
export interface Computed extends Marker {
|
|
91
|
+
readonly kind: typeof JS.Markers.Computed;
|
|
92
|
+
/**
|
|
93
|
+
* The space before the closing bracket.
|
|
94
|
+
*/
|
|
95
|
+
readonly suffix: J.Space;
|
|
96
|
+
}
|
|
97
|
+
|
|
83
98
|
/**
|
|
84
99
|
* Registers an RPC codec for any marker that has a `prefix: J.Space` field.
|
|
85
100
|
*/
|
|
@@ -107,11 +122,26 @@ registerPrefixedMarkerCodec<Generator>(JS.Markers.Generator);
|
|
|
107
122
|
registerPrefixedMarkerCodec<NonNullAssertion>(JS.Markers.NonNullAssertion);
|
|
108
123
|
registerPrefixedMarkerCodec<FunctionDeclaration>(JS.Markers.FunctionDeclaration);
|
|
109
124
|
|
|
125
|
+
RpcCodecs.registerCodec(JS.Markers.Computed, {
|
|
126
|
+
async rpcReceive(before: Computed, q: RpcReceiveQueue): Promise<Computed> {
|
|
127
|
+
return updateIfChanged(before, {
|
|
128
|
+
id: await q.receive(before.id),
|
|
129
|
+
suffix: await q.receive(before.suffix),
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
async rpcSend(after: Computed, q: RpcSendQueue): Promise<void> {
|
|
134
|
+
await q.getAndSend(after, a => a.id);
|
|
135
|
+
await q.getAndSend(after, a => a.suffix);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
110
139
|
// Register codec for PrettierStyle (a NamedStyles that contains Prettier configuration)
|
|
111
140
|
// Only serialize the variable fields; constant fields are defined in the interface
|
|
112
141
|
RpcCodecs.registerCodec(StyleKind.PrettierStyle, {
|
|
113
142
|
async rpcReceive(before: PrettierStyle, q: RpcReceiveQueue): Promise<PrettierStyle> {
|
|
114
|
-
|
|
143
|
+
// the fields that never vary are not sent, so a marker first met here does not have them yet
|
|
144
|
+
return updateIfChanged(before.name ? before : {...prettierStyle(before.id, {}), ...before}, {
|
|
115
145
|
id: await q.receive(before.id),
|
|
116
146
|
config: await q.receive(before.config),
|
|
117
147
|
prettierVersion: await q.receive(before.prettierVersion),
|
|
@@ -131,7 +161,7 @@ RpcCodecs.registerCodec(StyleKind.PrettierStyle, {
|
|
|
131
161
|
// Only serialize the variable fields (id, styles); constant fields are defined in the interface
|
|
132
162
|
RpcCodecs.registerCodec(StyleKind.Autodetect, {
|
|
133
163
|
async rpcReceive(before: Autodetect, q: RpcReceiveQueue): Promise<Autodetect> {
|
|
134
|
-
return updateIfChanged(before, {
|
|
164
|
+
return updateIfChanged(before.name ? before : {...autodetect(before.id, []), ...before}, {
|
|
135
165
|
id: await q.receive(before.id),
|
|
136
166
|
styles: (await q.receiveList(before.styles))!,
|
|
137
167
|
});
|
|
@@ -19,12 +19,13 @@ import {TreeVisitor} from "../../../visitor";
|
|
|
19
19
|
import {ExecutionContext} from "../../../execution";
|
|
20
20
|
import {JavaScriptVisitor} from "../../visitor";
|
|
21
21
|
import {J} from "../../../java";
|
|
22
|
+
import {JS} from "../../tree";
|
|
22
23
|
import {create as produce} from "mutative";
|
|
23
24
|
|
|
24
25
|
export class ModernizeOctalEscapeSequences extends Recipe {
|
|
25
26
|
name = "org.openrewrite.javascript.migrate.es6.modernize-octal-escape-sequences";
|
|
26
27
|
displayName = "Modernize octal escape sequences";
|
|
27
|
-
description = "Convert
|
|
28
|
+
description = "Convert legacy octal escape sequences in string literals (e.g., `\\1`, `\\123`) to hex escape sequences (e.g., `\\x01`, `\\x53`) or Unicode escape sequences (e.g., `\\u0001`, `\\u0053`). The `\\0` escape is left alone unless a digit follows it.";
|
|
28
29
|
|
|
29
30
|
@Option({
|
|
30
31
|
displayName: "Use Unicode escapes",
|
|
@@ -41,50 +42,41 @@ export class ModernizeOctalEscapeSequences extends Recipe {
|
|
|
41
42
|
|
|
42
43
|
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
43
44
|
const useUnicode = this.useUnicodeEscapes;
|
|
45
|
+
const modernize = (source: string) => source.replace(
|
|
46
|
+
/\\([0-3][0-7]{0,2}|[4-7][0-7]?|[\s\S])/g,
|
|
47
|
+
(escape: string, body: string, offset: number) => {
|
|
48
|
+
if (!/^[0-7]/.test(body) || (body === '0' && !/[0-9]/.test(source[offset + 2] ?? ''))) {
|
|
49
|
+
return escape;
|
|
50
|
+
}
|
|
51
|
+
const code = parseInt(body, 8);
|
|
52
|
+
return useUnicode ?
|
|
53
|
+
`\\u${code.toString(16).padStart(4, '0')}` :
|
|
54
|
+
`\\x${code.toString(16).padStart(2, '0')}`;
|
|
55
|
+
});
|
|
44
56
|
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
45
57
|
|
|
46
58
|
protected async visitLiteral(literal: J.Literal, _ctx: ExecutionContext): Promise<J | undefined> {
|
|
47
|
-
// Only process string literals
|
|
48
|
-
if (typeof literal.value !== 'string') {
|
|
49
|
-
return literal;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
59
|
const valueSource = literal.valueSource;
|
|
53
|
-
if (!valueSource)
|
|
60
|
+
if (!valueSource || (valueSource[0] !== '"' && valueSource[0] !== "'") ||
|
|
61
|
+
this.cursor.parentTree()?.value.kind === JS.Kind.JsxAttribute) {
|
|
54
62
|
return literal;
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// Replace all octal escape sequences with hex or Unicode equivalents
|
|
67
|
-
modernized = valueSource.replace(octalEscapePattern, (match, octalDigits) => {
|
|
68
|
-
hasOctalEscapes = true;
|
|
69
|
-
// Convert octal string to decimal number
|
|
70
|
-
const decimalValue = parseInt(octalDigits, 8);
|
|
71
|
-
|
|
72
|
-
if (useUnicode) {
|
|
73
|
-
// Convert to Unicode escape sequence (4 hex digits, zero-padded)
|
|
74
|
-
return `\\u${decimalValue.toString(16).padStart(4, '0')}`;
|
|
75
|
-
} else {
|
|
76
|
-
// Convert to hex escape sequence (2 hex digits, zero-padded)
|
|
77
|
-
return `\\x${decimalValue.toString(16).padStart(2, '0')}`;
|
|
78
|
-
}
|
|
65
|
+
// Surrogate escapes are held outside valueSource, so each run between them is rewritten on its own
|
|
66
|
+
// and the escapes are moved to where their runs now end.
|
|
67
|
+
let modernized = '';
|
|
68
|
+
let cut = 0;
|
|
69
|
+
const unicodeEscapes = literal.unicodeEscapes?.map(escape => {
|
|
70
|
+
modernized += modernize(valueSource.slice(cut, escape.valueSourceIndex));
|
|
71
|
+
cut = escape.valueSourceIndex;
|
|
72
|
+
return {...escape, valueSourceIndex: modernized.length};
|
|
79
73
|
});
|
|
74
|
+
modernized += modernize(valueSource.slice(cut));
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return literal;
|
|
76
|
+
return modernized === valueSource ? literal : produce(literal, draft => {
|
|
77
|
+
draft.valueSource = modernized;
|
|
78
|
+
draft.unicodeEscapes = unicodeEscapes;
|
|
79
|
+
});
|
|
88
80
|
}
|
|
89
81
|
}
|
|
90
82
|
}
|
|
@@ -659,7 +659,7 @@ export function createNodeResolutionResultMarker(
|
|
|
659
659
|
resolvedDependencies,
|
|
660
660
|
packageManager,
|
|
661
661
|
engines: normalizeEngines(packageJsonContent.engines),
|
|
662
|
-
npmrcConfigs,
|
|
662
|
+
npmrcConfigs: npmrcConfigs?.length ? npmrcConfigs : undefined,
|
|
663
663
|
} as NodeResolutionResult;
|
|
664
664
|
}
|
|
665
665
|
|
|
@@ -1022,7 +1022,8 @@ RpcCodecs.registerCodec(NodeResolutionResultKind, {
|
|
|
1022
1022
|
resolvedDependencies: (await q.receiveList(before.resolvedDependencies)) || [],
|
|
1023
1023
|
packageManager: await q.receive(before.packageManager),
|
|
1024
1024
|
engines: await q.receive(before.engines),
|
|
1025
|
-
|
|
1025
|
+
// an empty list is how having none is sent
|
|
1026
|
+
npmrcConfigs: await q.receiveList(before.npmrcConfigs).then(configs => configs?.length ? configs : undefined),
|
|
1026
1027
|
});
|
|
1027
1028
|
},
|
|
1028
1029
|
|