@openrewrite/rewrite 8.62.4 → 8.62.6
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/tree.d.ts +12 -6
- package/dist/java/tree.d.ts.map +1 -1
- package/dist/java/tree.js +12 -5
- package/dist/java/tree.js.map +1 -1
- package/dist/java/type.d.ts +2 -0
- package/dist/java/type.d.ts.map +1 -1
- package/dist/java/type.js +12 -0
- package/dist/java/type.js.map +1 -1
- package/dist/java/visitor.d.ts +8 -0
- package/dist/java/visitor.d.ts.map +1 -1
- package/dist/java/visitor.js +23 -1
- package/dist/java/visitor.js.map +1 -1
- package/dist/javascript/index.d.ts +3 -0
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +3 -0
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/method-matcher.d.ts +16 -0
- package/dist/javascript/method-matcher.d.ts.map +1 -0
- package/dist/javascript/method-matcher.js +222 -0
- package/dist/javascript/method-matcher.js.map +1 -0
- package/dist/javascript/parser.js +1 -1
- package/dist/javascript/parser.js.map +1 -1
- package/dist/javascript/preconditions.d.ts +6 -0
- package/dist/javascript/preconditions.d.ts.map +1 -0
- package/dist/javascript/preconditions.js +58 -0
- package/dist/javascript/preconditions.js.map +1 -0
- package/dist/javascript/remove-import.d.ts +56 -0
- package/dist/javascript/remove-import.d.ts.map +1 -0
- package/dist/javascript/remove-import.js +715 -0
- package/dist/javascript/remove-import.js.map +1 -0
- package/dist/javascript/rpc.js +2 -2
- package/dist/javascript/rpc.js.map +1 -1
- package/dist/javascript/search/index.d.ts +3 -0
- package/dist/javascript/search/index.d.ts.map +1 -0
- package/dist/javascript/search/index.js +19 -0
- package/dist/javascript/search/index.js.map +1 -0
- package/dist/javascript/search/uses-method.d.ts +8 -0
- package/dist/javascript/search/uses-method.d.ts.map +1 -0
- package/dist/javascript/search/uses-method.js +35 -0
- package/dist/javascript/search/uses-method.js.map +1 -0
- package/dist/javascript/search/uses-type.d.ts +8 -0
- package/dist/javascript/search/uses-type.d.ts.map +1 -0
- package/dist/javascript/search/uses-type.js +71 -0
- package/dist/javascript/search/uses-type.js.map +1 -0
- package/dist/javascript/templating.d.ts +1 -1
- package/dist/javascript/templating.d.ts.map +1 -1
- package/dist/javascript/templating.js +1 -1
- package/dist/javascript/templating.js.map +1 -1
- package/dist/javascript/tree.d.ts +3 -3
- package/dist/javascript/tree.d.ts.map +1 -1
- package/dist/javascript/tree.js +28 -0
- package/dist/javascript/tree.js.map +1 -1
- package/dist/javascript/type-mapping.d.ts +4 -0
- package/dist/javascript/type-mapping.d.ts.map +1 -1
- package/dist/javascript/type-mapping.js +92 -46
- package/dist/javascript/type-mapping.js.map +1 -1
- package/dist/javascript/visitor.js +1 -1
- package/dist/javascript/visitor.js.map +1 -1
- package/dist/print.d.ts +1 -0
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +6 -0
- package/dist/print.js.map +1 -1
- package/dist/rpc/rewrite-rpc.d.ts +1 -1
- package/dist/rpc/rewrite-rpc.d.ts.map +1 -1
- package/dist/rpc/rewrite-rpc.js +0 -3
- package/dist/rpc/rewrite-rpc.js.map +1 -1
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +18 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/is-source-file.d.ts +8 -0
- package/dist/search/is-source-file.d.ts.map +1 -0
- package/dist/search/is-source-file.js +70 -0
- package/dist/search/is-source-file.js.map +1 -0
- package/dist/test/rewrite-test.d.ts.map +1 -1
- package/dist/test/rewrite-test.js +3 -0
- package/dist/test/rewrite-test.js.map +1 -1
- package/dist/util.d.ts +1 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +13 -0
- package/dist/util.js.map +1 -1
- package/dist/version.txt +1 -1
- package/dist/visitor.d.ts +1 -1
- package/dist/visitor.d.ts.map +1 -1
- package/dist/visitor.js +3 -2
- package/dist/visitor.js.map +1 -1
- package/package.json +3 -1
- package/src/java/tree.ts +19 -11
- package/src/java/type.ts +14 -0
- package/src/java/visitor.ts +28 -8
- package/src/javascript/index.ts +4 -0
- package/src/javascript/method-matcher.ts +250 -0
- package/src/javascript/parser.ts +1 -1
- package/src/javascript/preconditions.ts +40 -0
- package/src/javascript/remove-import.ts +780 -0
- package/src/javascript/rpc.ts +2 -2
- package/src/javascript/search/index.ts +2 -0
- package/src/javascript/search/uses-method.ts +21 -0
- package/src/javascript/search/uses-type.ts +27 -0
- package/src/javascript/templating.ts +4 -3
- package/src/javascript/tree.ts +47 -3
- package/src/javascript/type-mapping.ts +113 -50
- package/src/javascript/visitor.ts +125 -125
- package/src/print.ts +9 -3
- package/src/rpc/rewrite-rpc.ts +1 -4
- package/src/search/index.ts +1 -0
- package/src/search/is-source-file.ts +26 -0
- package/src/test/rewrite-test.ts +4 -1
- package/src/util.ts +19 -4
- package/src/visitor.ts +3 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExecutionContext } from "../execution";
|
|
2
|
+
import { TreeVisitor } from "../visitor";
|
|
3
|
+
export declare function hasSourcePath(filePattern: string): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
4
|
+
export declare function usesMethod(methodMatcher: string, matchOverrides?: boolean): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
5
|
+
export declare function usesType(fullyQualifiedType: string): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
6
|
+
//# sourceMappingURL=preconditions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preconditions.d.ts","sourceRoot":"","sources":["../../src/javascript/preconditions.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAGvC,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAIpG;AAED,wBAAsB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,GAAE,OAAe,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAKpI;AAED,wBAAsB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAItG"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.hasSourcePath = hasSourcePath;
|
|
13
|
+
exports.usesMethod = usesMethod;
|
|
14
|
+
exports.usesType = usesType;
|
|
15
|
+
/*
|
|
16
|
+
* Copyright 2025 the original author or authors.
|
|
17
|
+
* <p>
|
|
18
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
19
|
+
* you may not use this file except in compliance with the License.
|
|
20
|
+
* You may obtain a copy of the License at
|
|
21
|
+
* <p>
|
|
22
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
23
|
+
* <p>
|
|
24
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
25
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
26
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
+
* See the License for the specific language governing permissions and
|
|
28
|
+
* limitations under the License.
|
|
29
|
+
*/
|
|
30
|
+
const rpc_1 = require("../rpc");
|
|
31
|
+
const search_1 = require("./search");
|
|
32
|
+
const search_2 = require("../search");
|
|
33
|
+
function hasSourcePath(filePattern) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
return (yield ((_b = (yield ((_a = rpc_1.RewriteRpc.get()) === null || _a === void 0 ? void 0 : _a.prepareRecipe("org.openrewrite.FindSourceFiles", {
|
|
37
|
+
filePattern
|
|
38
|
+
})))) === null || _b === void 0 ? void 0 : _b.editor())) || new search_2.IsSourceFile(filePattern);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function usesMethod(methodMatcher_1) {
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* (methodMatcher, matchOverrides = false) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
return (yield ((_b = (yield ((_a = rpc_1.RewriteRpc.get()) === null || _a === void 0 ? void 0 : _a.prepareRecipe("org.openrewrite.java.search.UsesMethod", {
|
|
45
|
+
methodMatcher,
|
|
46
|
+
matchOverrides
|
|
47
|
+
})))) === null || _b === void 0 ? void 0 : _b.editor())) || new search_1.UsesMethod(methodMatcher);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function usesType(fullyQualifiedType) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
return (yield ((_b = (yield ((_a = rpc_1.RewriteRpc.get()) === null || _a === void 0 ? void 0 : _a.prepareRecipe("org.openrewrite.java.search.UsesType", {
|
|
54
|
+
fullyQualifiedType
|
|
55
|
+
})))) === null || _b === void 0 ? void 0 : _b.editor())) || new search_1.UsesType(fullyQualifiedType);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=preconditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preconditions.js","sourceRoot":"","sources":["../../src/javascript/preconditions.ts"],"names":[],"mappings":";;;;;;;;;;;AAsBA,sCAIC;AAED,gCAKC;AAED,4BAIC;AAvCD;;;;;;;;;;;;;;GAcG;AACH,gCAAkC;AAElC,qCAA8C;AAG9C,sCAAuC;AAEvC,SAAsB,aAAa,CAAC,WAAmB;;;QACnD,OAAO,CAAA,MAAM,CAAA,MAAA,CAAC,MAAM,CAAA,MAAA,gBAAU,CAAC,GAAG,EAAE,0CAAE,aAAa,CAAC,iCAAiC,EAAE;YACnF,WAAW;SACd,CAAC,CAAA,CAAC,0CAAE,MAAM,EAAE,CAAA,KAAI,IAAI,qBAAY,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;CAAA;AAED,SAAsB,UAAU;yDAAC,aAAqB,EAAE,iBAA0B,KAAK;;QACnF,OAAO,CAAA,MAAM,CAAA,MAAA,CAAC,MAAM,CAAA,MAAA,gBAAU,CAAC,GAAG,EAAE,0CAAE,aAAa,CAAC,wCAAwC,EAAE;YAC1F,aAAa;YACb,cAAc;SACjB,CAAC,CAAA,CAAC,0CAAE,MAAM,EAAE,CAAA,KAAI,IAAI,mBAAU,CAAC,aAAa,CAAC,CAAA;IAClD,CAAC;CAAA;AAED,SAAsB,QAAQ,CAAC,kBAA0B;;;QACrD,OAAO,CAAA,MAAM,CAAA,MAAA,CAAC,MAAM,CAAA,MAAA,gBAAU,CAAC,GAAG,EAAE,0CAAE,aAAa,CAAC,sCAAsC,EAAE;YACxF,kBAAkB;SACrB,CAAC,CAAA,CAAC,0CAAE,MAAM,EAAE,CAAA,KAAI,IAAI,iBAAQ,CAAC,kBAAkB,CAAC,CAAC;IACtD,CAAC;CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { JavaScriptVisitor } from "./visitor";
|
|
2
|
+
import { J } from "../java";
|
|
3
|
+
import { JS } from "./tree";
|
|
4
|
+
/**
|
|
5
|
+
* @param visitor The visitor to add the import removal to
|
|
6
|
+
* @param target Either the module name (e.g., 'fs') to remove specific members from,
|
|
7
|
+
* or the name of the import to remove entirely
|
|
8
|
+
* @param member Optionally, the specific member to remove from the import.
|
|
9
|
+
* If not specified, removes the import matching `target`
|
|
10
|
+
*/
|
|
11
|
+
export declare function maybeRemoveImport(visitor: JavaScriptVisitor<any>, target: string, member?: string): void;
|
|
12
|
+
export declare class RemoveImport<P> extends JavaScriptVisitor<P> {
|
|
13
|
+
readonly target: string;
|
|
14
|
+
readonly member?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* @param target Either the module name (e.g., 'fs') to remove specific members from,
|
|
17
|
+
* or the name of the import to remove entirely
|
|
18
|
+
* @param member Optionally, the specific member to remove from the import.
|
|
19
|
+
* If not specified, removes the import matching `target`
|
|
20
|
+
*/
|
|
21
|
+
constructor(target: string, member?: string | undefined);
|
|
22
|
+
/**
|
|
23
|
+
* Generic helper to filter elements from a RightPadded array while preserving formatting.
|
|
24
|
+
* When removing elements, the prefix from the first removed element is applied to the
|
|
25
|
+
* first remaining element to maintain proper spacing.
|
|
26
|
+
*/
|
|
27
|
+
private filterElementsWithPrefixPreservation;
|
|
28
|
+
/**
|
|
29
|
+
* Helper to update an import clause by removing specific bindings
|
|
30
|
+
*/
|
|
31
|
+
private updateImportClause;
|
|
32
|
+
visitJsCompilationUnit(compilationUnit: JS.CompilationUnit, p: P): Promise<J | undefined>;
|
|
33
|
+
private processImport;
|
|
34
|
+
private processNamedImports;
|
|
35
|
+
private processRequireFromVarDecls;
|
|
36
|
+
private processObjectBindingPattern;
|
|
37
|
+
private getImportName;
|
|
38
|
+
private getBindingElementName;
|
|
39
|
+
private shouldRemoveImport;
|
|
40
|
+
private isTargetModule;
|
|
41
|
+
/**
|
|
42
|
+
* Helper to traverse parameters from various node types
|
|
43
|
+
*/
|
|
44
|
+
private traverseParameters;
|
|
45
|
+
/**
|
|
46
|
+
* Helper to traverse statements from various node types
|
|
47
|
+
*/
|
|
48
|
+
private traverseStatements;
|
|
49
|
+
/**
|
|
50
|
+
* Helper to check for type expressions and collect type usage
|
|
51
|
+
*/
|
|
52
|
+
private checkTypeExpression;
|
|
53
|
+
private collectUsedIdentifiers;
|
|
54
|
+
private collectTypeUsage;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=remove-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-import.d.ts","sourceRoot":"","sources":["../../src/javascript/remove-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAC,CAAC,EAAC,MAAM,SAAS,CAAC;AAC1B,OAAO,EAAC,EAAE,EAAC,MAAM,QAAQ,CAAC;AAG1B;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,QAOjG;AAUD,qBAAa,YAAY,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAOzC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAPpC;;;;;OAKG;gBACkB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,YAAA;IAIpC;;;;OAIG;YACW,oCAAoC;IAqClD;;OAEG;YACW,kBAAkB;IAejB,sBAAsB,CAAC,eAAe,EAAE,EAAE,CAAC,eAAe,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;YAwE1F,aAAa;YAuGb,mBAAmB;YA6CnB,0BAA0B;YA8D1B,2BAA2B;IAoDzC,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,cAAc;IAmBtB;;OAEG;YACW,kBAAkB;IAyBhC;;OAEG;YACW,kBAAkB;IAiBhC;;OAEG;YACW,mBAAmB;YASnB,sBAAsB;YAwLtB,gBAAgB;CAmCjC"}
|