完成 Xilinx 到普通项目的转换

This commit is contained in:
锦恢 2024-12-02 19:09:13 +08:00
parent f6d6f47b62
commit 06a6c92e45
35 changed files with 397 additions and 1773 deletions

View File

@ -78,5 +78,9 @@
"info.simulate.vvp.vcd-generate": "vcd-Datei wurde erstellt in {0}", "info.simulate.vvp.vcd-generate": "vcd-Datei wurde erstellt in {0}",
"error.simluate.icarus.use-primitives": "Es wurde ein Primitiv {0} erkannt, aber Icarus iverilog unterstützt keine Primitiven.", "error.simluate.icarus.use-primitives": "Es wurde ein Primitiv {0} erkannt, aber Icarus iverilog unterstützt keine Primitiven.",
"error.simluate.icarus.use-ip": "Es wurde die IP {0} verwendet, aber Icarus iverilog unterstützt keine IP.", "error.simluate.icarus.use-ip": "Es wurde die IP {0} verwendet, aber Icarus iverilog unterstützt keine IP.",
"error.simulation.error-happen-run-command": "Fehler bei der Icarus-Simulation:" "error.simulation.error-happen-run-command": "Fehler bei der Icarus-Simulation:",
"info.command.structure.transform-xilinx-to-standard": "Konvertiere Xilinx-Projektstruktur in Digital IDE-Standardstruktur",
"error.command.structure.not-valid-xilinx-project": "Das aktuelle Projekt ist kein gültiges Xilinx-Projekt, die Konvertierung ist fehlgeschlagen!",
"info.command.structure.reload-vscode": "Projektstrukturkonvertierung abgeschlossen, bitte starten Sie vscode neu, um die Änderungen zu übernehmen.",
"info.common.confirm": "Bestätigen"
} }

View File

@ -78,5 +78,9 @@
"info.simulate.vvp.vcd-generate": "vcd file has been generated to {0}", "info.simulate.vvp.vcd-generate": "vcd file has been generated to {0}",
"error.simluate.icarus.use-primitives": "Primitive {0} detected, but Icarus iverilog does not support primitives.", "error.simluate.icarus.use-primitives": "Primitive {0} detected, but Icarus iverilog does not support primitives.",
"error.simluate.icarus.use-ip": "Detected the use of IP {0}, but Icarus iverilog does not support IP.", "error.simluate.icarus.use-ip": "Detected the use of IP {0}, but Icarus iverilog does not support IP.",
"error.simulation.error-happen-run-command": "Error during Icarus simulation:" "error.simulation.error-happen-run-command": "Error during Icarus simulation:",
"info.command.structure.transform-xilinx-to-standard": "Converting Xilinx project structure to Digital IDE standard structure",
"error.command.structure.not-valid-xilinx-project": "The current project is not a valid Xilinx project, the conversion failed!",
"info.command.structure.reload-vscode": "Project structure conversion completed, please restart vscode to apply the changes.",
"info.common.confirm": "Confirm"
} }

View File

@ -78,5 +78,9 @@
"info.simulate.vvp.vcd-generate": "vcdファイルが生成されました: {0}", "info.simulate.vvp.vcd-generate": "vcdファイルが生成されました: {0}",
"error.simluate.icarus.use-primitives": "プリミティブ {0} が検出されましたが、Icarus iverilog はプリミティブをサポートしていません。", "error.simluate.icarus.use-primitives": "プリミティブ {0} が検出されましたが、Icarus iverilog はプリミティブをサポートしていません。",
"error.simluate.icarus.use-ip": "IP {0} が使用されていますが、Icarus iverilog は IP をサポートしていません。", "error.simluate.icarus.use-ip": "IP {0} が使用されていますが、Icarus iverilog は IP をサポートしていません。",
"error.simulation.error-happen-run-command": "Icarusシミュレーション中にエラーが発生しました" "error.simulation.error-happen-run-command": "Icarusシミュレーション中にエラーが発生しました",
"info.command.structure.transform-xilinx-to-standard": "Xilinx プロジェクト構造を Digital IDE 標準構造に変換しています",
"error.command.structure.not-valid-xilinx-project": "現在のプロジェクトは有効なXilinxプロジェクトではありません、変換に失敗しました",
"info.command.structure.reload-vscode": "プロジェクト構造の変換が完了しました。変更を適用するために vscode を再起動してください。",
"info.common.confirm": "確認"
} }

View File

@ -78,5 +78,9 @@
"info.simulate.vvp.vcd-generate": "vcd 文件已经生成至 {0}", "info.simulate.vvp.vcd-generate": "vcd 文件已经生成至 {0}",
"error.simluate.icarus.use-primitives": "检测到使用了原语 {0},但是 Icarus iverilog 并不支持原语", "error.simluate.icarus.use-primitives": "检测到使用了原语 {0},但是 Icarus iverilog 并不支持原语",
"error.simluate.icarus.use-ip": "检测到使用了 IP {0},但是 Icarus iverilog 并不支持 IP", "error.simluate.icarus.use-ip": "检测到使用了 IP {0},但是 Icarus iverilog 并不支持 IP",
"error.simulation.error-happen-run-command": "Icarus 仿真时,出现错误:" "error.simulation.error-happen-run-command": "Icarus 仿真时,出现错误:",
"info.command.structure.transform-xilinx-to-standard": "正在将 Xilinx 项目结构转变为 Digital IDE 标准结构",
"error.command.structure.not-valid-xilinx-project": "当前项目不是一个有效的 Xilinx 项目,转换失败!",
"info.command.structure.reload-vscode": "项目结构转换完成,请重启 vscode 使应用生效",
"info.common.confirm": "确定"
} }

View File

@ -78,5 +78,9 @@
"info.simulate.vvp.vcd-generate": "vcd 檔案已生成至 {0}", "info.simulate.vvp.vcd-generate": "vcd 檔案已生成至 {0}",
"error.simluate.icarus.use-primitives": "偵測到使用了原語 {0},但是 Icarus iverilog 並不支援原語。", "error.simluate.icarus.use-primitives": "偵測到使用了原語 {0},但是 Icarus iverilog 並不支援原語。",
"error.simluate.icarus.use-ip": "偵測到使用了 IP {0},但是 Icarus iverilog 並不支援 IP。", "error.simluate.icarus.use-ip": "偵測到使用了 IP {0},但是 Icarus iverilog 並不支援 IP。",
"error.simulation.error-happen-run-command": "Icarus 模擬時,出現錯誤:" "error.simulation.error-happen-run-command": "Icarus 模擬時,出現錯誤:",
"info.command.structure.transform-xilinx-to-standard": "正在將 Xilinx 專案結構轉變為 Digital IDE 標準結構",
"error.command.structure.not-valid-xilinx-project": "當前專案不是一個有效的 Xilinx 專案,轉換失敗!",
"info.command.structure.reload-vscode": "專案結構轉換完成,請重新啟動 vscode 使應用生效。",
"info.common.confirm": "確定"
} }

View File

@ -597,6 +597,11 @@
"command": "digital-ide.tool.clean", "command": "digital-ide.tool.clean",
"category": "Digital-IDE", "category": "Digital-IDE",
"title": "%digital-ide.tool.clean.title%" "title": "%digital-ide.tool.clean.title%"
},
{
"command": "digital-ide.structure.from-xilinx-to-standard",
"category": "Digital-IDE",
"title": "%digital-ide.structure.from-xilinx-to-standard.title%"
} }
], ],
"menus": { "menus": {

View File

@ -91,5 +91,6 @@
"digital-ide.function.instantiation.addComment.title": "add comment like // ports, // input, // output when doing instantiation, including completion for module invoking", "digital-ide.function.instantiation.addComment.title": "add comment like // ports, // input, // output when doing instantiation, including completion for module invoking",
"digital-ide.function.instantiation.autoNetOutputDeclaration.title": "auto declare output type nets in the scope when instantiation happens.", "digital-ide.function.instantiation.autoNetOutputDeclaration.title": "auto declare output type nets in the scope when instantiation happens.",
"fpga-support.onTypeFormattingTriggerCharacters.title": "Trigger characters for onTypeFormatting", "fpga-support.onTypeFormattingTriggerCharacters.title": "Trigger characters for onTypeFormatting",
"digital-ide.function.lsp.file-parse-maxsize.title": "" "digital-ide.function.lsp.file-parse-maxsize.title": "",
"digital-ide.structure.from-xilinx-to-standard.title": "Konvertieren Sie Xilinx-Projekte in die Digital IDE-Standardprojektstruktur"
} }

View File

@ -91,5 +91,6 @@
"digital-ide.function.instantiation.addComment.title": "インスタンス化時に // ポート, // 入力, // 出力 のようなコメントを追加し、モジュール呼び出しの補完を含みます", "digital-ide.function.instantiation.addComment.title": "インスタンス化時に // ポート, // 入力, // 出力 のようなコメントを追加し、モジュール呼び出しの補完を含みます",
"digital-ide.function.instantiation.autoNetOutputDeclaration.title": "インスタンス化が発生したときにスコープ内で出力タイプのネットを自動的に宣言します。", "digital-ide.function.instantiation.autoNetOutputDeclaration.title": "インスタンス化が発生したときにスコープ内で出力タイプのネットを自動的に宣言します。",
"fpga-support.onTypeFormattingTriggerCharacters.title": "onTypeFormatting のトリガー文字", "fpga-support.onTypeFormattingTriggerCharacters.title": "onTypeFormatting のトリガー文字",
"digital-ide.function.lsp.file-parse-maxsize.title": "" "digital-ide.function.lsp.file-parse-maxsize.title": "",
"digital-ide.structure.from-xilinx-to-standard.title": "Xilinx プロジェクトを Digital IDE 標準プロジェクト構造に変換する"
} }

View File

@ -91,5 +91,6 @@
"digital-ide.function.instantiation.addComment.title": "Add comments like // ports, // input, // output when doing instantiation, including completion for module invoking", "digital-ide.function.instantiation.addComment.title": "Add comments like // ports, // input, // output when doing instantiation, including completion for module invoking",
"digital-ide.function.instantiation.autoNetOutputDeclaration.title": "Automatically declare output type nets in the scope when instantiation happens.", "digital-ide.function.instantiation.autoNetOutputDeclaration.title": "Automatically declare output type nets in the scope when instantiation happens.",
"fpga-support.onTypeFormattingTriggerCharacters.title": "Trigger characters for onTypeFormatting", "fpga-support.onTypeFormattingTriggerCharacters.title": "Trigger characters for onTypeFormatting",
"digital-ide.function.lsp.file-parse-maxsize.title": "" "digital-ide.function.lsp.file-parse-maxsize.title": "",
"digital-ide.structure.from-xilinx-to-standard.title": "Convert Xilinx projects to Digital IDE standard project structure"
} }

View File

@ -91,5 +91,6 @@
"digital-ide.function.instantiation.addComment.title": "在进行实例化时添加注释,如 // 端口, // 输入, // 输出,包括模块调用的完成", "digital-ide.function.instantiation.addComment.title": "在进行实例化时添加注释,如 // 端口, // 输入, // 输出,包括模块调用的完成",
"digital-ide.function.instantiation.autoNetOutputDeclaration.title": "在实例化发生时自动在作用域中声明输出类型的网络。", "digital-ide.function.instantiation.autoNetOutputDeclaration.title": "在实例化发生时自动在作用域中声明输出类型的网络。",
"fpga-support.onTypeFormattingTriggerCharacters.title": "onTypeFormatting 的触发字符", "fpga-support.onTypeFormattingTriggerCharacters.title": "onTypeFormatting 的触发字符",
"digital-ide.function.lsp.file-parse-maxsize.title": "最大解析的文件阈值,大小超出这个值的文件不会被解析。单位为 MB必须是整数。默认为 1MB" "digital-ide.function.lsp.file-parse-maxsize.title": "最大解析的文件阈值,大小超出这个值的文件不会被解析。单位为 MB必须是整数。默认为 1MB",
"digital-ide.structure.from-xilinx-to-standard.title": "将 Xilinx 项目转换成 Digital IDE 标准项目结构"
} }

View File

