do LibPick
This commit is contained in:
parent
a246fbdebe
commit
52349329df
37
package.json
37
package.json
@ -273,6 +273,23 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"menus": {
|
"menus": {
|
||||||
|
"view/title": [
|
||||||
|
{
|
||||||
|
"command": "digital-ide.treeView.arch.collapse",
|
||||||
|
"group": "navigation",
|
||||||
|
"when": "view == digital-ide-treeView-arch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "TOOL.libPick",
|
||||||
|
"group": "navigation",
|
||||||
|
"when": "view == digital-ide-treeView-arch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "digital-ide.treeView.arch.refresh",
|
||||||
|
"group": "navigation",
|
||||||
|
"when": "view == digital-ide-treeView-arch"
|
||||||
|
}
|
||||||
|
],
|
||||||
"editor/title": [
|
"editor/title": [
|
||||||
{
|
{
|
||||||
"when": "editorLangId == verilog || editorLangId == systemverilog || editorLangId == vhdl",
|
"when": "editorLangId == verilog || editorLangId == systemverilog || editorLangId == vhdl",
|
||||||
@ -286,6 +303,26 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"views": {
|
||||||
|
"TOOL": [
|
||||||
|
{
|
||||||
|
"id": "digital-ide-treeView-arch",
|
||||||
|
"name": "architecture"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "digital-ide-treeView-tool",
|
||||||
|
"name": "TOOL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "digital-ide-treeView-hardware",
|
||||||
|
"name": "HARD Options"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "digital-ide-treeView-software",
|
||||||
|
"name": "SOFT Options"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"keybindings": [
|
"keybindings": [
|
||||||
{
|
{
|
||||||
"command": "digital-ide.tool.instance",
|
"command": "digital-ide.tool.instance",
|
||||||
|
@ -7,24 +7,24 @@
|
|||||||
"digital-ide.tool.instance.title": "生成选中 module 的例化模板",
|
"digital-ide.tool.instance.title": "生成选中 module 的例化模板",
|
||||||
"digital-ide.tool.testbench.title": "从当前文件中选择 module 生成 testbench",
|
"digital-ide.tool.testbench.title": "从当前文件中选择 module 生成 testbench",
|
||||||
"digital-ide.tool.icarus.simulateFile.title": "对当前文件进行仿真",
|
"digital-ide.tool.icarus.simulateFile.title": "对当前文件进行仿真",
|
||||||
"digital-ide.treeView.arch.expand.title": "",
|
"digital-ide.treeView.arch.expand.title": "扩大树视图中的所有项目",
|
||||||
"digital-ide.treeView.arch.collapse.title": "",
|
"digital-ide.treeView.arch.collapse.title": "崩溃树视图中的所有项目",
|
||||||
"digital-ide.treeView.arch.refresh.title": "",
|
"digital-ide.treeView.arch.refresh.title": "刷新树视图",
|
||||||
"digital-ide.treeView.arch.openFile.title": "",
|
"digital-ide.treeView.arch.openFile.title": "在树视图打开相应的文件",
|
||||||
"digital-ide.tool.tool.clean.title": "",
|
"digital-ide.tool.tool.clean.title": "干净的当前项目",
|
||||||
"digital-ide.soft.launch.title": "",
|
"digital-ide.soft.launch.title": "启动SDK开发辅助功能",
|
||||||
"digital-ide.soft.build.title": "",
|
"digital-ide.soft.build.title": "建立项目当前的SDK",
|
||||||
"digital-ide.soft.download.title": "",
|
"digital-ide.soft.download.title": "下载文件到设备引导",
|
||||||
"digital-ide.hard.launch.title": "",
|
"digital-ide.hard.launch.title": "启动FPGA开发辅助功能",
|
||||||
"digital-ide.hard.simulate.title": "",
|
"digital-ide.hard.simulate.title": "启动生产仿真",
|
||||||
"digital-ide.hard.simulate.cli.title": "",
|
"digital-ide.hard.simulate.cli.title": "在CLI推出制造商模拟",
|
||||||
"digital-ide.hard.simulate.gui.title": "",
|
"digital-ide.hard.simulate.gui.title": "在GUI推出制造商模拟",
|
||||||
"digital-ide.hard.refresh.title": "",
|
"digital-ide.hard.refresh.title": "刷新当前的项目文件",
|
||||||
"digital-ide.hard.build.title": "",
|
"digital-ide.hard.build.title": "fpga构建当前项目",
|
||||||
"digital-ide.hard.build.synth.title": "",
|
"digital-ide.hard.build.synth.title": "Synth当前项目",
|
||||||
"digital-ide.hard.build.impl.title": "",
|
"digital-ide.hard.build.impl.title": "Impl当前项目",
|
||||||
"digital-ide.hard.build.bitstream.title": "",
|
"digital-ide.hard.build.bitstream.title": "生成一些文件",
|
||||||
"digital-ide.hard.program.title": "",
|
"digital-ide.hard.program.title": "下载文件到设备",
|
||||||
"digital-ide.hard.gui.title": "",
|
"digital-ide.hard.gui.title": "打开界面",
|
||||||
"digital-ide.hard.exit.title": ""
|
"digital-ide.hard.exit.title": "退出当前项目"
|
||||||
}
|
}
|
@ -1,30 +1,30 @@
|
|||||||
{
|
{
|
||||||
"digital-ide.property-json.generate.title": "",
|
"digital-ide.property-json.generate.title": "生成 property.json 配置文件",
|
||||||
"digital-ide.property-json.overwrite.title": "",
|
"digital-ide.property-json.overwrite.title": "修改默認的 property.json 模板文件",
|
||||||
"digital-ide.hdlDoc.exportFile.title": "",
|
"digital-ide.hdlDoc.exportFile.title": "導出當前文件的文檔",
|
||||||
"digital-ide.hdlDoc.exportProject.title": "",
|
"digital-ide.hdlDoc.exportProject.title": "導出當前項目的文檔",
|
||||||
"digital-ide.hdlDoc.showWebview.title": "",
|
"digital-ide.hdlDoc.showWebview.title": "在 webview 中展示文檔",
|
||||||
"digital-ide.tool.instance.title": "",
|
"digital-ide.tool.instance.title": "生成選中 module 的例化模板",
|
||||||
"digital-ide.tool.testbench.title": "",
|
"digital-ide.tool.testbench.title": "從當前文件中選擇 module 生成 testbench",
|
||||||
"digital-ide.tool.icarus.simulateFile.title": "",
|
"digital-ide.tool.icarus.simulateFile.title": "對當前文件進行仿真",
|
||||||
"digital-ide.treeView.arch.expand.title": "",
|
"digital-ide.treeView.arch.expand.title": "擴大樹視圖中的所有項目",
|
||||||
"digital-ide.treeView.arch.collapse.title": "",
|
"digital-ide.treeView.arch.collapse.title": "崩潰樹視圖中的所有項目",
|
||||||
"digital-ide.treeView.arch.refresh.title": "",
|
"digital-ide.treeView.arch.refresh.title": "刷新樹視圖",
|
||||||
"digital-ide.treeView.arch.openFile.title": "",
|
"digital-ide.treeView.arch.openFile.title": "在樹視圖打開相應的文件",
|
||||||
"digital-ide.tool.tool.clean.title": "",
|
"digital-ide.tool.tool.clean.title": "乾淨的當前項目",
|
||||||
"digital-ide.soft.launch.title": "",
|
"digital-ide.soft.launch.title": "啟動SDK開發輔助功能",
|
||||||
"digital-ide.soft.build.title": "",
|
"digital-ide.soft.build.title": "建立項目當前的SDK",
|
||||||
"digital-ide.soft.download.title": "",
|
"digital-ide.soft.download.title": "下載文件到設備引導",
|
||||||
"digital-ide.hard.launch.title": "",
|
"digital-ide.hard.launch.title": "啟動FPGA開發輔助功能",
|
||||||
"digital-ide.hard.simulate.title": "",
|
"digital-ide.hard.simulate.title": "啟動生產仿真",
|
||||||
"digital-ide.hard.simulate.cli.title": "",
|
"digital-ide.hard.simulate.cli.title": "在CLI推出製造商模擬",
|
||||||
"digital-ide.hard.simulate.gui.title": "",
|
"digital-ide.hard.simulate.gui.title": "在GUI推出製造商模擬",
|
||||||
"digital-ide.hard.refresh.title": "",
|
"digital-ide.hard.refresh.title": "刷新當前的項目文件",
|
||||||
"digital-ide.hard.build.title": "",
|
"digital-ide.hard.build.title": "fpga構建當前項目",
|
||||||
"digital-ide.hard.build.synth.title": "",
|
"digital-ide.hard.build.synth.title": "Synth當前項目",
|
||||||
"digital-ide.hard.build.impl.title": "",
|
"digital-ide.hard.build.impl.title": "Impl當前項目",
|
||||||
"digital-ide.hard.build.bitstream.title": "",
|
"digital-ide.hard.build.bitstream.title": "生成一些文件",
|
||||||
"digital-ide.hard.program.title": "",
|
"digital-ide.hard.program.title": "下載文件到設備",
|
||||||
"digital-ide.hard.gui.title": "",
|
"digital-ide.hard.gui.title": "打開界面",
|
||||||
"digital-ide.hard.exit.title": ""
|
"digital-ide.hard.exit.title": "退出當前項目"
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ PACKAGE_FILE = './package.json'
|
|||||||
LANG_PACKGE_FILES = {
|
LANG_PACKGE_FILES = {
|
||||||
'en': './package.nls.json',
|
'en': './package.nls.json',
|
||||||
'zh-cn': './package.nls.zh-cn.json',
|
'zh-cn': './package.nls.zh-cn.json',
|
||||||
'zh-tw': './package.nls.zh-tw.json'
|
'zh-tw': './package.nls.zh-tw.json',
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate_title_token(command_name: str) -> str:
|
def generate_title_token(command_name: str) -> str:
|
||||||
|
@ -1,6 +1,69 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
sys.path.append(os.path.abspath('.'))
|
sys.path.append(os.path.abspath('.'))
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
import requests as r
|
||||||
|
from zhconv import convert
|
||||||
|
|
||||||
from script.util import read_json, write_json
|
from script.util import read_json, write_json
|
||||||
|
|
||||||
|
|
||||||
|
PACKAGE_FILE = './package.json'
|
||||||
|
|
||||||
|
LANG_PACKGE_FILES = {
|
||||||
|
'en': './package.nls.json',
|
||||||
|
'zh-cn': './package.nls.zh-cn.json',
|
||||||
|
'zh-tw': './package.nls.zh-tw.json',
|
||||||
|
}
|
||||||
|
|
||||||
|
def youdao_translate(query: str, from_lang: str='AUTO', to_lang: str='AUTO') -> str:
|
||||||
|
url = 'http://fanyi.youdao.com/translate'
|
||||||
|
data = {
|
||||||
|
"i": query, # 待翻译的字符串
|
||||||
|
"from": from_lang,
|
||||||
|
"to": to_lang,
|
||||||
|
"smartresult": "dict",
|
||||||
|
"client": "fanyideskweb",
|
||||||
|
"salt": "16081210430989",
|
||||||
|
"doctype": "json",
|
||||||
|
"version": "2.1",
|
||||||
|
"keyfrom": "fanyi.web",
|
||||||
|
"action": "FY_BY_CLICKBUTTION"
|
||||||
|
}
|
||||||
|
res = r.post(url, data=data).json()
|
||||||
|
return res['translateResult'][0][0]['tgt']
|
||||||
|
|
||||||
|
def to_complex_zh(words: str) -> str:
|
||||||
|
return convert(words, 'zh-tw')
|
||||||
|
|
||||||
|
def translate_from_en(en_config: Dict[str, str], target_config: Dict[str, str], target_lang_id: str):
|
||||||
|
for command in target_config.keys():
|
||||||
|
desc = target_config[command]
|
||||||
|
if len(desc) == 0:
|
||||||
|
en_desc = en_config.get(command, '')
|
||||||
|
assert len(en_desc) > 0, f'command:{command} in en_config is empty'
|
||||||
|
target_desc = youdao_translate(en_desc, from_lang='en', to_lang=target_lang_id)
|
||||||
|
target_config[command] = target_desc
|
||||||
|
|
||||||
|
def translate_complex_zh(zh_config: Dict[str, str], zh_tw_config: Dict[str, str]):
|
||||||
|
for command in zh_tw_config.keys():
|
||||||
|
zh_desc = zh_config.get(command, '')
|
||||||
|
assert len(zh_desc) > 0, f'{command} in zh_config is empty'
|
||||||
|
complex_zh_desc = to_complex_zh(zh_desc)
|
||||||
|
zh_tw_config[command] = complex_zh_desc
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
en_config = read_json(LANG_PACKGE_FILES["en"])
|
||||||
|
|
||||||
|
zh_cn_config = read_json(LANG_PACKGE_FILES["zh-cn"])
|
||||||
|
zh_tw_config = read_json(LANG_PACKGE_FILES["zh-tw"])
|
||||||
|
|
||||||
|
translate_from_en(en_config, zh_cn_config, 'zh')
|
||||||
|
translate_complex_zh(zh_cn_config, zh_tw_config)
|
||||||
|
|
||||||
|
write_json(LANG_PACKGE_FILES["zh-cn"], zh_cn_config)
|
||||||
|
write_json(LANG_PACKGE_FILES["zh-tw"], zh_tw_config)
|
||||||
|
|
||||||
|
main()
|
@ -2,12 +2,12 @@ import * as vscode from 'vscode';
|
|||||||
|
|
||||||
import { opeParam, MainOutput, ReportType } from './global';
|
import { opeParam, MainOutput, ReportType } from './global';
|
||||||
import { hdlParam } from './hdlParser';
|
import { hdlParam } from './hdlParser';
|
||||||
import { prjManage } from './manager';
|
import { prjManage, registerManagerCommands } from './manager';
|
||||||
|
import { registerFunctionCommands } from './function';
|
||||||
import { registerAllCommands } from './function';
|
|
||||||
|
|
||||||
async function registerCommand(context: vscode.ExtensionContext) {
|
async function registerCommand(context: vscode.ExtensionContext) {
|
||||||
registerAllCommands(context);
|
registerFunctionCommands(context);
|
||||||
|
registerManagerCommands(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function launch(context: vscode.ExtensionContext) {
|
async function launch(context: vscode.ExtensionContext) {
|
||||||
|
@ -17,7 +17,7 @@ function registerSimulation(context: vscode.ExtensionContext) {
|
|||||||
vscode.commands.registerCommand('digital-ide.tool.icarus.simulateFile', sim.Icarus.simulateFile);
|
vscode.commands.registerCommand('digital-ide.tool.icarus.simulateFile', sim.Icarus.simulateFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerAllCommands(context: vscode.ExtensionContext) {
|
function registerFunctionCommands(context: vscode.ExtensionContext) {
|
||||||
registerDocumentation(context);
|
registerDocumentation(context);
|
||||||
registerSimulation(context);
|
registerSimulation(context);
|
||||||
registerTreeView(context);
|
registerTreeView(context);
|
||||||
@ -25,10 +25,10 @@ function registerAllCommands(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
function registerTreeView(context: vscode.ExtensionContext) {
|
function registerTreeView(context: vscode.ExtensionContext) {
|
||||||
// register normal tree
|
// register normal tree
|
||||||
vscode.window.registerTreeDataProvider('digital-ide.treeView.arch', treeView.moduleTreeProvider);
|
vscode.window.registerTreeDataProvider('digital-ide-treeView-arch', treeView.moduleTreeProvider);
|
||||||
vscode.window.registerTreeDataProvider('digital-ide.treeView.tool', treeView.toolTreeProvider);
|
vscode.window.registerTreeDataProvider('digital-ide-treeView-tool', treeView.toolTreeProvider);
|
||||||
vscode.window.registerTreeDataProvider('digital-ide.treeView.hardware', treeView.hardwareTreeProvider);
|
vscode.window.registerTreeDataProvider('digital-ide-treeView-hardware', treeView.hardwareTreeProvider);
|
||||||
vscode.window.registerTreeDataProvider('digital-ide.treeView.software', treeView.softwareTreeProvider);
|
vscode.window.registerTreeDataProvider('digital-ide-treeView-software', treeView.softwareTreeProvider);
|
||||||
|
|
||||||
// constant used in tree
|
// constant used in tree
|
||||||
vscode.commands.executeCommand('setContext', 'TOOL-tree-expand', false);
|
vscode.commands.executeCommand('setContext', 'TOOL-tree-expand', false);
|
||||||
@ -43,5 +43,5 @@ function registerTreeView(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
registerAllCommands
|
registerFunctionCommands
|
||||||
};
|
};
|
@ -21,7 +21,7 @@ function expandTreeView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function collapseTreeView() {
|
function collapseTreeView() {
|
||||||
vscode.commands.executeCommand('workbench.actions.treeView.TOOL-tree-arch.collapseAll');
|
vscode.commands.executeCommand('workbench.actions.treeView.digital-ide-treeView-arch.collapseAll');
|
||||||
vscode.commands.executeCommand('setContext', 'TOOL-tree-expand', true);
|
vscode.commands.executeCommand('setContext', 'TOOL-tree-expand', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
import { prjManage } from './prj';
|
import { prjManage } from './prj';
|
||||||
|
|
||||||
|
|
||||||
|
function registerManagerCommands(context: vscode.ExtensionContext) {
|
||||||
|
vscode.commands.registerCommand('digital-ide.property-json.generate', prjManage.generatePropertyJson);
|
||||||
|
vscode.commands.registerCommand('digital-ide.property-json.overwrite', prjManage.overwritePropertyJson);
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
prjManage
|
prjManage,
|
||||||
|
registerManagerCommands
|
||||||
};
|
};
|
172
src/manager/libPick.ts
Normal file
172
src/manager/libPick.ts
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
import * as fspath from 'path';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
import { AbsPath, opeParam } from '../global';
|
||||||
|
import { HdlLangID } from '../global/enum';
|
||||||
|
import { hdlDir, hdlFile, hdlPath } from '../hdlFs';
|
||||||
|
import { getIconConfig } from '../hdlFs/icons';
|
||||||
|
|
||||||
|
type MissPathType = { path?: string };
|
||||||
|
type LibPickItem = vscode.QuickPickItem & MissPathType;
|
||||||
|
|
||||||
|
class LibPick {
|
||||||
|
commonPath: AbsPath;
|
||||||
|
customPath: AbsPath;
|
||||||
|
commonQuickPickItem: LibPickItem;
|
||||||
|
customQuickPickItem: LibPickItem;
|
||||||
|
rootItems: LibPickItem[];
|
||||||
|
backQuickPickItem: LibPickItem;
|
||||||
|
curPath: AbsPath;
|
||||||
|
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.commonQuickPickItem = {
|
||||||
|
label: "$(libpick-common) common",
|
||||||
|
description: 'common library provided by us',
|
||||||
|
detail: 'current path: ' + this.commonPath,
|
||||||
|
path: this.commonPath,
|
||||||
|
buttons: [{iconPath: getIconConfig('import'), tooltip: 'import everything in common'}]
|
||||||
|
};
|
||||||
|
|
||||||
|
this.customQuickPickItem = {
|
||||||
|
label: "$(libpick-custom) custom",
|
||||||
|
description: 'custom library by yourself',
|
||||||
|
detail: 'current path: ' + this.customPath,
|
||||||
|
path: this.customPath,
|
||||||
|
buttons: [{iconPath: getIconConfig('import'), tooltip: 'import everything in custom'}]
|
||||||
|
};
|
||||||
|
|
||||||
|
this.rootItems = [
|
||||||
|
this.commonQuickPickItem,
|
||||||
|
this.customQuickPickItem
|
||||||
|
];
|
||||||
|
|
||||||
|
this.backQuickPickItem = {
|
||||||
|
label: '...',
|
||||||
|
description: 'return'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.curPath = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
getPathIcon(path: AbsPath): string {
|
||||||
|
let prompt;
|
||||||
|
if (hdlFile.isFile(path)) {
|
||||||
|
const langID = hdlFile.getLanguageId(path);
|
||||||
|
if (langID === HdlLangID.Vhdl) {
|
||||||
|
prompt = 'vhdl';
|
||||||
|
} else if (langID === HdlLangID.Verilog ||
|
||||||
|
langID === HdlLangID.SystemVerilog) {
|
||||||
|
prompt = 'verilog';
|
||||||
|
} else {
|
||||||
|
prompt = 'unknown';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prompt = 'folder';
|
||||||
|
}
|
||||||
|
return `$(libpick-${prompt})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private makeQuickPickItemsByPath(path: AbsPath, back: boolean=true): LibPickItem[] {
|
||||||
|
const items: LibPickItem[] = [];
|
||||||
|
if (!hdlPath.exist(path)) {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
if (back) {
|
||||||
|
items.push(this.backQuickPickItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const fileName of fs.readdirSync(path)) {
|
||||||
|
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 description = mdText ? mdText : '';
|
||||||
|
const buttons = [{iconPath: getIconConfig('import'), tooltip: 'import everything in ' + fileName}];
|
||||||
|
items.push({label, description, path: filePath, buttons});
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private provideQuickPickItem(item?: LibPickItem) {
|
||||||
|
if (!item) {
|
||||||
|
return this.rootItems;
|
||||||
|
} else if (item === this.backQuickPickItem) {
|
||||||
|
if ((this.curPath === this.commonPath) ||
|
||||||
|
(this.curPath === this.customPath)) {
|
||||||
|
return this.rootItems;
|
||||||
|
} else {
|
||||||
|
// rollback the current path
|
||||||
|
this.curPath = fspath.dirname(this.curPath);
|
||||||
|
}
|
||||||
|
} else if (item === this.commonQuickPickItem) {
|
||||||
|
this.curPath = this.commonPath;
|
||||||
|
} else if (item === this.customQuickPickItem) {
|
||||||
|
this.curPath = this.customPath;
|
||||||
|
} else {
|
||||||
|
const label = item.label;
|
||||||
|
const fileName = label.replace(/\$\([\s\S]*\)/, '').trim();
|
||||||
|
this.curPath = hdlPath.join(this.curPath, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.makeQuickPickItemsByPath(this.curPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
async pickItems() {
|
||||||
|
const pickWidget = vscode.window.createQuickPick<LibPickItem>();
|
||||||
|
|
||||||
|
pickWidget.placeholder = 'pick the library';
|
||||||
|
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) {
|
||||||
|
pickWidget.items = childernItems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pickWidget.onDidTriggerItemButton(event => {
|
||||||
|
const selectedPath = event.item.path;
|
||||||
|
|
||||||
|
if (selectedPath && hdlPath.exist(selectedPath)) {
|
||||||
|
const ppyPath = hdlPath.join(opeParam.workspacePath, '.vscode', 'property.json');
|
||||||
|
let prjInfo = null;
|
||||||
|
// 如果存在,则读取用户的配置文件,否则使用默认的
|
||||||
|
if (!hdlPath.exist(ppyPath)) {
|
||||||
|
prjInfo = hdlFile.readJSON(opeParam.propertyInitPath);
|
||||||
|
} 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 + '/', '');
|
||||||
|
|
||||||
|
appendLibraryCommonPath(relPath, prjInfo);
|
||||||
|
} else {
|
||||||
|
// this is a module import from custom, use absolute path
|
||||||
|
const relPath = selectedPath.replace(this.customQuickPickItem.path + '/', '');
|
||||||
|
appendLibraryCustomPath(relPath, prjInfo);
|
||||||
|
}
|
||||||
|
hdlFile.writeJSON(ppyPath, prjInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pickWidget.show();
|
||||||
|
}
|
||||||
|
}
|
@ -8,15 +8,8 @@ import { RawPrjInfo } from '../global/prjInfo';
|
|||||||
import { hdlFile, hdlPath } from '../hdlFs';
|
import { hdlFile, hdlPath } from '../hdlFs';
|
||||||
|
|
||||||
class PrjManage {
|
class PrjManage {
|
||||||
constructor() {
|
|
||||||
vscode.commands.registerCommand('digital-ide.property-json.generate',
|
|
||||||
this.generatePropertyJson);
|
|
||||||
vscode.commands.registerCommand('digital-ide.property-json.overwrite',
|
|
||||||
this.overwritePropertyJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate property template and write it to .vscode/property.json
|
// generate property template and write it to .vscode/property.json
|
||||||
private async generatePropertyJson() {
|
public async generatePropertyJson() {
|
||||||
if (fs.existsSync(opeParam.propertyJsonPath)) {
|
if (fs.existsSync(opeParam.propertyJsonPath)) {
|
||||||
vscode.window.showWarningMessage('property file already exists !!!');
|
vscode.window.showWarningMessage('property file already exists !!!');
|
||||||
return;
|
return;
|
||||||
@ -26,7 +19,7 @@ class PrjManage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// overwrite content in current property.json to property-init.json
|
// overwrite content in current property.json to property-init.json
|
||||||
private async overwritePropertyJson() {
|
public async overwritePropertyJson() {
|
||||||
const options = {
|
const options = {
|
||||||
preview: false,
|
preview: false,
|
||||||
viewColumn: vscode.ViewColumn.Active
|
viewColumn: vscode.ViewColumn.Active
|
||||||
|
Loading…
x
Reference in New Issue
Block a user