@openrewrite/rewrite 8.91.1 → 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 +127 -38
- package/dist/javascript/add-import.d.ts.map +1 -1
- package/dist/javascript/add-import.js +684 -195
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/amd.d.ts +148 -0
- package/dist/javascript/amd.d.ts.map +1 -0
- package/dist/javascript/amd.js +802 -0
- package/dist/javascript/amd.js.map +1 -0
- package/dist/javascript/binding.d.ts +102 -0
- package/dist/javascript/binding.d.ts.map +1 -0
- package/dist/javascript/binding.js +308 -0
- package/dist/javascript/binding.js.map +1 -0
- 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 +8 -1
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +46 -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 +7 -9
- package/dist/javascript/parser-utils.js.map +1 -1
- package/dist/javascript/parser.d.ts +7 -1
- package/dist/javascript/parser.d.ts.map +1 -1
- package/dist/javascript/parser.js +55 -4
- 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 +4 -3
- package/dist/javascript/recipes/change-import.d.ts.map +1 -1
- package/dist/javascript/recipes/change-import.js +12 -504
- package/dist/javascript/recipes/change-import.js.map +1 -1
- package/dist/javascript/remove-import.d.ts +2 -28
- package/dist/javascript/remove-import.d.ts.map +1 -1
- package/dist/javascript/remove-import.js +19 -57
- package/dist/javascript/remove-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 +82 -0
- package/dist/javascript/scope.d.ts.map +1 -0
- package/dist/javascript/scope.js +476 -0
- package/dist/javascript/scope.js.map +1 -0
- package/dist/javascript/templating/bindings.d.ts +0 -11
- package/dist/javascript/templating/bindings.d.ts.map +1 -1
- package/dist/javascript/templating/bindings.js +2 -49
- package/dist/javascript/templating/bindings.js.map +1 -1
- package/dist/javascript/templating/comparator.d.ts +12 -0
- package/dist/javascript/templating/comparator.d.ts.map +1 -1
- package/dist/javascript/templating/comparator.js +68 -14
- package/dist/javascript/templating/comparator.js.map +1 -1
- package/dist/javascript/templating/engine.d.ts +22 -4
- package/dist/javascript/templating/engine.d.ts.map +1 -1
- package/dist/javascript/templating/engine.js +68 -24
- package/dist/javascript/templating/engine.js.map +1 -1
- package/dist/javascript/templating/index.d.ts +1 -1
- package/dist/javascript/templating/index.d.ts.map +1 -1
- package/dist/javascript/templating/index.js.map +1 -1
- package/dist/javascript/templating/pattern.d.ts.map +1 -1
- package/dist/javascript/templating/pattern.js +2 -2
- package/dist/javascript/templating/pattern.js.map +1 -1
- package/dist/javascript/templating/placeholder-replacement.d.ts +2 -0
- package/dist/javascript/templating/placeholder-replacement.d.ts.map +1 -1
- package/dist/javascript/templating/placeholder-replacement.js +10 -5
- package/dist/javascript/templating/placeholder-replacement.js.map +1 -1
- package/dist/javascript/templating/precedence.d.ts +12 -4
- package/dist/javascript/templating/precedence.d.ts.map +1 -1
- package/dist/javascript/templating/precedence.js +18 -11
- package/dist/javascript/templating/precedence.js.map +1 -1
- package/dist/javascript/templating/rewrite.d.ts.map +1 -1
- package/dist/javascript/templating/rewrite.js +7 -1
- package/dist/javascript/templating/rewrite.js.map +1 -1
- package/dist/javascript/templating/template.d.ts +7 -1
- package/dist/javascript/templating/template.d.ts.map +1 -1
- package/dist/javascript/templating/template.js +54 -28
- package/dist/javascript/templating/template.js.map +1 -1
- package/dist/javascript/templating/types.d.ts +15 -18
- package/dist/javascript/templating/types.d.ts.map +1 -1
- package/dist/javascript/templating/utils.d.ts +1 -1
- package/dist/javascript/templating/utils.d.ts.map +1 -1
- package/dist/javascript/templating/utils.js +3 -2
- package/dist/javascript/templating/utils.js.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 +2 -2
- package/src/execution.ts +23 -0
- package/src/javascript/add-import.ts +753 -238
- package/src/javascript/amd.ts +954 -0
- package/src/javascript/binding.ts +435 -0
- 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 +19 -1
- package/src/javascript/parser-utils.ts +7 -11
- package/src/javascript/parser.ts +78 -6
- package/src/javascript/print.ts +10 -0
- package/src/javascript/recipes/change-import.ts +13 -593
- package/src/javascript/remove-import.ts +20 -56
- package/src/javascript/rpc.ts +2 -0
- package/src/javascript/scope.ts +517 -0
- package/src/javascript/templating/bindings.ts +2 -55
- package/src/javascript/templating/comparator.ts +81 -16
- package/src/javascript/templating/engine.ts +107 -38
- package/src/javascript/templating/index.ts +0 -1
- package/src/javascript/templating/pattern.ts +4 -2
- package/src/javascript/templating/placeholder-replacement.ts +16 -6
- package/src/javascript/templating/precedence.ts +21 -13
- package/src/javascript/templating/rewrite.ts +9 -1
- package/src/javascript/templating/template.ts +68 -29
- package/src/javascript/templating/types.ts +17 -18
- package/src/javascript/templating/utils.ts +4 -2
- 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
package/dist/execution.d.ts
CHANGED
|
@@ -2,9 +2,17 @@ export declare class ExecutionContext {
|
|
|
2
2
|
readonly messages: {
|
|
3
3
|
[key: string | symbol]: any;
|
|
4
4
|
};
|
|
5
|
+
/** Mirrors `org.openrewrite.ExecutionContext.REQUIRE_PRINT_EQUALS_INPUT`. */
|
|
6
|
+
static readonly REQUIRE_PRINT_EQUALS_INPUT = "org.openrewrite.requirePrintEqualsInput";
|
|
5
7
|
readonly kind: string;
|
|
6
8
|
constructor(messages?: {
|
|
7
9
|
[key: string | symbol]: any;
|
|
8
10
|
});
|
|
11
|
+
/**
|
|
12
|
+
* Option maps are loosely typed across peers, so a value that arrived as a string counts the same as
|
|
13
|
+
* its boolean form. The spellings accepted are Go's `strconv.ParseBool`, which peers parse with;
|
|
14
|
+
* anything else falls back to `defaultValue`.
|
|
15
|
+
*/
|
|
16
|
+
getBoolean(key: string, defaultValue: boolean): boolean;
|
|
9
17
|
}
|
|
10
18
|
//# sourceMappingURL=execution.d.ts.map
|
package/dist/execution.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAiBA,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAiBA,qBAAa,gBAAgB;aAMG,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAA;KAAE;IALrE,6EAA6E;IAC7E,MAAM,CAAC,QAAQ,CAAC,0BAA0B,6CAA6C;IAEvF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAA6C;gBAEtC,QAAQ,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAA;KAAO;IAG1E;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO;CAc1D"}
|
package/dist/execution.js
CHANGED
|
@@ -22,8 +22,39 @@ class ExecutionContext {
|
|
|
22
22
|
this.messages = messages;
|
|
23
23
|
this.kind = "org.openrewrite.InMemoryExecutionContext";
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Option maps are loosely typed across peers, so a value that arrived as a string counts the same as
|
|
27
|
+
* its boolean form. The spellings accepted are Go's `strconv.ParseBool`, which peers parse with;
|
|
28
|
+
* anything else falls back to `defaultValue`.
|
|
29
|
+
*/
|
|
30
|
+
getBoolean(key, defaultValue) {
|
|
31
|
+
const value = this.messages[key];
|
|
32
|
+
if (typeof value === "boolean") {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
switch (value) {
|
|
36
|
+
case "1":
|
|
37
|
+
case "t":
|
|
38
|
+
case "T":
|
|
39
|
+
case "true":
|
|
40
|
+
case "TRUE":
|
|
41
|
+
case "True":
|
|
42
|
+
return true;
|
|
43
|
+
case "0":
|
|
44
|
+
case "f":
|
|
45
|
+
case "F":
|
|
46
|
+
case "false":
|
|
47
|
+
case "FALSE":
|
|
48
|
+
case "False":
|
|
49
|
+
return false;
|
|
50
|
+
default:
|
|
51
|
+
return defaultValue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
25
54
|
}
|
|
26
55
|
exports.ExecutionContext = ExecutionContext;
|
|
56
|
+
/** Mirrors `org.openrewrite.ExecutionContext.REQUIRE_PRINT_EQUALS_INPUT`. */
|
|
57
|
+
ExecutionContext.REQUIRE_PRINT_EQUALS_INPUT = "org.openrewrite.requirePrintEqualsInput";
|
|
27
58
|
const executionContextCodec = {
|
|
28
59
|
rpcNew() {
|
|
29
60
|
return new ExecutionContext();
|
package/dist/execution.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,+BAAyE;AAEzE,MAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,+BAAyE;AAEzE,MAAa,gBAAgB;IAMzB,YAA4B,WAA4C,EAAE;QAA9C,aAAQ,GAAR,QAAQ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
4
|
export type QuoteChar = "'" | '"';
|
|
5
5
|
export declare enum ImportStyle {
|
|
@@ -10,8 +10,9 @@ export declare enum ImportStyle {
|
|
|
10
10
|
}
|
|
11
11
|
export interface AddImportOptions {
|
|
12
12
|
/** The module name (e.g., 'fs', 'react') to import from.
|
|
13
|
-
* Pass a `J.Literal` to reuse its source form
|
|
14
|
-
*
|
|
13
|
+
* Pass a `J.Literal` to reuse its source form, which carries the escapes and unicode form of a
|
|
14
|
+
* specifier being moved from elsewhere in the source. A Prettier configuration settles the
|
|
15
|
+
* quoting; see `quoteStyle`. */
|
|
15
16
|
module: string | J.Literal;
|
|
16
17
|
/** Optionally, the specific member to import from the module.
|
|
17
18
|
* If not specified, adds a default import or namespace import.
|
|
@@ -45,45 +46,60 @@ export interface AddImportOptions {
|
|
|
45
46
|
/** Optional import style to use. If not specified, auto-detects from file and existing imports */
|
|
46
47
|
style?: ImportStyle;
|
|
47
48
|
/** Quote character for the module specifier. If not specified, detected from the file.
|
|
48
|
-
* A `J.Literal` module carries its own quoting and takes precedence over this.
|
|
49
|
+
* A `J.Literal` module carries its own quoting and takes precedence over this. A Prettier
|
|
50
|
+
* configuration outranks both, since running Prettier would arrive at its quote anyway. */
|
|
49
51
|
quoteStyle?: QuoteChar;
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
*
|
|
54
|
+
* Ensures an import for `options.module` exists, queuing an `AddImport` edit where none already
|
|
55
|
+
* serves the request. `maybeBind`'s ESM/CommonJS lane is this function; its own JSDoc carries the
|
|
56
|
+
* return-value contract. `refuseCreate` answers `undefined` instead of queuing a new import,
|
|
57
|
+
* without affecting whether an existing binding answers the request first.
|
|
58
|
+
*/
|
|
59
|
+
export declare function bindImport(visitor: JavaScriptVisitor<any>, options: AddImportOptions, refuseCreate?: boolean): string | undefined;
|
|
60
|
+
/** `'default'` and an absent member both name a default import, which binds no member name of its own. */
|
|
61
|
+
export declare function memberName(member: string | undefined): string | undefined;
|
|
62
|
+
/** A name introduced into the file's module scope, and where it came from when that is an import. */
|
|
63
|
+
export interface ModuleScopeBinding {
|
|
64
|
+
name: string;
|
|
65
|
+
module?: string;
|
|
66
|
+
/** Carries the {@link AddImportOptions.member} spelling, so `undefined` means a default import. */
|
|
67
|
+
member?: string;
|
|
68
|
+
typeOnly?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** What the file's imports and `require`s bind at module scope, and the module each name comes from. */
|
|
71
|
+
export declare function moduleScopeBindings(cu: JS.CompilationUnit): ModuleScopeBinding[];
|
|
72
|
+
/** Whether a top-level statement already marks the file as a module: an import or any export form. */
|
|
73
|
+
export declare function hasEsmSyntax(cu: JS.CompilationUnit): boolean;
|
|
74
|
+
/** Whether the file binds its modules with `require`, which decides whether a create is possible. */
|
|
75
|
+
export declare function isCommonJs(cu: JS.CompilationUnit): boolean;
|
|
76
|
+
/** The module a `const X = require('m')` declaration names, for the one variable it declares. */
|
|
77
|
+
export declare function requiredModuleOfDeclaration(declaration: J.VariableDeclarations): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* The module a `require(...)` call loads. `obj.require('x')` selects a method rather than loading a
|
|
80
|
+
* module, and a specifier that is not a string literal names none that can be read here.
|
|
81
|
+
*/
|
|
82
|
+
export declare function requiredModuleOf(methodInv: J.MethodInvocation): string | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* `names`, plus those pending `AddImport`s on the `afterVisit` queue have claimed. A queued
|
|
85
|
+
* `RemoveImport` does not free one: it removes only what the file leaves unused, and binding a name
|
|
86
|
+
* it keeps is an error, where an unnecessary suffix merely reads oddly.
|
|
87
|
+
*/
|
|
88
|
+
export declare function takenNames(names: ReadonlySet<string>, visitor: JavaScriptVisitor<any>): Set<string>;
|
|
89
|
+
/** As {@link takenNames}, for a caller asking about one name rather than probing repeatedly. */
|
|
90
|
+
export declare function nameTaken(name: string, names: ReadonlySet<string>, visitor: JavaScriptVisitor<any>): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The parser lifts surrogate pairs out of `valueSource` into `unicodeEscapes` and, when it does,
|
|
93
|
+
* sets `value` to the quoted source (`parser.ts` `mapLiteral`), so neither field alone is the
|
|
94
|
+
* module name. Reuniting them and stripping the quotes yields it for either shape of literal.
|
|
95
|
+
*/
|
|
96
|
+
export declare function moduleNameOf(module: string | J.Literal): string;
|
|
97
|
+
/**
|
|
98
|
+
* Adds the import {@link AddImportOptions} describes, under the name derived there. An import
|
|
99
|
+
* already in the file answers where it binds that same name, or where the request expressed no
|
|
100
|
+
* preference at all. Reuse under some other name belongs to {@link bindImport}, whose caller
|
|
101
|
+
* learns which name came back; a recipe driving this visitor is stuck with the one it derived.
|
|
79
102
|
*/
|
|
80
|
-
export declare function maybeAddImport(visitor: JavaScriptVisitor<any>, options: AddImportOptions & {
|
|
81
|
-
sideEffectOnly: true;
|
|
82
|
-
}): undefined;
|
|
83
|
-
export declare function maybeAddImport(visitor: JavaScriptVisitor<any>, options: AddImportOptions & {
|
|
84
|
-
sideEffectOnly?: false;
|
|
85
|
-
}): string;
|
|
86
|
-
export declare function maybeAddImport(visitor: JavaScriptVisitor<any>, options: AddImportOptions): string | undefined;
|
|
87
103
|
export declare class AddImport<P> extends JavaScriptVisitor<P> {
|
|
88
104
|
readonly module: string;
|
|
89
105
|
/** Set when the caller supplied the module specifier as a literal; printed verbatim. */
|
|
@@ -170,4 +186,77 @@ export declare class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
170
186
|
*/
|
|
171
187
|
private findImportInsertionIndex;
|
|
172
188
|
}
|
|
189
|
+
export interface ExistingImportBinding {
|
|
190
|
+
localName: string;
|
|
191
|
+
onlyMemberOfStatement: boolean;
|
|
192
|
+
/** Whether the source states this local name — `import {a as b}` — or takes it from the member. */
|
|
193
|
+
aliased: boolean;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The existing binding for `member` of `module`, read from `cu`'s own import statements — what
|
|
197
|
+
* `maybeRebind` reads before committing to a `RebindImport` edit.
|
|
198
|
+
*/
|
|
199
|
+
export declare function existingImportBinding(cu: JS.CompilationUnit, module: string, member: string | undefined): ExistingImportBinding | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* Moves the binding `from` names to `to`, binding it under `boundName`. In place when the
|
|
202
|
+
* statement that carries it binds nothing else — module and member specifier rewritten there
|
|
203
|
+
* directly; otherwise the old specifier drops and {@link bindImport} queues the replacement.
|
|
204
|
+
* A `boundName` of its own renames the binding, and the file's references to it follow.
|
|
205
|
+
*
|
|
206
|
+
* Not built on `RemoveImport`/`maybeUnbind`: those only drop a binding once nothing references
|
|
207
|
+
* it, but a rebind moves one that is still in use — removal here has to be unconditional.
|
|
208
|
+
*/
|
|
209
|
+
export declare class RebindImport<P> extends JavaScriptVisitor<P> {
|
|
210
|
+
readonly from: {
|
|
211
|
+
module: string;
|
|
212
|
+
member?: string;
|
|
213
|
+
};
|
|
214
|
+
readonly to: {
|
|
215
|
+
module: string;
|
|
216
|
+
member?: string;
|
|
217
|
+
};
|
|
218
|
+
readonly localName: string;
|
|
219
|
+
readonly boundName: string;
|
|
220
|
+
constructor(from: {
|
|
221
|
+
module: string;
|
|
222
|
+
member?: string;
|
|
223
|
+
}, to: {
|
|
224
|
+
module: string;
|
|
225
|
+
member?: string;
|
|
226
|
+
}, localName: string, boundName: string);
|
|
227
|
+
private transformedInPlace;
|
|
228
|
+
private typeOnly;
|
|
229
|
+
private readonly movedTypes;
|
|
230
|
+
/** Identifiers settled as references to the binding, so a parent need not settle it again. */
|
|
231
|
+
private readonly references;
|
|
232
|
+
private get renaming();
|
|
233
|
+
visitJsCompilationUnit(cu: JS.CompilationUnit, p: P): Promise<J | undefined>;
|
|
234
|
+
visitImportDeclaration(jsImport: JS.Import, p: P): Promise<J | undefined>;
|
|
235
|
+
visitIdentifier(identifier: J.Identifier, p: P): Promise<J | undefined>;
|
|
236
|
+
visitMethodInvocation(method: J.MethodInvocation, p: P): Promise<J | undefined>;
|
|
237
|
+
visitNewClass(newClass: J.NewClass, p: P): Promise<J | undefined>;
|
|
238
|
+
visitFunctionCall(functionCall: JS.FunctionCall, p: P): Promise<J | undefined>;
|
|
239
|
+
/**
|
|
240
|
+
* Whether `callee` is the identifier `visitIdentifier` settled as a reference to the binding.
|
|
241
|
+
* A rewrite keeps the identifier's id, so the one it settled is the one still standing here.
|
|
242
|
+
*/
|
|
243
|
+
private referencesMovedBinding;
|
|
244
|
+
/**
|
|
245
|
+
* A decorator and the other type-name positions reach the tree through this hook, which the
|
|
246
|
+
* base visitor holds closed; a reference in one of them is a reference like any other.
|
|
247
|
+
*/
|
|
248
|
+
protected visitTypeName<N extends NameTree>(nameTree: N, p: P): Promise<N>;
|
|
249
|
+
/**
|
|
250
|
+
* An export specifier's own name is the module's public surface, which its consumers read and
|
|
251
|
+
* the rename leaves alone. See CLAUDE.md: Which name a rebind binds.
|
|
252
|
+
*/
|
|
253
|
+
visitExportSpecifier(exportSpecifier: JS.ExportSpecifier, p: P): Promise<J | undefined>;
|
|
254
|
+
/**
|
|
255
|
+
* Whether the identifier at the cursor stands for the moved binding: the right name, in a
|
|
256
|
+
* position that references rather than declares, reaching the module scope that binds it.
|
|
257
|
+
*/
|
|
258
|
+
private referencesBinding;
|
|
259
|
+
/** A shorthand property's name slot is also the reference to the binding. */
|
|
260
|
+
visitPropertyAssignment(propertyAssignment: JS.PropertyAssignment, p: P): Promise<J | undefined>;
|
|
261
|
+
}
|
|
173
262
|
//# sourceMappingURL=add-import.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-import.d.ts","sourceRoot":"","sources":["../../src/javascript/add-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"add-import.d.ts","sourceRoot":"","sources":["../../src/javascript/add-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAoD,CAAC,EAAE,QAAQ,EAAmD,MAAM,SAAS,CAAC;AACzI,OAAO,EAAC,EAAE,EAAM,MAAM,QAAQ,CAAC;AAU/B,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,CAAC;AAElC,oBAAY,WAAW;IACnB,QAAQ,IAAA,CAAO,6BAA6B;IAC5C,YAAY,IAAA,CAAG,8BAA8B;IAC7C,UAAU,IAAA,CAAK,yBAAyB;IACxC,QAAQ,IAAA;CACX;AAED,MAAM,WAAW,gBAAgB;IAC7B;;;oCAGgC;IAChC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC;IAE3B;;;;;;;mDAO+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;mDAI+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;mDAE+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;mDAC+C;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;2EACuE;IACvE,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;mDAE+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,kGAAkG;IAClG,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB;;+FAE2F;IAC3F,UAAU,CAAC,EAAE,SAAS,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACtB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC/B,OAAO,EAAE,gBAA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