js-code-detector 0.0.55 → 0.0.56
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/cjs/index.d.ts +1 -1
- package/dist/cjs/services/DetectService.d.ts +1 -1
- package/dist/cjs/services/ProjectService.d.ts +2 -0
- package/dist/cjs/services/projectServiceClass/UmiProjectService.js +4 -0
- package/dist/cjs/services/projectServiceClass/ViteProjectService.js +5 -1
- package/dist/cjs/services/projectServiceClass/VueProjectService.js +4 -0
- package/dist/cjs/util/ast_util/AstKit.js +6 -2
- package/dist/cjs/util/ast_util/helper/convertAliasToLocal.d.ts +3 -0
- package/dist/cjs/util/ast_util/helper/convertAliasToLocal.js +27 -0
- package/dist/cjs/util/ast_util/helper/findImportUsageInExport.d.ts +2 -0
- package/dist/cjs/util/ast_util/helper/findImportUsageInExport.js +119 -0
- package/dist/cjs/util/ast_util/helper/findRelateUsageOfExport.d.ts +9 -0
- package/dist/cjs/util/ast_util/helper/findRelateUsageOfExport.js +76 -0
- package/dist/cjs/util/ast_util/helper/getEffectedExportMembersOfLineRange.d.ts +2 -0
- package/dist/cjs/util/ast_util/helper/getEffectedExportMembersOfLineRange.js +124 -0
- package/dist/cjs/util/ast_util/helper/getExportedNameOfAncestor.js +3 -3
- package/dist/cjs/util/ast_util/helper/syncTravel.js +54 -37
- package/dist/cjs/util/report_util/filterEffectedExportMember.js +3 -2
- package/dist/cjs/util/shared/collectUpstreamFiles.js +1 -2
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -30,5 +30,5 @@ export { isRepoTypeSupported } from "./util/shared/getRepoSupportFlag";
|
|
|
30
30
|
export declare function runDiffDetect(compareUrl?: string, token?: string): Promise<{
|
|
31
31
|
error: Error | null;
|
|
32
32
|
repoType: string;
|
|
33
|
-
effectedImportUsage: [string, string][];
|
|
33
|
+
effectedImportUsage: [string, string][] | never[];
|
|
34
34
|
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DetectService } from "./DetectService";
|
|
2
2
|
import { formatGitDiffContent } from "../util/format_git_diff_content";
|
|
3
|
+
import { RelateUsageOfExport } from "../util/ast_util/helper/findRelateUsageOfExport";
|
|
3
4
|
export interface ProjectService {
|
|
4
5
|
detectService: DetectService;
|
|
5
6
|
gitDiffDetail: ReturnType<typeof formatGitDiffContent>;
|
|
@@ -10,6 +11,7 @@ export interface ProjectService {
|
|
|
10
11
|
outputResult: {
|
|
11
12
|
effectedImportUsage: [string, string][];
|
|
12
13
|
error: Error | null;
|
|
14
|
+
relatedExportUsage: RelateUsageOfExport[];
|
|
13
15
|
};
|
|
14
16
|
run(): void;
|
|
15
17
|
}
|
|
@@ -40,6 +40,7 @@ var import_collectUpstreamFiles = __toESM(require("../../util/shared/collectUpst
|
|
|
40
40
|
var import_createDependenceMap = require("../../util/report_util/createDependenceMap");
|
|
41
41
|
var import_filterEffectedExportMember = __toESM(require("../../util/report_util/filterEffectedExportMember"));
|
|
42
42
|
var import_constants = require("../../util/constants");
|
|
43
|
+
var import_findRelateUsageOfExport = __toESM(require("../../util/ast_util/helper/findRelateUsageOfExport"));
|
|
43
44
|
var UmiProjectService = class {
|
|
44
45
|
constructor(detectService) {
|
|
45
46
|
this.detectService = detectService;
|
|
@@ -49,6 +50,7 @@ var UmiProjectService = class {
|
|
|
49
50
|
parsedAlias: {}
|
|
50
51
|
};
|
|
51
52
|
this.outputResult = {
|
|
53
|
+
relatedExportUsage: [],
|
|
52
54
|
effectedImportUsage: [],
|
|
53
55
|
error: null
|
|
54
56
|
};
|
|
@@ -96,6 +98,8 @@ var UmiProjectService = class {
|
|
|
96
98
|
return effectedExportNames.includes(value);
|
|
97
99
|
});
|
|
98
100
|
this.outputResult.effectedImportUsage = effectedImportUsage;
|
|
101
|
+
const effectedImportUsageUnique = [...new Set(effectedImportUsage.map((item) => item[0]))].map((importFileAndMember) => importFileAndMember.split("#"));
|
|
102
|
+
this.outputResult.relatedExportUsage = (0, import_findRelateUsageOfExport.default)(effectedImportUsageUnique, import2export, indirectExportMembers, absPathPrefix);
|
|
99
103
|
const token = this.detectService.gitInfo.token;
|
|
100
104
|
if (!token) {
|
|
101
105
|
const pwd = (0, import_path.join)(this.detectService.directoryInfo.tmpWorkDir, "..");
|
|
@@ -43,6 +43,7 @@ var import_createDependenceMap = require("../../util/report_util/createDependenc
|
|
|
43
43
|
var import_filterEffectedExportMember = __toESM(require("../../util/report_util/filterEffectedExportMember"));
|
|
44
44
|
var import_isVueEntryFile = __toESM(require("../../util/project_umi_util/isVueEntryFile"));
|
|
45
45
|
var import_tsConfigPathsToWebpackAlias = require("../../util/project_umi_util/tsConfigPathsToWebpackAlias");
|
|
46
|
+
var import_findRelateUsageOfExport = __toESM(require("../../util/ast_util/helper/findRelateUsageOfExport"));
|
|
46
47
|
var ViteProjectService = class {
|
|
47
48
|
constructor(detectService) {
|
|
48
49
|
this.detectService = detectService;
|
|
@@ -52,6 +53,7 @@ var ViteProjectService = class {
|
|
|
52
53
|
parsedAlias: {}
|
|
53
54
|
};
|
|
54
55
|
this.outputResult = {
|
|
56
|
+
relatedExportUsage: [],
|
|
55
57
|
effectedImportUsage: [],
|
|
56
58
|
error: null
|
|
57
59
|
};
|
|
@@ -90,7 +92,7 @@ var ViteProjectService = class {
|
|
|
90
92
|
}
|
|
91
93
|
async readSrcDirFilesAndSetEntries() {
|
|
92
94
|
const targetDirPath = this.detectService.directoryInfo.targetBranchDir;
|
|
93
|
-
const projectFileList = (0, import_utils.readDirFiles)({ dir: (0, import_path.join)(targetDirPath, "src") }).filter((e) => e.filePath.endsWith(".ts") || e.filePath.endsWith(".js"));
|
|
95
|
+
const projectFileList = (0, import_utils.readDirFiles)({ dir: (0, import_path.join)(targetDirPath, "src") }).filter((e) => e.filePath.endsWith(".ts") && !e.filePath.endsWith(".d.ts") || e.filePath.endsWith(".js"));
|
|
94
96
|
this.viteHelpInfo.entryFiles = projectFileList.filter((file) => (0, import_isVueEntryFile.default)(file.filePath)).map((e) => e.filePath);
|
|
95
97
|
}
|
|
96
98
|
async getMadgeResult() {
|
|
@@ -133,6 +135,8 @@ var ViteProjectService = class {
|
|
|
133
135
|
return effectedExportNames.includes(value);
|
|
134
136
|
});
|
|
135
137
|
this.outputResult.effectedImportUsage = effectedImportUsage;
|
|
138
|
+
const effectedImportUsageUnique = [...new Set(effectedImportUsage.map((item) => item[0]))].map((importFileAndMember) => importFileAndMember.split("#"));
|
|
139
|
+
this.outputResult.relatedExportUsage = (0, import_findRelateUsageOfExport.default)(effectedImportUsageUnique, import2export, indirectExportMembers, absPathPrefix);
|
|
136
140
|
const token = this.detectService.gitInfo.token;
|
|
137
141
|
if (!token) {
|
|
138
142
|
const pwd = (0, import_path.join)(this.detectService.directoryInfo.tmpWorkDir, "..");
|
|
@@ -42,6 +42,7 @@ var import_collectUpstreamFiles = __toESM(require("../../util/shared/collectUpst
|
|
|
42
42
|
var import_createDependenceMap = require("../../util/report_util/createDependenceMap");
|
|
43
43
|
var import_filterEffectedExportMember = __toESM(require("../../util/report_util/filterEffectedExportMember"));
|
|
44
44
|
var import_await_to_js = __toESM(require("await-to-js"));
|
|
45
|
+
var import_findRelateUsageOfExport = __toESM(require("../../util/ast_util/helper/findRelateUsageOfExport"));
|
|
45
46
|
var VueProjectService = class {
|
|
46
47
|
constructor(detectService) {
|
|
47
48
|
this.detectService = detectService;
|
|
@@ -51,6 +52,7 @@ var VueProjectService = class {
|
|
|
51
52
|
parsedAlias: {}
|
|
52
53
|
};
|
|
53
54
|
this.outputResult = {
|
|
55
|
+
relatedExportUsage: [],
|
|
54
56
|
effectedImportUsage: [],
|
|
55
57
|
error: null
|
|
56
58
|
};
|
|
@@ -208,6 +210,8 @@ var VueProjectService = class {
|
|
|
208
210
|
return effectedExportNames.includes(value);
|
|
209
211
|
});
|
|
210
212
|
this.outputResult.effectedImportUsage = effectedImportUsage;
|
|
213
|
+
const effectedImportUsageUnique = [...new Set(effectedImportUsage.map((item) => item[0]))].map((importFileAndMember) => importFileAndMember.split("#"));
|
|
214
|
+
this.outputResult.relatedExportUsage = (0, import_findRelateUsageOfExport.default)(effectedImportUsageUnique, import2export, indirectExportMembers, absPathPrefix);
|
|
211
215
|
const token = this.detectService.gitInfo.token;
|
|
212
216
|
if (!token) {
|
|
213
217
|
const pwd = (0, import_path.join)(this.detectService.directoryInfo.tmpWorkDir, "..");
|
|
@@ -70,8 +70,12 @@ var AstUtil = class {
|
|
|
70
70
|
if (!node) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
try {
|
|
74
|
+
(0, import_syncTravel.default)(node, { filePath, mapUuidToNode, mapFileLineToNodeSet, mapPathToNodeSet, visitedNodeSet, upstreamIdentifiers: [] }, () => {
|
|
75
|
+
});
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.log("syncTravel in " + filePath, e);
|
|
78
|
+
}
|
|
75
79
|
}
|
|
76
80
|
};
|
|
77
81
|
AstUtil.EXPORT_DECLARATION_TYPES = import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/util/ast_util/helper/convertAliasToLocal.ts
|
|
20
|
+
var convertAliasToLocal_exports = {};
|
|
21
|
+
__export(convertAliasToLocal_exports, {
|
|
22
|
+
default: () => convertAliasToLocal
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(convertAliasToLocal_exports);
|
|
25
|
+
function convertAliasToLocal(parsedAlias, systemAbsPathPrefix) {
|
|
26
|
+
return Object.fromEntries(Object.entries(parsedAlias).map(([k, v]) => [k, v.startsWith(systemAbsPathPrefix) ? v.replace(systemAbsPathPrefix, "") : v]));
|
|
27
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/util/ast_util/helper/findImportUsageInExport.ts
|
|
30
|
+
var findImportUsageInExport_exports = {};
|
|
31
|
+
__export(findImportUsageInExport_exports, {
|
|
32
|
+
findImportUsageInExport: () => findImportUsageInExport
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(findImportUsageInExport_exports);
|
|
35
|
+
var import_deepSearchParamsIdentifier = __toESM(require("./deepSearchParamsIdentifier"));
|
|
36
|
+
var import_SHARED_CONSTANTS = require("../SHARED_CONSTANTS");
|
|
37
|
+
function findImportUsageInExport(programNode, importedNames) {
|
|
38
|
+
if (!programNode)
|
|
39
|
+
return [];
|
|
40
|
+
const importDeclarations = programNode._util.children.filter((node) => node.type === "ImportDeclaration");
|
|
41
|
+
const localIdentifiers = importDeclarations.map((node) => node.specifiers).flat().filter(Boolean).map((e) => e.local);
|
|
42
|
+
const targetSpecifiers = localIdentifiers.filter((item) => importedNames.includes(item.name));
|
|
43
|
+
return targetSpecifiers.map((item) => {
|
|
44
|
+
const members = wideDeepCollectNames([item]);
|
|
45
|
+
return [item.name, members];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function wideDeepCollectNames(nodes) {
|
|
49
|
+
const exportedNames = /* @__PURE__ */ new Set();
|
|
50
|
+
const identifierSet = /* @__PURE__ */ new Set();
|
|
51
|
+
const bodyMemberSet = /* @__PURE__ */ new Set();
|
|
52
|
+
const memberCallback = (n) => n && exportedNames.add(n);
|
|
53
|
+
wideHelper(nodes, bodyMemberSet, identifierSet, memberCallback);
|
|
54
|
+
return [...exportedNames];
|
|
55
|
+
}
|
|
56
|
+
function wideHelper(idNodes, bodyMemberSet, identifierSet, memberCallback) {
|
|
57
|
+
const identifierSetTmp = /* @__PURE__ */ new Set();
|
|
58
|
+
const bodyElements = idNodes.map((item) => [...item._util.provide].filter((e) => {
|
|
59
|
+
var _a;
|
|
60
|
+
return ((_a = e._util.parent) == null ? void 0 : _a.type) === "Program";
|
|
61
|
+
})).flat().filter((e) => !bodyMemberSet.has(e));
|
|
62
|
+
for (const node of bodyElements) {
|
|
63
|
+
bodyMemberSet.add(node);
|
|
64
|
+
collectIdentifiers(node, (id) => {
|
|
65
|
+
if (identifierSet.has(id) || !id)
|
|
66
|
+
return;
|
|
67
|
+
identifierSet.add(id);
|
|
68
|
+
identifierSetTmp.add(id);
|
|
69
|
+
});
|
|
70
|
+
collectExportIds(node, memberCallback, (id) => {
|
|
71
|
+
if (identifierSet.has(id) || !id)
|
|
72
|
+
return;
|
|
73
|
+
identifierSet.add(id);
|
|
74
|
+
identifierSetTmp.add(id);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (identifierSetTmp.size) {
|
|
78
|
+
wideHelper([...identifierSetTmp], bodyMemberSet, identifierSet, memberCallback);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function collectIdentifiers(node, callback) {
|
|
82
|
+
if (node.type === "VariableDeclaration") {
|
|
83
|
+
const declarations = node.declarations;
|
|
84
|
+
for (const declaration of declarations) {
|
|
85
|
+
if (declaration.type === "VariableDeclarator") {
|
|
86
|
+
const id = declaration.id;
|
|
87
|
+
(0, import_deepSearchParamsIdentifier.default)(id, callback);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES.includes(node.type)) {
|
|
92
|
+
const id = node.id;
|
|
93
|
+
id && callback(id);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function collectExportIds(node, memberCallback, idCallback) {
|
|
97
|
+
var _a;
|
|
98
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
99
|
+
const specifiers = node.specifiers;
|
|
100
|
+
for (const specifier of specifiers) {
|
|
101
|
+
if (specifier.type === "ExportSpecifier") {
|
|
102
|
+
memberCallback(specifier.local.name);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const declaration = node.declaration;
|
|
106
|
+
declaration && collectIdentifiers(declaration, (id) => {
|
|
107
|
+
idCallback(id);
|
|
108
|
+
memberCallback(id.name);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
112
|
+
idCallback((_a = node.declaration) == null ? void 0 : _a.id);
|
|
113
|
+
memberCallback("default");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
118
|
+
findImportUsageInExport
|
|
119
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type RelateUsageOfExport = {
|
|
2
|
+
filePath: string;
|
|
3
|
+
importMemberAndFile: {
|
|
4
|
+
fromFile: string;
|
|
5
|
+
localName: string;
|
|
6
|
+
}[];
|
|
7
|
+
exportMember: string;
|
|
8
|
+
};
|
|
9
|
+
export default function findRelateUsageOfExport(effectedImportUsage: [string, string][], import2export: Record<string, string>, indirectExportMembers: Record<string, string>, absPathPrefix: string): RelateUsageOfExport[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/util/ast_util/helper/findRelateUsageOfExport.ts
|
|
30
|
+
var findRelateUsageOfExport_exports = {};
|
|
31
|
+
__export(findRelateUsageOfExport_exports, {
|
|
32
|
+
default: () => findRelateUsageOfExport
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(findRelateUsageOfExport_exports);
|
|
35
|
+
var import_findImportUsageInExport = require("./findImportUsageInExport");
|
|
36
|
+
var import_getAstKitByFilePath = __toESM(require("../getAstKitByFilePath"));
|
|
37
|
+
function findRelateUsageOfExport(effectedImportUsage, import2export, indirectExportMembers, absPathPrefix) {
|
|
38
|
+
const result = [];
|
|
39
|
+
const ignoreList = [];
|
|
40
|
+
findRelateUsageOfExportHelper(effectedImportUsage, import2export, indirectExportMembers, absPathPrefix, result, ignoreList);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
function findRelateUsageOfExportHelper(effectedImportUsage, import2export, indirectExportMembers, absPathPrefix, result, ignoreList, count = 0) {
|
|
44
|
+
const mapFileToImportMembers = effectedImportUsage.reduce((acc, [file, member]) => {
|
|
45
|
+
acc[file] = acc[file] || [];
|
|
46
|
+
acc[file].push(member);
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
49
|
+
const effectedExportUsage = Object.entries(mapFileToImportMembers).map(([filePath, members]) => {
|
|
50
|
+
const astKit = (0, import_getAstKitByFilePath.default)(filePath, absPathPrefix);
|
|
51
|
+
const programNode = astKit.mapUuidToNode.get("Program");
|
|
52
|
+
if (!programNode)
|
|
53
|
+
return [];
|
|
54
|
+
const list = (0, import_findImportUsageInExport.findImportUsageInExport)(programNode, members).map(([, exportMembers]) => exportMembers).flat();
|
|
55
|
+
result.push(...list.map((exportMember) => {
|
|
56
|
+
const importMemberAndFile = members.map((member) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const fromFile = (_a = import2export[`${filePath}#${member}`]) == null ? void 0 : _a.split("#")[0];
|
|
59
|
+
return { fromFile, localName: member };
|
|
60
|
+
});
|
|
61
|
+
return { filePath, importMemberAndFile, exportMember };
|
|
62
|
+
}));
|
|
63
|
+
return list.map((item) => [filePath, item]);
|
|
64
|
+
}).flat();
|
|
65
|
+
const effectedExportUsageFileAndMember = effectedExportUsage.map(([f, m]) => `${f}#${m}`);
|
|
66
|
+
const effectedImportUsageList = [...Object.entries(import2export), ...Object.entries(indirectExportMembers)].filter(([, exportFileAndMember]) => {
|
|
67
|
+
return effectedExportUsageFileAndMember.includes(exportFileAndMember);
|
|
68
|
+
}).map(([_]) => _);
|
|
69
|
+
ignoreList.push(...effectedImportUsageList);
|
|
70
|
+
if (count > 10 || !effectedImportUsageList.length) {
|
|
71
|
+
console.log("findRelateUsageOfExportHelper", count, effectedImportUsageList);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
;
|
|
75
|
+
findRelateUsageOfExportHelper(effectedImportUsageList.map((e) => e.split("#")), import2export, indirectExportMembers, absPathPrefix, result, ignoreList, count + 1);
|
|
76
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/util/ast_util/helper/getEffectedExportMembersOfLineRange.ts
|
|
30
|
+
var getEffectedExportMembersOfLineRange_exports = {};
|
|
31
|
+
__export(getEffectedExportMembersOfLineRange_exports, {
|
|
32
|
+
default: () => getEffectedExportMembersOfLineRange
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(getEffectedExportMembersOfLineRange_exports);
|
|
35
|
+
var import_deepSearchParamsIdentifier = __toESM(require("./deepSearchParamsIdentifier"));
|
|
36
|
+
var import_SHARED_CONSTANTS = require("../SHARED_CONSTANTS");
|
|
37
|
+
var import_collectVariableDeclarationIdentifiers = __toESM(require("./collectVariableDeclarationIdentifiers"));
|
|
38
|
+
function getEffectedExportMembersOfLineRange(mapFileLineToNodeSet, startLine, endLine, filePath) {
|
|
39
|
+
var _a;
|
|
40
|
+
const effectedExportMembers = /* @__PURE__ */ new Set();
|
|
41
|
+
const identifiers = /* @__PURE__ */ new Set();
|
|
42
|
+
const callback = (identifier) => identifiers.add(identifier);
|
|
43
|
+
const programChildSet = /* @__PURE__ */ new Set();
|
|
44
|
+
for (let i = startLine; i <= endLine; i++) {
|
|
45
|
+
const nodes = mapFileLineToNodeSet.get(i);
|
|
46
|
+
if (!nodes)
|
|
47
|
+
continue;
|
|
48
|
+
for (const node of nodes) {
|
|
49
|
+
const ancestors = node._util.ancestors;
|
|
50
|
+
const programChild = ancestors.find((ancestor) => {
|
|
51
|
+
var _a2;
|
|
52
|
+
return ((_a2 = ancestor._util.parent) == null ? void 0 : _a2.type) === "Program";
|
|
53
|
+
});
|
|
54
|
+
if (programChild)
|
|
55
|
+
programChildSet.add(programChild);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const programChild of programChildSet) {
|
|
59
|
+
const { type, _util } = programChild;
|
|
60
|
+
if (type === "VariableDeclaration") {
|
|
61
|
+
Array.from(new Set(programChild.declarations)).forEach((declaration) => {
|
|
62
|
+
const id = declaration.id;
|
|
63
|
+
if (id) {
|
|
64
|
+
(0, import_deepSearchParamsIdentifier.default)(id, callback);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES.includes(programChild.type)) {
|
|
69
|
+
const id = programChild.id;
|
|
70
|
+
if (id) {
|
|
71
|
+
callback(id);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
for (const identifier of identifiers) {
|
|
76
|
+
const { _util } = identifier;
|
|
77
|
+
const { occupation } = _util;
|
|
78
|
+
for (const occ of occupation) {
|
|
79
|
+
const programElement = occ._util.ancestors.find((ancestor) => {
|
|
80
|
+
var _a2;
|
|
81
|
+
return ((_a2 = ancestor._util.parent) == null ? void 0 : _a2.type) === "Program";
|
|
82
|
+
});
|
|
83
|
+
if (programElement) {
|
|
84
|
+
programChildSet.add(programElement);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const programChild of programChildSet) {
|
|
89
|
+
const { type, specifiers, declaration } = programChild;
|
|
90
|
+
if (type === "ExportDefaultDeclaration") {
|
|
91
|
+
effectedExportMembers.add("default");
|
|
92
|
+
}
|
|
93
|
+
if (type === "ExportNamedDeclaration") {
|
|
94
|
+
Array.isArray(specifiers) && specifiers.forEach((specifier) => {
|
|
95
|
+
const { exported } = specifier;
|
|
96
|
+
if (exported) {
|
|
97
|
+
effectedExportMembers.add(exported.name);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (type === "ExportNamedDeclaration" && import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES.includes(declaration == null ? void 0 : declaration.type)) {
|
|
102
|
+
const idName = (_a = declaration.id) == null ? void 0 : _a.name;
|
|
103
|
+
if (idName) {
|
|
104
|
+
effectedExportMembers.add(idName);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (type === "ExportNamedDeclaration" && Array.isArray(declaration == null ? void 0 : declaration.declarations)) {
|
|
108
|
+
declaration == null ? void 0 : declaration.declarations.forEach((dec) => {
|
|
109
|
+
(0, import_collectVariableDeclarationIdentifiers.default)(dec, (identifier) => {
|
|
110
|
+
try {
|
|
111
|
+
const idName = identifier.name;
|
|
112
|
+
typeof idName === "string" && effectedExportMembers.add(idName);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
console.log("getEffectedExportMembersOfLineRange", e.message);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (effectedExportMembers.size === 0 && filePath.endsWith(".vue")) {
|
|
121
|
+
effectedExportMembers.add("default");
|
|
122
|
+
}
|
|
123
|
+
return Array.from(effectedExportMembers);
|
|
124
|
+
}
|
|
@@ -37,7 +37,7 @@ var import_getExportedNameOfDeclarationIdentifier = __toESM(require("./getExport
|
|
|
37
37
|
var import_collectVariableDeclarationIdentifiers = __toESM(require("./collectVariableDeclarationIdentifiers"));
|
|
38
38
|
var import_deepSearchParamsIdentifier = __toESM(require("./deepSearchParamsIdentifier"));
|
|
39
39
|
function getExportedNameOfAncestor(node) {
|
|
40
|
-
var _a, _b;
|
|
40
|
+
var _a, _b, _c;
|
|
41
41
|
if (!node) {
|
|
42
42
|
console.warn("获取 上级导出成员名字报错: node is null");
|
|
43
43
|
return [];
|
|
@@ -61,7 +61,7 @@ function getExportedNameOfAncestor(node) {
|
|
|
61
61
|
if (ancestor.type === "ExportNamedDeclaration") {
|
|
62
62
|
const declarationType = (_a = ancestor.declaration) == null ? void 0 : _a.type;
|
|
63
63
|
if (import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES.includes(declarationType)) {
|
|
64
|
-
const nameToAdd = ancestor.declaration.id.name;
|
|
64
|
+
const nameToAdd = (_b = ancestor.declaration.id) == null ? void 0 : _b.name;
|
|
65
65
|
if (nameToAdd) {
|
|
66
66
|
nameList.add(nameToAdd);
|
|
67
67
|
}
|
|
@@ -84,7 +84,7 @@ function getExportedNameOfAncestor(node) {
|
|
|
84
84
|
}
|
|
85
85
|
break outer;
|
|
86
86
|
}
|
|
87
|
-
if (["FunctionDeclaration", "ClassDeclaration"].includes(ancestor.type) && "Program" === ((
|
|
87
|
+
if (["FunctionDeclaration", "ClassDeclaration"].includes(ancestor.type) && "Program" === ((_c = ancestor._util.parent) == null ? void 0 : _c.type)) {
|
|
88
88
|
const ancestorId = ancestor.id;
|
|
89
89
|
if (ancestorId) {
|
|
90
90
|
const nameToAdd = (0, import_getExportedNameOfDeclarationIdentifier.default)(ancestorId);
|
|
@@ -73,7 +73,8 @@ function wideTravel(wideTravelNodeList, extra, travelFn) {
|
|
|
73
73
|
parent: wideTravelNode,
|
|
74
74
|
parentProperty: childKey,
|
|
75
75
|
indexOfProperty: null,
|
|
76
|
-
ancestors: [...wideTravelNode._util.ancestors, wideTravelNode]
|
|
76
|
+
ancestors: [...wideTravelNode._util.ancestors, wideTravelNode],
|
|
77
|
+
...childValue._util
|
|
77
78
|
});
|
|
78
79
|
childrenOfChild.push(childValue);
|
|
79
80
|
wideTravelNodes.push(childValue);
|
|
@@ -87,7 +88,8 @@ function wideTravel(wideTravelNodeList, extra, travelFn) {
|
|
|
87
88
|
parent: wideTravelNode,
|
|
88
89
|
parentProperty: childKey,
|
|
89
90
|
indexOfProperty: index,
|
|
90
|
-
ancestors: [...wideTravelNode._util.ancestors, wideTravelNode]
|
|
91
|
+
ancestors: [...wideTravelNode._util.ancestors, wideTravelNode],
|
|
92
|
+
...childInArray._util
|
|
91
93
|
});
|
|
92
94
|
childrenOfChild.push(childInArray);
|
|
93
95
|
wideTravelNodes.push(childInArray);
|
|
@@ -95,14 +97,17 @@ function wideTravel(wideTravelNodeList, extra, travelFn) {
|
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
|
-
const { hoistedNodeList,
|
|
100
|
+
const { hoistedNodeList, notHoistedNodes } = resortNodes(wideTravelNodes);
|
|
99
101
|
const holdingIdentifiers = [...extra.upstreamIdentifiers];
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
const importIdentifiers = /* @__PURE__ */ new Set();
|
|
103
|
+
for (const ele of hoistedNodeList) {
|
|
104
|
+
collectHoldingIdentifiers(ele, (identifier) => {
|
|
105
|
+
holdingIdentifiers.push(identifier);
|
|
106
|
+
}, (identifier) => importIdentifiers.add(identifier));
|
|
102
107
|
}
|
|
103
108
|
for (const ele of wideTravelNodes) {
|
|
104
109
|
if (notHoistedNodes.includes(ele)) {
|
|
105
|
-
collectHoldingIdentifiers(ele, holdingIdentifiers,
|
|
110
|
+
collectHoldingIdentifiers(ele, (identifier) => holdingIdentifiers.push(identifier), (identifier) => void 0);
|
|
106
111
|
}
|
|
107
112
|
const mergedExtra = { ...extra, upstreamIdentifiers: [...holdingIdentifiers] };
|
|
108
113
|
const holdingIdentifierSet = new Set(holdingIdentifiers);
|
|
@@ -120,11 +125,23 @@ function wideTravel(wideTravelNodeList, extra, travelFn) {
|
|
|
120
125
|
}
|
|
121
126
|
addIdentifiersToAncestors([ele], ele._util.ancestors);
|
|
122
127
|
}
|
|
128
|
+
importIdentifiers.forEach((identifier) => {
|
|
129
|
+
identifier._util.holdingIdType = "Import";
|
|
130
|
+
});
|
|
123
131
|
}
|
|
124
132
|
function deepTravel(deepTravelNode, extra, travelFn) {
|
|
125
133
|
const { upstreamIdentifiers } = extra;
|
|
126
134
|
const holdingIdentifiers = [...upstreamIdentifiers];
|
|
127
|
-
|
|
135
|
+
const paramIdentifierSet = /* @__PURE__ */ new Set();
|
|
136
|
+
if (import_SHARED_CONSTANTS.FUNCTION_TYPES.includes(deepTravelNode.type)) {
|
|
137
|
+
const params = deepTravelNode.params;
|
|
138
|
+
Array.isArray(params) && params.forEach((param) => {
|
|
139
|
+
(0, import_deepSearchParamsIdentifier.default)(param, (identifier) => {
|
|
140
|
+
holdingIdentifiers.push(identifier);
|
|
141
|
+
paramIdentifierSet.add(identifier);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
128
145
|
updateVariableScopeAndOccupation(deepTravelNode, holdingIdentifiers);
|
|
129
146
|
const { visitedNodeSet, filePath } = extra;
|
|
130
147
|
const { children } = deepTravelNode._util;
|
|
@@ -143,7 +160,8 @@ function deepTravel(deepTravelNode, extra, travelFn) {
|
|
|
143
160
|
visitedNodeSet.add(childValue);
|
|
144
161
|
childValue._util = (0, import_createAstNodeExt.default)({
|
|
145
162
|
indexOfProperty: null,
|
|
146
|
-
...commonNodeExt
|
|
163
|
+
...commonNodeExt,
|
|
164
|
+
...childValue._util
|
|
147
165
|
});
|
|
148
166
|
children.push(childValue);
|
|
149
167
|
} else if ((0, import_isValidArrayNodeCollect.default)(childValue)) {
|
|
@@ -153,14 +171,14 @@ function deepTravel(deepTravelNode, extra, travelFn) {
|
|
|
153
171
|
visitedNodeSet.add(childInArray);
|
|
154
172
|
childInArray._util = (0, import_createAstNodeExt.default)({
|
|
155
173
|
indexOfProperty: index,
|
|
156
|
-
...commonNodeExt
|
|
174
|
+
...commonNodeExt,
|
|
175
|
+
...childInArray._util
|
|
157
176
|
});
|
|
158
177
|
children.push(childInArray);
|
|
159
178
|
});
|
|
160
179
|
}
|
|
161
180
|
});
|
|
162
181
|
const mergedExtra = { ...extra, upstreamIdentifiers: holdingIdentifiers };
|
|
163
|
-
travelFn(deepTravelNode);
|
|
164
182
|
for (const child of children) {
|
|
165
183
|
if (shouldWideTravel(child)) {
|
|
166
184
|
wideTravel([child], mergedExtra, travelFn);
|
|
@@ -175,11 +193,22 @@ function deepTravel(deepTravelNode, extra, travelFn) {
|
|
|
175
193
|
}
|
|
176
194
|
addIdentifiersToAncestors([child], ancestors);
|
|
177
195
|
}
|
|
196
|
+
paramIdentifierSet.forEach((paramIdentifier) => {
|
|
197
|
+
paramIdentifier._util.holdingIdType = "Param";
|
|
198
|
+
});
|
|
199
|
+
const injectSet = new Set([...deepTravelNode._util.dependenceIds].filter((e) => isValidIdentifierOrJSXIdentifier(e)).map((e) => e._util.variableScope[0]).filter(Boolean).filter((e) => upstreamIdentifiers.includes(e)));
|
|
200
|
+
deepTravelNode._util.inject = injectSet;
|
|
201
|
+
for (const injectNode of injectSet) {
|
|
202
|
+
if (!injectNode._util) {
|
|
203
|
+
injectNode._util = { provide: /* @__PURE__ */ new Set() };
|
|
204
|
+
}
|
|
205
|
+
injectNode._util.provide.add(deepTravelNode);
|
|
206
|
+
}
|
|
207
|
+
travelFn(deepTravelNode);
|
|
178
208
|
}
|
|
179
209
|
function resortNodes(nodes) {
|
|
180
210
|
var _a, _b;
|
|
181
211
|
const hoistedNodeList = [];
|
|
182
|
-
const exportDeclarations = [];
|
|
183
212
|
for (const astNode of nodes) {
|
|
184
213
|
if (["ImportDeclaration", "FunctionDeclaration", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSTypeAliasDeclaration"].includes(astNode.type)) {
|
|
185
214
|
hoistedNodeList.push(astNode);
|
|
@@ -188,14 +217,13 @@ function resortNodes(nodes) {
|
|
|
188
217
|
const decType = (_a = astNode.declaration) == null ? void 0 : _a.type;
|
|
189
218
|
const decId = (_b = astNode.declaration) == null ? void 0 : _b.id;
|
|
190
219
|
if (["FunctionDeclaration", "TSEnumDeclaration", "TSInterfaceDeclaration", "TSTypeAliasDeclaration"].includes(decType) && decId) {
|
|
191
|
-
|
|
220
|
+
hoistedNodeList.push(astNode);
|
|
192
221
|
}
|
|
193
222
|
}
|
|
194
223
|
}
|
|
195
|
-
const notHoistedNodes = nodes.filter((node) => !
|
|
224
|
+
const notHoistedNodes = nodes.filter((node) => !hoistedNodeList.includes(node));
|
|
196
225
|
return {
|
|
197
226
|
hoistedNodeList,
|
|
198
|
-
exportDeclarations,
|
|
199
227
|
notHoistedNodes
|
|
200
228
|
};
|
|
201
229
|
}
|
|
@@ -212,47 +240,33 @@ function updateHoldingIdMap(holdingIdentifiers, holdingIdNameMap) {
|
|
|
212
240
|
holdingIdNameMap.set(holdingIdName, nodeSetOfIdName);
|
|
213
241
|
});
|
|
214
242
|
}
|
|
215
|
-
function
|
|
216
|
-
|
|
217
|
-
const params = deepTravelNode.params;
|
|
218
|
-
Array.isArray(params) && params.forEach((param) => {
|
|
219
|
-
(0, import_deepSearchParamsIdentifier.default)(param, (identifier) => {
|
|
220
|
-
holdingIdentifiers.push(identifier);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
function collectHoldingIdentifiers(ele, holdingIdentifiers, exportDeclarations) {
|
|
226
|
-
var _a, _b, _c;
|
|
243
|
+
function collectHoldingIdentifiers(ele, callback, importCallback) {
|
|
244
|
+
var _a, _b;
|
|
227
245
|
if (ele.type === "ImportDeclaration") {
|
|
228
246
|
const specifiers = ele.specifiers;
|
|
229
247
|
for (const specifier of specifiers) {
|
|
230
|
-
|
|
248
|
+
const local = specifier.local;
|
|
249
|
+
callback(local);
|
|
250
|
+
importCallback(local);
|
|
231
251
|
}
|
|
232
252
|
}
|
|
233
253
|
if (import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES.includes(ele.type)) {
|
|
234
254
|
const id = ele.id;
|
|
235
255
|
if (id) {
|
|
236
|
-
|
|
256
|
+
callback(id);
|
|
237
257
|
}
|
|
238
258
|
}
|
|
239
259
|
if (import_SHARED_CONSTANTS.EXPORT_DECLARATION_TYPES.includes((_a = ele.declaration) == null ? void 0 : _a.type)) {
|
|
240
260
|
const id = (_b = ele.declaration) == null ? void 0 : _b.id;
|
|
241
261
|
if (id) {
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (exportDeclarations.includes(ele)) {
|
|
246
|
-
const id = (_c = ele == null ? void 0 : ele.declaration) == null ? void 0 : _c.id;
|
|
247
|
-
if (id) {
|
|
248
|
-
holdingIdentifiers.push(id);
|
|
262
|
+
callback(id);
|
|
249
263
|
}
|
|
250
264
|
}
|
|
251
265
|
if (ele.type === "VariableDeclaration") {
|
|
252
266
|
Array.from(new Set(ele.declarations)).forEach((declaration) => {
|
|
253
267
|
const id = declaration.id;
|
|
254
268
|
if (id) {
|
|
255
|
-
(0, import_deepSearchParamsIdentifier.default)(id,
|
|
269
|
+
(0, import_deepSearchParamsIdentifier.default)(id, callback);
|
|
256
270
|
}
|
|
257
271
|
});
|
|
258
272
|
}
|
|
@@ -260,7 +274,7 @@ function collectHoldingIdentifiers(ele, holdingIdentifiers, exportDeclarations)
|
|
|
260
274
|
Array.from(new Set(ele.declaration.declarations)).forEach((declaration) => {
|
|
261
275
|
const id = declaration.id;
|
|
262
276
|
if (id) {
|
|
263
|
-
(0, import_deepSearchParamsIdentifier.default)(id,
|
|
277
|
+
(0, import_deepSearchParamsIdentifier.default)(id, callback);
|
|
264
278
|
}
|
|
265
279
|
});
|
|
266
280
|
}
|
|
@@ -296,6 +310,9 @@ function updateVariableScopeAndOccupation(deepTravelNode, holdingIdentifiers) {
|
|
|
296
310
|
const firstPick = deepTravelNode._util.variableScope[0];
|
|
297
311
|
if (firstPick && firstPick !== deepTravelNode) {
|
|
298
312
|
if (firstPick._util) {
|
|
313
|
+
if (!firstPick._util.occupation) {
|
|
314
|
+
firstPick._util.occupation = /* @__PURE__ */ new Set();
|
|
315
|
+
}
|
|
299
316
|
firstPick._util.occupation.add(deepTravelNode);
|
|
300
317
|
} else {
|
|
301
318
|
console.log(deepTravelNode._util.filePath, (_a = deepTravelNode.loc) == null ? void 0 : _a.start.line, deepTravelNode.type, deepTravelNode.name);
|
|
@@ -35,10 +35,11 @@ __export(filterEffectedExportMember_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(filterEffectedExportMember_exports);
|
|
36
36
|
var import_getAstKitByFilePath = __toESM(require("../ast_util/getAstKitByFilePath"));
|
|
37
37
|
var import_AstUtil = __toESM(require("../ast_util/AstUtil"));
|
|
38
|
+
var import_getEffectedExportMembersOfLineRange = __toESM(require("../ast_util/helper/getEffectedExportMembersOfLineRange"));
|
|
38
39
|
function filterEffectedExportMember(filePath, absPathPrefix, startLine, endLine) {
|
|
39
|
-
const astKit = (0, import_getAstKitByFilePath.default)(filePath, absPathPrefix
|
|
40
|
+
const astKit = (0, import_getAstKitByFilePath.default)(filePath, absPathPrefix);
|
|
40
41
|
const { mapFileLineToNodeSet } = astKit;
|
|
41
|
-
return
|
|
42
|
+
return (0, import_getEffectedExportMembersOfLineRange.default)(mapFileLineToNodeSet, startLine, endLine, filePath);
|
|
42
43
|
}
|
|
43
44
|
function extractEffectedExportMemberByLineRange(mapFileLineToNodeSet, startLine, endLine, filePath) {
|
|
44
45
|
const topScopeNodes = import_AstUtil.default.getTopScopeNodesByLineNumberRange(mapFileLineToNodeSet, startLine, endLine);
|
|
@@ -25,14 +25,13 @@ module.exports = __toCommonJS(collectUpstreamFiles_exports);
|
|
|
25
25
|
function collectUpstreamFiles(madgeResult, modifiedFilePaths, maxCount = 30) {
|
|
26
26
|
const changedFilePaths = [...modifiedFilePaths];
|
|
27
27
|
let tmpFiles = [...modifiedFilePaths];
|
|
28
|
-
for (let i = 0; i <
|
|
28
|
+
for (let i = 0; i < 9; i++) {
|
|
29
29
|
tmpFiles = tmpFiles.map((file) => madgeResult.depends(file)).flat();
|
|
30
30
|
if (tmpFiles.length === 0) {
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
changedFilePaths.push(...tmpFiles);
|
|
34
34
|
if (changedFilePaths.length > maxCount) {
|
|
35
|
-
break;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
return [...new Set(changedFilePaths)];
|