finish linter for sv

This commit is contained in:
锦恢 2023-12-11 23:04:22 +08:00
parent cec70eb5ed
commit fe90ed730c
12 changed files with 394 additions and 7 deletions

View File

@ -13,4 +13,5 @@ script
resources/**/*.js resources/**/*.js
resources/**/*.d.ts resources/**/*.d.ts
resources/**/*.wasm resources/**/*.wasm
tsconfig.json tsconfig.json
design

120
design/lsp.drawio Normal file
View File

@ -0,0 +1,120 @@
<mxfile host="65bd71144e">
<diagram id="Jyg0ghsg0WSuYoSyPP-c" name="linter">
<mxGraphModel dx="868" dy="626" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="10" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="2" target="3">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="11" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="2" target="4">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="12" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="2" target="5">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="13" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="2" target="6">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="2" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;base.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#f0a30a;fontColor=#000000;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="280" y="20" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="14" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="3" target="7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="17" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="3" target="8">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="3" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;default.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#f0a30a;fontColor=#000000;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="50" y="160" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="15" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="4" target="7">
<mxGeometry relative="1" as="geometry">
<mxPoint x="190" y="260" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="18" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="4" target="8">
<mxGeometry relative="1" as="geometry">
<mxPoint x="340" y="260" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="22" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="4" target="9">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;modelsim.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#f0a30a;fontColor=#000000;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="200" y="160" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="16" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="5" target="7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="20" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="5" target="8">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="23" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="5" target="9">
<mxGeometry relative="1" as="geometry">
<mxPoint x="490" y="260" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="5" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;vivado.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#f0a30a;fontColor=#000000;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="354" y="160" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="21" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="6" target="8">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="24" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="6" target="9">
<mxGeometry relative="1" as="geometry">
<mxPoint x="490" y="260" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="6" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;verilator.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#f0a30a;fontColor=#000000;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="510" y="160" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="29" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="7" target="25">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="7" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;vhdl.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#6a00ff;fontColor=#ffffff;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="130" y="300" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="28" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="8" target="25">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="8" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;vlog.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#6a00ff;fontColor=#ffffff;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="280" y="300" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="30" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="9" target="25">
<mxGeometry relative="1" as="geometry">
<mxPoint x="400" y="400" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="9" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;svlog.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#6a00ff;fontColor=#ffffff;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="430" y="300" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="27" style="edgeStyle=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="25" target="26">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="31" value="注册" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontSize=16;fontFamily=CodeNewRoman Nerd Font Mono;" vertex="1" connectable="0" parent="27">
<mxGeometry x="0.1282" y="1" relative="1" as="geometry">
<mxPoint x="-7" y="1" as="offset"/>
</mxGeometry>
</mxCell>
<mxCell id="25" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;index.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#647687;fontColor=#ffffff;strokeColor=#314354;" vertex="1" parent="1">
<mxGeometry x="280" y="418" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="26" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;全局 LSP&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#1ba1e2;fontColor=#ffffff;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="590" y="418" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="33" value="" style="edgeStyle=none;html=1;fontFamily=CodeNewRoman Nerd Font Mono;fontSize=16;" edge="1" parent="1" source="32" target="26">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="34" value="注册" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontSize=16;fontFamily=CodeNewRoman Nerd Font Mono;" vertex="1" connectable="0" parent="33">
<mxGeometry x="-0.2925" y="-1" relative="1" as="geometry">
<mxPoint as="offset"/>
</mxGeometry>
</mxCell>
<mxCell id="32" value="&lt;font face=&quot;CodeNewRoman Nerd Font Mono&quot; style=&quot;font-size: 16px;&quot;&gt;command.ts&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fontSize=16;fillColor=#f0a30a;fontColor=#000000;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="590" y="300" width="120" height="60" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

View File

