diff --git a/src/global/opeParam.ts b/src/global/opeParam.ts index d398aa0..c6e40b8 100644 --- a/src/global/opeParam.ts +++ b/src/global/opeParam.ts @@ -1,5 +1,6 @@ import * as assert from 'assert'; import * as fs from 'fs'; +import { hdlFile } from '../hdlFs'; import { Arch, PrjInfo, RawPrjInfo, resolve, toSlash } from './prjInfo'; @@ -141,6 +142,22 @@ class OpeParam { public resolvePathExtension(relPath: RelPath): AbsPath { return resolve(this._extensionPath, relPath); } + + /** + * get User's property.json + */ + public getUserPrjInfo() { + const propertyJsonPath = this.propertyJsonPath; + const userPrjInfo = new PrjInfo(); + if (fs.existsSync(propertyJsonPath)) { + const rawPrjInfo = hdlFile.readJSON(propertyJsonPath); + userPrjInfo.merge(rawPrjInfo); + } else { + // use default config instead + const rawPrjInfo = hdlFile.readJSON(this.propertyInitPath); + userPrjInfo.merge(rawPrjInfo); + } + } }; const opeParam: OpeParam = new OpeParam(); diff --git a/src/manager/libPick.ts b/src/manager/libPick.ts index 0c933ad..62458b8 100644 --- a/src/manager/libPick.ts +++ b/src/manager/libPick.ts @@ -145,6 +145,8 @@ class LibPick { if (selectedPath && hdlPath.exist(selectedPath)) { const ppyPath = hdlPath.join(opeParam.workspacePath, '.vscode', 'property.json'); + + // 抽象这块 let prjInfo = null; // 如果存在,则读取用户的配置文件,否则使用默认的 if (!hdlPath.exist(ppyPath)) { @@ -152,11 +154,10 @@ class LibPick { } else { prjInfo = hdlFile.readJSON(ppyPath); } - + if (selectedPath.includes(this.commonQuickPickItem.path!)) { // this is a module import from common, use relative path - const relPath = selectedPath.replace(this.commonQuickPickItem.path + '/', ''); - + const relPath = selectedPath.replace(this.commonQuickPickItem.path + '/', ''); appendLibraryCommonPath(relPath, prjInfo); } else { // this is a module import from custom, use absolute path diff --git a/src/manager/prj.ts b/src/manager/prj.ts index 8978ba5..fc4184a 100644 --- a/src/manager/prj.ts +++ b/src/manager/prj.ts @@ -86,7 +86,6 @@ class PrjManage { public initialise() { } - } const prjManage = new PrjManage();