@ -91,5 +91,6 @@
"digital-ide.function.instantiation.addComment.title": "在進行實例化時添加註釋,如 // 端口, // 輸入, // 輸出,包括模塊調用的完成", "digital-ide.function.instantiation.addComment.title": "在進行實例化時添加註釋,如 // 端口, // 輸入, // 輸出,包括模塊調用的完成",
"digital-ide.function.instantiation.autoNetOutputDeclaration.title": "在實例化發生時自動在作用域中聲明輸出類型的網絡。", "digital-ide.function.instantiation.autoNetOutputDeclaration.title": "在實例化發生時自動在作用域中聲明輸出類型的網絡。",
"fpga-support.onTypeFormattingTriggerCharacters.title": "onTypeFormatting 的觸發字符", "fpga-support.onTypeFormattingTriggerCharacters.title": "onTypeFormatting 的觸發字符",
"digital-ide.function.lsp.file-parse-maxsize.title": "" "digital-ide.function.lsp.file-parse-maxsize.title": "",
"digital-ide.structure.from-xilinx-to-standard.title": "將 Xilinx 專案轉換成 Digital IDE 標準專案結構"
} }

View File

@ -16,12 +16,23 @@ import { initialiseI18n, t } from './i18n';
async function registerCommand(context: vscode.ExtensionContext, packageJson: any) { async function registerCommand(context: vscode.ExtensionContext, packageJson: any) {
func.registerFunctionCommands(context); func.registerFunctionCommands(context);
func.registerTreeViewDataProvider(context); func.registerTreeViewDataProvider(context);
func.registerLsp(context, packageJson.version); func.registerLsp(context, packageJson.version);
func.registerToolCommands(context); func.registerToolCommands(context);
func.registerFSM(context); func.registerFSM(context);
func.registerNetlist(context); func.registerNetlist(context);
func.registerWaveViewer(context); func.registerWaveViewer(context);
// onCommand 激活事件中的命令
context.subscriptions.push(
vscode.commands.registerCommand('digital-ide.property-json.generate', () => {
manager.prjManage.generatePropertyJson(context);
})
);
context.subscriptions.push(
vscode.commands.registerCommand('digital-ide.structure.from-xilinx-to-standard', () => {
manager.prjManage.transformXilinxToStandard(context);
})
);
} }
function readPackageJson(context: vscode.ExtensionContext): any | undefined { function readPackageJson(context: vscode.ExtensionContext): any | undefined {
@ -87,6 +98,7 @@ async function launch(context: vscode.ExtensionContext) {
// 刷新结构树 // 刷新结构树
refreshArchTree(); refreshArchTree();
// 启动监视器
hdlMonitor.start(); hdlMonitor.start();
}); });

View File

@ -5,7 +5,7 @@ import * as hdlDoc from './hdlDoc';
import * as sim from './sim'; import * as sim from './sim';
import * as treeView from './treeView'; import * as treeView from './treeView';
import * as lspCompletion from './lsp/completion'; import { tclCompletionProvider } from './lsp/completion/tcl';
import * as lspFormatter from '../../resources/formatter'; import * as lspFormatter from '../../resources/formatter';
import * as lspTranslator from '../../resources/translator'; import * as lspTranslator from '../../resources/translator';
import * as lspLinter from './lsp/linter'; import * as lspLinter from './lsp/linter';
@ -117,26 +117,8 @@ function registerLsp(context: vscode.ExtensionContext, version: string) {
// translator // translator
vscode.commands.registerCommand('digital-ide.vhdl2vlog', uri => lspTranslator.vhdl2vlog(uri)); vscode.commands.registerCommand('digital-ide.vhdl2vlog', uri => lspTranslator.vhdl2vlog(uri));
// verilog lsp
// vscode.languages.registerDocumentSymbolProvider(vlogSelector, lspDocSymbol.vlogDocSymbolProvider);
// vscode.languages.registerDefinitionProvider(vlogSelector, lspDefinition.vlogDefinitionProvider);
// vscode.languages.registerHoverProvider(vlogSelector, lspHover.vlogHoverProvider);
// vscode.languages.registerCompletionItemProvider(vlogSelector, lspCompletion.vlogIncludeCompletionProvider, '/', '"');
// vscode.languages.registerCompletionItemProvider(vlogSelector, lspCompletion.vlogMacroCompletionProvider, '`');
// vscode.languages.registerCompletionItemProvider(vlogSelector, lspCompletion.vlogPositionPortProvider, '.');
// vscode.languages.registerCompletionItemProvider(vlogSelector, lspCompletion.vlogCompletionProvider);
// vscode.languages.registerDocumentSemanticTokensProvider(vlogSelector, lspDocSemantic.vlogDocSenmanticProvider, lspDocSemantic.vlogLegend);
// vhdl lsp
// vscode.languages.registerDocumentSymbolProvider(vhdlSelector, lspDocSymbol.vhdlDocSymbolProvider);
// vscode.languages.registerDefinitionProvider(vhdlSelector, lspDefinition.vhdlDefinitionProvider);
// vscode.languages.registerHoverProvider(vhdlSelector, lspHover.vhdlHoverProvider);
// vscode.languages.registerCompletionItemProvider(vhdlSelector, lspCompletion.vhdlCompletionProvider);
// tcl lsp // tcl lsp
vscode.languages.registerCompletionItemProvider(tclSelector, lspCompletion.tclCompletionProvider); vscode.languages.registerCompletionItemProvider(tclSelector, tclCompletionProvider);
// lsp linter // lsp linter
// make first symbols in workspace // make first symbols in workspace
@ -167,7 +149,6 @@ function registerNetlist(context: vscode.ExtensionContext) {
if (typeof uri === 'string') { if (typeof uri === 'string') {
uri = vscode.Uri.file(uri); uri = vscode.Uri.file(uri);
} }
console.log('get uri: ', uri);
Netlist.openNetlistViewer(context, uri); Netlist.openNetlistViewer(context, uri);
}); });
} }

View File

@ -1,12 +0,0 @@
// import { vlogCompletionProvider, vlogIncludeCompletionProvider, vlogMacroCompletionProvider, vlogPositionPortProvider } from './vlog';
// import { vhdlCompletionProvider } from './vhdl';
import { tclCompletionProvider } from './tcl';
export {
// vlogCompletionProvider,
// vlogIncludeCompletionProvider,
// vlogMacroCompletionProvider,
// vlogPositionPortProvider,
// vhdlCompletionProvider,
tclCompletionProvider
};

View File

@ -1,174 +0,0 @@
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as util from '../util';
import { hdlParam } from '../../../hdlParser';
import { AbsPath, MainOutput, RelPath, ReportType } from '../../../global';
import { Define, Include, RawSymbol } from '../../../hdlParser/common';
import { HdlInstance, HdlModule } from '../../../hdlParser/core';
import { vhdlKeyword } from '../util/keyword';
import { hdlPath } from '../../../hdlFs';
// class VhdlCompletionProvider implements vscode.CompletionItemProvider {
// public async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext): Promise<vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem> | null | undefined> {
// try {
// const filePath = hdlPath.toSlash(document.fileName);
// // 1. provide keyword
// const completions = this.makeKeywordItems(document, position);
// const symbolResult = await hdlSymbolStorage.getSymbol(filePath);
// if (!symbolResult) {
// return completions;
// }
// const symbols = symbolResult.content;
// for (const symbol of symbols) {
// const kind = this.getCompletionItemKind(symbol.type);
// const clItem = new vscode.CompletionItem(symbol.name, kind);
// completions.push(clItem);
// }
// return completions;
// } catch (err) {
// console.log(err);
// }
// }
// private getCompletionItemKind(type: string): vscode.CompletionItemKind {
// switch (type) {
// case 'entity': return vscode.CompletionItemKind.Class; break;
// case 'port': return vscode.CompletionItemKind.Variable; break;
// default: return vscode.CompletionItemKind.Value; break;
// }
// }
// private makeKeywordItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {
// const vhdlKeywordItems: vscode.CompletionItem[] = [];
// for (const keyword of vhdlKeyword.keys()) {
// const clItem = this.makekeywordCompletionItem(keyword, 'vhdl keyword');
// vhdlKeywordItems.push(clItem);
// }
// for (const keyword of vhdlKeyword.compilerKeys()) {
// const clItem = this.makekeywordCompletionItem(keyword, 'IEEE lib function');
// vhdlKeywordItems.push(clItem);
// }
// for (const keyword of vhdlKeyword.systemKeys()) {
// const clItem = this.makekeywordCompletionItem(keyword, 'vhdl keyword');
// vhdlKeywordItems.push(clItem);
// }
// return vhdlKeywordItems;
// }
// private makekeywordCompletionItem(keyword: string, detail: string): vscode.CompletionItem {
// const clItem = new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Keyword);
// clItem.detail = detail;
// switch (keyword) {
// case 'begin': clItem.insertText = new vscode.SnippetString("begin$1\nend"); break;
// case 'entity': clItem.insertText = new vscode.SnippetString("entity ${1:name} is\n\t${2:content}\nend entity;"); break;
// case 'architecture': clItem.insertText = new vscode.SnippetString("architecture ${1:name} of ${2:entity} is\n\t${3:definition}\nbegin\n\t${4:content}\nend architecture;"); break;
// default: break;
// }
// return clItem;
// }
// private async provideModules(document: vscode.TextDocument, position: vscode.Position, filePath: AbsPath, includes: Include[]): Promise<vscode.CompletionItem[]> {
// const suggestModules: vscode.CompletionItem[] = [];
// const lspVhdlConfig = vscode.workspace.getConfiguration('digital-ide.function.lsp.completion.vhdl');
// const auto-add-include: boolean = lspVhdlConfig.get('auto-add-include', true);
// const auto-add-output-declaration: boolean = lspVhdlConfig.get('auto-add-output-declaration', true);
// const includePaths = new Set<AbsPath>();
// let lastIncludeLine = 0;
// for (const include of includes) {
// const absIncludePath = hdlPath.rel2abs(filePath, include.path);
// includePaths.add(absIncludePath);
// lastIncludeLine = Math.max(include.range.end.line, lastIncludeLine);
// }
// const insertPosition = new vscode.Position(lastIncludeLine, 0);
// const insertRange = new vscode.Range(insertPosition, insertPosition);
// const fileFolder = hdlPath.resolve(filePath, '..');
// // used only when auto-add-output-declaration is true
// let completePrefix = '';
// if (auto-add-output-declaration) {
// const wordRange = document.getWordRangeAtPosition(position);
// const countStart = wordRange ? wordRange.start.character : position.character;
// const spaceNumber = Math.floor(countStart / 4) * 4;
// console.log(wordRange, countStart, spaceNumber);
// completePrefix = ' '.repeat(spaceNumber);
// }
// // for (const module of hdlParam.getAllHdlModules()) {
// // const clItem = new vscode.CompletionItem(module.name, vscode.CompletionItemKind.Class);
// // // feature 1 : auto add include path if there's no corresponding include path
// // if (auto-add-include && !includePaths.has(module.path)) {
// // const relPath: RelPath = hdlPath.relative(fileFolder, module.path);
// // const includeString = '`include "' + relPath + '"\n';
// // const textEdit = new vscode.TextEdit(insertRange, includeString);
// // clItem.additionalTextEdits = [textEdit];
// // }
// // // feature 2 : auto complete instance
// // if (auto-add-output-declaration) {
// // const snippetString = instanceVhdlCode(module, '', true);
// // clItem.insertText = new vscode.SnippetString(snippetString);
// // }
// // clItem.detail = 'module';
// // suggestModules.push(clItem);
// // }
// return suggestModules;
// }
// private async provideParamsPorts(module: HdlModule): Promise<vscode.CompletionItem[]> {
// if (!module) {
// return [];
// }
// const suggestParamsPorts = [];
// for (const param of module.params) {
// const clItem = new vscode.CompletionItem(param.name, vscode.CompletionItemKind.Constant);
// clItem.detail = 'param';
// suggestParamsPorts.push(clItem);
// }
// for (const port of module.ports) {
// const clItem = new vscode.CompletionItem(port.name, vscode.CompletionItemKind.Interface);
// clItem.detail = 'port';
// suggestParamsPorts.push(clItem);
// }
// return suggestParamsPorts;
// }
// private async provideNets(symbols: RawSymbol[]): Promise<vscode.CompletionItem[]> {
// if (!symbols) {
// return [];
// }
// const suggestNets = [];
// for (const symbol of symbols) {
// if (symbol.type === 'wire' || symbol.type === 'reg') {
// const clItem = new vscode.CompletionItem(symbol.name, vscode.CompletionItemKind.Variable);
// clItem.sortText = '';
// clItem.detail = symbol.type;
// suggestNets.push(clItem);
// }
// }
// return suggestNets;
// }
// };
// const vhdlCompletionProvider = new VhdlCompletionProvider();
// export {
// vhdlCompletionProvider
// };

