Skip to content

Commit 4d712cb

Browse files
authored
Merge branch 'master' into release-0.13.11-prep
2 parents c0958b2 + 9948327 commit 4d712cb

File tree

13 files changed

+1652
-16
lines changed

13 files changed

+1652
-16
lines changed

.github/workflows/codeql.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "master" ]
17+
pull_request:
18+
branches: [ "master" ]
19+
schedule:
20+
- cron: '41 8 * * 1'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
39+
actions: read
40+
contents: read
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- language: javascript-typescript
47+
build-mode: none
48+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
49+
# Use `c-cpp` to analyze code written in C, C++ or both
50+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
51+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
52+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
53+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
54+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
55+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v4
59+
60+
# Initializes the CodeQL tools for scanning.
61+
- name: Initialize CodeQL
62+
uses: github/codeql-action/init@v3
63+
with:
64+
languages: ${{ matrix.language }}
65+
build-mode: ${{ matrix.build-mode }}
66+
# If you wish to specify custom queries, you can do so here or in a config file.
67+
# By default, queries listed here will override any specified in a config file.
68+
# Prefix the list here with "+" to use these queries and those in the config file.
69+
70+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
71+
# queries: security-extended,security-and-quality
72+
73+
# If the analyze step fails for one of the languages you are analyzing with
74+
# "We were unable to automatically build your code", modify the matrix above
75+
# to set the build mode to "manual" for that language. Then modify this step
76+
# to build your code.
77+
# ℹ️ Command-line programs to run using the OS shell.
78+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
79+
- if: matrix.build-mode == 'manual'
80+
shell: bash
81+
run: |
82+
echo 'If you are using a "manual" build mode for one or more of the' \
83+
'languages you are analyzing, replace this with the commands to build' \
84+
'your code, for example:'
85+
echo ' make bootstrap'
86+
echo ' make release'
87+
exit 1
88+
89+
- name: Perform CodeQL Analysis
90+
uses: github/codeql-action/analyze@v3
91+
with:
92+
category: "/language:${{matrix.language}}"

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ More details can be found on the [Releases](https://github.com/eirikpre/VSCode-S
1010
- 💡 Back-end Language Server for Systemverilog
1111
- 💡 Complete syntax highlighting
1212

13+
### [0.13.10]
14+
15+
- Right-justified icons by `joecrop`
16+
- Added support for symbol resolution in vh, svh, vams, and veriloga files by `joecrop`
17+
- Added support for import statements within module headers when auto-instantiating modules by `Stavegu`
18+
1319
### [0.13.9]
1420

1521
- Added basic syntax highlighting support for sdc/xdc files inspired by [https://github.com/mshr-h/vscode-verilog-hdl-support](vscode-verilog-hdl-support) by `joecrop`
File renamed without changes.

configs/vhdl.configuration.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"comments": {
3+
"lineComment": "--",
4+
"blockComment": []
5+
},
6+
"brackets": [
7+
["{", "}"],
8+
["[", "]"],
9+
["(", ")"]
10+
]
11+
}

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,19 @@
157157
}
158158
},
159159
{
160+
"id": "vhdl",
161+
"aliases": [
162+
"VHDL",
163+
"vhdl"
164+
],
165+
"extensions": [
166+
".vhd",
167+
".vhdl",
168+
".vho"
169+
],
170+
"configuration": "./configs/vhdl.configuration.json"
171+
},
172+
{
160173
"id": "sdc",
161174
"aliases": [
162175
"Synopsys Design Constraints"
@@ -251,6 +264,11 @@
251264
"path": "./syntaxes/verilog-filelist.json"
252265
},
253266
{
267+
"language": "vhdl",
268+
"scopeName": "source.vhdl",
269+
"path": "./syntaxes/vhdl.tmLanguage.json"
270+
},
271+
{
254272
"language": "sdc",
255273
"scopeName": "source.sdc",
256274
"path": "./syntaxes/sdc.json"

src/parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class SystemVerilogParser {
1616
/(?:automatic\s+)?/,
1717
')',
1818
/(?<name>\w+)/,
19+
/(?<import>\s*import\s*\w+::[\w*]+;)?/,
1920
/(?<params>\s*#\s*\([\w\W]*?\))?/,
2021
/(?<ports>\s*\([\W\w]*?\))?/,
2122
/\s*;/,

src/providers/ModuleInstantiator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function isModuleParameterized(symbol: string, container: string): boolean {
108108
// Remove new lines
109109
container = container.replace(/\r\n|\n|\r/g, ' ');
110110
// Surround '#(' with space
111-
container = container.replace(/#\(/g, ' #( ');
111+
container = container.replace(/#\s*\(/g, ' #( ');
112112
// Replace multiple white spaces with a single whitespace
113113
container = container.replace(/\t+/g, ' ');
114114
container = container.replace(/ +/g, ' ');
@@ -118,7 +118,13 @@ function isModuleParameterized(symbol: string, container: string): boolean {
118118
return false;
119119
}
120120

121-
if (keys[0] === symbol && keys[1] === '#(') {
121+
// Get only indexes related to module header
122+
const subkeys = keys.slice(
123+
0,
124+
keys.findIndex((element) => element.includes(';') && !element.includes('::'))
125+
);
126+
127+
if (subkeys[0] === symbol && subkeys.find((element) => element === '#(')) {
122128
return true;
123129
}
124130

src/test/ModuleInstantiator.test.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ suite('ModuleInstantiator Tests', () => {
206206

207207
let fullRange = null;
208208
// Range of the module in the document
209-
fullRange = new vscode.Range(new vscode.Position(300, 6), new vscode.Position(324, 0));
209+
fullRange = new vscode.Range(new vscode.Position(301, 6), new vscode.Position(324, 0));
210210

211211
let container = document.getText(fullRange).replace(/^\s+|\s+$/g, '');
212212

@@ -239,6 +239,46 @@ suite('ModuleInstantiator Tests', () => {
239239

240240
compareInstantiation('azzer', container, instance);
241241
});
242+
243+
test('test #10: formatInstance without parameters and with import', async () => {
244+
let uri = vscode.Uri.file(path.join(__dirname, testFolderLocation, 'test-files', 'ModuleInstantiator.test.1.v')); // prettier-ignore
245+
let document = await vscode.workspace.openTextDocument(uri);
246+
247+
// Range of the module in the document
248+
let fullRange = null;
249+
fullRange = new vscode.Range(new vscode.Position(358, 6), new vscode.Position(392, 0));
250+
251+
const container = document.getText(fullRange).replace(/^\s+|\s+$/g, '');
252+
uri = vscode.Uri.file(path.join(__dirname, testFolderLocation, 'test-files', 'ModuleInstantiator.test.2.v'));
253+
document = await vscode.workspace.openTextDocument(uri);
254+
fullRange = new vscode.Range(new vscode.Position(168, 0), new vscode.Position(179, 0));
255+
256+
let instance = document.getText(fullRange);
257+
258+
compareInstantiation('abber', container, instance);
259+
});
260+
261+
test('test #11: formatInstance with parameters and specific import', async () => {
262+
let uri = vscode.Uri.file(path.join(__dirname, testFolderLocation, 'test-files', 'ModuleInstantiator.test.1.v')); // prettier-ignore
263+
let document = await vscode.workspace.openTextDocument(uri);
264+
265+
let fullRange = null;
266+
// Range of the module in the document
267+
fullRange = new vscode.Range(new vscode.Position(395, 6), new vscode.Position(431, 0));
268+
269+
let container = document.getText(fullRange).replace(/^\s+|\s+$/g, '');
270+
271+
console.log('Container \n\r' + container);
272+
273+
uri = vscode.Uri.file(path.join(__dirname, testFolderLocation, 'test-files', 'ModuleInstantiator.test.2.v'));
274+
document = await vscode.workspace.openTextDocument(uri);
275+
276+
fullRange = new vscode.Range(new vscode.Position(184, 0), new vscode.Position(198, 0));
277+
278+
let instance = document.getText(fullRange);
279+
280+
compareInstantiation('affer', container, instance);
281+
});
242282
});
243283

244284
function compareInstantiation(instance_name, container_name, expected): void {

src/test/indexer_map.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let symbols: Map<string, Array<SystemVerilogSymbol>>;
1717
const testFolderLocation = '../../src/test';
1818

1919
const uri = Uri.file(path.join(__dirname, testFolderLocation, 'test-files', 'ModuleInstantiator.test.1.v'));
20-
const documentSymbols = ['adder', 'bar', 'akker', 'accer', 'anner', 'atter', 'apper', 'golden'];
20+
const documentSymbols = ['adder', 'bar', 'akker', 'accer', 'anner', 'atter', 'apper', 'golden', 'abber', 'affer'];
2121

2222
const nonSVUri = Uri.file(path.join(__dirname, testFolderLocation, 'test-files', 'foo.txt'));
2323

@@ -31,10 +31,10 @@ suite('indexer_map Tests', () => {
3131
assert.strictEqual(symbols.size, 4);
3232
let count = await indexer.addDocumentSymbols(sVDocument, symbols);
3333

34-
assert.strictEqual(count, 10);
34+
assert.strictEqual(count, 12);
3535
assert.strictEqual(symbols.size, 5);
36-
assert.strictEqual(symbols.get(uri.fsPath).length, 10);
37-
assert.strictEqual(getSymbolsCount(), 23);
36+
assert.strictEqual(symbols.get(uri.fsPath).length, 12);
37+
assert.strictEqual(getSymbolsCount(), 25);
3838

3939
documentSymbols.forEach((symbolName) => {
4040
if (!symbolExists(symbolName)) {
@@ -47,28 +47,28 @@ suite('indexer_map Tests', () => {
4747
assert.strictEqual(count, 0);
4848
assert.strictEqual(symbols.size, 5);
4949
assert.strictEqual(symbols.get(nonSVUri.fsPath), undefined);
50-
assert.strictEqual(getSymbolsCount(), 23);
50+
assert.strictEqual(getSymbolsCount(), 25);
5151

5252
// undefined/null document
5353
count = await indexer.addDocumentSymbols(undefined, symbols);
5454
assert.strictEqual(count, 0);
5555
assert.strictEqual(symbols.size, 5);
56-
assert.strictEqual(getSymbolsCount(), 23);
56+
assert.strictEqual(getSymbolsCount(), 25);
5757

5858
count = await indexer.addDocumentSymbols(sVDocument, undefined);
5959
assert.strictEqual(count, 0);
6060
assert.strictEqual(symbols.size, 5);
61-
assert.strictEqual(getSymbolsCount(), 23);
61+
assert.strictEqual(getSymbolsCount(), 25);
6262

6363
count = await indexer.addDocumentSymbols(undefined, undefined);
6464
assert.strictEqual(count, 0);
6565
assert.strictEqual(symbols.size, 5);
66-
assert.strictEqual(getSymbolsCount(), 23);
66+
assert.strictEqual(getSymbolsCount(), 25);
6767

6868
count = await indexer.addDocumentSymbols(null, symbols);
6969
assert.strictEqual(count, 0);
7070
assert.strictEqual(symbols.size, 5);
71-
assert.strictEqual(getSymbolsCount(), 23);
71+
assert.strictEqual(getSymbolsCount(), 25);
7272
});
7373

7474
test('test #2: removeDocumentSymbols', async () => {
@@ -80,9 +80,9 @@ suite('indexer_map Tests', () => {
8080
assert.strictEqual(symbols.size, 4);
8181
let count = await indexer.addDocumentSymbols(sVDocument, symbols);
8282

83-
assert.strictEqual(count, 10);
83+
assert.strictEqual(count, 12);
8484
assert.strictEqual(symbols.size, 5);
85-
assert.strictEqual(getSymbolsCount(), 23);
85+
assert.strictEqual(getSymbolsCount(), 25);
8686

8787
count = indexer.removeDocumentSymbols(sVDocument.uri.fsPath, symbols);
8888

@@ -92,7 +92,7 @@ suite('indexer_map Tests', () => {
9292
}
9393
});
9494

95-
assert.strictEqual(count, -10);
95+
assert.strictEqual(count, -12);
9696
assert.strictEqual(symbols.size, 4);
9797
assert.strictEqual(getSymbolsCount(), 13);
9898

src/test/test-files/ModuleInstantiator.test.1.v

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,80 @@ module azzer #(parameter SIZE = (2*1)+1,
351351
assign c = tmp_c;
352352

353353
endmodule
354+
355+
// -------------------------------------------------------
356+
// -- Example without parameters and with import
357+
// -------------------------------------------------------
358+
359+
module abber import pa_Package::*; (
360+
input clk,
361+
input reset,
362+
input [3:0] a,
363+
// keep this single comment
364+
input [3:0] b,
365+
/* multiline comment should
366+
be kept*/
367+
input valid,
368+
output [6:0] c
369+
);
370+
371+
reg [6:0] tmp_c;
372+
373+
//Reset
374+
always_ff @(posedge reset)
375+
tmp_c <= pa_adder::RV_C;
376+
377+
`ifdef VERBOSE_RESET
378+
always @(posedge reset) begin
379+
wait(posedge reset);
380+
$display("Reset asserted!")
381+
end
382+
`endif
383+
384+
// Waddition operation
385+
always @(posedge clk)
386+
if(valid) tmp_c <= a + b;
387+
388+
assign c = tmp_c;
389+
390+
endmodule
391+
392+
// -------------------------------------------------------
393+
// -- Example with parameters and specific import
394+
// -------------------------------------------------------
395+
396+
module affer import pa_Package::PARAMETER1; #(
397+
parameter SIZE = PARAMETER1,
398+
parameter SIZE_TWO
399+
)(
400+
input clk,
401+
input reset,
402+
input [3:0] a,
403+
// keep this single comment
404+
input [3:0] b,
405+
/* multiline comment should
406+
be kept*/
407+
input valid,
408+
output [6:0] c
409+
);
410+
411+
reg [6:0] tmp_c;
412+
413+
//Reset
414+
always_ff @(posedge reset)
415+
tmp_c <= pa_adder::RV_C;
416+
417+
`ifdef VERBOSE_RESET
418+
always @(posedge reset) begin
419+
wait(posedge reset);
420+
$display("Reset asserted!")
421+
end
422+
`endif
423+
424+
// Waddition operation
425+
always @(posedge clk)
426+
if(valid) tmp_c <= a + b;
427+
428+
assign c = tmp_c;
429+
430+
endmodule

0 commit comments

Comments
 (0)