@openrewrite/rewrite 8.91.2 → 8.91.3
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/execution.d.ts +8 -0
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +31 -0
- package/dist/execution.js.map +1 -1
- package/dist/javascript/add-import.d.ts +64 -9
- package/dist/javascript/add-import.d.ts.map +1 -1
- package/dist/javascript/add-import.js +398 -71
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/amd.d.ts +11 -1
- package/dist/javascript/amd.d.ts.map +1 -1
- package/dist/javascript/amd.js +43 -9
- package/dist/javascript/amd.js.map +1 -1
- package/dist/javascript/binding.d.ts +10 -2
- package/dist/javascript/binding.d.ts.map +1 -1
- package/dist/javascript/binding.js +44 -71
- package/dist/javascript/binding.js.map +1 -1
- package/dist/javascript/comparator.d.ts +2 -0
- package/dist/javascript/comparator.d.ts.map +1 -1
- package/dist/javascript/comparator.js +5 -1
- package/dist/javascript/comparator.js.map +1 -1
- package/dist/javascript/format/format.d.ts +5 -2
- package/dist/javascript/format/format.d.ts.map +1 -1
- package/dist/javascript/format/format.js +51 -11
- package/dist/javascript/format/format.js.map +1 -1
- package/dist/javascript/format/minimum-viable-spacing-visitor.d.ts +19 -0
- package/dist/javascript/format/minimum-viable-spacing-visitor.d.ts.map +1 -1
- package/dist/javascript/format/minimum-viable-spacing-visitor.js +180 -7
- package/dist/javascript/format/minimum-viable-spacing-visitor.js.map +1 -1
- package/dist/javascript/format/prettier-format.d.ts +2 -1
- package/dist/javascript/format/prettier-format.d.ts.map +1 -1
- package/dist/javascript/format/prettier-format.js +33 -23
- package/dist/javascript/format/prettier-format.js.map +1 -1
- package/dist/javascript/index.d.ts +3 -3
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +21 -1
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/parser-utils.d.ts.map +1 -1
- package/dist/javascript/parser-utils.js +5 -9
- package/dist/javascript/parser-utils.js.map +1 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +48 -3
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/print.d.ts +1 -0
- package/dist/javascript/print.d.ts.map +1 -1
- package/dist/javascript/print.js +9 -0
- package/dist/javascript/print.js.map +1 -1
- package/dist/javascript/recipes/change-import.d.ts +6 -3
- package/dist/javascript/recipes/change-import.d.ts.map +1 -1
- package/dist/javascript/recipes/change-import.js +17 -277
- package/dist/javascript/recipes/change-import.js.map +1 -1
- package/dist/javascript/rpc.js +2 -0
- package/dist/javascript/rpc.js.map +1 -1
- package/dist/javascript/scope.d.ts +40 -7
- package/dist/javascript/scope.d.ts.map +1 -1
- package/dist/javascript/scope.js +182 -30
- package/dist/javascript/scope.js.map +1 -1
- package/dist/javascript/templating/bindings.js +2 -20
- package/dist/javascript/templating/bindings.js.map +1 -1
- package/dist/javascript/templating/comparator.d.ts +2 -0
- package/dist/javascript/templating/comparator.d.ts.map +1 -1
- package/dist/javascript/templating/comparator.js +25 -0
- package/dist/javascript/templating/comparator.js.map +1 -1
- package/dist/javascript/templating/engine.d.ts +5 -0
- package/dist/javascript/templating/engine.d.ts.map +1 -1
- package/dist/javascript/templating/engine.js +30 -12
- package/dist/javascript/templating/engine.js.map +1 -1
- package/dist/javascript/templating/template.d.ts.map +1 -1
- package/dist/javascript/templating/template.js +6 -0
- package/dist/javascript/templating/template.js.map +1 -1
- package/dist/javascript/templating/types.d.ts +5 -0
- package/dist/javascript/templating/types.d.ts.map +1 -1
- package/dist/javascript/tree.d.ts +1 -0
- package/dist/javascript/tree.d.ts.map +1 -1
- package/dist/javascript/tree.js.map +1 -1
- package/dist/javascript/type-mapping.d.ts.map +1 -1
- package/dist/javascript/type-mapping.js +14 -0
- package/dist/javascript/type-mapping.js.map +1 -1
- package/dist/javascript/visitor.d.ts.map +1 -1
- package/dist/javascript/visitor.js +1 -0
- package/dist/javascript/visitor.js.map +1 -1
- package/dist/parser.d.ts +6 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +23 -1
- package/dist/parser.js.map +1 -1
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +5 -2
- package/dist/print.js.map +1 -1
- package/dist/rewrite-javascript-version.txt +1 -1
- package/dist/rpc/request/parse-project.d.ts +11 -1
- package/dist/rpc/request/parse-project.d.ts.map +1 -1
- package/dist/rpc/request/parse-project.js +7 -2
- package/dist/rpc/request/parse-project.js.map +1 -1
- package/dist/rpc/request/parse.d.ts +13 -1
- package/dist/rpc/request/parse.d.ts.map +1 -1
- package/dist/rpc/request/parse.js +8 -2
- package/dist/rpc/request/parse.js.map +1 -1
- package/package.json +1 -1
- package/src/execution.ts +23 -0
- package/src/javascript/add-import.ts +449 -78
- package/src/javascript/amd.ts +49 -10
- package/src/javascript/binding.ts +60 -74
- package/src/javascript/comparator.ts +6 -1
- package/src/javascript/format/format.ts +56 -12
- package/src/javascript/format/minimum-viable-spacing-visitor.ts +196 -7
- package/src/javascript/format/prettier-format.ts +35 -25
- package/src/javascript/index.ts +10 -3
- package/src/javascript/parser-utils.ts +5 -11
- package/src/javascript/parser.ts +65 -6
- package/src/javascript/print.ts +10 -0
- package/src/javascript/recipes/change-import.ts +19 -349
- package/src/javascript/rpc.ts +2 -0
- package/src/javascript/scope.ts +210 -31
- package/src/javascript/templating/bindings.ts +2 -25
- package/src/javascript/templating/comparator.ts +29 -2
- package/src/javascript/templating/engine.ts +41 -14
- package/src/javascript/templating/template.ts +6 -0
- package/src/javascript/templating/types.ts +6 -0
- package/src/javascript/tree.ts +1 -0
- package/src/javascript/type-mapping.ts +15 -0
- package/src/javascript/visitor.ts +1 -0
- package/src/parser.ts +24 -1
- package/src/print.ts +5 -2
- package/src/rpc/request/parse-project.ts +6 -2
- package/src/rpc/request/parse.ts +7 -2
|
@@ -19,8 +19,7 @@ import { TreeVisitor } from "../../visitor";
|
|
|
19
19
|
import { ExecutionContext } from "../../execution";
|
|
20
20
|
import { JavaScriptVisitor, JS } from "../index";
|
|
21
21
|
import { maybeRebind } from "../binding";
|
|
22
|
-
import { J
|
|
23
|
-
import { create as produce } from "mutative";
|
|
22
|
+
import { J } from "../../java";
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* Changes an import from one module to another, updating all type attributions.
|
|
@@ -41,15 +40,16 @@ import { create as produce } from "mutative";
|
|
|
41
40
|
* // After: import { act } from 'react';
|
|
42
41
|
*
|
|
43
42
|
* @example
|
|
44
|
-
* //
|
|
43
|
+
* // Rename a member, carrying the references that resolve to it
|
|
45
44
|
* const recipe = new ChangeImport({
|
|
46
45
|
* oldModule: "lodash",
|
|
47
46
|
* oldMember: "extend",
|
|
48
47
|
* newModule: "lodash",
|
|
49
48
|
* newMember: "assign"
|
|
50
49
|
* });
|
|
51
|
-
* // Before: import { extend } from 'lodash';
|
|
52
|
-
* // After: import { assign
|
|
50
|
+
* // Before: import { extend } from 'lodash'; extend({}, {});
|
|
51
|
+
* // After: import { assign } from 'lodash'; assign({}, {});
|
|
52
|
+
* // Adding `newAlias: "extend"` instead binds it as `import { assign as extend }`.
|
|
53
53
|
*/
|
|
54
54
|
export class ChangeImport extends Recipe {
|
|
55
55
|
readonly name = "org.openrewrite.javascript.change-import";
|
|
@@ -85,11 +85,21 @@ export class ChangeImport extends Recipe {
|
|
|
85
85
|
})
|
|
86
86
|
newMember?: string;
|
|
87
87
|
|
|
88
|
+
@Option({
|
|
89
|
+
displayName: "New alias",
|
|
90
|
+
description: "The local name to bind the new member under. Defaults to the alias the import " +
|
|
91
|
+
"already had, or to the new member name where it had none.",
|
|
92
|
+
example: "act",
|
|
93
|
+
required: false
|
|
94
|
+
})
|
|
95
|
+
newAlias?: string;
|
|
96
|
+
|
|
88
97
|
constructor(options?: {
|
|
89
98
|
oldModule?: string;
|
|
90
99
|
oldMember?: string;
|
|
91
100
|
newModule?: string;
|
|
92
101
|
newMember?: string;
|
|
102
|
+
newAlias?: string;
|
|
93
103
|
}) {
|
|
94
104
|
super(options);
|
|
95
105
|
}
|
|
@@ -99,356 +109,16 @@ export class ChangeImport extends Recipe {
|
|
|
99
109
|
const oldMember = this.oldMember;
|
|
100
110
|
const newModule = this.newModule;
|
|
101
111
|
const newMember = this.newMember ?? oldMember;
|
|
102
|
-
|
|
103
|
-
// Build the old and new FQNs for type attribution updates
|
|
104
|
-
const oldFqn = oldMember === 'default' || oldMember === '*'
|
|
105
|
-
? oldModule
|
|
106
|
-
: `${oldModule}.${oldMember}`;
|
|
107
|
-
const newFqn = newMember === 'default' || newMember === '*'
|
|
108
|
-
? newModule
|
|
109
|
-
: `${newModule}.${newMember}`;
|
|
112
|
+
const newAlias = this.newAlias;
|
|
110
113
|
|
|
111
114
|
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
112
|
-
private hasOldImport = false;
|
|
113
|
-
|
|
114
115
|
override async visitJsCompilationUnit(cu: JS.CompilationUnit, ctx: ExecutionContext): Promise<J | undefined> {
|
|
115
|
-
|
|
116
|
+
maybeRebind(this, {
|
|
116
117
|
from: {module: oldModule, member: oldMember},
|
|
117
|
-
to: {module: newModule, member: newMember}
|
|
118
|
-
})
|
|
119
|
-
|
|
118
|
+
to: {module: newModule, member: newMember, alias: newAlias}
|
|
119
|
+
});
|
|
120
120
|
return super.visitJsCompilationUnit(cu, ctx);
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
override async visitIdentifier(identifier: J.Identifier, ctx: ExecutionContext): Promise<J | undefined> {
|
|
124
|
-
let ident = await super.visitIdentifier(identifier, ctx) as J.Identifier;
|
|
125
|
-
|
|
126
|
-
if (!this.hasOldImport) {
|
|
127
|
-
return ident;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Check and update type attribution
|
|
131
|
-
let changed = false;
|
|
132
|
-
|
|
133
|
-
// Update type if it references the old module
|
|
134
|
-
const updatedType = this.updateType(ident.type);
|
|
135
|
-
if (updatedType !== ident.type) {
|
|
136
|
-
changed = true;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Update fieldType if it references the old module
|
|
140
|
-
// fieldType is specifically Type.Variable, so we need to handle it specially
|
|
141
|
-
let updatedFieldType: Type.Variable | undefined = ident.fieldType;
|
|
142
|
-
if (ident.fieldType) {
|
|
143
|
-
const updated = this.updateVariableType(ident.fieldType);
|
|
144
|
-
if (updated !== ident.fieldType) {
|
|
145
|
-
updatedFieldType = updated;
|
|
146
|
-
changed = true;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (changed) {
|
|
151
|
-
return produce(ident, draft => {
|
|
152
|
-
if (updatedType !== ident.type) {
|
|
153
|
-
draft.type = updatedType;
|
|
154
|
-
}
|
|
155
|
-
if (updatedFieldType !== ident.fieldType) {
|
|
156
|
-
draft.fieldType = updatedFieldType;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return ident;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
override async visitMethodInvocation(method: J.MethodInvocation, ctx: ExecutionContext): Promise<J | undefined> {
|
|
165
|
-
let m = await super.visitMethodInvocation(method, ctx) as J.MethodInvocation;
|
|
166
|
-
|
|
167
|
-
if (!this.hasOldImport) {
|
|
168
|
-
return m;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Update methodType if it references the old module
|
|
172
|
-
const updatedMethodType = this.updateMethodType(m.methodType);
|
|
173
|
-
if (updatedMethodType !== m.methodType) {
|
|
174
|
-
return produce(m, draft => {
|
|
175
|
-
draft.methodType = updatedMethodType;
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return m;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
override async visitFieldAccess(fieldAccess: J.FieldAccess, ctx: ExecutionContext): Promise<J | undefined> {
|
|
183
|
-
let fa = await super.visitFieldAccess(fieldAccess, ctx) as J.FieldAccess;
|
|
184
|
-
|
|
185
|
-
if (!this.hasOldImport) {
|
|
186
|
-
return fa;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Update type if it references the old module
|
|
190
|
-
const updatedType = this.updateType(fa.type);
|
|
191
|
-
if (updatedType !== fa.type) {
|
|
192
|
-
return produce(fa, draft => {
|
|
193
|
-
draft.type = updatedType;
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return fa;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
override async visitFunctionCall(functionCall: JS.FunctionCall, ctx: ExecutionContext): Promise<J | undefined> {
|
|
201
|
-
let fc = await super.visitFunctionCall(functionCall, ctx) as JS.FunctionCall;
|
|
202
|
-
|
|
203
|
-
if (!this.hasOldImport) {
|
|
204
|
-
return fc;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Update methodType if it references the old module
|
|
208
|
-
const updatedMethodType = this.updateMethodType(fc.methodType);
|
|
209
|
-
if (updatedMethodType !== fc.methodType) {
|
|
210
|
-
return produce(fc, draft => {
|
|
211
|
-
draft.methodType = updatedMethodType;
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return fc;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
override async visitNewClass(newClass: J.NewClass, ctx: ExecutionContext): Promise<J | undefined> {
|
|
219
|
-
let nc = await super.visitNewClass(newClass, ctx) as J.NewClass;
|
|
220
|
-
|
|
221
|
-
if (!this.hasOldImport) {
|
|
222
|
-
return nc;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
let changed = false;
|
|
226
|
-
|
|
227
|
-
// Update methodType if it references the old module
|
|
228
|
-
const updatedMethodType = this.updateMethodType(nc.methodType);
|
|
229
|
-
if (updatedMethodType !== nc.methodType) {
|
|
230
|
-
changed = true;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Update constructorType if it references the old module
|
|
234
|
-
const updatedConstructorType = this.updateMethodType(nc.constructorType);
|
|
235
|
-
if (updatedConstructorType !== nc.constructorType) {
|
|
236
|
-
changed = true;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Update type if it references the old module
|
|
240
|
-
const updatedType = this.updateType(nc.type);
|
|
241
|
-
if (updatedType !== nc.type) {
|
|
242
|
-
changed = true;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (changed) {
|
|
246
|
-
return produce(nc, draft => {
|
|
247
|
-
if (updatedMethodType !== nc.methodType) {
|
|
248
|
-
draft.methodType = updatedMethodType;
|
|
249
|
-
}
|
|
250
|
-
if (updatedConstructorType !== nc.constructorType) {
|
|
251
|
-
draft.constructorType = updatedConstructorType;
|
|
252
|
-
}
|
|
253
|
-
if (updatedType !== nc.type) {
|
|
254
|
-
draft.type = updatedType;
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return nc;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Update a type if it references the old module
|
|
264
|
-
*/
|
|
265
|
-
private updateType(type: Type | undefined): Type | undefined {
|
|
266
|
-
if (!type) return type;
|
|
267
|
-
|
|
268
|
-
switch (type.kind) {
|
|
269
|
-
case Type.Kind.Class:
|
|
270
|
-
case Type.Kind.ShallowClass:
|
|
271
|
-
return this.updateClassType(type as Type.Class);
|
|
272
|
-
|
|
273
|
-
case Type.Kind.Method:
|
|
274
|
-
return this.updateMethodType(type as Type.Method);
|
|
275
|
-
|
|
276
|
-
case Type.Kind.Variable:
|
|
277
|
-
return this.updateVariableType(type as Type.Variable);
|
|
278
|
-
|
|
279
|
-
case Type.Kind.Parameterized:
|
|
280
|
-
return this.updateParameterizedType(type as Type.Parameterized);
|
|
281
|
-
|
|
282
|
-
case Type.Kind.Array:
|
|
283
|
-
return this.updateArrayType(type as Type.Array);
|
|
284
|
-
|
|
285
|
-
default:
|
|
286
|
-
return type;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Update a Class type if its FQN references the old module
|
|
292
|
-
*/
|
|
293
|
-
private updateClassType(classType: Type.Class): Type.Class {
|
|
294
|
-
let changed = false;
|
|
295
|
-
let newFullyQualifiedName = classType.fullyQualifiedName;
|
|
296
|
-
let newOwningClass = classType.owningClass;
|
|
297
|
-
|
|
298
|
-
// Check if the FQN matches or starts with the old module
|
|
299
|
-
if (classType.fullyQualifiedName === oldFqn) {
|
|
300
|
-
newFullyQualifiedName = newFqn;
|
|
301
|
-
changed = true;
|
|
302
|
-
} else if (classType.fullyQualifiedName === oldModule) {
|
|
303
|
-
newFullyQualifiedName = newModule;
|
|
304
|
-
changed = true;
|
|
305
|
-
} else if (classType.fullyQualifiedName.startsWith(oldModule + '.')) {
|
|
306
|
-
newFullyQualifiedName = newModule + classType.fullyQualifiedName.substring(oldModule.length);
|
|
307
|
-
changed = true;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// Recursively update owningClass
|
|
311
|
-
if (classType.owningClass) {
|
|
312
|
-
const updatedOwningClass = this.updateClassType(classType.owningClass);
|
|
313
|
-
if (updatedOwningClass !== classType.owningClass) {
|
|
314
|
-
newOwningClass = updatedOwningClass;
|
|
315
|
-
changed = true;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (changed) {
|
|
320
|
-
// Type objects are marked as non-draftable, so we manually create new objects
|
|
321
|
-
return {
|
|
322
|
-
...classType,
|
|
323
|
-
fullyQualifiedName: newFullyQualifiedName,
|
|
324
|
-
owningClass: newOwningClass
|
|
325
|
-
} as Type.Class;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return classType;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Update a Method type if its declaringType references the old module
|
|
333
|
-
*/
|
|
334
|
-
private updateMethodType(methodType: Type.Method | undefined): Type.Method | undefined {
|
|
335
|
-
if (!methodType) return methodType;
|
|
336
|
-
|
|
337
|
-
// Update the declaring type
|
|
338
|
-
if (Type.isFullyQualified(methodType.declaringType)) {
|
|
339
|
-
const declaringTypeFqn = Type.FullyQualified.getFullyQualifiedName(methodType.declaringType);
|
|
340
|
-
|
|
341
|
-
if (declaringTypeFqn === oldModule ||
|
|
342
|
-
declaringTypeFqn === oldFqn ||
|
|
343
|
-
declaringTypeFqn.startsWith(oldModule + '.')) {
|
|
344
|
-
|
|
345
|
-
// Need to update the declaring type
|
|
346
|
-
const updatedDeclaringType = this.updateType(methodType.declaringType) as Type.FullyQualified;
|
|
347
|
-
|
|
348
|
-
// Also update the method name if we're renaming the member
|
|
349
|
-
const updatedName = (oldMember !== 'default' && oldMember !== '*' &&
|
|
350
|
-
methodType.name === oldMember && newMember !== oldMember)
|
|
351
|
-
? newMember
|
|
352
|
-
: methodType.name;
|
|
353
|
-
|
|
354
|
-
// Type objects are marked as non-draftable, so we manually create new objects
|
|
355
|
-
return {
|
|
356
|
-
...methodType,
|
|
357
|
-
declaringType: updatedDeclaringType,
|
|
358
|
-
name: updatedName
|
|
359
|
-
} as Type.Method;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return methodType;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Update a Variable type if its owner references the old module
|
|
368
|
-
*/
|
|
369
|
-
private updateVariableType(variableType: Type.Variable): Type.Variable {
|
|
370
|
-
let changed = false;
|
|
371
|
-
let newOwner = variableType.owner;
|
|
372
|
-
let newInnerType = variableType.type;
|
|
373
|
-
|
|
374
|
-
// Update owner if it references the old module
|
|
375
|
-
if (variableType.owner) {
|
|
376
|
-
const updatedOwner = this.updateType(variableType.owner);
|
|
377
|
-
if (updatedOwner !== variableType.owner) {
|
|
378
|
-
newOwner = updatedOwner;
|
|
379
|
-
changed = true;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// Update inner type if it references the old module
|
|
384
|
-
const updatedInnerType = this.updateType(variableType.type);
|
|
385
|
-
if (updatedInnerType !== variableType.type) {
|
|
386
|
-
newInnerType = updatedInnerType!;
|
|
387
|
-
changed = true;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if (changed) {
|
|
391
|
-
// Type objects are marked as non-draftable, so we manually create new objects
|
|
392
|
-
return {
|
|
393
|
-
...variableType,
|
|
394
|
-
owner: newOwner,
|
|
395
|
-
type: newInnerType
|
|
396
|
-
} as Type.Variable;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return variableType;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Update a Parameterized type if its base type references the old module
|
|
404
|
-
*/
|
|
405
|
-
private updateParameterizedType(paramType: Type.Parameterized): Type.Parameterized {
|
|
406
|
-
let changed = false;
|
|
407
|
-
let newBaseType = paramType.type;
|
|
408
|
-
let newTypeParams = paramType.typeParameters;
|
|
409
|
-
|
|
410
|
-
// Update base type
|
|
411
|
-
if (Type.isFullyQualified(paramType.type)) {
|
|
412
|
-
const updatedType = this.updateType(paramType.type) as Type.FullyQualified;
|
|
413
|
-
if (updatedType !== paramType.type) {
|
|
414
|
-
newBaseType = updatedType;
|
|
415
|
-
changed = true;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// Update type parameters
|
|
420
|
-
const updatedParams = paramType.typeParameters.map(tp => this.updateType(tp)!);
|
|
421
|
-
if (updatedParams.some((p, i) => p !== paramType.typeParameters[i])) {
|
|
422
|
-
newTypeParams = updatedParams;
|
|
423
|
-
changed = true;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (changed) {
|
|
427
|
-
// Type objects are marked as non-draftable, so we manually create new objects
|
|
428
|
-
return {
|
|
429
|
-
...paramType,
|
|
430
|
-
type: newBaseType,
|
|
431
|
-
typeParameters: newTypeParams
|
|
432
|
-
} as Type.Parameterized;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
return paramType;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Update an Array type if its element type references the old module
|
|
440
|
-
*/
|
|
441
|
-
private updateArrayType(arrayType: Type.Array): Type.Array {
|
|
442
|
-
const updatedElemType = this.updateType(arrayType.elemType);
|
|
443
|
-
if (updatedElemType !== arrayType.elemType) {
|
|
444
|
-
// Type objects are marked as non-draftable, so we manually create new objects
|
|
445
|
-
return {
|
|
446
|
-
...arrayType,
|
|
447
|
-
elemType: updatedElemType!
|
|
448
|
-
} as Type.Array;
|
|
449
|
-
}
|
|
450
|
-
return arrayType;
|
|
451
|
-
}
|
|
452
122
|
}();
|
|
453
123
|
}
|
|
454
124
|
}
|
package/src/javascript/rpc.ts
CHANGED
|
@@ -229,6 +229,7 @@ class JavaScriptSender extends JavaScriptVisitor<RpcSendQueue> {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
override async visitPropertyAssignment(propertyAssignment: JS.PropertyAssignment, q: RpcSendQueue): Promise<J | undefined> {
|
|
232
|
+
await q.getAndSendList(propertyAssignment, el => el.modifiers, el => el.id, el => this.visit(el, q));
|
|
232
233
|
await q.getAndSend(propertyAssignment, el => el.name, el => this.visitRightPadded(el, q));
|
|
233
234
|
await q.getAndSend(propertyAssignment, el => el.assigmentToken);
|
|
234
235
|
await q.getAndSend(propertyAssignment, el => el.initializer, el => this.visit(el, q));
|
|
@@ -816,6 +817,7 @@ class JavaScriptReceiver extends JavaScriptVisitor<RpcReceiveQueue> {
|
|
|
816
817
|
|
|
817
818
|
override async visitPropertyAssignment(propertyAssignment: JS.PropertyAssignment, q: RpcReceiveQueue): Promise<J | undefined> {
|
|
818
819
|
const updates = {
|
|
820
|
+
modifiers: await q.receiveList(propertyAssignment.modifiers, el => this.visitDefined<J.Modifier>(el, q)),
|
|
819
821
|
name: await q.receive(propertyAssignment.name, el => this.visitRightPadded(el, q)),
|
|
820
822
|
assigmentToken: await q.receive(propertyAssignment.assigmentToken),
|
|
821
823
|
initializer: await q.receive(propertyAssignment.initializer, el => this.visitDefined<Expression>(el, q))
|