View File

@ -1,390 +0,0 @@
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as util from '../util';
import { hdlFile, hdlPath } from '../../../hdlFs';
import { hdlParam } from '../../../hdlParser';
import { AbsPath, MainOutput, RelPath, ReportType } from '../../../global';
import { Define, Include, RawSymbol } from '../../../hdlParser/common';
import { HdlInstance, HdlModule } from '../../../hdlParser/core';
import { vlogKeyword } from '../util/keyword';
import { instanceVlogCode } from '../../sim/instance';
// class VlogIncludeCompletionProvider implements vscode.CompletionItemProvider {
// public provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem>> {
// // console.log('VlogIncludeCompletionProvider');
// try {
// const items = this.provideIncludeFiles(document, position);
// return items;
// } catch (err) {
// console.log(err);
// }
// }
// private provideIncludeFiles(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {
// if (position.character === 0) {
// return [];
// }
// const filePath = hdlPath.toSlash(document.fileName);
// const lineText = document.lineAt(position).text;
// let firstQIndex = lineText.lastIndexOf('"', position.character - 1);
// let lastQIndex = lineText.indexOf('"', position.character);
// if (firstQIndex !== -1 && lastQIndex !== -1) {
// const currentPath = lineText.substring(firstQIndex + 1, lastQIndex);
// const folderName = currentPath.length === 0 ? '.' : currentPath;
// const folderAbsPath = hdlPath.rel2abs(filePath, folderName);
// return this.filterIncludeFiles(folderAbsPath, filePath);
// }
// return [];
// }
// private filterIncludeFiles(folderPath: AbsPath, currentPath: AbsPath) {
// if (fs.existsSync(folderPath)) {
// const suggestFiles = [];
// for (const fileName of fs.readdirSync(folderPath)) {
// const filePath = hdlPath.join(folderPath, fileName);
// if (filePath === currentPath) {
// continue;
// }
// const stat = fs.statSync(filePath);
// const clItem = new vscode.CompletionItem(fileName);
// if (stat.isDirectory()) {
// clItem.kind = vscode.CompletionItemKind.Folder;
// } else if (stat.isFile()) {
// clItem.kind = vscode.CompletionItemKind.File;
// }
// suggestFiles.push(clItem);
// }
// return suggestFiles;
// }
// return [];
// }
// };
// class VlogMacroCompletionProvider implements vscode.CompletionItemProvider {
// public async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext): Promise<vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem> | null | undefined> {
// // console.log('VlogMacroCompletionProvider');
// try {
// const targetWordRange = document.getWordRangeAtPosition(position, /[`_0-9a-zA-Z]+/);
// const targetWord = document.getText(targetWordRange);
// const filePath = document.fileName;
// const symbolResult = await hdlSymbolStorage.getSymbol(filePath);
// if (!symbolResult) {
// return null;
// }
// const items = this.provideMacros(targetWord, symbolResult.macro.defines);
// return items;
// } catch (err) {
// console.log(err);
// }
// }
// private provideMacros(targetWord: string, defines: Define[]): vscode.CompletionItem[] {
// const suggestMacros: vscode.CompletionItem[] = [];
// if (!defines || defines.length === 0) {
// return suggestMacros;
// }
// for (const define of defines) {
// const name = '`' + define.name;
// const clItem = new vscode.CompletionItem(name, vscode.CompletionItemKind.Constant);
// clItem.detail = 'macro ' + define.replacement;
// clItem.insertText = targetWord.startsWith('`') ? define.name : name;
// suggestMacros.push(clItem);
// }
// return suggestMacros;
// }
// }
// class VlogPositionPortProvider implements vscode.CompletionItemProvider {
// public async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext): Promise<vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem> | null | undefined> {
// // console.log('enter VlogPositionPortProvider');
// try {
// const suggestPositionPorts: vscode.CompletionItem[] = [];
// const filePath = hdlPath.toSlash(document.fileName);
// const symbolResult = await hdlSymbolStorage.getSymbol(filePath);
// // console.log(symbolResult?.content);
// // console.log(position.character, position.line);
// if (!symbolResult) {
// return null;
// }
// const scopeSymbols = util.locateVlogSymbol(position, symbolResult.content);
// if (!scopeSymbols ||
// !scopeSymbols.module ||
// !scopeSymbols.symbols ||
// !hdlParam.hasHdlModule(filePath, scopeSymbols.module.name)) {
// return suggestPositionPorts;
// }
// const currentModule = hdlParam.getHdlModule(filePath, scopeSymbols.module.name);
// if (!currentModule) {
// return;
// }
// const currentInst = util.filterInstanceByPosition(position, scopeSymbols.symbols, currentModule);
// // find instance and instMod is not null (solve the dependence already)
// if (currentInst && currentInst.module && currentInst.instModPath) {
// const portsparams = this.providePositionPorts(position, currentInst);
// suggestPositionPorts.push(...portsparams);
// }
// return suggestPositionPorts;
// } catch (err) {
// console.log(err);
// }
// }
// private providePositionPorts(position: vscode.Position, currentInst: HdlInstance): vscode.CompletionItem[] {
// if (!currentInst.module) {
// return [];
// }
// const params = currentInst.instparams;
// const ports = currentInst.instports;
// if (params &&
// util.positionAfterEqual(position, params.start) &&
// util.positionAfterEqual(params.end, position)) {
// return currentInst.module.params.map(param => {
// const clItem = new vscode.CompletionItem(param.name, vscode.CompletionItemKind.Constant);
// clItem.detail = 'param';
// return clItem;
// });
// }
// if (ports &&
// util.positionAfterEqual(position, ports.start) &&
// util.positionAfterEqual(ports.end, position)) {
// return currentInst.module.ports.map(port => {
// const clItem = new vscode.CompletionItem(port.name, vscode.CompletionItemKind.Interface);
// clItem.detail = 'port';
// return clItem;
// });
// }
// return [];
// }
// }
// class VlogCompletionProvider implements vscode.CompletionItemProvider {
// public async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext): Promise<vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem> | null | undefined> {
// // console.log('VlogCompletionProvider');
// try {
// const filePath = hdlPath.toSlash(document.fileName);
// // 1. provide keyword
// const completions = this.makeKeywordItems(document, position);
// completions.push(...this.makeCompilerKeywordItems(document, position));
// completions.push(...this.makeSystemKeywordItems(document, position));
// const symbolResult = await hdlSymbolStorage.getSymbol(filePath);
// if (!symbolResult) {
// return completions;
// }
// // locate at one module
// const scopeSymbols = util.locateVlogSymbol(position, symbolResult.content);
// if (!scopeSymbols ||
// !scopeSymbols.module ||
// !hdlParam.hasHdlModule(filePath, scopeSymbols.module.name)) {
// // MainOutput.report('Fail to get HdlModule ' + filePath + ' ' + scopeSymbols?.module.name, ReportType.Debug);
// return completions;
// }
// // find wrapper module
// const currentModule = hdlParam.getHdlModule(filePath, scopeSymbols.module.name);
// if (!currentModule) {
// return completions;
// }
// // 3. provide modules
// const suggestModulesPromise = this.provideModules(document, position, filePath, symbolResult.macro.includes);
// // 4. provide params and ports of wrapper module
// const suggestParamsPortsPromise = this.provideParamsPorts(currentModule);
// // 5. provide nets
// const suggestNetsPromise = this.provideNets(scopeSymbols.symbols);
// // collect
// completions.push(...await suggestModulesPromise);
// completions.push(...await suggestParamsPortsPromise);
// completions.push(...await suggestNetsPromise);
// return completions;
// } catch (err) {
// console.log(err);
// }
// }
// private makeKeywordItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {
// const vlogKeywordItems: vscode.CompletionItem[] = [];
// for (const keyword of vlogKeyword.keys()) {
// const clItem = this.makekeywordCompletionItem(keyword);
// vlogKeywordItems.push(clItem);
// }
// return vlogKeywordItems;
// }
// private makeCompilerKeywordItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {
// const items = [];
// const targetRange = document.getWordRangeAtPosition(position, /[`_0-9a-zA-Z]+/);
// const targetWord = document.getText(targetRange);
// const prefix = targetWord.startsWith('`') ? '' : '`';
// for (const keyword of vlogKeyword.compilerKeys()) {
// const clItem = new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Keyword);
// clItem.insertText = new vscode.SnippetString(prefix + keyword);
// clItem.detail = 'compiler directive';
// items.push(clItem);
// }
// return items;
// }
// private makeSystemKeywordItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {
// const items = [];
// for (const keyword of vlogKeyword.systemKeys()) {
// const clItem = new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Method);
// clItem.insertText = new vscode.SnippetString('\\$' + keyword + '($1);');
// clItem.detail = 'system task';
// items.push(clItem);
// }
// return items;
// }
// private makekeywordCompletionItem(keyword: string): vscode.CompletionItem {
// const clItem = new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Keyword);
// clItem.detail = 'verilog keyword';
// switch (keyword) {
// case 'begin': clItem.insertText = new vscode.SnippetString("begin$1\nend"); break;
// case 'function': clItem.insertText = new vscode.SnippetString("function ${1:name}\n\nendfunction"); break;
// default: break;
// }
// return clItem;
// }
// private async provideModules(document: vscode.TextDocument, position: vscode.Position, filePath: AbsPath, includes: Include[]): Promise<vscode.CompletionItem[]> {
// const suggestModules: vscode.CompletionItem[] = [];
// const lspVlogConfig = vscode.workspace.getConfiguration('digital-ide.function.lsp.completion.vlog');
// const auto-add-include: boolean = lspVlogConfig.get('auto-add-include', true);
// const auto-add-output-declaration: boolean = lspVlogConfig.get('auto-add-output-declaration', true);
// const includePaths = new Set<AbsPath>();
// let lastIncludeLine = 0;
// for (const include of includes) {
// const absIncludePath = hdlPath.rel2abs(filePath, include.path);
// includePaths.add(absIncludePath);
// lastIncludeLine = Math.max(include.range.end.line, lastIncludeLine);
// }
// const insertPosition = new vscode.Position(lastIncludeLine, 0);
// const insertRange = new vscode.Range(insertPosition, insertPosition);
// const fileFolder = hdlPath.resolve(filePath, '..');
// // used only when auto-add-output-declaration is true
// let completePrefix = '';
// if (auto-add-output-declaration) {
// const wordRange = document.getWordRangeAtPosition(position);
// const countStart = wordRange ? wordRange.start.character : position.character;
// const spaceNumber = Math.floor(countStart / 4) * 4;
// console.log(wordRange, countStart, spaceNumber);
// completePrefix = ' '.repeat(spaceNumber);
// }
// for (const module of hdlParam.getAllHdlModules()) {
// const clItem = new vscode.CompletionItem(module.name, vscode.CompletionItemKind.Class);
// // feature 1 : auto add include path if there's no corresponding include path
// if (auto-add-include && !includePaths.has(module.path)) {
// const relPath: RelPath = hdlPath.relative(fileFolder, module.path);
// const includeString = '`include "' + relPath + '"\n';
// const textEdit = new vscode.TextEdit(insertRange, includeString);
// clItem.additionalTextEdits = [textEdit];
// }
// // feature 2 : auto complete instance
// if (auto-add-output-declaration) {
// const snippetString = instanceVlogCode(module, '', true);
// clItem.insertText = new vscode.SnippetString(snippetString);
// }
// clItem.detail = 'module';
// suggestModules.push(clItem);
// }
// return suggestModules;
// }
// private async provideParamsPorts(module: HdlModule): Promise<vscode.CompletionItem[]> {
// if (!module) {
// return [];
// }
// const suggestParamsPorts = [];
// for (const param of module.params) {
// const clItem = new vscode.CompletionItem(param.name, vscode.CompletionItemKind.Constant);
// clItem.detail = 'param';
// suggestParamsPorts.push(clItem);
// }
// for (const port of module.ports) {
// const clItem = new vscode.CompletionItem(port.name, vscode.CompletionItemKind.Interface);
// clItem.detail = 'port';
// suggestParamsPorts.push(clItem);
// }
// return suggestParamsPorts;
// }
// private async provideNets(symbols: RawSymbol[]): Promise<vscode.CompletionItem[]> {
// if (!symbols) {
// return [];
// }
// const suggestNets = [];
// for (const symbol of symbols) {
// if (symbol.type === 'wire' || symbol.type === 'reg') {
// const clItem = new vscode.CompletionItem(symbol.name, vscode.CompletionItemKind.Variable);
// clItem.sortText = '';
// clItem.detail = symbol.type;
// suggestNets.push(clItem);
// }
// }
// return suggestNets;
// }
// };
// const vlogCompletionProvider = new VlogCompletionProvider();
// const vlogIncludeCompletionProvider = new VlogIncludeCompletionProvider();
// const vlogMacroCompletionProvider = new VlogMacroCompletionProvider();
// const vlogPositionPortProvider = new VlogPositionPortProvider();
// export {
// vlogCompletionProvider,
// vlogIncludeCompletionProvider,
// vlogMacroCompletionProvider,
// vlogPositionPortProvider
// };

