@openrewrite/rewrite 8.66.2 → 8.66.4
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/java/type.d.ts +6 -3
- package/dist/java/type.d.ts.map +1 -1
- package/dist/java/type.js +51 -5
- package/dist/java/type.js.map +1 -1
- package/dist/javascript/add-import.d.ts +18 -2
- package/dist/javascript/add-import.d.ts.map +1 -1
- package/dist/javascript/add-import.js +49 -15
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/format.d.ts +1 -0
- package/dist/javascript/format.d.ts.map +1 -1
- package/dist/javascript/format.js +45 -2
- package/dist/javascript/format.js.map +1 -1
- package/dist/javascript/parser.d.ts +2 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +7 -3
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/remove-import.d.ts +20 -2
- package/dist/javascript/remove-import.d.ts.map +1 -1
- package/dist/javascript/remove-import.js +121 -11
- package/dist/javascript/remove-import.js.map +1 -1
- package/dist/javascript/type-mapping.d.ts +17 -0
- package/dist/javascript/type-mapping.d.ts.map +1 -1
- package/dist/javascript/type-mapping.js +241 -44
- package/dist/javascript/type-mapping.js.map +1 -1
- package/dist/rpc/rewrite-rpc.js +1 -1
- package/dist/rpc/rewrite-rpc.js.map +1 -1
- package/dist/rpc/server.js +1 -1
- package/dist/rpc/server.js.map +1 -1
- package/dist/version.txt +1 -1
- package/package.json +1 -1
- package/src/java/type.ts +57 -5
- package/src/javascript/add-import.ts +55 -15
- package/src/javascript/format.ts +44 -3
- package/src/javascript/parser.ts +7 -3
- package/src/javascript/remove-import.ts +114 -11
- package/src/javascript/type-mapping.ts +282 -56
- package/src/rpc/rewrite-rpc.ts +1 -1
- package/src/rpc/server.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite-rpc.js","sourceRoot":"","sources":["../../src/rpc/rewrite-rpc.ts"],"names":[],"mappings":";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,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,GAAQ;QACR,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;CACJ"}
|
package/dist/rpc/server.js
CHANGED
|
@@ -79,7 +79,7 @@ function main() {
|
|
|
79
79
|
.option('--log-file <log_path>', 'log file path')
|
|
80
80
|
.option('--metrics-csv <metrics_csv_path>', 'metrics CSV output path')
|
|
81
81
|
.option('--trace-rpc-messages', 'trace RPC messages at the protocol level')
|
|
82
|
-
.option('--batch-size [size]', 'sets the batch size (default is 200)', s => parseInt(s, 10),
|
|
82
|
+
.option('--batch-size [size]', 'sets the batch size (default is 200)', s => parseInt(s, 10), 1000)
|
|
83
83
|
.option('--recipe-install-dir <install_dir>', 'Recipe installation directory (default is a temporary directory)')
|
|
84
84
|
.parse();
|
|
85
85
|
const options = program.opts();
|
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,uCAAyB;AACzB,yCAAkC;AAClC,6CAAgC;AAChC,6EAAuE;AAEvE,yDAAyD;AACzD,mBAAiB;AACjB,mBAAiB;AACjB,mBAAiB;AACjB,yBAAuB;AAE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;QAC5D,CAAC;QAED,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACrB,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE;YACpB,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACrC,CAAC,CAAC,CAAA;QAEF,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE;YACtB,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,0BAA0B;QAC1B,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;YACtC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,IAAI,wBAAU,CAAC,UAAU,EAAE;YACvB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,gBAAgB,EAAE,gBAAgB;SACrC,CAAC,CAAC;IACP,CAAC;CAAA;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
8.66.
|
|
1
|
+
8.66.4
|
package/package.json
CHANGED
package/src/java/type.ts
CHANGED
|
@@ -130,9 +130,9 @@ export namespace Type {
|
|
|
130
130
|
|
|
131
131
|
export namespace GenericTypeVariable {
|
|
132
132
|
export const enum Variance {
|
|
133
|
-
Covariant,
|
|
134
|
-
Contravariant,
|
|
135
|
-
Invariant
|
|
133
|
+
Covariant = "Covariant",
|
|
134
|
+
Contravariant = "Contravariant",
|
|
135
|
+
Invariant = "Invariant",
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -256,6 +256,18 @@ export namespace Type {
|
|
|
256
256
|
return type?.kind === Type.Kind.Parameterized;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
export function isGenericTypeVariable(type?: Type): type is Type.GenericTypeVariable {
|
|
260
|
+
return type?.kind === Type.Kind.GenericTypeVariable;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function isUnion(type?: Type): type is Type.Union {
|
|
264
|
+
return type?.kind === Type.Kind.Union;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function isIntersection(type?: Type): type is Type.Intersection {
|
|
268
|
+
return type?.kind === Type.Kind.Intersection;
|
|
269
|
+
}
|
|
270
|
+
|
|
259
271
|
export function isFullyQualified(type?: Type): type is Type.FullyQualified {
|
|
260
272
|
return type != null && (
|
|
261
273
|
type.kind === Type.Kind.Class ||
|
|
@@ -290,6 +302,8 @@ export namespace Type {
|
|
|
290
302
|
// Track type variable names and parameterized types to prevent infinite recursion
|
|
291
303
|
let typeVariableNameStack: Set<string> | null = null;
|
|
292
304
|
let parameterizedStack: Set<Type> | null = null;
|
|
305
|
+
let unionStack: Set<Type> | null = null;
|
|
306
|
+
let intersectionStack: Set<Type> | null = null;
|
|
293
307
|
|
|
294
308
|
export function signature(type: Type | undefined | null): string {
|
|
295
309
|
if (!type) {
|
|
@@ -349,7 +363,26 @@ export namespace Type {
|
|
|
349
363
|
}
|
|
350
364
|
case Type.Kind.Intersection: {
|
|
351
365
|
const intersection = type as Type.Intersection;
|
|
352
|
-
|
|
366
|
+
|
|
367
|
+
// Initialize stack if needed
|
|
368
|
+
if (intersectionStack === null) {
|
|
369
|
+
intersectionStack = new Set<Type>();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Check for recursion
|
|
373
|
+
if (intersectionStack.has(intersection)) {
|
|
374
|
+
return "<cyclic intersection>";
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Add to stack to track cycles
|
|
378
|
+
intersectionStack.add(intersection);
|
|
379
|
+
|
|
380
|
+
try {
|
|
381
|
+
return (intersection.bounds || []).map(b => signature(b)).join(" & ");
|
|
382
|
+
} finally {
|
|
383
|
+
// Remove from stack when done
|
|
384
|
+
intersectionStack.delete(intersection);
|
|
385
|
+
}
|
|
353
386
|
}
|
|
354
387
|
case Type.Kind.Method: {
|
|
355
388
|
const method = type as Type.Method;
|
|
@@ -386,7 +419,26 @@ export namespace Type {
|
|
|
386
419
|
}
|
|
387
420
|
case Type.Kind.Union: {
|
|
388
421
|
const union = type as Type.Union;
|
|
389
|
-
|
|
422
|
+
|
|
423
|
+
// Initialize stack if needed
|
|
424
|
+
if (unionStack === null) {
|
|
425
|
+
unionStack = new Set<Type>();
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// Check for recursion
|
|
429
|
+
if (unionStack.has(union)) {
|
|
430
|
+
return "<cyclic union>";
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Add to stack to track cycles
|
|
434
|
+
unionStack.add(union);
|
|
435
|
+
|
|
436
|
+
try {
|
|
437
|
+
return (union.bounds || []).map(b => signature(b)).join(" | ");
|
|
438
|
+
} finally {
|
|
439
|
+
// Remove from stack when done
|
|
440
|
+
unionStack.delete(union);
|
|
441
|
+
}
|
|
390
442
|
}
|
|
391
443
|
case Type.Kind.Unknown: {
|
|
392
444
|
return "<unknown>";
|
|
@@ -17,10 +17,14 @@ export interface AddImportOptions {
|
|
|
17
17
|
target: string;
|
|
18
18
|
|
|
19
19
|
/** Optionally, the specific member to import from the module.
|
|
20
|
-
* If not specified, adds a default import or namespace import
|
|
20
|
+
* If not specified, adds a default import or namespace import.
|
|
21
|
+
* Special values:
|
|
22
|
+
* - 'default': Adds a default import from the target module.
|
|
23
|
+
* When using 'default', the `alias` parameter is required. */
|
|
21
24
|
member?: string;
|
|
22
25
|
|
|
23
|
-
/** Optional alias for the imported member
|
|
26
|
+
/** Optional alias for the imported member.
|
|
27
|
+
* Required when member is 'default'. */
|
|
24
28
|
alias?: string;
|
|
25
29
|
|
|
26
30
|
/** If true, only add the import if the member is actually used in the file. Default: true */
|
|
@@ -34,6 +38,18 @@ export interface AddImportOptions {
|
|
|
34
38
|
* Register an AddImport visitor to add an import statement to a JavaScript/TypeScript file
|
|
35
39
|
* @param visitor The visitor to add the import addition to
|
|
36
40
|
* @param options Configuration options for the import to add
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Add a named import
|
|
44
|
+
* maybeAddImport(visitor, { target: 'fs', member: 'readFile' });
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Add a default import using the 'default' member specifier
|
|
48
|
+
* maybeAddImport(visitor, { target: 'react', member: 'default', alias: 'React' });
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Add a default import (legacy way, without specifying member)
|
|
52
|
+
* maybeAddImport(visitor, { target: 'react', alias: 'React' });
|
|
37
53
|
*/
|
|
38
54
|
export function maybeAddImport(
|
|
39
55
|
visitor: JavaScriptVisitor<any>,
|
|
@@ -59,6 +75,12 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
59
75
|
|
|
60
76
|
constructor(options: AddImportOptions) {
|
|
61
77
|
super();
|
|
78
|
+
|
|
79
|
+
// Validate that alias is provided when member is 'default'
|
|
80
|
+
if (options.member === 'default' && !options.alias) {
|
|
81
|
+
throw new Error("When member is 'default', the alias parameter is required");
|
|
82
|
+
}
|
|
83
|
+
|
|
62
84
|
this.target = options.target;
|
|
63
85
|
this.member = options.member;
|
|
64
86
|
this.alias = options.alias;
|
|
@@ -114,8 +136,8 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
114
136
|
|
|
115
137
|
// For .mjs or TypeScript, prefer ES6
|
|
116
138
|
if (sourcePath.endsWith('.mjs') || isTypeScript) {
|
|
117
|
-
// If we're importing a member, use named imports
|
|
118
|
-
if (this.member !== undefined) {
|
|
139
|
+
// If we're importing a member (but not 'default'), use named imports
|
|
140
|
+
if (this.member !== undefined && this.member !== 'default') {
|
|
119
141
|
return ImportStyle.ES6Named;
|
|
120
142
|
}
|
|
121
143
|
// Otherwise default import
|
|
@@ -175,8 +197,8 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
175
197
|
return ImportStyle.CommonJS;
|
|
176
198
|
}
|
|
177
199
|
|
|
178
|
-
// If importing a member, prefer named imports if they exist in the file
|
|
179
|
-
if (this.member !== undefined) {
|
|
200
|
+
// If importing a member (but not 'default'), prefer named imports if they exist in the file
|
|
201
|
+
if (this.member !== undefined && this.member !== 'default') {
|
|
180
202
|
if (hasNamedImports) {
|
|
181
203
|
return ImportStyle.ES6Named;
|
|
182
204
|
}
|
|
@@ -186,7 +208,7 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
186
208
|
}
|
|
187
209
|
|
|
188
210
|
// For default/whole module imports
|
|
189
|
-
if (this.member === undefined) {
|
|
211
|
+
if (this.member === undefined || this.member === 'default') {
|
|
190
212
|
if (hasNamespaceImports) {
|
|
191
213
|
return ImportStyle.ES6Namespace;
|
|
192
214
|
}
|
|
@@ -195,8 +217,10 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
195
217
|
}
|
|
196
218
|
}
|
|
197
219
|
|
|
198
|
-
// Default to named imports for members, default imports for modules
|
|
199
|
-
return this.member !== undefined
|
|
220
|
+
// Default to named imports for members (except 'default'), default imports for modules
|
|
221
|
+
return (this.member !== undefined && this.member !== 'default')
|
|
222
|
+
? ImportStyle.ES6Named
|
|
223
|
+
: ImportStyle.ES6Default;
|
|
200
224
|
}
|
|
201
225
|
|
|
202
226
|
/**
|
|
@@ -270,7 +294,8 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
270
294
|
const importStyle = this.determineImportStyle(compilationUnit);
|
|
271
295
|
|
|
272
296
|
// For ES6 named imports, check if we can merge into an existing import from the same module
|
|
273
|
-
|
|
297
|
+
// Don't try to merge default imports (member === 'default')
|
|
298
|
+
if (importStyle === ImportStyle.ES6Named && this.member !== undefined && this.member !== 'default') {
|
|
274
299
|
const mergedCu = await this.tryMergeIntoExistingImport(compilationUnit, p);
|
|
275
300
|
if (mergedCu !== compilationUnit) {
|
|
276
301
|
return mergedCu;
|
|
@@ -472,9 +497,18 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
472
497
|
}
|
|
473
498
|
|
|
474
499
|
// Check if the specific member or default import already exists
|
|
475
|
-
if (this.member === undefined) {
|
|
500
|
+
if (this.member === undefined || this.member === 'default') {
|
|
476
501
|
// We're adding a default import, check if one exists
|
|
477
|
-
|
|
502
|
+
// For member === 'default', also verify the alias matches if specified
|
|
503
|
+
if (importClause.name === undefined) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
// If we have an alias, check that it matches
|
|
507
|
+
if (this.alias && importClause.name.element?.kind === J.Kind.Identifier) {
|
|
508
|
+
const existingName = (importClause.name.element as J.Identifier).simpleName;
|
|
509
|
+
return existingName === this.alias;
|
|
510
|
+
}
|
|
511
|
+
return true;
|
|
478
512
|
} else {
|
|
479
513
|
// We're adding a named import, check if it exists
|
|
480
514
|
const namedBindings = importClause.namedBindings;
|
|
@@ -531,10 +565,15 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
531
565
|
|
|
532
566
|
// Check if the variable name matches what we're trying to add
|
|
533
567
|
const pattern = namedVar.name;
|
|
534
|
-
if (this.member === undefined && pattern?.kind === J.Kind.Identifier) {
|
|
568
|
+
if ((this.member === undefined || this.member === 'default') && pattern?.kind === J.Kind.Identifier) {
|
|
535
569
|
// Default import style: const fs = require('fs')
|
|
570
|
+
// For member === 'default', also check the alias matches if specified
|
|
571
|
+
if (this.alias) {
|
|
572
|
+
const varName = (pattern as J.Identifier).simpleName;
|
|
573
|
+
return varName === this.alias;
|
|
574
|
+
}
|
|
536
575
|
return true;
|
|
537
|
-
} else if (this.member !== undefined && pattern?.kind === JS.Kind.ObjectBindingPattern) {
|
|
576
|
+
} else if (this.member !== undefined && this.member !== 'default' && pattern?.kind === JS.Kind.ObjectBindingPattern) {
|
|
538
577
|
// Destructured import: const { member } = require('module')
|
|
539
578
|
const objectPattern = pattern as JS.ObjectBindingPattern;
|
|
540
579
|
for (const elem of objectPattern.bindings.elements) {
|
|
@@ -636,8 +675,9 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
636
675
|
|
|
637
676
|
let importClause: JS.ImportClause | undefined;
|
|
638
677
|
|
|
639
|
-
if (this.member === undefined) {
|
|
678
|
+
if (this.member === undefined || this.member === 'default') {
|
|
640
679
|
// Default import: import target from 'module'
|
|
680
|
+
// or: import alias from 'module' (when member === 'default')
|
|
641
681
|
const defaultName: J.Identifier = {
|
|
642
682
|
id: randomId(),
|
|
643
683
|
kind: J.Kind.Identifier,
|
package/src/javascript/format.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {isJavaScript, JS} from "./tree";
|
|
16
|
+
import {isJavaScript, JS, JSX} from "./tree";
|
|
17
17
|
import {JavaScriptVisitor} from "./visitor";
|
|
18
18
|
import {Comment, isJava, J, Statement} from "../java";
|
|
19
19
|
import {Draft, produce} from "immer";
|
|
@@ -60,6 +60,7 @@ export class AutoformatVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
60
60
|
return undefined;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
|
|
63
64
|
return t;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
@@ -1122,7 +1123,9 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
1122
1123
|
let indentShouldIncrease =
|
|
1123
1124
|
tree.kind === J.Kind.Block
|
|
1124
1125
|
|| this.cursor.parent?.parent?.parent?.value.kind == J.Kind.Case
|
|
1125
|
-
|| (tree.kind === JS.Kind.StatementExpression && (tree as JS.StatementExpression).statement.kind == J.Kind.MethodDeclaration && tree.prefix.whitespace.includes("\n"))
|
|
1126
|
+
|| (tree.kind === JS.Kind.StatementExpression && (tree as JS.StatementExpression).statement.kind == J.Kind.MethodDeclaration && tree.prefix.whitespace.includes("\n"))
|
|
1127
|
+
|| tree.kind === JS.Kind.JsxTag;
|
|
1128
|
+
|
|
1126
1129
|
|
|
1127
1130
|
const previousIndent = this.currentIndent;
|
|
1128
1131
|
|
|
@@ -1132,6 +1135,10 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
1132
1135
|
this.cursor.messages.set("indentToUse", this.currentIndent + this.singleIndent);
|
|
1133
1136
|
}
|
|
1134
1137
|
|
|
1138
|
+
if (tree.kind === JS.Kind.JsxTag) {
|
|
1139
|
+
this.cursor.messages.set("jsxTagIndent", this.currentIndent);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1135
1142
|
if (tree.kind === J.Kind.IfElse && this.cursor.messages.get("else-indent") !== undefined) {
|
|
1136
1143
|
this.cursor.messages.set("indentToUse", this.cursor.messages.get("else-indent"));
|
|
1137
1144
|
this.cursor.messages.delete("else-indent");
|
|
@@ -1170,6 +1177,8 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
1170
1177
|
if (forLoop.body.element.kind !== J.Kind.Block) {
|
|
1171
1178
|
indentShouldIncrease = true;
|
|
1172
1179
|
}
|
|
1180
|
+
} else if (tree.kind === JS.Kind.JsxTag) {
|
|
1181
|
+
indentShouldIncrease = true;
|
|
1173
1182
|
}
|
|
1174
1183
|
if (indentShouldIncrease) {
|
|
1175
1184
|
this.cursor.messages.set("indentToUse", this.currentIndent + this.singleIndent);
|
|
@@ -1178,6 +1187,20 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
1178
1187
|
return ret;
|
|
1179
1188
|
}
|
|
1180
1189
|
|
|
1190
|
+
override async visitSpace(space: J.Space, p: P): Promise<J.Space> {
|
|
1191
|
+
const ret = await super.visitSpace(space, p);
|
|
1192
|
+
if (space.whitespace.includes("\n")) {
|
|
1193
|
+
let parentCursor = this.cursor.parent;
|
|
1194
|
+
while (parentCursor != null && parentCursor.value.kind !== JS.Kind.JsxTag) {
|
|
1195
|
+
parentCursor = parentCursor.parent;
|
|
1196
|
+
}
|
|
1197
|
+
if (parentCursor && parentCursor.value.kind === JS.Kind.JsxTag) {
|
|
1198
|
+
parentCursor.messages.set("jsxTagWithNewline", true)
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
return ret;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1181
1204
|
async visit<R extends J>(tree: Tree, p: P, parent?: Cursor): Promise<R | undefined> {
|
|
1182
1205
|
if (this.cursor?.getNearestMessage("stop") != null) {
|
|
1183
1206
|
return tree as R;
|
|
@@ -1233,6 +1256,24 @@ export class TabsAndIndentsVisitor<P> extends JavaScriptVisitor<P> {
|
|
|
1233
1256
|
if (this.stopAfter != null && isScope(this.stopAfter, tree)) {
|
|
1234
1257
|
this.cursor?.root.messages.set("stop", true);
|
|
1235
1258
|
}
|
|
1236
|
-
|
|
1259
|
+
let treeChanged = tree;
|
|
1260
|
+
if (tree.kind == JS.Kind.JsxTag) {
|
|
1261
|
+
const tag = tree as JSX.Tag;
|
|
1262
|
+
if (this.cursor.messages.get("jsxTagWithNewline")) {
|
|
1263
|
+
const jsxTagIndent = this.cursor.messages.get("jsxTagIndent");
|
|
1264
|
+
if (jsxTagIndent) {
|
|
1265
|
+
this.cursor.messages.delete("jsxTagWithNewline");
|
|
1266
|
+
treeChanged = produce(tag, draft => {
|
|
1267
|
+
if (draft.children) {
|
|
1268
|
+
const lastChild = draft.children[draft.children.length - 1];
|
|
1269
|
+
if (lastChild.kind === J.Kind.Literal) {
|
|
1270
|
+
lastChild.prefix.whitespace = this.combineIndent(lastChild.prefix.whitespace, jsxTagIndent);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
return super.postVisit(treeChanged, p);
|
|
1237
1278
|
}
|
|
1238
1279
|
}
|
package/src/javascript/parser.ts
CHANGED
|
@@ -257,6 +257,10 @@ export class JavaScriptParser extends Parser {
|
|
|
257
257
|
|
|
258
258
|
const typeChecker = program.getTypeChecker();
|
|
259
259
|
|
|
260
|
+
// Create a single JavaScriptTypeMapping instance to be shared across all files in this parse batch.
|
|
261
|
+
// This ensures that TypeScript types with the same type.id map to the same Type instance,
|
|
262
|
+
// preventing duplicate Type.Class, Type.Parameterized, etc. instances.
|
|
263
|
+
const typeMapping = new JavaScriptTypeMapping(typeChecker);
|
|
260
264
|
|
|
261
265
|
for (const input of inputFiles.values()) {
|
|
262
266
|
const filePath = parserInputFile(input);
|
|
@@ -280,7 +284,7 @@ export class JavaScriptParser extends Parser {
|
|
|
280
284
|
|
|
281
285
|
try {
|
|
282
286
|
yield produce(
|
|
283
|
-
new JavaScriptParserVisitor(sourceFile, this.relativePath(input),
|
|
287
|
+
new JavaScriptParserVisitor(sourceFile, this.relativePath(input), typeMapping)
|
|
284
288
|
.visit(sourceFile) as SourceFile,
|
|
285
289
|
draft => {
|
|
286
290
|
if (this.styles) {
|
|
@@ -310,8 +314,8 @@ export class JavaScriptParserVisitor {
|
|
|
310
314
|
constructor(
|
|
311
315
|
private readonly sourceFile: ts.SourceFile,
|
|
312
316
|
private readonly sourcePath: string,
|
|
313
|
-
|
|
314
|
-
this.typeMapping =
|
|
317
|
+
typeMapping: JavaScriptTypeMapping) {
|
|
318
|
+
this.typeMapping = typeMapping;
|
|
315
319
|
}
|
|
316
320
|
|
|
317
321
|
visit = (node: ts.Node): any => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {JavaScriptVisitor} from "./visitor";
|
|
2
2
|
import {J} from "../java";
|
|
3
|
-
import {JS} from "./tree";
|
|
3
|
+
import {JS, JSX} from "./tree";
|
|
4
4
|
import {mapAsync} from "../util";
|
|
5
5
|
import {ElementRemovalFormatter} from "../java/formatting-utils";
|
|
6
6
|
|
|
@@ -9,7 +9,22 @@ import {ElementRemovalFormatter} from "../java/formatting-utils";
|
|
|
9
9
|
* @param target Either the module name (e.g., 'fs') to remove specific members from,
|
|
10
10
|
* or the name of the import to remove entirely
|
|
11
11
|
* @param member Optionally, the specific member to remove from the import.
|
|
12
|
-
* If not specified, removes the import matching `target
|
|
12
|
+
* If not specified, removes the import matching `target`.
|
|
13
|
+
* Special values:
|
|
14
|
+
* - 'default': Removes the default import from the target module if unused,
|
|
15
|
+
* regardless of its local name (e.g., `import React from 'react'`)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Remove a named import if unused
|
|
19
|
+
* maybeRemoveImport(visitor, 'fs', 'readFile');
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Remove the default import from 'react' if unused (regardless of local name)
|
|
23
|
+
* maybeRemoveImport(visitor, 'react', 'default');
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Remove an import by name if unused (no module specified)
|
|
27
|
+
* maybeRemoveImport(visitor, 'fs');
|
|
13
28
|
*/
|
|
14
29
|
export function maybeRemoveImport(visitor: JavaScriptVisitor<any>, target: string, member?: string) {
|
|
15
30
|
for (const v of visitor.afterVisit || []) {
|
|
@@ -33,7 +48,10 @@ export class RemoveImport<P> extends JavaScriptVisitor<P> {
|
|
|
33
48
|
* @param target Either the module name (e.g., 'fs') to remove specific members from,
|
|
34
49
|
* or the name of the import to remove entirely
|
|
35
50
|
* @param member Optionally, the specific member to remove from the import.
|
|
36
|
-
* If not specified, removes the import matching `target
|
|
51
|
+
* If not specified, removes the import matching `target`.
|
|
52
|
+
* Special values:
|
|
53
|
+
* - 'default': Removes the default import from the target module if unused,
|
|
54
|
+
* regardless of its local name
|
|
37
55
|
*/
|
|
38
56
|
constructor(readonly target: string,
|
|
39
57
|
readonly member?: string) {
|
|
@@ -88,13 +106,13 @@ export class RemoveImport<P> extends JavaScriptVisitor<P> {
|
|
|
88
106
|
private async updateImportClause(
|
|
89
107
|
jsImport: JS.Import,
|
|
90
108
|
importClause: JS.ImportClause,
|
|
91
|
-
updateFn: (draft: any) => void
|
|
109
|
+
updateFn: (draft: any) => void | Promise<void>,
|
|
92
110
|
p: P
|
|
93
111
|
): Promise<JS.Import> {
|
|
94
112
|
return this.produceJavaScript<JS.Import>(jsImport, p, async draft => {
|
|
95
113
|
if (draft.importClause) {
|
|
96
114
|
draft.importClause = await this.produceJavaScript<JS.ImportClause>(
|
|
97
|
-
importClause, p, async (clauseDraft: any) => updateFn(clauseDraft)
|
|
115
|
+
importClause, p, async (clauseDraft: any) => await updateFn(clauseDraft)
|
|
98
116
|
);
|
|
99
117
|
}
|
|
100
118
|
});
|
|
@@ -226,14 +244,34 @@ export class RemoveImport<P> extends JavaScriptVisitor<P> {
|
|
|
226
244
|
const identifier = defaultName as J.Identifier;
|
|
227
245
|
const name = identifier.simpleName;
|
|
228
246
|
|
|
229
|
-
if
|
|
247
|
+
// Check if we should remove this default import
|
|
248
|
+
let shouldRemove = false;
|
|
249
|
+
if (this.member === 'default') {
|
|
250
|
+
// Special case: member 'default' means remove any default import from the target module if unused
|
|
251
|
+
shouldRemove = !usedIdentifiers.has(name) && !usedTypes.has(name);
|
|
252
|
+
} else {
|
|
253
|
+
// Regular case: check if the import name matches the removal criteria
|
|
254
|
+
shouldRemove = this.shouldRemoveImport(name, usedIdentifiers, usedTypes);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (shouldRemove) {
|
|
230
258
|
// If there are no named imports, remove the entire import
|
|
231
259
|
if (!importClause.namedBindings) {
|
|
232
260
|
return undefined;
|
|
233
261
|
}
|
|
234
|
-
// Otherwise, just remove the default import
|
|
235
|
-
return this.updateImportClause(jsImport, importClause, draft => {
|
|
262
|
+
// Otherwise, just remove the default import and fix spacing
|
|
263
|
+
return this.updateImportClause(jsImport, importClause, async draft => {
|
|
236
264
|
draft.name = undefined;
|
|
265
|
+
// When removing the default import, we need to transfer its prefix to namedBindings
|
|
266
|
+
// to maintain proper spacing (the default import's prefix is typically empty)
|
|
267
|
+
if (draft.namedBindings && importClause.name?.element) {
|
|
268
|
+
const updatedBindings = await this.produceJavaScript(
|
|
269
|
+
importClause.namedBindings, p, async bindingsDraft => {
|
|
270
|
+
bindingsDraft.prefix = importClause.name!.element!.prefix;
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
draft.namedBindings = updatedBindings;
|
|
274
|
+
}
|
|
237
275
|
}, p);
|
|
238
276
|
}
|
|
239
277
|
}
|
|
@@ -691,7 +729,9 @@ export class RemoveImport<P> extends JavaScriptVisitor<P> {
|
|
|
691
729
|
|
|
692
730
|
if (Array.isArray(params)) {
|
|
693
731
|
for (const p of params) {
|
|
694
|
-
|
|
732
|
+
// Array elements might be RightPadded, so unwrap them
|
|
733
|
+
const elem = (p as any).element || p;
|
|
734
|
+
await this.collectUsedIdentifiers(elem, usedIdentifiers, usedTypes);
|
|
695
735
|
}
|
|
696
736
|
} else if (params.elements) {
|
|
697
737
|
for (const p of params.elements) {
|
|
@@ -913,6 +953,39 @@ export class RemoveImport<P> extends JavaScriptVisitor<P> {
|
|
|
913
953
|
if (lambda.body) {
|
|
914
954
|
await this.collectUsedIdentifiers(lambda.body, usedIdentifiers, usedTypes);
|
|
915
955
|
}
|
|
956
|
+
} else if (node.kind === JS.Kind.JsxTag) {
|
|
957
|
+
// Handle JSX tags like <div>content</div>
|
|
958
|
+
const jsxTag = node as JSX.Tag;
|
|
959
|
+
// Check attributes
|
|
960
|
+
if (jsxTag.attributes) {
|
|
961
|
+
for (const attr of jsxTag.attributes) {
|
|
962
|
+
if (attr.element) {
|
|
963
|
+
await this.collectUsedIdentifiers(attr.element, usedIdentifiers, usedTypes);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
// Check children
|
|
968
|
+
if (jsxTag.children) {
|
|
969
|
+
for (const child of jsxTag.children) {
|
|
970
|
+
if (child) {
|
|
971
|
+
await this.collectUsedIdentifiers(child, usedIdentifiers, usedTypes);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
} else if (node.kind === JS.Kind.JsxEmbeddedExpression) {
|
|
976
|
+
// Handle JSX embedded expressions like {React.version}
|
|
977
|
+
const embedded = node as JSX.EmbeddedExpression;
|
|
978
|
+
// The expression is wrapped in RightPadded, so unwrap it
|
|
979
|
+
const expr = embedded.expression?.element || embedded.expression;
|
|
980
|
+
if (expr) {
|
|
981
|
+
await this.collectUsedIdentifiers(expr, usedIdentifiers, usedTypes);
|
|
982
|
+
}
|
|
983
|
+
} else if (node.kind === JS.Kind.JsxAttribute) {
|
|
984
|
+
// Handle JSX attributes like onClick={handler}
|
|
985
|
+
const jsxAttr = node as any;
|
|
986
|
+
if (jsxAttr.value) {
|
|
987
|
+
await this.collectUsedIdentifiers(jsxAttr.value, usedIdentifiers, usedTypes);
|
|
988
|
+
}
|
|
916
989
|
} else if ((node as any).statements) {
|
|
917
990
|
// Generic handler for nodes with statements
|
|
918
991
|
await this.traverseStatements((node as any).statements, usedIdentifiers, usedTypes);
|
|
@@ -934,8 +1007,11 @@ export class RemoveImport<P> extends JavaScriptVisitor<P> {
|
|
|
934
1007
|
usedTypes.add((typeExpr as J.Identifier).simpleName);
|
|
935
1008
|
} else if (typeExpr.kind === J.Kind.ParameterizedType) {
|
|
936
1009
|
const paramType = typeExpr as J.ParameterizedType;
|
|
937
|
-
//
|
|
938
|
-
|
|
1010
|
+
// First, collect usage from the base type (e.g., React.Ref from React.Ref<T>)
|
|
1011
|
+
if (paramType.class) {
|
|
1012
|
+
await this.collectTypeUsage(paramType.class, usedTypes);
|
|
1013
|
+
}
|
|
1014
|
+
// Then collect usage from type parameters (e.g., HTMLButtonElement from React.Ref<HTMLButtonElement>)
|
|
939
1015
|
if (paramType.typeParameters) {
|
|
940
1016
|
for (const typeParam of paramType.typeParameters.elements) {
|
|
941
1017
|
if (typeParam.element) {
|
|
@@ -943,6 +1019,33 @@ export class RemoveImport<P> extends JavaScriptVisitor<P> {
|
|
|
943
1019
|
}
|
|
944
1020
|
}
|
|
945
1021
|
}
|
|
1022
|
+
} else if (typeExpr.kind === J.Kind.FieldAccess) {
|
|
1023
|
+
// Handle qualified names in type positions like React.Ref
|
|
1024
|
+
const fieldAccess = typeExpr as J.FieldAccess;
|
|
1025
|
+
if (fieldAccess.target?.kind === J.Kind.Identifier) {
|
|
1026
|
+
usedTypes.add((fieldAccess.target as J.Identifier).simpleName);
|
|
1027
|
+
} else if (fieldAccess.target) {
|
|
1028
|
+
// Recursively handle nested field accesses
|
|
1029
|
+
await this.collectTypeUsage(fieldAccess.target, usedTypes);
|
|
1030
|
+
}
|
|
1031
|
+
} else if (typeExpr.kind === JS.Kind.Intersection) {
|
|
1032
|
+
// Handle intersection types like ButtonProps & { ref?: React.Ref<HTMLButtonElement> }
|
|
1033
|
+
const intersection = typeExpr as JS.Intersection;
|
|
1034
|
+
for (const typeElem of intersection.types) {
|
|
1035
|
+
if (typeElem.element) {
|
|
1036
|
+
await this.collectTypeUsage(typeElem.element, usedTypes);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
} else if (typeExpr.kind === JS.Kind.TypeLiteral) {
|
|
1040
|
+
// Handle type literals like { ref?: React.Ref<HTMLButtonElement> }
|
|
1041
|
+
const typeLiteral = typeExpr as JS.TypeLiteral;
|
|
1042
|
+
// TypeLiteral members are in a Block, which contains statements
|
|
1043
|
+
for (const stmt of typeLiteral.members.statements) {
|
|
1044
|
+
if (stmt.element) {
|
|
1045
|
+
// Each statement is typically a VariableDeclarations representing a property
|
|
1046
|
+
await this.collectUsedIdentifiers(stmt.element, new Set(), usedTypes);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
946
1049
|
} else if (typeExpr.kind === JS.Kind.TypeQuery) {
|
|
947
1050
|
// Handle typeof type queries like: const x: typeof util
|
|
948
1051
|
const typeQuery = typeExpr as JS.TypeQuery;
|