From c26bd9316e3e2aa7ea423859f61f94f814ef0ccf Mon Sep 17 00:00:00 2001 From: LSTM-Kirigaya <1193466151@qq.com> Date: Mon, 23 Dec 2024 19:00:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20vhdl=20=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=8C=96=E6=B8=B2=E6=9F=93=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/function/hdlDoc/diagram.ts | 29 +++++++++++++++++++++-------- src/function/hdlDoc/markdown.ts | 2 ++ src/function/lsp/linter/common.ts | 5 +---- src/function/lsp/linter/manager.ts | 2 -- src/hdlParser/common.ts | 4 +++- src/hdlParser/core.ts | 11 +++-------- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/function/hdlDoc/diagram.ts b/src/function/hdlDoc/diagram.ts index b28c924..00a6477 100644 --- a/src/function/hdlDoc/diagram.ts +++ b/src/function/hdlDoc/diagram.ts @@ -42,6 +42,12 @@ function getArrowSvgString(name: 'left' | 'right' | 'left-right' | 'left-dot' | return svgString; } +/** + * @description 生成文档化中用于描述一个 module 的简易 diagram + * @param params + * @param ports + * @returns + */ function makeDiagram(params: HdlModuleParam[], ports: HdlModulePort[]): string { // make params block const diagramParamWrapper = makeDiagramParamWrapper(params); @@ -77,8 +83,15 @@ function makeDiagramPortWrapper(ports: HdlModulePort[]): string { return ''; } - const leftPorts = ports.filter(port => port.type === HdlModulePortType.Input || port.type === HdlModulePortType.Inout); - const rightPorts = ports.filter(port => port.type === HdlModulePortType.Output); + const leftPorts = ports.filter(port => + port.type === HdlModulePortType.Input || + port.type === HdlModulePortType.Inout || + port.type === HdlModulePortType.VhdlInput + ); + const rightPorts = ports.filter(port => + port.type === HdlModulePortType.Output || + port.type === HdlModulePortType.VhdlOutput + ); const leftDirection = makeLeftDirection(leftPorts); const diagramPorts = makeDiagramPorts(leftPorts, rightPorts); @@ -107,13 +120,13 @@ function makePortArrow(port: HdlModulePort, direction: 'left' | 'right'): string return getArrowSvgString('left-right'); } if (direction === 'left') { - if (port.type === HdlModulePortType.Input) { + if (port.type === HdlModulePortType.Input || port.type === HdlModulePortType.VhdlInput) { if (isValidWidth(port.width)) { return getArrowSvgString('right-dot'); } else { return getArrowSvgString('right'); } - } else if (port.type === HdlModulePortType.Output) { + } else if (port.type === HdlModulePortType.Output || port.type === HdlModulePortType.VhdlOutput) { if (isValidWidth(port.width)) { return getArrowSvgString('left-dot'); } else { @@ -121,13 +134,13 @@ function makePortArrow(port: HdlModulePort, direction: 'left' | 'right'): string } } } else if (direction === 'right') { - if (port.type === HdlModulePortType.Input) { + if (port.type === HdlModulePortType.Input || port.type === HdlModulePortType.VhdlInput) { if (isValidWidth(port.width)) { return getArrowSvgString('left-dot'); } else { return getArrowSvgString('left'); } - } else if (port.type === HdlModulePortType.Output) { + } else if (port.type === HdlModulePortType.Output || port.type === HdlModulePortType.VhdlOutput) { if (isValidWidth(port.width)) { return getArrowSvgString('right-dot'); } else { @@ -151,9 +164,9 @@ function makeLeftDirection(leftPorts: HdlModulePort[]): string { function makePortName(port: HdlModulePort): string { let portClass = ''; - if (port.type === HdlModulePortType.Input) { + if (port.type === HdlModulePortType.Input || port.type === HdlModulePortType.VhdlInput) { portClass = 'i-port-name'; - } else if (port.type === HdlModulePortType.Output) { + } else if (port.type === HdlModulePortType.Output || port.type === HdlModulePortType.VhdlOutput) { portClass = 'o-port-name'; } else { portClass = 'io-port-name'; diff --git a/src/function/hdlDoc/markdown.ts b/src/function/hdlDoc/markdown.ts index ab80e70..3a414d8 100644 --- a/src/function/hdlDoc/markdown.ts +++ b/src/function/hdlDoc/markdown.ts @@ -254,6 +254,8 @@ async function getDocsFromModule(module: HdlModule): Promise { )); } else { // 对于多文件,找出所有依赖项 + console.log(module); + insts = [...module.getAllDependenceInstance()]; } diff --git a/src/function/lsp/linter/common.ts b/src/function/lsp/linter/common.ts index f8db5c7..307d6fa 100644 --- a/src/function/lsp/linter/common.ts +++ b/src/function/lsp/linter/common.ts @@ -120,10 +120,7 @@ export enum LinterMode { Shutdown = 'shutdown' } -export function getLinterMode(): LinterMode { - console.log(vscode.workspace.getConfiguration().get('digital-ide.function.lsp.linter.mode')); - console.log(vscode.workspace.getConfiguration().get('digital-ide.function.lsp.linter.linter-level')); - +export function getLinterMode(): LinterMode { return vscode.workspace.getConfiguration().get('digital-ide.function.lsp.linter.mode') || LinterMode.Common; } diff --git a/src/function/lsp/linter/manager.ts b/src/function/lsp/linter/manager.ts index 7e856b9..1e34530 100644 --- a/src/function/lsp/linter/manager.ts +++ b/src/function/lsp/linter/manager.ts @@ -319,8 +319,6 @@ export async function refreshWorkspaceDiagonastics( const parallelChunk = Math.min(os.cpus().length, 32); const linterMode = getLinterMode(); - console.log('[refreshWorkspaceDiagonastics]', linterMode); - if (linterMode === LinterMode.Full) { // full,对工作区所有文件进行诊断 const consumer = async (path: string) => { diff --git a/src/hdlParser/common.ts b/src/hdlParser/common.ts index 340bd34..0694ccc 100644 --- a/src/hdlParser/common.ts +++ b/src/hdlParser/common.ts @@ -26,7 +26,9 @@ interface Range { enum HdlModulePortType { Inout = 'inout', Output = 'output', - Input = 'input', + Input = 'input', + VhdlInput = 'in', + VhdlOutput = 'out', Unknown = 'unknown' }; diff --git a/src/hdlParser/core.ts b/src/hdlParser/core.ts index b2037e5..9898293 100644 --- a/src/hdlParser/core.ts +++ b/src/hdlParser/core.ts @@ -471,7 +471,6 @@ class HdlParam { public updateFast(path: string, fast: common.Fast) { const moduleFile = this.getHdlFile(path); - if (moduleFile === undefined) { return; } @@ -867,8 +866,8 @@ class HdlModule { // 获取自身的 for (const inst of this.nameToInstances.values()) { instances.add(inst); - // 递归获取 inst 的 - if (inst.module) { + // 递归获取 inst 的,防止无限递归 + if (inst.module && inst.module !== this) { for (const subInst of inst.module.getAllDependenceInstance()) { instances.add(subInst); } @@ -910,9 +909,6 @@ class HdlModule { rawHdlInstance.range, this); - if (hdlInstance.module === undefined) { - hdlInstance.module = this; - } if (this.nameToInstances) { const key = this.makeInstanceKey(rawHdlInstance.name, rawHdlInstance.type); this.nameToInstances.set(key, hdlInstance); @@ -1152,8 +1148,7 @@ export class HdlFile { // make nameToModule this.nameToModule = new Map(); - - for (const rawHdlModule of modules) { + for (const rawHdlModule of modules) { this.createHdlModule(rawHdlModule); } }