View File

@ -1,7 +0,0 @@
// import { vlogDefinitionProvider } from './vlog';
// import { vhdlDefinitionProvider } from './vhdl';
export {
// vlogDefinitionProvider,
// vhdlDefinitionProvider
};

View File

@ -1,170 +0,0 @@
import * as vscode from 'vscode';
import { hdlPath } from '../../../hdlFs';
import { hdlParam } from '../../../hdlParser';
import { vlogKeyword } from '../util/keyword';
import * as util from '../util';
import { MainOutput, ReportType } from '../../../global';
import { RawSymbol } from '../../../hdlParser/common';
// class VhdlDefinitionProvider implements vscode.DefinitionProvider {
// public async provideDefinition(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Location | vscode.LocationLink[] | null> {
// // console.log('VhdlDefinitionProvider');
// // get current words
// const wordRange = document.getWordRangeAtPosition(position, /[`_0-9A-Za-z]+/);
// if (!wordRange) {
// return null;
// }
// const targetWord = document.getText(wordRange);
// // check if need skip
// if (this.needSkip(document, position, targetWord)) {
// return null;
// }
// const filePath = document.fileName;
// const vlogAll = await hdlSymbolStorage.getSymbol(filePath);
// if (!vlogAll) {
// return null;
// } else {
// const location = await this.makeDefinition(document, position, vlogAll, targetWord, wordRange);
// return location;
// }
// }
// private needSkip(document: vscode.TextDocument, position: vscode.Position, targetWord: string): boolean {
// // check keyword
// if (vlogKeyword.isKeyword(targetWord)) {
// return true;
// }
// // TODO: check comment
// return false;
// }
// private async makeDefinition(document: vscode.TextDocument, position: vscode.Position, all: All, targetWord: string, targetWordRange: vscode.Range): Promise<vscode.Location | vscode.LocationLink[] | null> {
// const filePath = hdlPath.toSlash(document.fileName);
// const lineText = document.lineAt(position).text;
// // locate at one entity or architecture
// // TODO: remove it after adjust of backend
// const rawSymbols = [];
// for (const symbol of all.content) {
// const rawSymbol: RawSymbol = {
// name: symbol.name,
// type: symbol.type,
// parent: symbol.parent,
// range: util.transformRange(symbol.range, -1),
// signed: symbol.signed,
// netType: symbol.netType
// };
// rawSymbols.push(rawSymbol);
// }
// const moduleScope = util.locateVhdlSymbol(position, rawSymbols);
// if (!moduleScope) {
// return null;
// }
// const scopeType = moduleScope.module.type;
// if (scopeType === 'architecture') {
// return await this.makeArchitectureDefinition(filePath, targetWord, targetWordRange, moduleScope);
// } else if (scopeType === 'entity') {
// return await this.makeEntityDefinition(filePath, targetWord, targetWordRange, moduleScope);
// }
// return null;
// }
// private async makeArchitectureDefinition(filePath: string, targetWord: string, targetWordRange: vscode.Range, moduleScope: util.ModuleScope): Promise<vscode.Location | vscode.LocationLink[] | null> {
// const architecture = moduleScope.module;
// // point to the entity of the architecture
// if (architecture.parent && architecture.parent === targetWord) {
// const entity = hdlParam.getHdlModule(filePath, architecture.parent);
// if (entity) {
// const targetUri = vscode.Uri.file(entity.path);
// const targetRange = util.transformRange(entity.range, -1, 0);
// const link: vscode.LocationLink = { targetUri, targetRange, originSelectionRange: targetWordRange };
// return [ link ];
// }
// }
// // filter defined signal
// for (const symbol of moduleScope.symbols) {
// if (symbol.name === targetWord) {
// const targetUri = vscode.Uri.file(filePath);
// const targetRange = util.transformRange(symbol.range, 0, 0);
// const link: vscode.LocationLink = { targetUri, targetRange, originSelectionRange: targetWordRange };
// return [ link ];
// }
// }
// // inner variable mapping to entity
// if (architecture.parent) {
// const entity = hdlParam.getHdlModule(filePath, architecture.parent);
// if (entity) {
// // find params definitio
// for (const param of entity.params) {
// if (param.name === targetWord) {
// const targetUri = vscode.Uri.file(entity.path);
// const targetRange = util.transformRange(param.range, -1, 0);
// const link: vscode.LocationLink = { targetUri, targetRange, originSelectionRange: targetWordRange };
// return [ link ];
// }
// }
// // find ports definition
// for (const port of entity.ports) {
// if (port.name === targetWord) {
// const targetUri = vscode.Uri.file(entity.path);
// const targetRange = util.transformRange(port.range, -1, 0);
// const link: vscode.LocationLink = { targetUri, targetRange, originSelectionRange: targetWordRange };
// return [ link ];
// }
// }
// }
// }
// return null;
// }
// private async makeEntityDefinition(filePath: string, targetWord: string, targetWordRange: vscode.Range, moduleScope: util.ModuleScope): Promise<vscode.Location | vscode.LocationLink[] | null> {
// const entity = hdlParam.getHdlModule(filePath, moduleScope.module.name);
// if (entity) {
// if (targetWord === entity.name) {
// const targetUri = vscode.Uri.file(entity.path);
// const targetRange = util.transformRange(entity.range, -1, 0);
// const link: vscode.LocationLink = { targetUri, targetRange, originSelectionRange: targetWordRange };
// return [ link ];
// }
// // find params definitio
// for (const param of entity.params) {
// if (param.name === targetWord) {
// const targetUri = vscode.Uri.file(entity.path);
// const targetRange = util.transformRange(param.range, -1, 0);
// const link: vscode.LocationLink = { targetUri, targetRange, originSelectionRange: targetWordRange };
// return [ link ];
// }
// }
// // find ports definition
// for (const port of entity.ports) {
// if (port.name === targetWord) {
// const targetUri = vscode.Uri.file(entity.path);
// const targetRange = util.transformRange(port.range, -1, 0);
// const link: vscode.LocationLink = { targetUri, targetRange, originSelectionRange: targetWordRange };
// return [ link ];
// }
// }
// }
// return null;
// }
// }
// const vhdlDefinitionProvider = new VhdlDefinitionProvider();
// export {
// vhdlDefinitionProvider
// };

View File

@ -1,161 +0,0 @@
import * as vscode from 'vscode';
import { hdlPath } from '../../../hdlFs';
import { hdlParam } from '../../../hdlParser';
import { vlogKeyword } from '../util/keyword';
import * as util from '../util';
import { MainOutput, ReportType } from '../../../global';
// class VlogDefinitionProvider implements vscode.DefinitionProvider {
// public async provideDefinition(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Location | vscode.LocationLink[] | null> {
// // console.log('VlogDefinitionProvider');
// // get current words
// const wordRange = document.getWordRangeAtPosition(position, /[`_0-9A-Za-z]+/);
// if (!wordRange) {
// return null;
// }
// const targetWord = document.getText(wordRange);
// // check if need skip
// if (this.needSkip(document, position, targetWord)) {
// return null;
// }
// const filePath = document.fileName;
// const vlogAll = await hdlSymbolStorage.getSymbol(filePath);
// if (!vlogAll) {
// return null;
// } else {
// const location = await this.makeDefinition(document, position, vlogAll, targetWord, wordRange);
// return location;
// }
// }
// private needSkip(document: vscode.TextDocument, position: vscode.Position, targetWord: string): boolean {
// // check keyword
// if (vlogKeyword.isKeyword(targetWord)) {
// return true;
// }
// // TODO: check comment
// return false;
// }
// private async makeDefinition(document: vscode.TextDocument, position: vscode.Position, all: All, targetWord: string, targetWordRange: vscode.Range): Promise<vscode.Location | vscode.LocationLink[] | null> {
// const filePath = hdlPath.toSlash(document.fileName);
// const lineText = document.lineAt(position).text;
// // match `include
// const includeResult = util.matchInclude(document, position, all.macro.includes);
// if (includeResult) {
// const absPath = hdlPath.rel2abs(filePath, includeResult.name);
// const targetFile = vscode.Uri.file(absPath);
// const targetPosition = new vscode.Position(0, 0);
// const targetRange = new vscode.Range(targetPosition, targetPosition);
// const originSelectionRange = document.getWordRangeAtPosition(position, /["\.\\\/_0-9A-Za-z]+/);
// const link: vscode.LocationLink = { targetUri: targetFile, targetRange, originSelectionRange };
// return [link];
// }
// // match macro
// const macroResult = util.matchDefineMacro(position, targetWord, all.macro.defines);
// if (macroResult) {
// const targetRange = util.transformRange(macroResult.range, -1, -1);
// const link: vscode.LocationLink = { targetUri: document.uri, targetRange: targetRange, originSelectionRange: targetWordRange };
// return [link];
// }
// // locate at one module
// const scopeSymbols = util.locateVlogSymbol(position, all.content);
// if (!scopeSymbols || !scopeSymbols.module) {
// return null;
// }
// const currentModule = hdlParam.getHdlModule(filePath, scopeSymbols.module.name);
// if (!currentModule) {
// MainOutput.report('Fail to get HdlModule ' + filePath + ' ' + scopeSymbols.module.name, ReportType.Debug);
// return null;
// }
// // match instance
// const instResult = util.matchInstance(targetWord, currentModule);
// if (instResult) {
// const instModule = instResult.module;
// if (!instModule || !instResult.instModPath) {
// return null;
// }
// const targetFile = vscode.Uri.file(instResult.instModPath);
// const targetRange = util.transformRange(instModule.range, -1, 0, 1);
// const link: vscode.LocationLink = { targetUri: targetFile, targetRange };
// return [link];
// }
// // match port or param definition (position input)
// if (util.isPositionInput(lineText, position.character)) {
// const currentInstResult = util.filterInstanceByPosition(position, scopeSymbols.symbols, currentModule);
// if (!currentInstResult || !currentInstResult.instModPath) {
// return null;
// }
// const instParamPromise = util.getInstParamByPosition(currentInstResult, position, targetWord);
// const instPortPromise = util.getInstPortByPosition(currentInstResult, position, targetWord);
// const instParam = await instParamPromise;
// const instPort = await instPortPromise;
// const instModPathUri = vscode.Uri.file(currentInstResult.instModPath);
// if (instParam) {
// const targetRange = util.transformRange(instParam.range, -1, 0);
// const link: vscode.LocationLink = { targetUri: instModPathUri, targetRange };
// return [link];
// }
// if (instPort) {
// const targetRange = util.transformRange(instPort.range, -1, 0);
// const link: vscode.LocationLink = { targetUri: instModPathUri, targetRange };
// return [link];
// }
// return null;
// }
// // match params
// const paramResult = util.matchParams(targetWord, currentModule);
// if (paramResult) {
// const targetRange = util.transformRange(paramResult.range, -1, 0);
// const link: vscode.LocationLink = { targetUri: document.uri, targetRange };
// return [link];
// }
// // match ports
// const portResult = util.matchPorts(targetWord, currentModule);
// if (portResult) {
// const targetRange = util.transformRange(portResult.range, -1, 0);
// const link: vscode.LocationLink = { targetUri: document.uri, targetRange };
// return [link];
// }
// // match others
// const normalResult = util.matchNormalSymbol(targetWord, scopeSymbols.symbols);
// if (normalResult) {
// const targetRange = util.transformRange(normalResult.range, -1, 0);
// const link: vscode.LocationLink = { targetUri: document.uri, targetRange };
// return [link];
// }
// return null;
// }
// }
// const vlogDefinitionProvider = new VlogDefinitionProvider();
// export {
// vlogDefinitionProvider
// };

View File

@ -1,6 +0,0 @@
// import { vlogDocSenmanticProvider, vlogLegend } from './vlog';
// export {
// vlogDocSenmanticProvider,
// vlogLegend
// };

View File

