summaryrefslogtreecommitdiff
path: root/ale_linters/java
diff options
context:
space:
mode:
authorJohannes Wienke <jwienke@techfak.uni-bielefeld.de>2018-11-07 13:25:48 +0100
committerJohannes Wienke <jwienke@techfak.uni-bielefeld.de>2018-11-07 13:25:48 +0100
commit5d6b4ef73f1d9532fe3f16cdbf5994aa6a3eb9fe (patch)
tree8d7a62b5309b0ea0aac4cfbbc306ad96b1b3c172 /ale_linters/java
parentad98cb74488c017a4b23e5a848e37ac5bc0840b0 (diff)
downloadale-5d6b4ef73f1d9532fe3f16cdbf5994aa6a3eb9fe.zip
Support older checkstyle versions
The output format used by older checkstyle versions differs from the one of new versions. This commit adds a second parsing iteration on the output lines with a suitable pattern to support both versions in parallel. Due to the differences in the order of matching groups this is hard to achieve in a single pass through the output lines. An appropriate test case is added.
Diffstat (limited to 'ale_linters/java')
-rw-r--r--ale_linters/java/checkstyle.vim15
1 files changed, 14 insertions, 1 deletions
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim
index 8155170a..7d0c31ba 100644
--- a/ale_linters/java/checkstyle.vim
+++ b/ale_linters/java/checkstyle.vim
@@ -2,9 +2,11 @@
" Description: checkstyle for Java files
function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
- let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
let l:output = []
+ " modern checkstyle versions
+ let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'type': l:match[1] is? 'WARN' ? 'W' : 'E',
@@ -15,6 +17,17 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
\})
endfor
+ " old checkstyle versions
+ let l:pattern = '\v(.+):(\d+): ([^:]+): (.+)$'
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'type': l:match[3] is? 'warning' ? 'W' : 'E',
+ \ 'lnum': l:match[2] + 0,
+ \ 'text': l:match[4],
+ \})
+ endfor
+
return l:output
endfunction