finish linter for sv
This commit is contained in:
parent
cec70eb5ed
commit
fe90ed730c
@ -14,3 +14,4 @@ resources/**/*.js
|
||||
resources/**/*.d.ts
|
||||
resources/**/*.wasm
|
||||
tsconfig.json
|
||||
design
|
120
design/lsp.drawio
Normal file
120
design/lsp.drawio
Normal 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">base.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">default.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">modelsim.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">vivado.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">verilator.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">vhdl.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">vlog.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">svlog.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">index.ts</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">全局 LSP</font>" 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="<font face="CodeNewRoman Nerd Font Mono" style="font-size: 16px;">command.ts</font>" 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>
|
20
package.json
20
package.json
@ -238,6 +238,21 @@
|
||||
"default": "default",
|
||||
"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": {
|
||||
"type": "string",
|
||||
"enumDescriptions": [
|
||||
@ -504,6 +519,11 @@
|
||||
"category": "Digital-IDE",
|
||||
"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",
|
||||
"category": "Digital-IDE",
|
||||
|
@ -42,6 +42,7 @@
|
||||
"digital-ide.fsm.show.title": "Show FSM graph 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.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.systemverilog.linter.pick.title": "select a diagnostic for systemverilog"
|
||||
}
|
@ -42,6 +42,7 @@
|
||||
"digital-ide.fsm.show.title": "显示当前文件的FSM图",
|
||||
"digital-ide.netlist.show.title": "显示当前文件的netlist",
|
||||
"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.systemverilog.linter.pick.title": "选择 SystemVerilog 的诊断"
|
||||
}
|
@ -42,6 +42,7 @@
|
||||
"digital-ide.fsm.show.title": "顯示當前文件的FSM圖",
|
||||
"digital-ide.netlist.show.title": "顯示當前文件的netlist",
|
||||
"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.systemverilog.linter.pick.title": "選擇 SystemVerilog 的診斷"
|
||||
}
|
8
script/test/svlogAll.js
Normal file
8
script/test/svlogAll.js
Normal 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, ' '));
|
||||
})();
|
@ -97,9 +97,11 @@ function registerLsp(context: vscode.ExtensionContext) {
|
||||
lspCore.hdlSymbolStorage.initialise();
|
||||
lspLinter.vlogLinterManager.initialise();
|
||||
lspLinter.vhdlLinterManager.initialise();
|
||||
lspLinter.svlogLinterManager.initialise();
|
||||
|
||||
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.svlog.linter.pick', lspLinter.pickSvlogLinter);
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,6 +108,42 @@ async function pickVlogLinter() {
|
||||
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() {
|
||||
const pickWidget = vscode.window.createQuickPick<LinterItem>();
|
||||
pickWidget.placeholder = 'select a linter for code diagnostic';
|
||||
@ -145,5 +181,6 @@ async function pickVhdlLinter() {
|
||||
|
||||
export {
|
||||
pickVlogLinter,
|
||||
pickVhdlLinter
|
||||
pickVhdlLinter,
|
||||
pickSvlogLinter
|
||||
};
|
@ -1,11 +1,14 @@
|
||||
import { vlogLinterManager } from './vlog';
|
||||
import { vhdlLinterManager } from './vhdl';
|
||||
import { svlogLinterManager } from './svlog';
|
||||
|
||||
import { pickVlogLinter, pickVhdlLinter } from './command';
|
||||
import { pickVlogLinter, pickVhdlLinter, pickSvlogLinter } from './command';
|
||||
|
||||
export {
|
||||
vlogLinterManager,
|
||||
vhdlLinterManager,
|
||||
svlogLinterManager,
|
||||
pickVlogLinter,
|
||||
pickVhdlLinter
|
||||
pickVhdlLinter,
|
||||
pickSvlogLinter,
|
||||
};
|
192
src/function/lsp/linter/svlog.ts
Normal file
192
src/function/lsp/linter/svlog.ts
Normal 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
|
||||
};
|
@ -14,8 +14,7 @@ import { libManage } from '../manager/lib';
|
||||
import type { HdlMonitor } from './index';
|
||||
import { HdlLangID, ToolChainType } from '../global/enum';
|
||||
import { hdlSymbolStorage } from '../function/lsp/core';
|
||||
import { vlogLinterManager, vhdlLinterManager } from '../function/lsp/linter';
|
||||
import { isVerilogFile } from '../hdlFs/file';
|
||||
import { vlogLinterManager, vhdlLinterManager, svlogLinterManager } from '../function/lsp/linter';
|
||||
|
||||
enum Event {
|
||||
Add = 'add', // emit when add file
|
||||
@ -102,6 +101,8 @@ class HdlAction extends BaseAction {
|
||||
vlogLinterManager.remove(uri);
|
||||
} else if (langID === HdlLangID.Vhdl) {
|
||||
vhdlLinterManager.remove(uri);
|
||||
} else if (langID === HdlLangID.SystemVerilog) {
|
||||
svlogLinterManager.remove(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +142,7 @@ class HdlAction extends BaseAction {
|
||||
} else if (langID === HdlLangID.Vhdl) {
|
||||
vhdlLinterManager.lint(document);
|
||||
} else if (langID === HdlLangID.SystemVerilog) {
|
||||
// TODO
|
||||
svlogLinterManager.lint(document);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user