diff --git a/images/svg/DIDE.svg b/images/svg/DIDE.svg index 9e271a2..83ae052 100644 --- a/images/svg/DIDE.svg +++ b/images/svg/DIDE.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + \ No newline at end of file diff --git a/images/svg/view.svg b/images/svg/view.svg new file mode 100644 index 0000000..52e2deb --- /dev/null +++ b/images/svg/view.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/system.drawio b/images/system.drawio index 6a4def4..d1b4d55 100644 --- a/images/system.drawio +++ b/images/system.drawio @@ -1,6 +1,6 @@ - + @@ -60,4 +60,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json index f644dc0..d68c917 100644 --- a/package.json +++ b/package.json @@ -318,15 +318,24 @@ } ] }, + "viewsContainers": { + "activitybar": [ + { + "id": "TreeView", + "title": "Digital-IDE", + "icon": "images/svg/view.svg" + } + ] + }, "views": { - "TOOL": [ + "TreeView": [ { "id": "digital-ide-treeView-arch", "name": "architecture" }, { "id": "digital-ide-treeView-tool", - "name": "TOOL" + "name": "TOOL Options" }, { "id": "digital-ide-treeView-hardware", diff --git a/project/property-init.json b/project/property-init.json index 5bff5f5..07c77fc 100644 --- a/project/property-init.json +++ b/project/property-init.json @@ -6,6 +6,18 @@ "soc": { "core": "none" }, + "arch": { + "prjPath": "./prj", + "hardware": { + "src": "./user/src", + "sim": "./user/sim", + "data": "./user/data" + }, + "software": { + "src": "./user/software/src", + "data": "./user/software/data" + } + }, "enableShowLog": false, "device": "none" } \ No newline at end of file diff --git a/src/function/treeView/command.ts b/src/function/treeView/command.ts index c350e87..39d1b17 100644 --- a/src/function/treeView/command.ts +++ b/src/function/treeView/command.ts @@ -49,10 +49,16 @@ class BaseCommandTreeProvider implements vscode.TreeDataProvider { - const childNum = Object.keys(element.children).length; + const childNum = this.getElementChildrenNum(element); const treeItem = new vscode.TreeItem( element.name, childNum === 0 ? diff --git a/src/global/prjInfo.ts b/src/global/prjInfo.ts index 67a338e..1777476 100644 --- a/src/global/prjInfo.ts +++ b/src/global/prjInfo.ts @@ -225,7 +225,6 @@ class PrjInfo implements PrjInfoMeta { uniformPath = toSlash(uniformPath); - if (check) { if (fs.existsSync(uniformPath)) { return uniformPath; @@ -472,11 +471,19 @@ class PrjInfo implements PrjInfoMeta { } public get libCommonPath(): AbsPath { - return join(this._extensionPath, 'lib', 'common'); + const libPath = join(this._extensionPath, 'lib', 'common'); + if (!fs.existsSync(libPath)) { + vscode.window.showErrorMessage('common lib path in extension is invalid, maybe extension has been corrupted, reinstall the extension'); + } + return libPath; } public get libCustomPath(): AbsPath { - return vscode.workspace.getConfiguration().get('prj.lib.custom.path', this._workspacePath); + const libPath = vscode.workspace.getConfiguration().get('prj.lib.custom.path', this._workspacePath); + if (!fs.existsSync(libPath)) { + vscode.window.showErrorMessage('property "prj.lib.custom.path" is empty or is an invalid path'); + } + return libPath; } public json(): RawPrjInfo { diff --git a/src/hdlFs/file.ts b/src/hdlFs/file.ts index 4186767..ca459b6 100644 --- a/src/hdlFs/file.ts +++ b/src/hdlFs/file.ts @@ -248,7 +248,7 @@ function copyFile(src: AbsPath, dest: AbsPath, cover: boolean = true): boolean { } try { - let parent = fspath.dirname(dest); + const parent = fspath.dirname(dest); fs.mkdirSync(parent, {recursive: true}); if (!fs.existsSync(dest) || cover) { fs.copyFileSync(src, dest); @@ -297,8 +297,8 @@ function isHasAttr(obj: any, attr: string): boolean{ attr = attr.replace(/\[(\w+)\]/g, '.$1'); attr = attr.replace(/^\./, ''); - let keyArr = attr.split('.'); - for (let i = 0; i < keyArr.length; i++) { + const keyArr = attr.split('.'); + for (let i = 0; i < keyArr.length; ++ i) { const element = keyArr[i]; if (!tempObj) { return false; @@ -321,8 +321,8 @@ function isHasValue(obj: any, attr: string, value: any): boolean{ attr = attr.replace(/\[(\w+)\]/g, '.$1'); attr = attr.replace(/^\./, ''); - let keyArr = attr.split('.'); - for (let i = 0; i < keyArr.length; i++) { + const keyArr = attr.split('.'); + for (let i = 0; i < keyArr.length; ++ i) { const element = keyArr[i]; if (!tempObj) { return false; diff --git a/src/manager/lib.ts b/src/manager/lib.ts index 5fd5a1d..c21e851 100644 --- a/src/manager/lib.ts +++ b/src/manager/lib.ts @@ -168,13 +168,19 @@ class LibManage { } remote2Local(remotes: Path[], callback: (src: AbsPath, dist: AbsPath) => void) { + const localLibPath = this.localLibPath; + const sourceLibPath = this.sourceLibPath; + const customerPath = this.customerPath; + const customerPathValid = hdlFile.isDir(customerPath); + for (const src of remotes) { let dist; - if (src.includes(this.customerPath)) { - dist = src.replace(this.customerPath, this.localLibPath); + if (customerPathValid && src.includes(customerPath)) { + dist = src.replace(customerPath, localLibPath); } else { - dist = src.replace(this.sourceLibPath, this.localLibPath); + dist = src.replace(sourceLibPath, localLibPath); } + callback(src, dist); } } diff --git a/src/manager/libPick.ts b/src/manager/libPick.ts index e606db6..8a15caf 100644 --- a/src/manager/libPick.ts +++ b/src/manager/libPick.ts @@ -22,8 +22,8 @@ class LibPick { selectedQuickPickItem: LibPickItem | undefined; constructor () { - this.commonPath = hdlPath.join(opeParam.extensionPath, 'lib', 'common'); - this.customPath = hdlPath.toSlash(vscode.workspace.getConfiguration('PRJ.custom.Lib.repo').get('path', '')); + this.commonPath = opeParam.prjInfo.libCommonPath; + this.customPath = opeParam.prjInfo.libCustomPath; this.commonQuickPickItem = { label: "$(libpick-common) common", @@ -72,6 +72,18 @@ class LibPick { return `$(libpick-${prompt})`; } + private getReadmeText(path: AbsPath, fileName: string): string | undefined { + const mdPath1 = hdlPath.join(path, fileName, 'readme.md'); + if (fs.existsSync(mdPath1)) { + return hdlFile.readFile(mdPath1); + } + const mdPath2 = hdlPath.join(path, fileName, 'README.md'); + if (fs.existsSync(mdPath2)) { + return hdlFile.readFile(mdPath2); + } + return undefined; + } + private makeQuickPickItemsByPath(path: AbsPath, back: boolean=true): LibPickItem[] { const items: LibPickItem[] = []; if (!hdlPath.exist(path)) { @@ -85,8 +97,7 @@ class LibPick { const filePath = hdlPath.join(path, fileName); const themeIcon = this.getPathIcon(filePath); const label = themeIcon + " " + fileName; - const mdPath = hdlPath.join(path, fileName, 'readme.md'); - const mdText = hdlFile.readFile(mdPath); + const mdText = this.getReadmeText(path, fileName); const description = mdText ? mdText : ''; const buttons = [{iconPath: getIconConfig('import'), tooltip: 'import everything in ' + fileName}]; items.push({label, description, path: filePath, buttons}); @@ -125,14 +136,12 @@ class LibPick { pickWidget.items = this.provideQuickPickItem(); pickWidget.onDidChangeSelection(items => { - console.log('enter onDidChangeSelection'); if (items[0]) { this.selectedQuickPickItem = items[0]; } }); pickWidget.onDidAccept(() => { - console.log('enter onDidAccept'); if (this.selectedQuickPickItem) { const childernItems = this.provideQuickPickItem(this.selectedQuickPickItem); if (childernItems && childernItems.length > 0) { diff --git a/src/manager/prj.ts b/src/manager/prj.ts index 135c934..1ed9d45 100644 --- a/src/manager/prj.ts +++ b/src/manager/prj.ts @@ -15,7 +15,8 @@ class PrjManage { vscode.window.showWarningMessage('property file already exists !!!'); return; } - const template = hdlFile.readJSON(opeParam.propertyInitPath); + const template = hdlFile.readJSON(opeParam.propertyInitPath) as RawPrjInfo; + template.arch?.hardware. hdlFile.writeJSON(opeParam.propertyJsonPath, template); }