From 2e41f742964874a530bd6d9cf28b6e08acaedb68 Mon Sep 17 00:00:00 2001 From: jiangbo Date: Mon, 20 Jun 2022 19:38:10 +0800 Subject: [PATCH] jiangbo91@huawei.com fix system module name case sensitive. Signed-off-by: jiangbo --- compiler/main.js | 9 +++++++++ compiler/src/ets_checker.ts | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index 9c3b6c5..2b5bb55 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -44,6 +44,7 @@ const resources = { app: {}, sys: {} }; +const systemModules = []; const abilityPagesFullPath = []; function initProjectConfig(projectConfig) { @@ -304,6 +305,13 @@ function filterWorker(workerPath) { } })() +;(function readSystemModules() { + const systemModulesPath = path.resolve(__dirname,'../../api'); + if (fs.existsSync(systemModulesPath)) { + systemModules.push(...fs.readdirSync(systemModulesPath)); + } +})() + function readAppResource(resources, filePath) { if (fs.existsSync(filePath)) { const appResource = fs.readFileSync(filePath, "utf-8"); @@ -374,3 +382,4 @@ exports.abilityConfig = abilityConfig; exports.readWorkerFile = readWorkerFile; exports.abilityPagesFullPath = abilityPagesFullPath; exports.loadModuleInfo = loadModuleInfo; +exports.systemModules = systemModules; diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index f976be3..a8ea338 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -17,7 +17,10 @@ import fs from 'fs'; import path from 'path'; import * as ts from 'typescript'; -import { projectConfig } from '../main'; +import { + projectConfig, + systemModules +} from '../main'; import { processSystemApi, preprocessExtend, @@ -142,7 +145,7 @@ function resolveModuleNames(moduleNames: string[], containingFile: string): ts.R } } else if (/^@(system|ohos)/.test(moduleName.trim())) { const modulePath: string = path.resolve(__dirname, '../../../api', moduleName + '.d.ts'); - if (ts.sys.fileExists(modulePath)) { + if (systemModules.includes(moduleName + '.d.ts') && ts.sys.fileExists(modulePath)) { resolvedModules.push(getResolveModule(modulePath, '.d.ts')); } else { resolvedModules.push(null);