From 98b0dcd7d6ff51685c7b2d5d782bcbec1e8e5a58 Mon Sep 17 00:00:00 2001 From: "Thomas A. Werne" Date: Sat, 5 Oct 2019 10:44:02 -0700 Subject: [PATCH 1/3] Update vlog parser to handle new output format Re #2812, the parser now takes a second pass through the output using an updated regex. --- ale_linters/verilog/vlog.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ale_linters/verilog/vlog.vim b/ale_linters/verilog/vlog.vim index 37d21c4c..ad160111 100644 --- a/ale_linters/verilog/vlog.vim +++ b/ale_linters/verilog/vlog.vim @@ -24,6 +24,20 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort \}) endfor + "Matches patterns like the following: + "** Warning: (vlog-2623) add.v(7): Undefined variable: C. + "** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C. + " let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:pattern = '^**\s\(\w*\):\s\([^)]*)\)[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[3] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[2] . " " . l:match[4], + \}) + endfor + return l:output endfunction From 89fa43551f1d22c957235ef4b8129c3623f7e0db Mon Sep 17 00:00:00 2001 From: "Thomas A. Werne" Date: Sat, 5 Oct 2019 10:58:30 -0700 Subject: [PATCH 2/3] Add test for new vlog format --- test/handler/test_vlog_handler.vader | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/handler/test_vlog_handler.vader b/test/handler/test_vlog_handler.vader index a70665db..daf3cdcf 100644 --- a/test/handler/test_vlog_handler.vader +++ b/test/handler/test_vlog_handler.vader @@ -4,7 +4,7 @@ Before: After: call ale#linter#Reset() -Execute(The vlog handler should parse lines correctly): +Execute(The vlog handler should parse old-style lines correctly): AssertEqual \ [ \ { @@ -22,3 +22,22 @@ Execute(The vlog handler should parse lines correctly): \ '** Warning: add.v(7): (vlog-2623) Undefined variable: C.', \ '** Error: file.v(1): (vlog-13294) Identifier must be declared with a port mode: C.', \ ]) + +Execute(The vlog handler should parse new-style lines correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 7, + \ 'type': 'W', + \ 'text': '(vlog-2623) Undefined variable: C.' + \ }, + \ { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': '(vlog-13294) Identifier must be declared with a port mode: C.' + \ }, + \ ], + \ ale_linters#verilog#vlog#Handle(bufnr(''), [ + \ '** Warning: (vlog-2623) add.v(7): Undefined variable: C.', + \ '** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C.', + \ ]) From d0e87c0df4d922c8b47e5935bb859518d347a24a Mon Sep 17 00:00:00 2001 From: "Thomas A. Werne" Date: Sat, 5 Oct 2019 11:25:29 -0700 Subject: [PATCH 3/3] Correct vint-discovered advisory in vlog handler --- ale_linters/verilog/vlog.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/verilog/vlog.vim b/ale_linters/verilog/vlog.vim index ad160111..951e2037 100644 --- a/ale_linters/verilog/vlog.vim +++ b/ale_linters/verilog/vlog.vim @@ -34,7 +34,7 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort call add(l:output, { \ 'lnum': l:match[3] + 0, \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', - \ 'text': l:match[2] . " " . l:match[4], + \ 'text': l:match[2] . ' ' . l:match[4], \}) endfor