@openrewrite/rewrite 8.106.1 → 8.107.1
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/comparator.d.ts +12 -0
- package/dist/javascript/comparator.d.ts.map +1 -1
- package/dist/javascript/comparator.js +40 -5
- package/dist/javascript/comparator.js.map +1 -1
- package/dist/javascript/type-mapping.d.ts +3 -0
- package/dist/javascript/type-mapping.d.ts.map +1 -1
- package/dist/javascript/type-mapping.js +28 -12
- package/dist/javascript/type-mapping.js.map +1 -1
- package/dist/markers.d.ts +3 -0
- package/dist/markers.d.ts.map +1 -1
- package/dist/markers.js +11 -8
- package/dist/markers.js.map +1 -1
- package/dist/rewrite-javascript-version.txt +1 -1
- package/dist/rpc/index.d.ts +2 -0
- package/dist/rpc/index.d.ts.map +1 -1
- package/dist/rpc/index.js +4 -1
- package/dist/rpc/index.js.map +1 -1
- package/dist/rpc/request/prepare-recipe.d.ts.map +1 -1
- package/dist/rpc/request/prepare-recipe.js +19 -11
- package/dist/rpc/request/prepare-recipe.js.map +1 -1
- package/dist/test/{java-rpc.d.ts → java-rpc.d.mts} +7 -4
- package/dist/test/java-rpc.d.mts.map +1 -0
- package/dist/test/{java-rpc.js → java-rpc.mjs} +12 -14
- package/dist/test/java-rpc.mjs.map +1 -0
- package/package.json +11 -3
- package/src/javascript/comparator.ts +44 -5
- package/src/javascript/type-mapping.ts +31 -12
- package/src/markers.ts +17 -14
- package/src/rpc/index.ts +2 -0
- package/src/rpc/request/prepare-recipe.ts +17 -11
- package/src/test/{java-rpc.ts → java-rpc.mts} +7 -4
- package/dist/test/java-rpc.d.ts.map +0 -1
- package/dist/test/java-rpc.js.map +0 -1
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.describeJavaRpc = exports.testJavaRpc = exports.JavaRpcTestServer = exports.findTestClasspath = void 0;
|
|
4
1
|
/*
|
|
5
2
|
* Copyright 2025 the original author or authors.
|
|
6
3
|
* <p>
|
|
@@ -39,21 +36,22 @@ exports.describeJavaRpc = exports.testJavaRpc = exports.JavaRpcTestServer = expo
|
|
|
39
36
|
*
|
|
40
37
|
* The classpath is resolved via {@link findTestClasspath}; the suite is skipped
|
|
41
38
|
* (via {@link describeJavaRpc}) when no classpath has been configured.
|
|
39
|
+
*
|
|
40
|
+
* This is an ES module, since vitest cannot be loaded with `require`. A CommonJS TypeScript
|
|
41
|
+
* file needs `module: nodenext` or `moduleResolution: bundler` to type-check its import.
|
|
42
42
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Object.defineProperty(exports, "findTestClasspath", { enumerable: true, get: function () { return java_rpc_client_2.findTestClasspath; } });
|
|
48
|
-
Object.defineProperty(exports, "JavaRpcTestServer", { enumerable: true, get: function () { return java_rpc_client_2.JavaRpcTestServer; } });
|
|
43
|
+
import { describe, test as base } from "vitest";
|
|
44
|
+
import { findTestClasspath, JavaRpcTestServer } from "../rpc/java-rpc-client.js";
|
|
45
|
+
import { RewriteRpc } from "../rpc/rewrite-rpc.js";
|
|
46
|
+
export { findTestClasspath, JavaRpcTestServer } from "../rpc/java-rpc-client.js";
|
|
49
47
|
/**
|
|
50
48
|
* Vitest test API extended with a {@link JavaRpcTestServer} fixture. The JVM
|
|
51
49
|
* is spawned once per worker; state is reset before every test.
|
|
52
50
|
*/
|
|
53
|
-
|
|
51
|
+
export const testJavaRpc = base.extend({
|
|
54
52
|
_javaRpcServer: [
|
|
55
53
|
async ({}, use) => {
|
|
56
|
-
const server = await
|
|
54
|
+
const server = await JavaRpcTestServer.start();
|
|
57
55
|
try {
|
|
58
56
|
await use(server);
|
|
59
57
|
}
|
|
@@ -65,7 +63,7 @@ exports.testJavaRpc = vitest_1.test.extend({
|
|
|
65
63
|
],
|
|
66
64
|
javaRpc: async ({ _javaRpcServer }, use) => {
|
|
67
65
|
// any RewriteRpc constructed in this worker since has replaced it as the active connection
|
|
68
|
-
|
|
66
|
+
RewriteRpc.set(_javaRpcServer.rpc);
|
|
69
67
|
await _javaRpcServer.reset();
|
|
70
68
|
await use(_javaRpcServer);
|
|
71
69
|
},
|
|
@@ -78,5 +76,5 @@ exports.testJavaRpc = vitest_1.test.extend({
|
|
|
78
76
|
* Run `./gradlew :rewrite-javascript:generateTestClasspath` to enable, or set
|
|
79
77
|
* the `REWRITE_JAVASCRIPT_CLASSPATH` environment variable.
|
|
80
78
|
*/
|
|
81
|
-
|
|
82
|
-
//# sourceMappingURL=java-rpc.
|
|
79
|
+
export const describeJavaRpc = findTestClasspath() ? describe : describe.skip;
|
|
80
|
+
//# sourceMappingURL=java-rpc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-rpc.mjs","sourceRoot":"","sources":["../../src/test/java-rpc.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAC,QAAQ,EAAiB,IAAI,IAAI,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAmB/E;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAkB;IACpD,cAAc,EAAE;QACZ,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;YACd,MAAM,MAAM,GAAG,MAAM,iBAAiB,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,UAAU,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;AACH,MAAM,CAAC,MAAM,eAAe,GACxB,iBAAiB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAE,QAAQ,CAAC,IAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name" : "@openrewrite/rewrite",
|
|
3
|
-
"version" : "8.
|
|
3
|
+
"version" : "8.107.1",
|
|
4
4
|
"license" : "Moderne Source Available License",
|
|
5
5
|
"description" : "OpenRewrite JavaScript.",
|
|
6
6
|
"repository" : {
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"default" : "./dist/test/index.js"
|
|
47
47
|
},
|
|
48
48
|
"./test/java-rpc" : {
|
|
49
|
-
"types" : "./dist/test/java-rpc.d.
|
|
50
|
-
"default" : "./dist/test/java-rpc.
|
|
49
|
+
"types" : "./dist/test/java-rpc.d.mts",
|
|
50
|
+
"default" : "./dist/test/java-rpc.mjs"
|
|
51
51
|
},
|
|
52
52
|
"./yaml" : {
|
|
53
53
|
"types" : "./dist/yaml/index.d.ts",
|
|
@@ -94,6 +94,14 @@
|
|
|
94
94
|
"prettier" : "^3.7.4",
|
|
95
95
|
"vitest" : "^4.1.8"
|
|
96
96
|
},
|
|
97
|
+
"peerDependencies" : {
|
|
98
|
+
"vitest" : "^4.0.0"
|
|
99
|
+
},
|
|
100
|
+
"peerDependenciesMeta" : {
|
|
101
|
+
"vitest" : {
|
|
102
|
+
"optional" : true
|
|
103
|
+
}
|
|
104
|
+
},
|
|
97
105
|
"optionalDependencies" : {
|
|
98
106
|
"@pyroscope/nodejs" : "^0.4.0",
|
|
99
107
|
"prettier" : "^3.7.4"
|
|
@@ -2496,6 +2496,7 @@ export class JavaScriptSemanticComparatorVisitor extends JavaScriptComparatorVis
|
|
|
2496
2496
|
* 1. Type checking for field access
|
|
2497
2497
|
* 2. Semantic equivalence between `undefined` identifier and void expressions
|
|
2498
2498
|
* 3. Names that differ but denote one declaration, as an import alias and its export do
|
|
2499
|
+
* 4. An import read through its module, as `os.EOL` is for `EOL`
|
|
2499
2500
|
*/
|
|
2500
2501
|
override async visitIdentifier(identifier: J.Identifier, other: J): Promise<J | undefined> {
|
|
2501
2502
|
// Check if this identifier is "undefined" and the other is a void expression
|
|
@@ -2504,6 +2505,10 @@ export class JavaScriptSemanticComparatorVisitor extends JavaScriptComparatorVis
|
|
|
2504
2505
|
return identifier;
|
|
2505
2506
|
}
|
|
2506
2507
|
|
|
2508
|
+
if (other.kind === J.Kind.FieldAccess && this.readsImport(other as J.FieldAccess, identifier)) {
|
|
2509
|
+
return identifier;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2507
2512
|
if (other.kind !== J.Kind.Identifier) {
|
|
2508
2513
|
return this.kindMismatch<J>();
|
|
2509
2514
|
}
|
|
@@ -2516,7 +2521,8 @@ export class JavaScriptSemanticComparatorVisitor extends JavaScriptComparatorVis
|
|
|
2516
2521
|
|
|
2517
2522
|
// For identifiers with field types, check type attribution
|
|
2518
2523
|
if (identifier.fieldType && otherIdentifier.fieldType) {
|
|
2519
|
-
if (!this.isOfType(identifier.fieldType, otherIdentifier.fieldType)
|
|
2524
|
+
if (!this.isOfType(identifier.fieldType, otherIdentifier.fieldType) ||
|
|
2525
|
+
!this.lenientTypeMatching && !this.sameOwner(identifier, otherIdentifier)) {
|
|
2520
2526
|
return this.typeMismatch('fieldType');
|
|
2521
2527
|
}
|
|
2522
2528
|
} else if (identifier.fieldType || otherIdentifier.fieldType) {
|
|
@@ -2530,13 +2536,40 @@ export class JavaScriptSemanticComparatorVisitor extends JavaScriptComparatorVis
|
|
|
2530
2536
|
return super.visitIdentifier(identifier, other);
|
|
2531
2537
|
}
|
|
2532
2538
|
|
|
2539
|
+
/** The counterpart of `visitIdentifier`'s case for an import read through its module. */
|
|
2540
|
+
override async visitFieldAccess(fieldAccess: J.FieldAccess, other: J): Promise<J | undefined> {
|
|
2541
|
+
if (other.kind === J.Kind.Identifier && this.readsImport(fieldAccess, other as J.Identifier)) {
|
|
2542
|
+
return fieldAccess;
|
|
2543
|
+
}
|
|
2544
|
+
return super.visitFieldAccess(fieldAccess, other);
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
/** Whether `fieldAccess` reads through its module what `identifier` imports by name, as `os.EOL` does for `EOL`. */
|
|
2548
|
+
private readsImport(fieldAccess: J.FieldAccess, identifier: J.Identifier): boolean {
|
|
2549
|
+
return this.sameVariable(identifier.fieldType, fieldAccess.name.element.fieldType);
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
/**
|
|
2553
|
+
* Whether two variables of one spelling have one owner, which is a module for an import and nothing for a
|
|
2554
|
+
* variable the file declares. Only a reference is asked. A member's owner is whichever class in a
|
|
2555
|
+
* hierarchy declares it, and it is named where it is read from a receiver or declared.
|
|
2556
|
+
*/
|
|
2557
|
+
private sameOwner(identifier: J.Identifier, other: J.Identifier): boolean {
|
|
2558
|
+
const parent = this.cursor.parentTree()?.value;
|
|
2559
|
+
if (parent?.kind === J.Kind.FieldAccess && (parent as J.FieldAccess).name.element === identifier ||
|
|
2560
|
+
parent?.kind === J.Kind.NamedVariable && (parent as J.VariableDeclarations.NamedVariable).name === identifier) {
|
|
2561
|
+
return true;
|
|
2562
|
+
}
|
|
2563
|
+
const owner = identifier.fieldType?.owner;
|
|
2564
|
+
const otherOwner = other.fieldType?.owner;
|
|
2565
|
+
return Type.isFullyQualified(owner) || Type.isFullyQualified(otherOwner) ?
|
|
2566
|
+
this.sameFullyQualifiedName(owner, otherOwner) : true;
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2533
2569
|
/** An import alias and its export denote one declaration, where a variable holding the same value does not. */
|
|
2534
2570
|
private denoteOneDeclaration(identifier: J.Identifier, other: J.Identifier): boolean {
|
|
2535
2571
|
if (identifier.fieldType || other.fieldType) {
|
|
2536
|
-
|
|
2537
|
-
return !!identifier.fieldType && !!other.fieldType &&
|
|
2538
|
-
identifier.fieldType.name === other.fieldType.name && identifier.fieldType.name !== 'unknown' &&
|
|
2539
|
-
this.sameFullyQualifiedName(identifier.fieldType.owner, other.fieldType.owner);
|
|
2572
|
+
return this.sameVariable(identifier.fieldType, other.fieldType);
|
|
2540
2573
|
}
|
|
2541
2574
|
// Only a nominal type names a declaration. The function and object type shells are shared,
|
|
2542
2575
|
// and a parameterized type is named after its base alone.
|
|
@@ -2545,6 +2578,12 @@ export class JavaScriptSemanticComparatorVisitor extends JavaScriptComparatorVis
|
|
|
2545
2578
|
this.sameFullyQualifiedName(identifier.type, other.type);
|
|
2546
2579
|
}
|
|
2547
2580
|
|
|
2581
|
+
private sameVariable(variable?: Type.Variable, other?: Type.Variable): boolean {
|
|
2582
|
+
// An unresolved import has the placeholder name `unknown`, which identifies nothing
|
|
2583
|
+
return !!variable && !!other && variable.name === other.name && variable.name !== 'unknown' &&
|
|
2584
|
+
this.sameFullyQualifiedName(variable.owner, other.owner);
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2548
2587
|
private sameFullyQualifiedName(type?: Type, other?: Type): boolean {
|
|
2549
2588
|
return Type.isFullyQualified(type) && Type.isFullyQualified(other) &&
|
|
2550
2589
|
Type.FullyQualified.getFullyQualifiedName(type) === Type.FullyQualified.getFullyQualifiedName(other);
|
|
@@ -651,18 +651,7 @@ export class JavaScriptTypeMapping {
|
|
|
651
651
|
const binding = this.moduleBinding(symbol.declarations?.[0], node);
|
|
652
652
|
if (symbol.flags & ts.SymbolFlags.Alias || (binding && binding.kind !== 'namespace')) {
|
|
653
653
|
if (binding) {
|
|
654
|
-
ownerType =
|
|
655
|
-
kind: Type.Kind.Class,
|
|
656
|
-
flags: 0,
|
|
657
|
-
classKind: Type.Class.Kind.Interface,
|
|
658
|
-
fullyQualifiedName: binding.module,
|
|
659
|
-
typeParameters: [],
|
|
660
|
-
annotations: [],
|
|
661
|
-
interfaces: [],
|
|
662
|
-
members: [],
|
|
663
|
-
methods: [],
|
|
664
|
-
toJSON: typeSignatureToJSON
|
|
665
|
-
} as Type.Class;
|
|
654
|
+
ownerType = this.importOwner(binding.module);
|
|
666
655
|
}
|
|
667
656
|
} else {
|
|
668
657
|
// For non-imported variables, check if they belong to a class/interface/namespace
|
|
@@ -711,6 +700,12 @@ export class JavaScriptTypeMapping {
|
|
|
711
700
|
}
|
|
712
701
|
}
|
|
713
702
|
|
|
703
|
+
// An export read as `os.EOL` has the owner `import {EOL} from 'os'` gives it, unless a class or namespace declares it
|
|
704
|
+
if (!Type.isFullyQualified(ownerType)) {
|
|
705
|
+
const module = this.moduleReadThrough(node);
|
|
706
|
+
ownerType = module ? this.importOwner(module) : ownerType;
|
|
707
|
+
}
|
|
708
|
+
|
|
714
709
|
// Create the Type.Variable
|
|
715
710
|
const variable = {
|
|
716
711
|
kind: Type.Kind.Variable,
|
|
@@ -841,6 +836,30 @@ export class JavaScriptTypeMapping {
|
|
|
841
836
|
return undefined;
|
|
842
837
|
}
|
|
843
838
|
|
|
839
|
+
/** The module `os` binds in `os.EOL`, given the node of `EOL`, where `os` binds a whole module. */
|
|
840
|
+
private moduleReadThrough(node: ts.Node): string | undefined {
|
|
841
|
+
if (!ts.isIdentifier(node) || !ts.isPropertyAccessExpression(node.parent) || node.parent.name !== node) {
|
|
842
|
+
return undefined;
|
|
843
|
+
}
|
|
844
|
+
const receiver = this.bindingOf(node.parent.expression);
|
|
845
|
+
return receiver?.kind === 'namespace' ? receiver.module : undefined;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
private importOwner(module: string): Type.Class {
|
|
849
|
+
return {
|
|
850
|
+
kind: Type.Kind.Class,
|
|
851
|
+
flags: 0,
|
|
852
|
+
classKind: Type.Class.Kind.Interface,
|
|
853
|
+
fullyQualifiedName: module,
|
|
854
|
+
typeParameters: [],
|
|
855
|
+
annotations: [],
|
|
856
|
+
interfaces: [],
|
|
857
|
+
members: [],
|
|
858
|
+
methods: [],
|
|
859
|
+
toJSON: typeSignatureToJSON
|
|
860
|
+
} as Type.Class;
|
|
861
|
+
}
|
|
862
|
+
|
|
844
863
|
/** A binding of the export `name` names, where that is a static name. `default` names the default export. */
|
|
845
864
|
private memberBinding(module: string, name: ts.Node): ModuleBinding | undefined {
|
|
846
865
|
if (!ts.isIdentifier(name) && !ts.isStringLiteralLike(name)) {
|
package/src/markers.ts
CHANGED
|
@@ -172,22 +172,25 @@ export interface SearchResult extends Marker {
|
|
|
172
172
|
readonly description?: string
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Marks `t` as a search result, unless it already carries one with this description.
|
|
177
|
+
*/
|
|
175
178
|
export function foundSearchResult<T extends { markers: Markers }>(t: T, description?: string): T {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return
|
|
179
|
-
...t,
|
|
180
|
-
markers: {
|
|
181
|
-
...t.markers,
|
|
182
|
-
markers: [...t.markers.markers, {
|
|
183
|
-
kind: MarkersKind.SearchResult,
|
|
184
|
-
id: randomId(),
|
|
185
|
-
description: description
|
|
186
|
-
} as SearchResult]
|
|
187
|
-
}
|
|
188
|
-
} as T;
|
|
179
|
+
if (t.markers.markers.some(m => m.kind === MarkersKind.SearchResult &&
|
|
180
|
+
(m as SearchResult).description === description)) {
|
|
181
|
+
return t;
|
|
189
182
|
}
|
|
190
|
-
return
|
|
183
|
+
return {
|
|
184
|
+
...t,
|
|
185
|
+
markers: {
|
|
186
|
+
...t.markers,
|
|
187
|
+
markers: [...t.markers.markers, {
|
|
188
|
+
kind: MarkersKind.SearchResult,
|
|
189
|
+
id: randomId(),
|
|
190
|
+
description: description
|
|
191
|
+
} as SearchResult]
|
|
192
|
+
}
|
|
193
|
+
} as T;
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
export interface ParseExceptionResult extends Marker {
|
package/src/rpc/index.ts
CHANGED
|
@@ -35,6 +35,8 @@ export * from "../reference";
|
|
|
35
35
|
export {RewriteRpc} from "./rewrite-rpc";
|
|
36
36
|
export {RpcRecipe, RpcVisitor} from "./recipe";
|
|
37
37
|
export {DelegatingRecipe, prepareJavaRecipe} from "./java-recipe";
|
|
38
|
+
export {findTestClasspath, JavaRpcTestServer} from "./java-rpc-client";
|
|
39
|
+
export type {JavaRpcOptions} from "./java-rpc-client";
|
|
38
40
|
export {registerVisitor} from "./request/visitor-registry";
|
|
39
41
|
|
|
40
42
|
RpcCodecs.registerCodec(TreeKind.Checksum, {
|
|
@@ -160,24 +160,29 @@ export class PrepareRecipe {
|
|
|
160
160
|
*/
|
|
161
161
|
private static async optimizePreconditions(recipe: Recipe, phase: "edit" | "scan", preconditions: Precondition[]): Promise<Recipe> {
|
|
162
162
|
let visitor: TreeVisitor<any, ExecutionContext>;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (recipe instanceof ScanningRecipe) {
|
|
167
|
-
visitor = await recipe.scanner(
|
|
163
|
+
try {
|
|
164
|
+
if (phase === "edit") {
|
|
165
|
+
visitor = await recipe.editor();
|
|
166
|
+
} else if (recipe instanceof ScanningRecipe) {
|
|
167
|
+
visitor = await recipe.scanner(recipe.initialValue(new ExecutionContext()));
|
|
168
168
|
} else {
|
|
169
169
|
return recipe;
|
|
170
170
|
}
|
|
171
|
+
} catch {
|
|
172
|
+
// A visitor that can only be built during a run keeps its preconditions, which it then checks itself.
|
|
173
|
+
return recipe;
|
|
171
174
|
}
|
|
172
175
|
|
|
173
176
|
if (visitor! instanceof Check) {
|
|
174
|
-
const wireEntry = this.conditionWireEntry(visitor.check
|
|
177
|
+
const wireEntry = this.conditionWireEntry(visitor.check);
|
|
175
178
|
if (wireEntry) {
|
|
176
179
|
preconditions.push(wireEntry);
|
|
177
180
|
if (phase === "edit") {
|
|
181
|
+
const editor = recipe.editor;
|
|
178
182
|
recipe = PrepareRecipe.withOverrides(recipe, {
|
|
179
|
-
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
180
|
-
|
|
183
|
+
async editor(this: Recipe): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
184
|
+
const editVisitor = await editor.call(this);
|
|
185
|
+
return editVisitor instanceof Check ? editVisitor.v : editVisitor;
|
|
181
186
|
}
|
|
182
187
|
});
|
|
183
188
|
} else {
|
|
@@ -211,11 +216,11 @@ export class PrepareRecipe {
|
|
|
211
216
|
* condition can't be serialized — the caller leaves the wrapper
|
|
212
217
|
* intact so the gate runs in-process as a fallback.
|
|
213
218
|
*/
|
|
214
|
-
private static conditionWireEntry(condition: CheckArg
|
|
219
|
+
private static conditionWireEntry(condition: CheckArg): Precondition | undefined {
|
|
215
220
|
if (condition instanceof CompositePrecondition) {
|
|
216
221
|
const operands: Precondition[] = [];
|
|
217
222
|
for (const operand of condition.operands) {
|
|
218
|
-
const entry = this.conditionWireEntry(operand
|
|
223
|
+
const entry = this.conditionWireEntry(operand);
|
|
219
224
|
if (entry === undefined) {
|
|
220
225
|
return undefined;
|
|
221
226
|
}
|
|
@@ -232,7 +237,8 @@ export class PrepareRecipe {
|
|
|
232
237
|
return {visitorName: ref.recipeName, visitorOptions: {...ref.options}};
|
|
233
238
|
}
|
|
234
239
|
if (condition instanceof RpcRecipe) {
|
|
235
|
-
|
|
240
|
+
// A recipe gates with its editor in either phase, as Check evaluates it in-process.
|
|
241
|
+
return {visitorName: condition.editVisitor};
|
|
236
242
|
}
|
|
237
243
|
return undefined;
|
|
238
244
|
}
|
|
@@ -36,13 +36,16 @@
|
|
|
36
36
|
*
|
|
37
37
|
* The classpath is resolved via {@link findTestClasspath}; the suite is skipped
|
|
38
38
|
* (via {@link describeJavaRpc}) when no classpath has been configured.
|
|
39
|
+
*
|
|
40
|
+
* This is an ES module, since vitest cannot be loaded with `require`. A CommonJS TypeScript
|
|
41
|
+
* file needs `module: nodenext` or `moduleResolution: bundler` to type-check its import.
|
|
39
42
|
*/
|
|
40
43
|
import {describe, type SuiteAPI, test as base} from "vitest";
|
|
41
|
-
import {findTestClasspath, JavaRpcTestServer} from "../rpc/java-rpc-client";
|
|
42
|
-
import {RewriteRpc} from "../rpc/rewrite-rpc";
|
|
44
|
+
import {findTestClasspath, JavaRpcTestServer} from "../rpc/java-rpc-client.js";
|
|
45
|
+
import {RewriteRpc} from "../rpc/rewrite-rpc.js";
|
|
43
46
|
|
|
44
|
-
export {findTestClasspath, JavaRpcTestServer} from "../rpc/java-rpc-client";
|
|
45
|
-
export type {JavaRpcOptions} from "../rpc/java-rpc-client";
|
|
47
|
+
export {findTestClasspath, JavaRpcTestServer} from "../rpc/java-rpc-client.js";
|
|
48
|
+
export type {JavaRpcOptions} from "../rpc/java-rpc-client.js";
|
|
46
49
|
|
|
47
50
|
interface JavaRpcFixtures {
|
|
48
51
|
/**
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|