@ -1,49 +0,0 @@
import * as vscode from 'vscode';
import { transformRange } from '../util';
const tokenTypes = ['class', 'function', 'variable'];
const tokenModifiers = ['declaration', 'documentation'];
const vlogLegend = new vscode.SemanticTokensLegend(tokenTypes, tokenModifiers);
// class VlogDocSenmanticProvider implements vscode.DocumentSemanticTokensProvider {
// public async provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.SemanticTokens | null | undefined> {
// // TODO : finish this
// const tokensBuilder = new vscode.SemanticTokensBuilder(vlogLegend);
// return tokensBuilder.build();
// }
// private prepareTokensBuilder(builder: vscode.SemanticTokensBuilder, all: All){
// for (const rawSymbol of all.content) {
// const semanticRange = transformRange(rawSymbol.range, -1, 0);
// const tokenType = this.getTokenTypes(rawSymbol.type);
// if (tokenType) {
// builder.push(semanticRange, tokenType);
// }
// }
// }
// private getTokenTypes(type: string): string | undefined {
// switch (type) {
// case 'input':
// return 'variable';
// case 'output':
// return 'variable';
// case 'wire':
// return 'variable';
// case 'reg':
// return 'variable';
// default:
// return;
// }
// }
// }
// const vlogDocSenmanticProvider = new VlogDocSenmanticProvider();
// export {
// vlogDocSenmanticProvider,
// vlogLegend
// };

View File

@ -1,8 +0,0 @@
// import { vlogDocSymbolProvider } from './vlog';
// import { vhdlDocSymbolProvider } from './vhdl';
// export {
// vlogDocSymbolProvider,
// vhdlDocSymbolProvider
// };

View File

@ -1,85 +0,0 @@
import * as vscode from 'vscode';
import { AllowNull } from '../../../global';
import { RawSymbol, Range } from '../../../hdlParser/common';
// interface DocSymbolContainer {
// docSymbol: AllowNull<vscode.DocumentSymbol>,
// range: AllowNull<Range>
// };
// const vhdlSymbolKind: Record<string, vscode.SymbolKind> = {
// entity: vscode.SymbolKind.Interface,
// port: vscode.SymbolKind.Property,
// architecture: vscode.SymbolKind.Variable,
// signal: vscode.SymbolKind.Property
// };
// class VhdlDocSymbolProvider implements vscode.DocumentSymbolProvider {
// public async provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.DocumentSymbol[]> {
// const path = document.fileName;
// const vhdlAll = await hdlSymbolStorage.getSymbol(path);
// if (!vhdlAll || !vhdlAll.content) {
// return [];
// } else {
// const symbols = vhdlAll.content;
// const symbolInfos = this.makeDocumentSymbols(document, symbols);
// return symbolInfos;
// }
// }
// private makeDocumentSymbols(document: vscode.TextDocument, symbols: RawSymbol[]): vscode.DocumentSymbol[] {
// const docSymbols: vscode.DocumentSymbol[] = [];
// for (const symbol of symbols) {
// const symbolStart = new vscode.Position(symbol.range.start.line - 1, symbol.range.start.character);
// const symbolEnd = new vscode.Position(symbol.range.end.line - 1, symbol.range.end.character);
// const symbolRange = new vscode.Range(symbolStart, symbolEnd);
// if (symbol.type === 'entity') {
// const docSymbol = new vscode.DocumentSymbol(symbol.name,
// symbol.name,
// vhdlSymbolKind[symbol.type],
// symbolRange,
// symbolRange);
// docSymbols.push(docSymbol);
// } else if (symbol.type === 'port') {
// const parentEntity = docSymbols[docSymbols.length - 1];
// const docSymbol = new vscode.DocumentSymbol(symbol.name,
// symbol.name,
// vhdlSymbolKind[symbol.type],
// symbolRange,
// symbolRange);
// parentEntity.children.push(docSymbol);
// } else if (symbol.type === 'architecture') {
// const docSymbol = new vscode.DocumentSymbol(symbol.name,
// symbol.name,
// vhdlSymbolKind[symbol.type],
// symbolRange,
// symbolRange);
// docSymbols.push(docSymbol);
// } else if (symbol.type === 'signal') {
// const parentArchitecture = docSymbols[docSymbols.length - 1];
// if (parentArchitecture.kind === vhdlSymbolKind['architecture']) {
// const docSymbol = new vscode.DocumentSymbol(symbol.name,
// symbol.name,
// vhdlSymbolKind[symbol.type],
// symbolRange,
// symbolRange);
// parentArchitecture.children.push(docSymbol);
// }
// }
// }
// return docSymbols;
// }
// }
// const vhdlDocSymbolProvider = new VhdlDocSymbolProvider();
// export {
// vhdlDocSymbolProvider
// };

View File

@ -1,191 +0,0 @@
import * as vscode from 'vscode';
import { AllowNull } from '../../../global';
import { RawSymbol, Range } from '../../../hdlParser/common';
import { positionAfterEqual } from '../util';
// interface DocSymbolContainer {
// docSymbol: AllowNull<vscode.DocumentSymbol>,
// range: AllowNull<Range>
// };
// class VlogDocSymbolProvider implements vscode.DocumentSymbolProvider {
// public async provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.DocumentSymbol[]> {
// // console.log('VlogDocSymbolProvider');
// const path = document.fileName;
// const vlogAll = await hdlSymbolStorage.getSymbol(path);
// if (!vlogAll || !vlogAll.content) {
// return [];
// } else {
// const symbols = vlogAll.content;
// const symbolInfos = this.makeDocumentSymbols(document, symbols);
// return symbolInfos;
// }
// }
// private makeDocumentSymbols(document: vscode.TextDocument, symbols: RawSymbol[]): vscode.DocumentSymbol[] {
// const docSymbols = [];
// const visitedSymbols = new Set();
// const moduleSymbols = symbols.filter(symbol => {
// if (symbol.type === 'module') {
// visitedSymbols.add(symbol);
// return true;
// }
// return false;
// });
// for (const moduleSymbol of moduleSymbols) {
// const moduleName = moduleSymbol.name;
// const moduleKind = this.getSymbolKind(moduleSymbol.type);
// const moduleStart = new vscode.Position(moduleSymbol.range.start.line - 1, moduleSymbol.range.start.character);
// const moduleEnd = new vscode.Position(moduleSymbol.range.end.line - 1, moduleSymbol.range.start.character);
// const moduleRange = new vscode.Range(moduleStart, moduleEnd);
// const moduleDocSymbol = new vscode.DocumentSymbol(moduleName,
// moduleName,
// moduleKind,
// moduleRange,
// moduleRange);
// docSymbols.push(moduleDocSymbol);
// const paramContainer: DocSymbolContainer = {
// docSymbol: null,
// range: null
// };
// const portContainer: DocSymbolContainer = {
// docSymbol: null,
// range: null
// };
// const portTypes = ['input', 'inout', 'output'];
// // make others in module inner
// for (const symbol of symbols) {
// if (visitedSymbols.has(symbol)) {
// continue;
// }
// if (!(positionAfterEqual(symbol.range.start, moduleSymbol.range.start) &&
// positionAfterEqual(moduleSymbol.range.end, symbol.range.end))) {
// continue;
// }
// if (!symbol.name) {
// symbol.name = '???';
// }
// visitedSymbols.add(symbol);
// const symbolStart = new vscode.Position(symbol.range.start.line - 1, symbol.range.start.character);
// const symbolEnd = new vscode.Position(symbol.range.end.line - 1, symbol.range.end.character);
// const symbolRange = new vscode.Range(symbolStart, symbolEnd);
// if (symbol.type === 'parameter') {
// if (!paramContainer.range) {
// paramContainer.range = symbolRange;
// paramContainer.docSymbol = new vscode.DocumentSymbol('param',
// 'param description',
// vscode.SymbolKind.Method,
// symbolRange,
// symbolRange);
// moduleDocSymbol.children.push(paramContainer.docSymbol);
// }
// const paramDocSymbol = new vscode.DocumentSymbol(symbol.name,
// symbol.type,
// vscode.SymbolKind.Constant,
// symbolRange,
// symbolRange);
// paramContainer.docSymbol?.children.push(paramDocSymbol);
// } else if (portTypes.includes(symbol.type)) {
// if (!portContainer.range) {
// portContainer.range = symbolRange;
// portContainer.docSymbol = new vscode.DocumentSymbol('port',
// 'port description',
// vscode.SymbolKind.Method,
// symbolRange,
// symbolRange);
// moduleDocSymbol.children.push(portContainer.docSymbol);
// }
// const portDocSymbol = new vscode.DocumentSymbol(symbol.name,
// symbol.type,
// vscode.SymbolKind.Interface,
// symbolRange,
// symbolRange);
// portContainer.docSymbol?.children.push(portDocSymbol);
// } else {
// const symbolKind = this.getSymbolKind(symbol.type);
// const symbolDocSymbol = new vscode.DocumentSymbol(symbol.name,
// symbol.type,
// symbolKind,
// symbolRange,
// symbolRange);
// moduleDocSymbol.children.push(symbolDocSymbol);
// }
// }
// }
// return docSymbols;
// }
// private getSymbolKind(name: string): vscode.SymbolKind {
// if (name.indexOf('[') !== -1) {
// return vscode.SymbolKind.Array;
// }
// switch (name) {
// case 'module': return vscode.SymbolKind.Class;
// case 'program': return vscode.SymbolKind.Module;
// case 'package': return vscode.SymbolKind.Package;
// case 'import': return vscode.SymbolKind.Package;
// case 'always': return vscode.SymbolKind.Operator;
// case 'processe': return vscode.SymbolKind.Operator;
// case 'task': return vscode.SymbolKind.Method;
// case 'function': return vscode.SymbolKind.Function;
// case 'assert': return vscode.SymbolKind.Boolean;
// case 'event': return vscode.SymbolKind.Event;
// case 'instance': return vscode.SymbolKind.Event;
// case 'time': return vscode.SymbolKind.TypeParameter;
// case 'define': return vscode.SymbolKind.TypeParameter;
// case 'typedef': return vscode.SymbolKind.TypeParameter;
// case 'generate': return vscode.SymbolKind.Operator;
// case 'enum': return vscode.SymbolKind.Enum;
// case 'modport': return vscode.SymbolKind.Boolean;
// case 'property': return vscode.SymbolKind.Property;
// // port
// case 'interface': return vscode.SymbolKind.Interface;
// case 'buffer': return vscode.SymbolKind.Interface;
// case 'output': return vscode.SymbolKind.Interface;
// case 'input': return vscode.SymbolKind.Interface;
// case 'inout': return vscode.SymbolKind.Interface;
// // synth param
// case 'localparam': return vscode.SymbolKind.Constant;
// case 'parameter': return vscode.SymbolKind.Constant;
// case 'integer': return vscode.SymbolKind.Number;
// case 'char': return vscode.SymbolKind.Number;
// case 'float': return vscode.SymbolKind.Number;
// case 'int': return vscode.SymbolKind.Number;
// // unsynth param
// case 'string': return vscode.SymbolKind.String;
// case 'struct': return vscode.SymbolKind.Struct;
// case 'class': return vscode.SymbolKind.Class;
// case 'logic': return vscode.SymbolKind.Constant;
// case 'wire': return vscode.SymbolKind.Constant;
// case 'reg': return vscode.SymbolKind.Constant;
// case 'net': return vscode.SymbolKind.Variable;
// case 'bit': return vscode.SymbolKind.Boolean;
// default: return vscode.SymbolKind.Event;
// }
// }
// }
// const vlogDocSymbolProvider = new VlogDocSymbolProvider();
// export {
// vlogDocSymbolProvider
// };

View File

@ -1,7 +0,0 @@
// import { vlogHoverProvider } from './vlog';
// import { vhdlHoverProvider } from './vhdl';
// export {
// vlogHoverProvider,
// vhdlHoverProvider
// };

View File

