summaryrefslogtreecommitdiff
path: root/ale_linters/java/checkstyle.vim
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-11-11 10:00:37 +0000
committerGitHub <noreply@github.com>2018-11-11 10:00:37 +0000
commitd30da203b91345b472e5d83f048bd42a6ca13804 (patch)
tree21a60fbdf8237d845e06992237bfce6843f8633b /ale_linters/java/checkstyle.vim
parent7dd460303d38b460373b795f6f74a5b0b967eb48 (diff)
parent8e24a1a91658600771512e80c0c42c1ab1d6c117 (diff)
downloadale-d30da203b91345b472e5d83f048bd42a6ca13804.zip
Merge pull request #2063 from languitar/better-checkstyle
Checkstyle improvements
Diffstat (limited to 'ale_linters/java/checkstyle.vim')
-rw-r--r--ale_linters/java/checkstyle.vim18
1 files changed, 16 insertions, 2 deletions
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim
index 8155170a..c07b65d0 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,13 +17,24 @@ 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
function! ale_linters#java#checkstyle#GetCommand(buffer) abort
return 'checkstyle '
\ . ale#Var(a:buffer, 'java_checkstyle_options')
- \ . ' %t'
+ \ . ' %s'
endfunction
if !exists('g:ale_java_checkstyle_options')
@@ -33,4 +46,5 @@ call ale#linter#Define('java', {
\ 'executable': 'checkstyle',
\ 'command_callback': 'ale_linters#java#checkstyle#GetCommand',
\ 'callback': 'ale_linters#java#checkstyle#Handle',
+\ 'lint_file': 1,
\})