From 8a473d33a4d81502b731791a1c566c7238e59438 Mon Sep 17 00:00:00 2001 From: lihong Date: Tue, 9 Aug 2022 09:17:35 +0000 Subject: [PATCH] lihong67@huawei.com revert optimize ts check increment. Signed-off-by: lihong Change-Id: I2ed2c793d0c51cf9d9c3ddca428bc95486230745 --- compiler/src/compile_info.ts | 57 +----------------------------------- compiler/src/ets_checker.ts | 27 ----------------- 2 files changed, 1 insertion(+), 83 deletions(-) diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 50dcce1..965a083 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -68,19 +68,6 @@ interface Info { }; } -export interface CacheFileName { - mtimeMs: number, - children: string[], - error: boolean -} - -interface NeedUpdateFlag { - flag: boolean; -} - -export let cache: Cache; -type Cache = Record; - export class ResultStates { private mStats: Stats; private mErrorCount: number = 0; @@ -199,10 +186,7 @@ export class ResultStates { createWatchCompilerHost(rootFileNames, this.printDiagnostic.bind(this), this.delayPrintLogCount.bind(this))); } else { - const cacheFile = path.resolve(projectConfig.cachePath, '../.ts_checker_cache'); - cache = fs.existsSync(cacheFile) ? JSON.parse(fs.readFileSync(cacheFile).toString()) : {}; - const filterFiles: string[] = filterInput(rootFileNames); - const languageService: ts.LanguageService = createLanguageService(filterFiles); + const languageService: ts.LanguageService = createLanguageService(rootFileNames); globalProgram.program = languageService.getProgram(); const allDiagnostics: ts.Diagnostic[] = globalProgram.program .getSyntacticDiagnostics() @@ -211,7 +195,6 @@ export class ResultStates { allDiagnostics.forEach((diagnostic: ts.Diagnostic) => { this.printDiagnostic(diagnostic); }); - fs.writeFileSync(cacheFile, JSON.stringify(cache, null, 2)); } }); @@ -236,9 +219,6 @@ export class ResultStates { private printDiagnostic(diagnostic: ts.Diagnostic): void { const message: string = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); if (this.validateError(message)) { - if (process.env.watchMode !== 'true') { - updateErrorFileCache(diagnostic); - } this.mErrorCount += 1; if (diagnostic.file) { const { line, character }: ts.LineAndCharacter = @@ -431,38 +411,3 @@ export class ResultStates { return message; } } - -function updateErrorFileCache(diagnostic: ts.Diagnostic): void { - if (diagnostic.file && cache[path.resolve(diagnostic.file.fileName)]) { - cache[path.resolve(diagnostic.file.fileName)].error = true; - } -} - -function filterInput(rootFileNames: string[]): string[] { - return rootFileNames.filter((file: string) => { - const needUpdate: NeedUpdateFlag = { flag: false }; - checkNeedUpdateFiles(path.resolve(file), needUpdate); - return needUpdate.flag; - }); -} - -function checkNeedUpdateFiles(file: string, needUpdate: NeedUpdateFlag): void { - if (needUpdate.flag) { - return; - } - - const value: CacheFileName = cache[file]; - const mtimeMs: number = fs.statSync(file).mtimeMs; - if (value) { - if (value.error || value.mtimeMs !== mtimeMs) { - needUpdate.flag = true; - return; - } - for (let i = 0; i < value.children.length; ++i) { - checkNeedUpdateFiles(value.children[i], needUpdate); - } - } else { - cache[file] = { mtimeMs, children: [], error: false }; - needUpdate.flag = true; - } -} diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 903d509..587da55 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -41,10 +41,6 @@ import { getName } from './process_component_build'; import { INNER_COMPONENT_NAMES } from './component_map'; import { props } from './compile_info'; import { resolveSourceFile } from './resolve_ohm_url'; -import { - CacheFileName, - cache -} from './compile_info'; function readDeaclareFiles(): string[] { const declarationsFileNames: string[] = []; @@ -186,32 +182,9 @@ function resolveModuleNames(moduleNames: string[], containingFile: string): ts.R } } } - if (process.env.watchMode !== 'true') { - createOrUpdateCache(resolvedModules, containingFile); - } return resolvedModules; } -function createOrUpdateCache(resolvedModules: ts.ResolvedModuleFull[], containingFile: string): void { - const children: string[] = []; - const error: boolean = false; - resolvedModules.forEach(moduleObj => { - if (moduleObj && moduleObj.resolvedFileName && /(? {