diff --git a/lib/tsserver.js b/lib/tsserver.js index 1c17251281..9ebcc51e01 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -196529,7 +196529,7 @@ var ts; function srcFilePathContainsDirectory(srcFile, dir) { var pathComps = srcFilePathComponents.get(srcFile); if (!pathComps) { - pathComps = ts.getPathComponents(Utils.normalizePath(srcFile.fileName)); + pathComps = ts.getPathComponents(ts.normalizePath(srcFile.fileName)); srcFilePathComponents.set(srcFile, pathComps); } for (var _i = 0, pathComps_1 = pathComps; _i < pathComps_1.length; _i++) { @@ -197300,23 +197300,9 @@ var ts; return exportDeclSet; } Utils.searchFileExportDecl = searchFileExportDecl; - var normalizedPathCache = new ts.Map(); - function normalizePath(path) { - normalizedPathCache = normalizedPathCache ? normalizedPathCache : new ts.Map(); - var cached = normalizedPathCache.get(path); - if (cached) { - return cached; - } - var normalized = ts.normalizePath(path); - normalizedPathCache.set(path, normalized); - return normalized; - } - Utils.normalizePath = normalizePath; function clearUtilsGlobalvariables() { parentSymbolCache === null || parentSymbolCache === void 0 ? void 0 : parentSymbolCache.clear(); parentSymbolCache = undefined; - normalizedPathCache === null || normalizedPathCache === void 0 ? void 0 : normalizedPathCache.clear(); - normalizedPathCache = undefined; } Utils.clearUtilsGlobalvariables = clearUtilsGlobalvariables; })(Utils = ArkTSLinter_1_1.Utils || (ArkTSLinter_1_1.Utils = {})); @@ -200608,15 +200594,14 @@ var ts; ArkTSLinter_1_1.Utils.setTypeChecker(ArkTSLinter_1_1.TypeScriptLinter.tsTypeChecker); linter.lint(); // Get list of bad nodes from the current run. - currentDiagnostics = (_a = tscStrictDiagnostics.get(ArkTSLinter_1_1.Utils.normalizePath(fileToLint.fileName))) !== null && _a !== void 0 ? _a : []; + currentDiagnostics = (_a = tscStrictDiagnostics.get(ts.normalizePath(fileToLint.fileName))) !== null && _a !== void 0 ? _a : []; ArkTSLinter_1_1.TypeScriptLinter.problemsInfos.forEach(function (x) { return currentDiagnostics.push(translateDiag(fileToLint, x)); }); } else { ArkTSLinter_1_1.InteropTypescriptLinter.initStatic(); var isKit = ts.getBaseFileName(fileToLint.fileName).indexOf('@kit.') === 0; var etsLoaderPath = program.getCompilerOptions().etsLoaderPath; - var isInSdk = etsLoaderPath ? - ArkTSLinter_1_1.Utils.normalizePath(fileToLint.fileName).indexOf(ts.resolvePath(etsLoaderPath, '../..')) === 0 : false; + var isInSdk = etsLoaderPath ? ts.normalizePath(fileToLint.fileName).indexOf(ts.resolvePath(etsLoaderPath, '../..')) === 0 : false; var isInOhModules = ts.isOHModules(fileToLint.fileName); var tsImportSendableEnable = program.getCompilerOptions().tsImportSendableEnable; if (isKit || isInOhModules || (!tsImportSendableEnable && !isInSdk)) { diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 5b8521ad37..9219c3dbb2 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -13459,7 +13459,6 @@ declare namespace ts { function isNonSendableFunctionTypeAlias(type: ts.Type): boolean; function isWrongSendableFunctionAssignment(lhsType: ts.Type, rhsType: ts.Type): boolean; function searchFileExportDecl(sourceFile: ts.SourceFile, targetDecls?: ts.SyntaxKind[]): Set; - function normalizePath(path: string): string; function clearUtilsGlobalvariables(): void; } } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 657dc128fa..e7847c47c2 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -196274,7 +196274,7 @@ var ts; function srcFilePathContainsDirectory(srcFile, dir) { var pathComps = srcFilePathComponents.get(srcFile); if (!pathComps) { - pathComps = ts.getPathComponents(Utils.normalizePath(srcFile.fileName)); + pathComps = ts.getPathComponents(ts.normalizePath(srcFile.fileName)); srcFilePathComponents.set(srcFile, pathComps); } for (var _i = 0, pathComps_1 = pathComps; _i < pathComps_1.length; _i++) { @@ -197045,23 +197045,9 @@ var ts; return exportDeclSet; } Utils.searchFileExportDecl = searchFileExportDecl; - var normalizedPathCache = new ts.Map(); - function normalizePath(path) { - normalizedPathCache = normalizedPathCache ? normalizedPathCache : new ts.Map(); - var cached = normalizedPathCache.get(path); - if (cached) { - return cached; - } - var normalized = ts.normalizePath(path); - normalizedPathCache.set(path, normalized); - return normalized; - } - Utils.normalizePath = normalizePath; function clearUtilsGlobalvariables() { parentSymbolCache === null || parentSymbolCache === void 0 ? void 0 : parentSymbolCache.clear(); parentSymbolCache = undefined; - normalizedPathCache === null || normalizedPathCache === void 0 ? void 0 : normalizedPathCache.clear(); - normalizedPathCache = undefined; } Utils.clearUtilsGlobalvariables = clearUtilsGlobalvariables; })(Utils = ArkTSLinter_1_1.Utils || (ArkTSLinter_1_1.Utils = {})); @@ -200353,15 +200339,14 @@ var ts; ArkTSLinter_1_1.Utils.setTypeChecker(ArkTSLinter_1_1.TypeScriptLinter.tsTypeChecker); linter.lint(); // Get list of bad nodes from the current run. - currentDiagnostics = (_a = tscStrictDiagnostics.get(ArkTSLinter_1_1.Utils.normalizePath(fileToLint.fileName))) !== null && _a !== void 0 ? _a : []; + currentDiagnostics = (_a = tscStrictDiagnostics.get(ts.normalizePath(fileToLint.fileName))) !== null && _a !== void 0 ? _a : []; ArkTSLinter_1_1.TypeScriptLinter.problemsInfos.forEach(function (x) { return currentDiagnostics.push(translateDiag(fileToLint, x)); }); } else { ArkTSLinter_1_1.InteropTypescriptLinter.initStatic(); var isKit = ts.getBaseFileName(fileToLint.fileName).indexOf('@kit.') === 0; var etsLoaderPath = program.getCompilerOptions().etsLoaderPath; - var isInSdk = etsLoaderPath ? - ArkTSLinter_1_1.Utils.normalizePath(fileToLint.fileName).indexOf(ts.resolvePath(etsLoaderPath, '../..')) === 0 : false; + var isInSdk = etsLoaderPath ? ts.normalizePath(fileToLint.fileName).indexOf(ts.resolvePath(etsLoaderPath, '../..')) === 0 : false; var isInOhModules = ts.isOHModules(fileToLint.fileName); var tsImportSendableEnable = program.getCompilerOptions().tsImportSendableEnable; if (isKit || isInOhModules || (!tsImportSendableEnable && !isInSdk)) { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index e0c027c513..40cd06e408 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -9513,7 +9513,6 @@ declare namespace ts { function isNonSendableFunctionTypeAlias(type: ts.Type): boolean; function isWrongSendableFunctionAssignment(lhsType: ts.Type, rhsType: ts.Type): boolean; function searchFileExportDecl(sourceFile: ts.SourceFile, targetDecls?: ts.SyntaxKind[]): Set; - function normalizePath(path: string): string; function clearUtilsGlobalvariables(): void; } } diff --git a/lib/typescript.js b/lib/typescript.js index 8290297d13..07f343e00b 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -185368,7 +185368,7 @@ var ts; function srcFilePathContainsDirectory(srcFile, dir) { var pathComps = srcFilePathComponents.get(srcFile); if (!pathComps) { - pathComps = ts.getPathComponents(Utils.normalizePath(srcFile.fileName)); + pathComps = ts.getPathComponents(ts.normalizePath(srcFile.fileName)); srcFilePathComponents.set(srcFile, pathComps); } for (var _i = 0, pathComps_1 = pathComps; _i < pathComps_1.length; _i++) { @@ -186139,23 +186139,9 @@ var ts; return exportDeclSet; } Utils.searchFileExportDecl = searchFileExportDecl; - var normalizedPathCache = new ts.Map(); - function normalizePath(path) { - normalizedPathCache = normalizedPathCache ? normalizedPathCache : new ts.Map(); - var cached = normalizedPathCache.get(path); - if (cached) { - return cached; - } - var normalized = ts.normalizePath(path); - normalizedPathCache.set(path, normalized); - return normalized; - } - Utils.normalizePath = normalizePath; function clearUtilsGlobalvariables() { parentSymbolCache === null || parentSymbolCache === void 0 ? void 0 : parentSymbolCache.clear(); parentSymbolCache = undefined; - normalizedPathCache === null || normalizedPathCache === void 0 ? void 0 : normalizedPathCache.clear(); - normalizedPathCache = undefined; } Utils.clearUtilsGlobalvariables = clearUtilsGlobalvariables; })(Utils = ArkTSLinter_1_1.Utils || (ArkTSLinter_1_1.Utils = {})); @@ -189447,15 +189433,14 @@ var ts; ArkTSLinter_1_1.Utils.setTypeChecker(ArkTSLinter_1_1.TypeScriptLinter.tsTypeChecker); linter.lint(); // Get list of bad nodes from the current run. - currentDiagnostics = (_a = tscStrictDiagnostics.get(ArkTSLinter_1_1.Utils.normalizePath(fileToLint.fileName))) !== null && _a !== void 0 ? _a : []; + currentDiagnostics = (_a = tscStrictDiagnostics.get(ts.normalizePath(fileToLint.fileName))) !== null && _a !== void 0 ? _a : []; ArkTSLinter_1_1.TypeScriptLinter.problemsInfos.forEach(function (x) { return currentDiagnostics.push(translateDiag(fileToLint, x)); }); } else { ArkTSLinter_1_1.InteropTypescriptLinter.initStatic(); var isKit = ts.getBaseFileName(fileToLint.fileName).indexOf('@kit.') === 0; var etsLoaderPath = program.getCompilerOptions().etsLoaderPath; - var isInSdk = etsLoaderPath ? - ArkTSLinter_1_1.Utils.normalizePath(fileToLint.fileName).indexOf(ts.resolvePath(etsLoaderPath, '../..')) === 0 : false; + var isInSdk = etsLoaderPath ? ts.normalizePath(fileToLint.fileName).indexOf(ts.resolvePath(etsLoaderPath, '../..')) === 0 : false; var isInOhModules = ts.isOHModules(fileToLint.fileName); var tsImportSendableEnable = program.getCompilerOptions().tsImportSendableEnable; if (isKit || isInOhModules || (!tsImportSendableEnable && !isInSdk)) { diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index fc8530ae83..85e82a69ad 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -9513,7 +9513,6 @@ declare namespace ts { function isNonSendableFunctionTypeAlias(type: ts.Type): boolean; function isWrongSendableFunctionAssignment(lhsType: ts.Type, rhsType: ts.Type): boolean; function searchFileExportDecl(sourceFile: ts.SourceFile, targetDecls?: ts.SyntaxKind[]): Set; - function normalizePath(path: string): string; function clearUtilsGlobalvariables(): void; } } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 9b251d8075..41bb79ad76 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -185368,7 +185368,7 @@ var ts; function srcFilePathContainsDirectory(srcFile, dir) { var pathComps = srcFilePathComponents.get(srcFile); if (!pathComps) { - pathComps = ts.getPathComponents(Utils.normalizePath(srcFile.fileName)); + pathComps = ts.getPathComponents(ts.normalizePath(srcFile.fileName)); srcFilePathComponents.set(srcFile, pathComps); } for (var _i = 0, pathComps_1 = pathComps; _i < pathComps_1.length; _i++) { @@ -186139,23 +186139,9 @@ var ts; return exportDeclSet; } Utils.searchFileExportDecl = searchFileExportDecl; - var normalizedPathCache = new ts.Map(); - function normalizePath(path) { - normalizedPathCache = normalizedPathCache ? normalizedPathCache : new ts.Map(); - var cached = normalizedPathCache.get(path); - if (cached) { - return cached; - } - var normalized = ts.normalizePath(path); - normalizedPathCache.set(path, normalized); - return normalized; - } - Utils.normalizePath = normalizePath; function clearUtilsGlobalvariables() { parentSymbolCache === null || parentSymbolCache === void 0 ? void 0 : parentSymbolCache.clear(); parentSymbolCache = undefined; - normalizedPathCache === null || normalizedPathCache === void 0 ? void 0 : normalizedPathCache.clear(); - normalizedPathCache = undefined; } Utils.clearUtilsGlobalvariables = clearUtilsGlobalvariables; })(Utils = ArkTSLinter_1_1.Utils || (ArkTSLinter_1_1.Utils = {})); @@ -189447,15 +189433,14 @@ var ts; ArkTSLinter_1_1.Utils.setTypeChecker(ArkTSLinter_1_1.TypeScriptLinter.tsTypeChecker); linter.lint(); // Get list of bad nodes from the current run. - currentDiagnostics = (_a = tscStrictDiagnostics.get(ArkTSLinter_1_1.Utils.normalizePath(fileToLint.fileName))) !== null && _a !== void 0 ? _a : []; + currentDiagnostics = (_a = tscStrictDiagnostics.get(ts.normalizePath(fileToLint.fileName))) !== null && _a !== void 0 ? _a : []; ArkTSLinter_1_1.TypeScriptLinter.problemsInfos.forEach(function (x) { return currentDiagnostics.push(translateDiag(fileToLint, x)); }); } else { ArkTSLinter_1_1.InteropTypescriptLinter.initStatic(); var isKit = ts.getBaseFileName(fileToLint.fileName).indexOf('@kit.') === 0; var etsLoaderPath = program.getCompilerOptions().etsLoaderPath; - var isInSdk = etsLoaderPath ? - ArkTSLinter_1_1.Utils.normalizePath(fileToLint.fileName).indexOf(ts.resolvePath(etsLoaderPath, '../..')) === 0 : false; + var isInSdk = etsLoaderPath ? ts.normalizePath(fileToLint.fileName).indexOf(ts.resolvePath(etsLoaderPath, '../..')) === 0 : false; var isInOhModules = ts.isOHModules(fileToLint.fileName); var tsImportSendableEnable = program.getCompilerOptions().tsImportSendableEnable; if (isKit || isInOhModules || (!tsImportSendableEnable && !isInSdk)) { diff --git a/src/linter/ArkTSLinter_1_1/LinterRunner.ts b/src/linter/ArkTSLinter_1_1/LinterRunner.ts index dfecedf8a1..f28501fb9e 100644 --- a/src/linter/ArkTSLinter_1_1/LinterRunner.ts +++ b/src/linter/ArkTSLinter_1_1/LinterRunner.ts @@ -94,14 +94,13 @@ export function runArkTSLinter(tsBuilderProgram: BuilderProgram, srcFile?: Sourc linter.lint(); // Get list of bad nodes from the current run. - currentDiagnostics = tscStrictDiagnostics.get(Utils.normalizePath(fileToLint.fileName)) ?? []; + currentDiagnostics = tscStrictDiagnostics.get(normalizePath(fileToLint.fileName)) ?? []; TypeScriptLinter.problemsInfos.forEach((x) => currentDiagnostics.push(translateDiag(fileToLint, x))); } else { InteropTypescriptLinter.initStatic(); const isKit = ts.getBaseFileName(fileToLint.fileName).indexOf('@kit.') === 0; const etsLoaderPath = program.getCompilerOptions().etsLoaderPath; - const isInSdk = etsLoaderPath ? - Utils.normalizePath(fileToLint.fileName).indexOf(resolvePath(etsLoaderPath, '../..')) === 0 : false; + const isInSdk = etsLoaderPath ? normalizePath(fileToLint.fileName).indexOf(resolvePath(etsLoaderPath, '../..')) === 0 : false; const isInOhModules = isOHModules(fileToLint.fileName); const tsImportSendableEnable = program.getCompilerOptions().tsImportSendableEnable; if (isKit || isInOhModules || (!tsImportSendableEnable && !isInSdk)) { diff --git a/src/linter/ArkTSLinter_1_1/Utils.ts b/src/linter/ArkTSLinter_1_1/Utils.ts index 53b6c9a2db..b6dc69c2eb 100644 --- a/src/linter/ArkTSLinter_1_1/Utils.ts +++ b/src/linter/ArkTSLinter_1_1/Utils.ts @@ -1534,7 +1534,7 @@ const srcFilePathComponents = new Map(); export function srcFilePathContainsDirectory(srcFile: SourceFile, dir: string): boolean { let pathComps = srcFilePathComponents.get(srcFile); if (!pathComps) { - pathComps = getPathComponents(Utils.normalizePath(srcFile.fileName)); + pathComps = getPathComponents(normalizePath(srcFile.fileName)); srcFilePathComponents.set(srcFile, pathComps); } for (const subdir of pathComps) { @@ -2355,23 +2355,9 @@ export function searchFileExportDecl(sourceFile: ts.SourceFile, targetDecls?: ts return exportDeclSet; } -let normalizedPathCache: ESMap | undefined = new Map(); -export function normalizePath(path: string): string { - normalizedPathCache = normalizedPathCache ? normalizedPathCache : new Map(); - const cached = normalizedPathCache.get(path); - if (cached) { - return cached; - } - const normalized = ts.normalizePath(path); - normalizedPathCache.set(path, normalized); - return normalized; -} - export function clearUtilsGlobalvariables(): void { parentSymbolCache?.clear(); parentSymbolCache = undefined; - normalizedPathCache?.clear(); - normalizedPathCache = undefined; } } } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5b8521ad37..9219c3dbb2 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -13459,7 +13459,6 @@ declare namespace ts { function isNonSendableFunctionTypeAlias(type: ts.Type): boolean; function isWrongSendableFunctionAssignment(lhsType: ts.Type, rhsType: ts.Type): boolean; function searchFileExportDecl(sourceFile: ts.SourceFile, targetDecls?: ts.SyntaxKind[]): Set; - function normalizePath(path: string): string; function clearUtilsGlobalvariables(): void; } } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index e0c027c513..40cd06e408 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -9513,7 +9513,6 @@ declare namespace ts { function isNonSendableFunctionTypeAlias(type: ts.Type): boolean; function isWrongSendableFunctionAssignment(lhsType: ts.Type, rhsType: ts.Type): boolean; function searchFileExportDecl(sourceFile: ts.SourceFile, targetDecls?: ts.SyntaxKind[]): Set; - function normalizePath(path: string): string; function clearUtilsGlobalvariables(): void; } }