@ -1,180 +0,0 @@
import * as vscode from 'vscode';
import { hdlPath } from '../../../hdlFs';
import { hdlParam } from '../../../hdlParser';
import { vhdlKeyword } from '../util/keyword';
import * as util from '../util';
import { MainOutput, ReportType } from '../../../global';
import { HdlLangID } from '../../../global/enum';
import { RawSymbol } from '../../../hdlParser/common';
// class VhdlHoverProvider implements vscode.HoverProvider {
// public async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Hover | null> {
// // console.log('VhdlHoverProvider');
// // get current words
// const wordRange = document.getWordRangeAtPosition(position, /[`_0-9A-Za-z]+/);
// if (!wordRange) {
// return null;
// }
// const targetWord = document.getText(wordRange);
// // check if need skip
// if (this.needSkip(document, position, targetWord)) {
// return null;
// }
// const keywordHover = this.getKeywordHover(targetWord);
// if (keywordHover) {
// return keywordHover;
// }
// const filePath = document.fileName;
// const vhdlAll = await hdlSymbolStorage.getSymbol(filePath);
// if (!vhdlAll) {
// return null;
// } else {
// const hover = await this.makeHover(document, position, vhdlAll, targetWord, wordRange);
// return hover;
// }
// }
// private getKeywordHover(words: string): vscode.Hover | undefined {
// const content = new vscode.MarkdownString('', true);
// if (vhdlKeyword.compilerKeys().has(words)) {
// content.appendMarkdown('IEEE Library data type');
// return new vscode.Hover(content);
// }
// return undefined;
// }
// private needSkip(document: vscode.TextDocument, position: vscode.Position, targetWord: string): boolean {
// // check keyword
// if (vhdlKeyword.isKeyword(targetWord)) {
// return true;
// }
// // TODO: check comment
// return false;
// }
// private async makeHover(document: vscode.TextDocument, position: vscode.Position, all: All, targetWord: string, targetWordRange: vscode.Range): Promise<vscode.Hover | null> {
// const lineText = document.lineAt(position).text;
// const filePath = hdlPath.toSlash(document.fileName);
// // locate at one entity or architecture
// // TODO: remove it after adjust of backend
// const rawSymbols = [];
// for (const symbol of all.content) {
// const rawSymbol: RawSymbol = {
// name: symbol.name,
// type: symbol.type,
// parent: symbol.parent,
// range: util.transformRange(symbol.range, -1),
// signed: symbol.signed,
// netType: symbol.netType
// };
// rawSymbols.push(rawSymbol);
// }
// const moduleScope = util.locateVhdlSymbol(position, rawSymbols);
// if (!moduleScope) {
// return null;
// }
// const scopeType = moduleScope.module.type;
// if (scopeType === 'architecture') {
// return await this.makeArchitectureHover(filePath, targetWord, targetWordRange, moduleScope);
// } else if (scopeType === 'entity') {
// return await this.makeEntityHover(filePath, targetWord, targetWordRange, moduleScope);
// }
// return null;
// }
// private async makeArchitectureHover(filePath: string, targetWord: string, targetWordRange: vscode.Range, moduleScope: util.ModuleScope): Promise<vscode.Hover | null> {
// const architecture = moduleScope.module;
// const content = new vscode.MarkdownString('', true);
// // point to the entity of the architecture
// if (architecture.parent && architecture.parent === targetWord) {
// const entity = hdlParam.getHdlModule(filePath, architecture.parent);
// if (entity) {
// await util.makeVhdlHoverContent(content, entity);
// return new vscode.Hover(content);
// }
// }
// // filter defined signal
// for (const symbol of moduleScope.symbols) {
// if (symbol.name === targetWord) {
// content.appendCodeblock(symbol.type, 'vhdl');
// return new vscode.Hover(content);
// }
// }
// // inner variable mapping to entity
// if (architecture.parent) {
// const entity = hdlParam.getHdlModule(filePath, architecture.parent);
// if (entity) {
// // find params definitio
// for (const param of entity.params) {
// if (param.name === targetWord) {
// const desc = util.makeParamDesc(param);
// content.appendCodeblock(desc, 'vhdl');
// return new vscode.Hover(content);
// }
// }
// // find ports definition
// for (const port of entity.ports) {
// if (port.name === targetWord) {
// const desc = util.makePortDesc(port);
// content.appendCodeblock(desc, 'vhdl');
// return new vscode.Hover(content);
// }
// }
// }
// }
// return null;
// }
// private async makeEntityHover(filePath: string, targetWord: string, targetWordRange: vscode.Range, moduleScope: util.ModuleScope): Promise<vscode.Hover | null> {
// const entity = hdlParam.getHdlModule(filePath, moduleScope.module.name);
// const content = new vscode.MarkdownString('', true);
// if (entity) {
// if (targetWord === entity.name) {
// await util.makeVhdlHoverContent(content, entity);
// return new vscode.Hover(content);
// }
// // find params definitio
// for (const param of entity.params) {
// if (param.name === targetWord) {
// const desc = util.makeParamDesc(param);
// content.appendCodeblock(desc, 'vhdl');
// return new vscode.Hover(content);
// }
// }
// // find ports definition
// for (const port of entity.ports) {
// if (port.name === targetWord) {
// const desc = util.makePortDesc(port);
// content.appendCodeblock(desc, 'vhdl');
// return new vscode.Hover(content);
// }
// }
// }
// return null;
// }
// }
// const vhdlHoverProvider = new VhdlHoverProvider();
// export {
// vhdlHoverProvider
// };

View File

@ -1,209 +0,0 @@
import * as vscode from 'vscode';
import { hdlPath } from '../../../hdlFs';
import { hdlParam } from '../../../hdlParser';
import { vlogKeyword } from '../util/keyword';
import * as util from '../util';
import { LspOutput, MainOutput, ReportType } from '../../../global';
import { HdlLangID } from '../../../global/enum';
// class VlogHoverProvider implements vscode.HoverProvider {
// public async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Hover | null> {
// // console.log('VlogHoverProvider');
// // get current words
// const wordRange = document.getWordRangeAtPosition(position, /[`_0-9A-Za-z]+/);
// if (!wordRange) {
// return null;
// }
// const targetWord = document.getText(wordRange);
// // check if need skip
// if (this.needSkip(document, position, targetWord)) {
// return null;
// }
// const filePath = document.fileName;
// const vlogAll = await hdlSymbolStorage.getSymbol(filePath);
// if (!vlogAll) {
// return null;
// } else {
// const hover = await this.makeHover(document, position, vlogAll, targetWord, wordRange);
// return hover;
// }
// }
// private needSkip(document: vscode.TextDocument, position: vscode.Position, targetWord: string): boolean {
// // check keyword
// if (vlogKeyword.isKeyword(targetWord)) {
// return true;
// }
// // TODO: check comment
// return false;
// }
// private async makeHover(document: vscode.TextDocument, position: vscode.Position, all: All, targetWord: string, targetWordRange: vscode.Range): Promise<vscode.Hover | null> {
// const lineText = document.lineAt(position).text;
// const filePath = hdlPath.toSlash(document.fileName);
// // total content rendered on the hover box
// const content = new vscode.MarkdownString('', true);
// // match `include
// const includeResult = util.matchInclude(document, position, all.macro.includes);
// if (includeResult) {
// const absPath = hdlPath.rel2abs(filePath, includeResult.name);
// content.appendCodeblock(`"${absPath}"`, HdlLangID.Verilog);
// const targetRange = document.getWordRangeAtPosition(position, /[1-9a-zA-Z_\.]+/);
// return new vscode.Hover(content, targetRange);
// } else if (lineText.trim().startsWith('`include')) {
// return null;
// }
// // match macro
// const macroResult = util.matchDefineMacro(position, targetWord, all.macro.defines);
// if (macroResult) {
// const name = macroResult.name;
// const value = macroResult.value;
// content.appendCodeblock(`\`define ${name} ${value}`, HdlLangID.Verilog);
// return new vscode.Hover(content, targetWordRange);
// }
// // locate at one module
// const scopeSymbols = util.locateVlogSymbol(position, all.content);
// if (!scopeSymbols || !scopeSymbols.module || !hdlParam.hasHdlModule(filePath, scopeSymbols.module.name)) {
// return null;
// }
// const currentModule = hdlParam.getHdlModule(filePath, scopeSymbols.module.name);
// if (!currentModule) {
// MainOutput.report('Fail to get HdlModule ' + filePath + ' ' + scopeSymbols.module.name, ReportType.Debug);
// return null;
// }
// // match instance
// const instResult = util.matchInstance(targetWord, currentModule);
// if (instResult) {
// const instModule = instResult.module;
// if (!instModule || !instResult.instModPath) {
// content.appendMarkdown('cannot find the definition of the module');
// return new vscode.Hover(content);
// }
// await util.makeVlogHoverContent(content, instModule);
// return new vscode.Hover(content);
// }
// // match port or param definition (position input)
// /** for example, when you hover the ".clk" below, the branch will be entered
// template u_template(
// //input
// .clk ( clk ),
// );
// *
// */
// if (util.isPositionInput(lineText, position.character)) {
// // console.log('enter position input');
// const currentInstResult = util.filterInstanceByPosition(position, scopeSymbols.symbols, currentModule);
// if (!currentInstResult || !currentInstResult.instModPath) {
// return null;
// }
// // console.log(currentInstResult);
// const instParamPromise = util.getInstParamByPosition(currentInstResult, position, targetWord);
// const instPortPromise = util.getInstPortByPosition(currentInstResult, position, targetWord);
// const instParam = await instParamPromise;
// const instPort = await instPortPromise;
// if (instParam) {
// const paramComment = await util.searchCommentAround(currentInstResult.instModPath, instParam.range);
// const paramDesc = util.makeParamDesc(instParam);
// content.appendCodeblock(paramDesc, HdlLangID.Verilog);
// if (paramComment) {
// content.appendCodeblock(paramComment, HdlLangID.Verilog);
// }
// return new vscode.Hover(content);
// }
// if (instPort) {
// const portComment = await util.searchCommentAround(currentInstResult.instModPath, instPort.range);
// const portDesc = util.makePortDesc(instPort);
// content.appendCodeblock(portDesc, HdlLangID.Verilog);
// if (portComment) {
// content.appendCodeblock(portComment, HdlLangID.Verilog);
// }
// return new vscode.Hover(content);
// }
// return null;
// }
// // match params
// const paramResult = util.matchParams(targetWord, currentModule);
// if (paramResult) {
// LspOutput.report('<vlog hover> get param info ' + paramResult?.name;
// const paramComment = await util.searchCommentAround(filePath, paramResult.range);
// const paramDesc = util.makeParamDesc(paramResult);
// content.appendCodeblock(paramDesc, HdlLangID.Verilog);
// if (paramComment) {
// content.appendMarkdown(paramComment);
// }
// return new vscode.Hover(content);
// }
// // match ports
// const portResult = util.matchPorts(targetWord, currentModule);
// if (portResult) {
// LspOutput.report('<vlog hover> get port info ' + portResult?.name;
// const portComment = await util.searchCommentAround(filePath, portResult.range);
// const portDesc = util.makePortDesc(portResult);
// content.appendCodeblock(portDesc, HdlLangID.Verilog);
// if (portComment) {
// content.appendMarkdown(portComment);
// }
// return new vscode.Hover(content);
// }
// // match others
// const normalResult = util.matchNormalSymbol(targetWord, scopeSymbols.symbols);
// if (normalResult) {
// const normalComment = await util.searchCommentAround(filePath, normalResult.range);
// const normalDesc = util.makeNormalDesc(normalResult);
// content.appendCodeblock(normalDesc, HdlLangID.Verilog);
// if (normalComment) {
// content.appendCodeblock(normalComment, HdlLangID.Verilog);
// }
// return new vscode.Hover(content);
// }
// // feature 1. number signed and unsigned number display
// const numberResult = util.transferVlogNumber(lineText, position.character);
// if (numberResult) {
// const bits = targetWord.length - 1;
// content.appendCodeblock(bits + "'" + targetWord, HdlLangID.Verilog);
// content.appendMarkdown("`unsigned` " + numberResult.unsigned);
// content.appendText('\n');
// content.appendMarkdown("`signed` " + numberResult.signed);
// }
// return new vscode.Hover(content);
// }
// }
// const vlogHoverProvider = new VlogHoverProvider();
// export {
// vlogHoverProvider
// };

View File