@ -238,6 +238,21 @@
"default": "default", "default": "default",
"description": "choose diagnostor to do linter in editing verilog" "description": "choose diagnostor to do linter in editing verilog"
}, },
"digital-ide.function.lsp.linter.svlog.diagnostor": {
"type": "string",
"enumDescriptions": [
"use diagnostor in vivado",
"use diagnostor in modelsim",
"use our buildin diagnostor"
],
"enum": [
"vivado",
"modelsim",
"default"
],
"default": "default",
"description": "choose diagnostor to do linter in editing verilog"
},
"digital-ide.function.lsp.linter.vhdl.diagnostor": { "digital-ide.function.lsp.linter.vhdl.diagnostor": {
"type": "string", "type": "string",
"enumDescriptions": [ "enumDescriptions": [
@ -504,6 +519,11 @@
"category": "Digital-IDE", "category": "Digital-IDE",
"title": "%digital-ide.lsp.vlog.linter.pick.title%" "title": "%digital-ide.lsp.vlog.linter.pick.title%"
}, },
{
"command": "digital-ide.lsp.svlog.linter.pick",
"category": "Digital-IDE",
"title": "%digital-ide.lsp.svlog.linter.pick.title%"
},
{ {
"command": "digital-ide.lsp.vhdl.linter.pick", "command": "digital-ide.lsp.vhdl.linter.pick",
"category": "Digital-IDE", "category": "Digital-IDE",

View File

@ -42,6 +42,7 @@
"digital-ide.fsm.show.title": "Show FSM graph of current file", "digital-ide.fsm.show.title": "Show FSM graph of current file",
"digital-ide.netlist.show.title": "Show netlist of current file", "digital-ide.netlist.show.title": "Show netlist of current file",
"digital-ide.lsp.vlog.linter.pick.title": "select a diagnostic for verilog", "digital-ide.lsp.vlog.linter.pick.title": "select a diagnostic for verilog",
"digital-ide.lsp.svlog.linter.pick.title": "select a diagnostic for systemverilog verilog",
"digital-ide.lsp.vhdl.linter.pick.title": "select a diagnostic for vhdl", "digital-ide.lsp.vhdl.linter.pick.title": "select a diagnostic for vhdl",
"digital-ide.lsp.systemverilog.linter.pick.title": "select a diagnostic for systemverilog" "digital-ide.lsp.systemverilog.linter.pick.title": "select a diagnostic for systemverilog"
} }

View File

@ -42,6 +42,7 @@
"digital-ide.fsm.show.title": "显示当前文件的FSM图", "digital-ide.fsm.show.title": "显示当前文件的FSM图",
"digital-ide.netlist.show.title": "显示当前文件的netlist", "digital-ide.netlist.show.title": "显示当前文件的netlist",
"digital-ide.lsp.vlog.linter.pick.title": "选择 Verilog 的诊断", "digital-ide.lsp.vlog.linter.pick.title": "选择 Verilog 的诊断",
"digital-ide.lsp.svlog.linter.pick.title": "选择 System Verilog 的诊断",
"digital-ide.lsp.vhdl.linter.pick.title": "选择 VHDL 的诊断", "digital-ide.lsp.vhdl.linter.pick.title": "选择 VHDL 的诊断",
"digital-ide.lsp.systemverilog.linter.pick.title": "选择 SystemVerilog 的诊断" "digital-ide.lsp.systemverilog.linter.pick.title": "选择 SystemVerilog 的诊断"
} }

View File

@ -42,6 +42,7 @@
"digital-ide.fsm.show.title": "顯示當前文件的FSM圖", "digital-ide.fsm.show.title": "顯示當前文件的FSM圖",
"digital-ide.netlist.show.title": "顯示當前文件的netlist", "digital-ide.netlist.show.title": "顯示當前文件的netlist",
"digital-ide.lsp.vlog.linter.pick.title": "選擇 Verilog 的診斷", "digital-ide.lsp.vlog.linter.pick.title": "選擇 Verilog 的診斷",
"digital-ide.lsp.svlog.linter.pick.title": "選擇 System Verilog 的診斷",
"digital-ide.lsp.vhdl.linter.pick.title": "選擇 VHDL 的診斷", "digital-ide.lsp.vhdl.linter.pick.title": "選擇 VHDL 的診斷",
"digital-ide.lsp.systemverilog.linter.pick.title": "選擇 SystemVerilog 的診斷" "digital-ide.lsp.systemverilog.linter.pick.title": "選擇 SystemVerilog 的診斷"
} }

