#fix hover | #fix completion
This commit is contained in:
parent
56d88b9c45
commit
f10f6cee18
@ -41,7 +41,7 @@ async function callParser(path, func) {
|
|||||||
const res = wasmModule.ccall('call_parser', 'string', ['string', 'int', 'int'], [file, fileLength, func]);
|
const res = wasmModule.ccall('call_parser', 'string', ['string', 'int', 'int'], [file, fileLength, func]);
|
||||||
debug.compute += Date.now() - s3;
|
debug.compute += Date.now() - s3;
|
||||||
|
|
||||||
console.log(debug);
|
console.log(path, debug);
|
||||||
return JSON.parse(res);
|
return JSON.parse(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as fspath from 'path';
|
||||||
|
|
||||||
import { opeParam, MainOutput, ReportType } from './global';
|
import { opeParam, MainOutput, ReportType, AbsPath } from './global';
|
||||||
import { hdlParam } from './hdlParser';
|
import { hdlParam } from './hdlParser';
|
||||||
import * as manager from './manager';
|
import * as manager from './manager';
|
||||||
import * as func from './function';
|
import * as func from './function';
|
||||||
import { hdlMonitor } from './monitor';
|
import { hdlMonitor } from './monitor';
|
||||||
|
import { hdlPath } from './hdlFs';
|
||||||
|
import { vlogFast } from '../resources/hdlParser';
|
||||||
|
|
||||||
async function registerCommand(context: vscode.ExtensionContext) {
|
async function registerCommand(context: vscode.ExtensionContext) {
|
||||||
manager.registerManagerCommands(context);
|
manager.registerManagerCommands(context);
|
||||||
@ -14,10 +18,46 @@ async function registerCommand(context: vscode.ExtensionContext) {
|
|||||||
func.registerToolCommands(context);
|
func.registerToolCommands(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function* walk(path: AbsPath, ext: string): Generator {
|
||||||
|
if (fs.lstatSync(path).isFile()) {
|
||||||
|
if (path.endsWith(ext)) {
|
||||||
|
yield path;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (const file of fs.readdirSync(path)) {
|
||||||
|
const stat = fs.lstatSync(path);
|
||||||
|
const filePath = fspath.join(path, file);
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
for (const targetPath of walk(filePath, ext)) {
|
||||||
|
yield targetPath;
|
||||||
|
}
|
||||||
|
} else if (stat.isFile()) {
|
||||||
|
if (filePath.endsWith(ext)) {
|
||||||
|
yield filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function test(context: vscode.ExtensionContext) {
|
||||||
|
if (vscode.workspace.workspaceFolders !== undefined &&
|
||||||
|
vscode.workspace.workspaceFolders.length !== 0) {
|
||||||
|
const wsPath = hdlPath.toSlash(vscode.workspace.workspaceFolders[0].uri.fsPath);
|
||||||
|
for (const file of walk(wsPath, '.v')) {
|
||||||
|
if (typeof file === 'string') {
|
||||||
|
await vlogFast(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function launch(context: vscode.ExtensionContext) {
|
async function launch(context: vscode.ExtensionContext) {
|
||||||
await manager.prjManage.initialise(context);
|
await manager.prjManage.initialise(context);
|
||||||
await registerCommand(context);
|
await registerCommand(context);
|
||||||
hdlMonitor.start();
|
hdlMonitor.start();
|
||||||
|
// await vlogFast("e:/Project/Digial-IDE/TestWs/simulate/user/sim/tb_file/scc018ug_hd_rvt.v");
|
||||||
|
|
||||||
console.log(hdlParam);
|
console.log(hdlParam);
|
||||||
|
|
||||||
|
@ -177,9 +177,9 @@ class VlogCompletionProvider implements vscode.CompletionItemProvider {
|
|||||||
const filePath = hdlPath.toSlash(document.fileName);
|
const filePath = hdlPath.toSlash(document.fileName);
|
||||||
|
|
||||||
// 1. provide keyword
|
// 1. provide keyword
|
||||||
const completions = this.makeKeywordItems();
|
const completions = this.makeKeywordItems(document, position);
|
||||||
completions.push(...this.makeCompilerKeywordItems());
|
completions.push(...this.makeCompilerKeywordItems(document, position));
|
||||||
completions.push(...this.makeSystemKeywordItems());
|
completions.push(...this.makeSystemKeywordItems(document, position));
|
||||||
|
|
||||||
const symbolResult = await HdlSymbol.all(filePath);
|
const symbolResult = await HdlSymbol.all(filePath);
|
||||||
if (!symbolResult) {
|
if (!symbolResult) {
|
||||||
@ -222,7 +222,7 @@ class VlogCompletionProvider implements vscode.CompletionItemProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private makeKeywordItems(): vscode.CompletionItem[] {
|
private makeKeywordItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {
|
||||||
const vlogKeywordItem = [];
|
const vlogKeywordItem = [];
|
||||||
for (const keyword of vlogKeyword.keys()) {
|
for (const keyword of vlogKeyword.keys()) {
|
||||||
const clItem = this.makekeywordCompletionItem(keyword);
|
const clItem = this.makekeywordCompletionItem(keyword);
|
||||||
@ -232,18 +232,21 @@ class VlogCompletionProvider implements vscode.CompletionItemProvider {
|
|||||||
return vlogKeywordItem;
|
return vlogKeywordItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private makeCompilerKeywordItems(): vscode.CompletionItem[] {
|
private makeCompilerKeywordItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {
|
||||||
const items = [];
|
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()) {
|
for (const keyword of vlogKeyword.compilerKeys()) {
|
||||||
const clItem = new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Keyword);
|
const clItem = new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Keyword);
|
||||||
clItem.insertText = new vscode.SnippetString('`' + keyword);
|
clItem.insertText = new vscode.SnippetString(prefix + keyword);
|
||||||
clItem.detail = 'compiler directive';
|
clItem.detail = 'compiler directive';
|
||||||
items.push(clItem);
|
items.push(clItem);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private makeSystemKeywordItems(): vscode.CompletionItem[] {
|
private makeSystemKeywordItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {
|
||||||
const items = [];
|
const items = [];
|
||||||
for (const keyword of vlogKeyword.systemKeys()) {
|
for (const keyword of vlogKeyword.systemKeys()) {
|
||||||
const clItem = new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Method);
|
const clItem = new vscode.CompletionItem(keyword, vscode.CompletionItemKind.Method);
|
||||||
@ -260,7 +263,8 @@ class VlogCompletionProvider implements vscode.CompletionItemProvider {
|
|||||||
clItem.detail = 'keyword';
|
clItem.detail = 'keyword';
|
||||||
|
|
||||||
switch (keyword) {
|
switch (keyword) {
|
||||||
case 'begin': clItem.insertText = new vscode.SnippetString("begin$1end"); break;
|
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;
|
default: break;
|
||||||
}
|
}
|
||||||
return clItem;
|
return clItem;
|
||||||
|
@ -158,6 +158,8 @@ class VlogHoverProvider implements vscode.HoverProvider {
|
|||||||
const normalResult = util.matchNormalSymbol(targetWord, scopeSymbols.symbols);
|
const normalResult = util.matchNormalSymbol(targetWord, scopeSymbols.symbols);
|
||||||
if (normalResult) {
|
if (normalResult) {
|
||||||
const normalComment = await util.searchCommentAround(filePath, normalResult.range);
|
const normalComment = await util.searchCommentAround(filePath, normalResult.range);
|
||||||
|
console.log(normalResult);
|
||||||
|
|
||||||
const normalDesc = util.makeNormalDesc(normalResult);
|
const normalDesc = util.makeNormalDesc(normalResult);
|
||||||
|
|
||||||
content.appendCodeblock(normalDesc, HdlLangID.Verilog);
|
content.appendCodeblock(normalDesc, HdlLangID.Verilog);
|
||||||
|
@ -319,7 +319,11 @@ function makeParamDesc(param: HdlModuleParam): string {
|
|||||||
|
|
||||||
function makeNormalDesc(normal: RawSymbol): string {
|
function makeNormalDesc(normal: RawSymbol): string {
|
||||||
const width = normal.width ? normal.width : '';
|
const width = normal.width ? normal.width : '';
|
||||||
const desc = normal.type + ' ' + width + ' ' + normal.name;
|
const signed = normal.signed === 1 ? 'signed' : '';
|
||||||
|
let desc = normal.type + ' ' + signed + ' ' + width + ' ' + normal.name;
|
||||||
|
if (normal.init) {
|
||||||
|
desc += ' = ' + normal.init;
|
||||||
|
}
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +165,8 @@ interface RawSymbol {
|
|||||||
type: string
|
type: string
|
||||||
range: Range
|
range: Range
|
||||||
width?: string
|
width?: string
|
||||||
|
init?: string
|
||||||
|
signed: number
|
||||||
};
|
};
|
||||||
|
|
||||||
interface InstModPathSearchResult {
|
interface InstModPathSearchResult {
|
||||||
|
11
src/test/.vscode/property.json
vendored
Normal file
11
src/test/.vscode/property.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"toolChain": "xilinx",
|
||||||
|
"prjName": {
|
||||||
|
"PL": "template"
|
||||||
|
},
|
||||||
|
"soc": {
|
||||||
|
"core": "none"
|
||||||
|
},
|
||||||
|
"enableShowLog": false,
|
||||||
|
"device": "none"
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
`include "./Cordic.v"
|
||||||
module instance_test (
|
module instance_test (
|
||||||
input input_a,
|
input input_a,
|
||||||
input input_b,
|
input input_b,
|
||||||
|
@ -7,38 +7,24 @@
|
|||||||
"name": "Verilog",
|
"name": "Verilog",
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
"begin": "\\s*(wire|reg)\\s+\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
|
"begin": "\\s*(wire|reg)\\s+(signed|unsigned)?\\s+\\[(.*?)(:)(.*?)\\]\\s+\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
|
||||||
"beginCaptures": {
|
"beginCaptures": {
|
||||||
"1": {
|
"1": {
|
||||||
"name": "keyword.control.verilog"
|
"name": "keyword.control.verilog"
|
||||||
},
|
},
|
||||||
"2": {
|
"2": {
|
||||||
"name": "variable.other.constant.declaration.verilog"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"end": "(;)",
|
|
||||||
"endCaptures": {
|
|
||||||
"1": {
|
|
||||||
"name": "source.verilog"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"begin": "\\s*(wire|reg)\\s+\\[(.*?)(:)(.*?)\\]\\s+\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
|
|
||||||
"beginCaptures": {
|
|
||||||
"1": {
|
|
||||||
"name": "keyword.control.verilog"
|
"name": "keyword.control.verilog"
|
||||||
},
|
},
|
||||||
"2": {
|
|
||||||
"name": "constant.numeric.width.verilog"
|
|
||||||
},
|
|
||||||
"3": {
|
"3": {
|
||||||
"name": "entity.name.function.width.spliter.verilog"
|
|
||||||
},
|
|
||||||
"4": {
|
|
||||||
"name": "constant.numeric.width.verilog"
|
"name": "constant.numeric.width.verilog"
|
||||||
},
|
},
|
||||||
|
"4": {
|
||||||
|
"name": "entity.name.function.width.spliter.verilog"
|
||||||
|
},
|
||||||
"5": {
|
"5": {
|
||||||
|
"name": "constant.numeric.width.verilog"
|
||||||
|
},
|
||||||
|
"6": {
|
||||||
"name": "variable.other.constant.declaration.verilog"
|
"name": "variable.other.constant.declaration.verilog"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -47,7 +33,43 @@
|
|||||||
"1": {
|
"1": {
|
||||||
"name": "source.verilog"
|
"name": "source.verilog"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#constants"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#operators"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"begin": "\\s*(wire|reg)\\s+(signed|unsigned)?\\s+\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
|
||||||
|
"beginCaptures": {
|
||||||
|
"1": {
|
||||||
|
"name": "keyword.control.verilog"
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
"name": "keyword.control.verilog"
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
"name": "variable.other.constant.declaration.verilog"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"end": "(;)",
|
||||||
|
"endCaptures": {
|
||||||
|
"1": {
|
||||||
|
"name": "source.verilog"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#constants"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#operators"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"begin": "\\s*\\b(function|task)\\b(\\s+automatic)?",
|
"begin": "\\s*\\b(function|task)\\b(\\s+automatic)?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user