@ -178,11 +178,13 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
public getTopModuleItemList(element: ModuleDataItem): ModuleDataItem[] { public getTopModuleItemList(element: ModuleDataItem): ModuleDataItem[] {
// src or sim // src or sim
const hardwarePath = opeParam.prjInfo.arch.hardware;
const moduleType = element.name as keyof (SrcPath & SimPath); const moduleType = element.name as keyof (SrcPath & SimPath);
// 获取所有对应类型src | sim下的顶层模块数量
const topModules = hdlParam.getTopModulesByType(moduleType); const topModules = hdlParam.getTopModulesByType(moduleType);
const topModuleItemList = topModules.map<ModuleDataItem>(module => ({
// 将所有顶层模块转换成 ModuleDataItem 自定义 treeview item 数据结构
let topModuleItemList = topModules.map<ModuleDataItem>(module => ({
icon: this.judgeTopModuleIconByDoFastType(module.file.doFastType), icon: this.judgeTopModuleIconByDoFastType(module.file.doFastType),
type: moduleType, type: moduleType,
doFastFileType: module.file.doFastType, doFastFileType: module.file.doFastType,
@ -198,40 +200,40 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
if (topModuleItemList.length > 0) { if (topModuleItemList.length > 0) {
const type = moduleType as keyof FirstTop; const type = moduleType as keyof FirstTop;
const firstTop = topModuleItemList[0]; // 默认选择依赖模块最多的作为 first top
if (!this.firstTop[type]) { let firstTop: { path: string, name: string } | undefined = undefined;
let maxDepSize = 0;
for (const hdlModule of topModules) {
// 此处断言是因为当前的 name 和 path 是从 topModules 中提取的
// 它们对应的 hdlModule 一定存在
const deps = hdlParam.getAllDependences(hdlModule.path, hdlModule.name)!;
const depSize = deps.include.length + deps.others.length;
if (depSize > maxDepSize) {
maxDepSize = depSize;
firstTop = { path: hdlModule.path, name: hdlModule.name };
}
}
if (firstTop === undefined) {
// 没有找到顶层模块,代表当前本来就是空的
// 此时 topModuleItemList 一定是 []
return topModuleItemList;
}
// 将当前模块设置为 first top
this.setFirstTop(type, firstTop.name, firstTop.path); this.setFirstTop(type, firstTop.name, firstTop.path);
}
const name = this.firstTop[type]!.name;
const path = this.firstTop[type]!.path;
const icon = this.makeFirstTopIconName(type);
const range = firstTop.range;
const parent = element;
// TODO: check
const doFastFileType = undefined;
const tops = topModuleItemList.filter(item => item.path === path && item.name === name); // 将 first top 放到数据列表开头
const adjustItemList = []; const firstTopIcon = this.makeFirstTopIconName(type);
if (tops.length > 0 || !hdlParam.hasHdlModule(path, name)) {
// mean that the seleted top is an original top module
// push it to the top of the *topModuleItemList*
const headItem = tops[0] ? tops[0] : topModuleItemList[0];
headItem.icon = icon; // 将 topModuleItemList 中的 first top 元素调整到第一个位置
adjustItemList.push(headItem); const dataItem = topModuleItemList.filter(item => item.name === firstTop.name && item.path === firstTop.path)[0];
for (const item of topModuleItemList) { dataItem.icon = firstTopIcon;
if (item !== headItem) { let newTopModuleItemList = [dataItem];
adjustItemList.push(item); newTopModuleItemList = newTopModuleItemList.concat(topModuleItemList.filter(item => item !== dataItem));
}
} return newTopModuleItemList;
} else {
// mean the selected top is not an original top module
// create it and add it to the head of *topModuleItemList*
const selectedTopItem: ModuleDataItem = {icon, type, name, range, path, parent, doFastFileType};
adjustItemList.push(selectedTopItem);
adjustItemList.push(...topModuleItemList);
}
return adjustItemList;
} }
return topModuleItemList; return topModuleItemList;

View File

@ -3,7 +3,7 @@ import * as fspath from 'path';
import { AbsPath } from '../global'; import { AbsPath } from '../global';
import * as hdlPath from './path'; import * as hdlPath from './path';
function isDir(path: AbsPath): boolean { export function isDir(path: AbsPath): boolean {
if (!fs.existsSync(path)) { if (!fs.existsSync(path)) {
return false; return false;
} }
@ -15,7 +15,7 @@ function isDir(path: AbsPath): boolean {
return false; return false;
} }
function mkdir(path: AbsPath): boolean { export function mkdir(path: AbsPath): boolean {
if (!path) { if (!path) {
return false; return false;
} }
@ -34,8 +34,10 @@ function mkdir(path: AbsPath): boolean {
return false; return false;
} }
function rmdir(path: AbsPath): void { export function rmdir(path: AbsPath): void {
fs.rm(path, { recursive: true, force: true }, () => {}); if (fs.existsSync(path)) {
fs.rmSync(path, { recursive: true, force: true });
}
// if (fs.existsSync(path)) { // if (fs.existsSync(path)) {
// if (fs.statSync(path).isDirectory()) { // if (fs.statSync(path).isDirectory()) {
// const files = fs.readdirSync(path); // const files = fs.readdirSync(path);
@ -54,7 +56,7 @@ function rmdir(path: AbsPath): void {
// } // }
} }
function mvdir(src: AbsPath, dest: AbsPath, cover: boolean): boolean { export function mvdir(src: AbsPath, dest: AbsPath, cover: boolean): boolean {
if (src === dest) { if (src === dest) {
return false; return false;
} }
@ -67,7 +69,8 @@ function mvdir(src: AbsPath, dest: AbsPath, cover: boolean): boolean {
} }
} }
function cpdir(src: AbsPath, dest: AbsPath, cover: boolean) {
export function cpdir(src: AbsPath, dest: AbsPath, cover: boolean) {
if (src === dest) { if (src === dest) {
return false; return false;
} }
@ -123,10 +126,3 @@ function cpdir(src: AbsPath, dest: AbsPath, cover: boolean) {
return true; return true;
} }
export {
mkdir,
rmdir,
cpdir,
mvdir
};

View File

@ -8,6 +8,7 @@ import * as hdlPath from './path';
import { HdlFileProjectType } from '../hdlParser/common'; import { HdlFileProjectType } from '../hdlParser/common';
import { opeParam } from '../global'; import { opeParam } from '../global';
import { hdlIgnore } from '../manager/ignore'; import { hdlIgnore } from '../manager/ignore';
import { hdlDir } from '.';
/** /**
* judge if the path represent a file * judge if the path represent a file
@ -172,7 +173,7 @@ export function writeFile(path: AbsPath, content: string): boolean {
} }
} }
export function readJSON(path: AbsPath): object { export function readJSON(path: AbsPath): any {
try { try {
const context = fs.readFileSync(path, 'utf-8'); const context = fs.readFileSync(path, 'utf-8');
return JSON.parse(context); return JSON.parse(context);
@ -392,3 +393,19 @@ export function diffFiles(newFiles: AbsPath[], oldFiles: AbsPath[]): DiffResult
addFiles, delFiles addFiles, delFiles
}; };
} }
/**
* @description source target target
* - source target/source
* - source target/source
* @param source
* @param target
*/
export function move(source: AbsPath, target: AbsPath) {
if (isDir(source)) {
hdlDir.mvdir(source, target, true);
} else {
const filename = fspath.basename(source);
moveFile(source, hdlPath.join(target, filename));
}
}

View File

@ -8,7 +8,7 @@ import { AbsPath, opeParam, RelPath } from '../global';
* @param path * @param path
* @returns * @returns
*/ */
function toSlash(path: AbsPath | RelPath): AbsPath | RelPath { export function toSlash(path: AbsPath | RelPath): AbsPath | RelPath {
return path.replace(/\\/g,"\/"); return path.replace(/\\/g,"\/");
} }
@ -18,7 +18,7 @@ function toSlash(path: AbsPath | RelPath): AbsPath | RelPath {
* @param relPath relative path in curPath * @param relPath relative path in curPath
* @returns * @returns
*/ */
function rel2abs(curPath: AbsPath, relPath: RelPath): AbsPath { export function rel2abs(curPath: AbsPath, relPath: RelPath): AbsPath {
if (fspath.isAbsolute(relPath)) { if (fspath.isAbsolute(relPath)) {
return relPath; return relPath;
} }
@ -28,7 +28,7 @@ function rel2abs(curPath: AbsPath, relPath: RelPath): AbsPath {
} }
function relative(from: AbsPath, to: AbsPath): RelPath { export function relative(from: AbsPath, to: AbsPath): RelPath {
let rel = fspath.relative(from, to); let rel = fspath.relative(from, to);
if (!rel.startsWith('.') && !rel.startsWith('./')) { if (!rel.startsWith('.') && !rel.startsWith('./')) {
rel = './' + rel; rel = './' + rel;
@ -41,7 +41,7 @@ function relative(from: AbsPath, to: AbsPath): RelPath {
* @param paths * @param paths
* @returns * @returns
*/ */
function join(...paths: string[]): AbsPath | RelPath { export function join(...paths: string[]): AbsPath | RelPath {
return paths.join('/'); return paths.join('/');
} }
@ -51,7 +51,7 @@ function join(...paths: string[]): AbsPath | RelPath {
* @param paths * @param paths
* @returns * @returns
*/ */
function resolve(...paths: string[]): AbsPath | RelPath { export function resolve(...paths: string[]): AbsPath | RelPath {
const absPath = fspath.resolve(...paths); const absPath = fspath.resolve(...paths);
return toSlash(absPath); return toSlash(absPath);
} }
@ -64,7 +64,7 @@ function resolve(...paths: string[]): AbsPath | RelPath {
* @returns reserveSplitor=true src/file.txt -> .txt * @returns reserveSplitor=true src/file.txt -> .txt
* reserveSplitor=false src/file.txt -> txt * reserveSplitor=false src/file.txt -> txt
*/ */
function extname(path: AbsPath | RelPath, reserveSplitor: boolean = true): string { export function extname(path: AbsPath | RelPath, reserveSplitor: boolean = true): string {
let ext = fspath.extname(path).toLowerCase(); let ext = fspath.extname(path).toLowerCase();
if (!reserveSplitor && ext.startsWith('.')) { if (!reserveSplitor && ext.startsWith('.')) {
ext = ext.substring(1); ext = ext.substring(1);
@ -72,7 +72,7 @@ function extname(path: AbsPath | RelPath, reserveSplitor: boolean = true): strin
return ext; return ext;
} }
function basename(path: AbsPath | RelPath) { export function basename(path: AbsPath | RelPath) {
return fspath.basename(path, extname(path, true)); return fspath.basename(path, extname(path, true));
} }
@ -82,19 +82,19 @@ function basename(path: AbsPath | RelPath) {
* @param path * @param path
* @returns src/file.txt -> file * @returns src/file.txt -> file
*/ */
function filename(path: AbsPath | RelPath): string { export function filename(path: AbsPath | RelPath): string {
const ext = extname(path, true); const ext = extname(path, true);
return fspath.basename(path, ext); return fspath.basename(path, ext);
} }
function exist(path: AbsPath | undefined): boolean { export function exist(path: AbsPath | undefined): boolean {
if (!path) { if (!path) {
return false; return false;
} }
return fs.existsSync(path); return fs.existsSync(path);
} }
function toEscapePath(path: AbsPath): AbsPath { export function toEscapePath(path: AbsPath): AbsPath {
if (os.platform() === 'win32') { if (os.platform() === 'win32') {
return path.startsWith('/') ? toSlash(path.slice(1)) : toSlash(path); return path.startsWith('/') ? toSlash(path.slice(1)) : toSlash(path);
} else { } else {
@ -102,24 +102,10 @@ function toEscapePath(path: AbsPath): AbsPath {
} }
} }
function toPureRelativePath(path: RelPath): RelPath { export function toPureRelativePath(path: RelPath): RelPath {
if (path.startsWith('./') || path.startsWith('.\\')) { if (path.startsWith('./') || path.startsWith('.\\')) {
return path.slice(2); return path.slice(2);
} }
return path; return path;
} }
export {
toSlash,
rel2abs,
relative,
join,
resolve,
filename,
extname,
basename,
exist,
toEscapePath,
toPureRelativePath
};

View File

@ -32,6 +32,18 @@ class HdlParam {
return this.pathToHdlFiles.get(path); return this.pathToHdlFiles.get(path);
} }
/**
* @description
*/
public clear() {
this.topModules.clear();
this.srcTopModules.clear();
this.simTopModules.clear();
this.pathToHdlFiles.clear();
this.modules.clear();
this.unhandleInstances.clear();
}
public getAllHdlFiles(): HdlFile[] { public getAllHdlFiles(): HdlFile[] {
const hdlFiles = []; const hdlFiles = [];
for (const [_, hdlFile] of this.pathToHdlFiles) { for (const [_, hdlFile] of this.pathToHdlFiles) {
@ -163,16 +175,18 @@ class HdlParam {
topModuleSource.delete(hdlModule); topModuleSource.delete(hdlModule);
} }
/**
* @description
* @param path
* @param name
* @returns
*/
public getAllDependences(path: AbsPath, name: string): common.HdlDependence | undefined { public getAllDependences(path: AbsPath, name: string): common.HdlDependence | undefined {
const module = this.getHdlModule(path, name); const module = this.getHdlModule(path, name);
if (!module) { if (!module) {
return undefined; return undefined;
} }
if (this.isTopModule(path, name)) {
console.log(module);
}
const dependencies : common.HdlDependence = { const dependencies : common.HdlDependence = {
current: [], current: [],
include: [], include: [],

View File

@ -12,11 +12,6 @@ function registerManagerCommands(context: vscode.ExtensionContext) {
const plManage = prjManage.pl; const plManage = prjManage.pl;
// const psManage = prjManage.ps; // const psManage = prjManage.ps;
vscode.commands.registerCommand('digital-ide.property-json.generate', prjManage.generatePropertyJson);
// 丢弃原因:插件更新后,用户修改的部分会被覆盖,没有存在必要了
// vscode.commands.registerCommand('digital-ide.property-json.overwrite', prjManage.overwritePropertyJson);
// libpick // libpick
vscode.commands.registerCommand('digital-ide.pickLibrary', pickLibrary); vscode.commands.registerCommand('digital-ide.pickLibrary', pickLibrary);

View File

@ -7,17 +7,16 @@ import { AbsPath, IProgress, LspClient, MainOutput, opeParam, ReportType } from
import { PathSet } from '../global/util'; import { PathSet } from '../global/util';
import { RawPrjInfo } from '../global/prjInfo'; import { RawPrjInfo } from '../global/prjInfo';
import { hdlDir, hdlFile, hdlPath } from '../hdlFs'; import { hdlDir, hdlFile, hdlPath } from '../hdlFs';
import { libManage } from './lib';
import { hdlParam } from '../hdlParser'; import { hdlParam } from '../hdlParser';
import { PlManage } from './PL'; import { PlManage } from './PL';
import { PsManage } from './PS'; import { PsManage } from './PS';
import { hdlIgnore } from './ignore'; import { hdlIgnore } from './ignore';
import { hdlMonitor } from '../monitor'; import { hdlMonitor } from '../monitor';
import { NotificationType } from 'vscode-jsonrpc';
import { refreshArchTree } from '../function/treeView';
import { Fast } from '../hdlParser/common';
import { t } from '../i18n'; import { t } from '../i18n';
import { PpyAction } from '../monitor/propery'; import { PpyAction } from '../monitor/propery';
import { refreshArchTree } from '../function/treeView';
import * as lspClient from '../function/lsp-client';
interface RefreshPrjConfig { interface RefreshPrjConfig {
mkdir: boolean mkdir: boolean
@ -27,8 +26,11 @@ class PrjManage {
pl?: PlManage; pl?: PlManage;
ps?: PsManage; ps?: PsManage;
// generate property template and write it to .vscode/property.json /**
public async generatePropertyJson() { * @description .vscode/property.json
* @returns
*/
public async generatePropertyJson(context: vscode.ExtensionContext) {
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;
@ -283,6 +285,245 @@ class PrjManage {
} }
return 'PL'; return 'PL';
} }
/**
* @description `digital-ide.structure.from-xilinx-to-standard`
*
* Xilinx
*/
public async transformXilinxToStandard(context: vscode.ExtensionContext) {
function xprFile(): string | undefined {
if (opeParam.openMode === 'file' || opeParam.workspacePath.length === 0) {
return undefined;
}
for (const filename of fs.readdirSync(opeParam.workspacePath)) {
if (filename.endsWith('.xpr')) {
return filename;
}
}
return undefined;
}
/**
* @description PL PS
* @param workspace
* @param plname
*/
function transformXilinxNonP(
workspace: string,
plname: string
) {
const xilinxPL = plname + '.srcs';
const xilinxPS = plname + '.sdk';
const ignores = ['user', 'prj', '.vscode', xilinxPL, xilinxPS];
hdlDir.rmdir(hdlPath.join(workspace, '.Xil'));
for (const file of fs.readdirSync(workspace)) {
// 排除标准文件夹
if (ignores.includes(file)) {
continue;
}
if (file.startsWith(plname)) {
const targetFolder = hdlPath.join(workspace, 'prj', 'xilinx');
const sourcePath = hdlPath.join(workspace, file);
hdlFile.move(sourcePath, targetFolder);
} else {
const targetFolder = hdlPath.join(workspace, 'user', 'src');
const sourcePath = hdlPath.join(workspace, file);
hdlFile.move(sourcePath, targetFolder);
}
}
}
/**
* @description Xilinx IP
*
* IP ${workspace}/${plname}.srcs/sources_xxx/ip
*/
function transformIP(
matchPrefix: string,
workspace: string,
plname: string
) {
const xilinxSrcsPath = hdlPath.join(workspace, plname + '.srcs');
const standardIpPath = hdlPath.join(workspace, 'user', 'ip');
if (!fs.existsSync(xilinxSrcsPath)) {
return;
}
const sourceNames = fs.readdirSync(xilinxSrcsPath).filter(filename => filename.startsWith(matchPrefix));
for (const sn of sourceNames) {
const ipPath = hdlPath.join(xilinxSrcsPath, sn, 'ip');
if (!hdlFile.isDir(ipPath)) {
continue;
}
for (const ipname of fs.readdirSync(ipPath)) {
const sourcePath = hdlPath.join(ipPath, ipname);
hdlDir.mvdir(sourcePath, standardIpPath, true);
}
hdlDir.rmdir(ipPath);
}
}
/**
* @description Xilinx
* ${workspace}/${plname}.srcs source_
* - source_1 ${workspace}/${plname}.srcs/sources_1
* - source_* ${workspace}/${plname}.srcs
* @returns
*/
function transformXilinxPL(
sourceType: 'src' | 'sim' | 'data',
matchPrefix: string,
workspace: string,
plname: string
) {
const xilinxSrcsPath = hdlPath.join(workspace, plname + '.srcs');
if (!fs.existsSync(xilinxSrcsPath)) {
return;
}
const sourceNames = fs.readdirSync(xilinxSrcsPath).filter(filename => filename.startsWith(matchPrefix));
if (sourceNames.length === 0) {
return;
} else if (sourceNames.length === 1) {
// 如果只有一个 source_1则将 ${workspace}/${plname}.srcs/sources_1 迁移
const sourceFolderPath = hdlPath.join(workspace, plname + '.srcs', sourceNames[0]);
const targetPath = hdlPath.join(workspace, 'user', sourceType);
for (const filename of fs.readdirSync(sourceFolderPath)) {
const sourcePath = hdlPath.join(sourceFolderPath, filename);
hdlFile.move(sourcePath, targetPath);
}
hdlDir.rmdir(sourceFolderPath);
} else {
// 如果有多个 source_*,则将 ${workspace}/${plname}.srcs 迁移
for (const sn of sourceNames) {
const sourcePath = hdlPath.join(workspace, plname + '.srcs', sn);
const targetPath = hdlPath.join(workspace, 'user', sourceType);
hdlDir.mvdir(sourcePath, targetPath, true);
}
}
}
/**
* @description ${workspace}/${plname}.sdk user/sdk
* @returns
*/
function transformXilinxPS(
workspace: string,
plname: string
) {
const xilinxSdkPath = hdlPath.join(workspace, plname + '.sdk');
if (!fs.existsSync(xilinxSdkPath)) {
return;
}
const standardSdkPath = hdlPath.join(workspace, 'user', 'sdk');
hdlDir.mvdir(xilinxSdkPath, standardSdkPath, true);
const hwNames = fs.readdirSync(standardSdkPath).filter(filename => filename.includes("_hw_platform_"));
if (hwNames.length === 0) {
return;
} else if (hwNames.length === 1) {
const hwFolderPath = hdlPath.join(standardSdkPath, hwNames[0]);
const targetPath = hdlPath.join(standardSdkPath, 'data');
for (const filename of fs.readdirSync(hwFolderPath)) {
hdlFile.move(hdlPath.join(hwFolderPath, filename), targetPath);
}
hdlDir.rmdir(hwFolderPath);
} else {
for (const hw of hwNames) {
const hwPath = hdlPath.join(standardSdkPath, hw);
const targetPath = hdlPath.join(standardSdkPath, 'data');
hdlDir.mvdir(hwPath, targetPath, true);
}
}
}
// 下方操作会产生大量的文件移动,为了进行性能优化,先关闭 monitor
hdlMonitor.close();
await vscode.window.withProgress({
title: t('info.command.structure.transform-xilinx-to-standard'),
location: vscode.ProgressLocation.Notification
}, async () => {
// 先获取 project name
const xprfile = xprFile();
if (xprfile === undefined) {
MainOutput.report(t('error.command.structure.not-valid-xilinx-project'), {
level: ReportType.Error,
notify: true
});
return;
}
const plname = xprfile.slice(0, -4);
const workspacePath = opeParam.workspacePath;
// 创建标准项目结构基本文件夹
// xilinx prj
hdlDir.mkdir(hdlPath.join(workspacePath, 'prj', 'xilinx'));
// hardware
hdlDir.mkdir(hdlPath.join(workspacePath, 'user', 'src'));
hdlDir.mkdir(hdlPath.join(workspacePath, 'user', 'sim'));
hdlDir.mkdir(hdlPath.join(workspacePath, 'user', 'data'));
hdlDir.mkdir(hdlPath.join(workspacePath, 'user', 'ip'));
// software
hdlDir.mkdir(hdlPath.join(workspacePath, 'user', 'sdk'));
hdlDir.mkdir(hdlPath.join(workspacePath, 'user', 'sdk', 'data'));
// 非 ${workspace}/${plname}.srcs ${workspace}/${plname}.sdk 的 ${workspace}/${plname}.* 文件夹迁移到 prj/xilinx 下
// 其他文件夹迁移到 user/src 下面
transformXilinxNonP(workspacePath, plname);
// 迁移 IP
transformIP('sources_', workspacePath, plname);
transformIP('sim_', workspacePath, plname);
// 迁移文件夹 ${workspace}/${plname}.srcs
transformXilinxPL('src', 'sources_', workspacePath, plname);
transformXilinxPL('sim', 'sim_', workspacePath, plname);
transformXilinxPL('data', 'constrs_', workspacePath, plname);
// 迁移文件夹 ${workspace}/${plname}.sdk
transformXilinxPS(workspacePath, plname);
// 删除原本的项目文件夹 ${workspace}/${plname}.srcs 和 ${workspace}/${plname}.sdk
hdlDir.rmdir(hdlPath.join(workspacePath, plname + '.srcs'));
hdlDir.rmdir(hdlPath.join(workspacePath, plname + '.sdk'));
// 创建 property.json
const ppyTemplate = hdlFile.readJSON(opeParam.propertyInitPath);
ppyTemplate.prjName = {
PL: plname
};
hdlFile.writeJSON(opeParam.propertyJsonPath, ppyTemplate);
});
const res = await vscode.window.showInformationMessage(
t('info.command.structure.reload-vscode'),
{ title: t('info.common.confirm'), value: true }
);
if (res?.value) {
await vscode.commands.executeCommand('workbench.action.reloadWindow');
}
// await vscode.window.withProgress({
// location: vscode.ProgressLocation.Window,
// title: t('info.progress.initialization')
// }, async (progress: vscode.Progress<IProgress>, token: vscode.CancellationToken) => {
// hdlParam.clear();
// // 初始化解析
// await this.initialise(context, progress, false);
// // 刷新结构树
// refreshArchTree();
// // 启动监视器
// hdlMonitor.start();
// });
}
} }
const prjManage = new PrjManage(); const prjManage = new PrjManage();

View File

@ -1,8 +1,6 @@
import * as chokidar from 'chokidar'; import * as chokidar from 'chokidar';
import { MainOutput, opeParam, ReportType } from '../global'; import { MainOutput, opeParam, ReportType } from '../global';
import { hdlExts } from '../global/lang';
import { PathSet } from '../global/util'; import { PathSet } from '../global/util';
import { hdlPath } from '../hdlFs';
import { t } from '../i18n'; import { t } from '../i18n';
import { HdlAction } from './hdl'; import { HdlAction } from './hdl';
@ -74,6 +72,7 @@ class HdlMonitor{
public close() { public close() {
this.hdlMonitor?.close(); this.hdlMonitor?.close();
this.ppyMonitor?.close(); this.ppyMonitor?.close();
this.ignoreMonitor?.close();
} }
public start() { public start() {