8
script/test/svlogAll.js Normal file
View File

@ -0,0 +1,8 @@
const { svAll } = require('../../resources/hdlParser');
const testFile = '../Digital-Test/svlog/user/src/hello.sv';
(async () => {
const all = await svAll(testFile);
console.log(JSON.stringify(all, null, ' '));
})();

View File

@ -97,9 +97,11 @@ function registerLsp(context: vscode.ExtensionContext) {
lspCore.hdlSymbolStorage.initialise(); lspCore.hdlSymbolStorage.initialise();
lspLinter.vlogLinterManager.initialise(); lspLinter.vlogLinterManager.initialise();
lspLinter.vhdlLinterManager.initialise(); lspLinter.vhdlLinterManager.initialise();
lspLinter.svlogLinterManager.initialise();
vscode.commands.registerCommand('digital-ide.lsp.vlog.linter.pick', lspLinter.pickVlogLinter); vscode.commands.registerCommand('digital-ide.lsp.vlog.linter.pick', lspLinter.pickVlogLinter);
vscode.commands.registerCommand('digital-ide.lsp.vhdl.linter.pick', lspLinter.pickVhdlLinter); vscode.commands.registerCommand('digital-ide.lsp.vhdl.linter.pick', lspLinter.pickVhdlLinter);
vscode.commands.registerCommand('digital-ide.lsp.svlog.linter.pick', lspLinter.pickSvlogLinter);
} }

View File

@ -108,6 +108,42 @@ async function pickVlogLinter() {
pickWidget.show(); pickWidget.show();
} }
async function pickSvlogLinter() {
const pickWidget = vscode.window.createQuickPick<LinterItem>();
pickWidget.placeholder = 'select a linter for verilog code diagnostic';
pickWidget.canSelectMany = false;
await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: 'Parsing local environment ...',
cancellable: true
}, async () => {
pickWidget.items = [
// TODO : add this if system verilog is supported
// await makeDefaultPickItem(),
await makeVivadoPickItem(HdlLangID.Verilog),
await makeModelsimPickItem(HdlLangID.Verilog)
];
});
pickWidget.onDidChangeSelection(items => {
const selectedItem = items[0];
_selectVlogLinter = selectedItem.name;
});
pickWidget.onDidAccept(() => {
if (_selectVlogLinter) {
const vlogLspConfig = vscode.workspace.getConfiguration('digital-ide.function.lsp.linter.svlog');
vlogLspConfig.update('diagnostor', _selectVlogLinter);
pickWidget.hide();
}
});
pickWidget.show();
}
async function pickVhdlLinter() { async function pickVhdlLinter() {
const pickWidget = vscode.window.createQuickPick<LinterItem>(); const pickWidget = vscode.window.createQuickPick<LinterItem>();
pickWidget.placeholder = 'select a linter for code diagnostic'; pickWidget.placeholder = 'select a linter for code diagnostic';
@ -145,5 +181,6 @@ async function pickVhdlLinter() {
export { export {
pickVlogLinter, pickVlogLinter,
pickVhdlLinter pickVhdlLinter,
pickSvlogLinter
}; };

View File

@ -1,11 +1,14 @@
import { vlogLinterManager } from './vlog'; import { vlogLinterManager } from './vlog';
import { vhdlLinterManager } from './vhdl'; import { vhdlLinterManager } from './vhdl';
import { svlogLinterManager } from './svlog';
import { pickVlogLinter, pickVhdlLinter } from './command'; import { pickVlogLinter, pickVhdlLinter, pickSvlogLinter } from './command';
export { export {
vlogLinterManager, vlogLinterManager,
vhdlLinterManager, vhdlLinterManager,
svlogLinterManager,
pickVlogLinter, pickVlogLinter,
pickVhdlLinter pickVhdlLinter,
pickSvlogLinter,
}; };

View File

@ -0,0 +1,192 @@
import * as vscode from 'vscode';
import { LspOutput, ReportType } from '../../../global';
import { HdlLangID } from '../../../global/enum';
import { BaseLinter, BaseManager } from './base';
import { defaultVlogLinter } from './default';
import { modelsimLinter } from './modelsim';
import { vivadoLinter } from './vivado';
import { hdlFile, hdlPath } from '../../../hdlFs';
class SvlogLinterManager implements BaseManager {
currentLinter: BaseLinter | undefined;
activateLinterName: string;
statusBarItem: vscode.StatusBarItem;
initialized: boolean;
constructor() {
this.activateLinterName = 'default';
this.initialized = false;
// make a status bar for rendering
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
this.statusBarItem.command = 'digital-ide.lsp.svlog.linter.pick';
// when changing file, hide if langID is not verilog
vscode.window.onDidChangeActiveTextEditor(editor => {
if (!editor) {
return;
}
const currentFileName = hdlPath.toSlash(editor.document.fileName);
if (hdlFile.isSystemVerilogFile(currentFileName)) {
this.statusBarItem.show();
} else {
this.statusBarItem.hide();
}
});
// update when user's config is changed
vscode.workspace.onDidChangeConfiguration(() => {
this.updateLinter();
});
}
async initialise(): Promise<void> {
const success = await this.updateLinter();
if (!success) {
return;
}
this.initialized = true;
for (const doc of vscode.workspace.textDocuments) {
const fileName = hdlPath.toSlash(doc.fileName);
if (hdlFile.isSystemVerilogFile(fileName)) {
await this.lint(doc);
}
}
LspOutput.report('<svlog lsp manager> finish initialization of svlog linter. Linter name: ' + this.activateLinterName, ReportType.Launch);
// hide it if current window is not verilog
const editor = vscode.window.activeTextEditor;
if (editor && hdlFile.isSystemVerilogFile(editor.document.fileName)) {
this.statusBarItem.show();
} else {
this.statusBarItem.hide();
}
}
async lint(document: vscode.TextDocument) {
this.currentLinter?.remove(document.uri);
await this.currentLinter?.lint(document);
}
async remove(uri: vscode.Uri): Promise<void> {
this.currentLinter?.remove(uri);
}
public getUserDiagnostorSelection() {
const vlogLspConfig = vscode.workspace.getConfiguration('digital-ide.function.lsp.linter.svlog');
const diagnostor = vlogLspConfig.get('diagnostor', 'xxx');
return diagnostor;
}
public async updateLinter(): Promise<boolean> {
const diagnostorName = this.getUserDiagnostorSelection();
const lastDiagnostorName = this.activateLinterName;
const lastDiagnostor = this.currentLinter;
if (this.initialized && diagnostorName === lastDiagnostorName) {
// no need for update
return true;
}
LspOutput.report(`<svlog lsp manager> detect linter setting changes, switch from ${lastDiagnostorName} to ${diagnostorName}.`, ReportType.Launch);
let launch = false;
switch (diagnostorName) {
case 'vivado': launch = await this.activateVivado(); break;
case 'modelsim': launch = await this.activateModelsim(); break;
case 'default': launch = await this.activateDefault(); break;
default: launch = await this.activateDefault(); break;
}
for (const doc of vscode.workspace.textDocuments) {
const fileName = hdlPath.toSlash(doc.fileName);
if (hdlFile.isSystemVerilogFile(fileName)) {
lastDiagnostor?.remove(doc.uri);
await this.lint(doc);
}
}
return launch;
}
public async activateVivado(): Promise<boolean> {
const selectedLinter = vivadoLinter;
let launch = true;
launch = await selectedLinter.initialise(HdlLangID.SystemVerilog);
if (launch) {
this.statusBarItem.text = '$(getting-started-beginner) Linter(vivado)';
LspOutput.report('<svlog lsp manager> vivado linter has been activated', ReportType.Info);
} else {
this.statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.warningBackground');
this.statusBarItem.tooltip = 'Fail to launch vivado linter';
this.statusBarItem.text = '$(extensions-warning-message) Linter(vivado)';
LspOutput.report('<svlog lsp manager> Fail to launch vivado linter', ReportType.Error);
}
this.currentLinter = selectedLinter;
this.activateLinterName = 'vivado';
this.statusBarItem.show();
return launch;
}
public async activateModelsim(): Promise<boolean> {
const selectedLinter = modelsimLinter;
let launch = true;
launch = await selectedLinter.initialise(HdlLangID.SystemVerilog);
if (launch) {
this.statusBarItem.text = '$(getting-started-beginner) Linter(modelsim)';
LspOutput.report('<svlog lsp manager> modelsim linter has been activated', ReportType.Info);
} else {
this.statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.warningBackground');
this.statusBarItem.tooltip = 'Fail to launch modelsim linter';
this.statusBarItem.text = '$(extensions-warning-message) Linter(modelsim)';
LspOutput.report('<svlog lsp manager> Fail to launch modelsim linter', ReportType.Error);
}
this.currentLinter = selectedLinter;
this.activateLinterName = 'modelsim';
this.statusBarItem.show();
return launch;
}
public async activateDefault(): Promise<boolean> {
const selectedLinter = defaultVlogLinter;
let launch = true;
if (launch) {
this.statusBarItem.text = '$(getting-started-beginner) Linter(default)';
LspOutput.report('<svlog lsp manager> default build-in linter has been activated', ReportType.Info);
} else {
this.statusBarItem.backgroundColor = undefined;
this.statusBarItem.tooltip = 'Fail to launch default linter';
this.statusBarItem.text = '$(extensions-warning-message) Linter(default)';
LspOutput.report('<svlog lsp manager> Fail to launch default linter', ReportType.Error);
}
this.currentLinter = selectedLinter;
this.activateLinterName = 'default';
this.statusBarItem.show();
return launch;
}
}
const svlogLinterManager = new SvlogLinterManager();
export {
svlogLinterManager
};

View File

@ -14,8 +14,7 @@ import { libManage } from '../manager/lib';
import type { HdlMonitor } from './index'; import type { HdlMonitor } from './index';
import { HdlLangID, ToolChainType } from '../global/enum'; import { HdlLangID, ToolChainType } from '../global/enum';
import { hdlSymbolStorage } from '../function/lsp/core'; import { hdlSymbolStorage } from '../function/lsp/core';
import { vlogLinterManager, vhdlLinterManager } from '../function/lsp/linter'; import { vlogLinterManager, vhdlLinterManager, svlogLinterManager } from '../function/lsp/linter';
import { isVerilogFile } from '../hdlFs/file';
enum Event { enum Event {
Add = 'add', // emit when add file Add = 'add', // emit when add file
@ -102,6 +101,8 @@ class HdlAction extends BaseAction {
vlogLinterManager.remove(uri); vlogLinterManager.remove(uri);
} else if (langID === HdlLangID.Vhdl) { } else if (langID === HdlLangID.Vhdl) {
vhdlLinterManager.remove(uri); vhdlLinterManager.remove(uri);
} else if (langID === HdlLangID.SystemVerilog) {
svlogLinterManager.remove(uri);
} }
} }
@ -141,7 +142,7 @@ class HdlAction extends BaseAction {
} else if (langID === HdlLangID.Vhdl) { } else if (langID === HdlLangID.Vhdl) {
vhdlLinterManager.lint(document); vhdlLinterManager.lint(document);
} else if (langID === HdlLangID.SystemVerilog) { } else if (langID === HdlLangID.SystemVerilog) {
// TODO svlogLinterManager.lint(document);
} }
} }