1f7679e619
* Remove 'col' from linters where it is hardcoded to 1 When 'col' is 1, the first column will get highlighted for no reason. It should be 0 (which is the default). In the scalac linter there was also a check about the outcome of `stridx`. It would set l:col to 0 if it was -1, and then it uses `'col': l:col + 1` to convert the outcome of `stridx` to the actual column number. This will make 'col' equals 1 when there is no match. We can remove the check because `-1 + 1 = 0`. * Remove outdated comments about vcol vcol was added as a default, and the loclists that follow these comments do not contain 'vcol' anymore Conflicts: ale_linters/elixir/dogma.vim
52 lines
1.5 KiB
VimL
52 lines
1.5 KiB
VimL
" Author: farenjihn <farenjihn@gmail.com>, w0rp <devw0rp@gmail.com>
|
|
" Description: Lints java files using javac
|
|
|
|
let g:ale_java_javac_options = get(g:, 'ale_java_javac_options', '')
|
|
let g:ale_java_javac_classpath = get(g:, 'ale_java_javac_classpath', '')
|
|
|
|
function! ale_linters#java#javac#GetCommand(buffer) abort
|
|
let l:cp_option = !empty(g:ale_java_javac_classpath)
|
|
\ ? '-cp ' . g:ale_java_javac_classpath
|
|
\ : ''
|
|
|
|
return 'javac -Xlint '
|
|
\ . l:cp_option
|
|
\ . ' ' . g:ale_java_javac_options
|
|
\ . ' %t'
|
|
endfunction
|
|
|
|
function! ale_linters#java#javac#Handle(buffer, lines) abort
|
|
" Look for lines like the following.
|
|
"
|
|
" Main.java:13: warning: [deprecation] donaught() in Testclass has been deprecated
|
|
" Main.java:16: error: ';' expected
|
|
|
|
let l:pattern = '^.*\:\(\d\+\):\ \(.*\):\(.*\)$'
|
|
let l:output = []
|
|
|
|
for l:line in a:lines
|
|
let l:match = matchlist(l:line, l:pattern)
|
|
|
|
if len(l:match) == 0
|
|
continue
|
|
endif
|
|
|
|
call add(l:output, {
|
|
\ 'bufnr': a:buffer,
|
|
\ 'lnum': l:match[1] + 0,
|
|
\ 'text': l:match[2] . ':' . l:match[3],
|
|
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
|
|
\})
|
|
endfor
|
|
|
|
return l:output
|
|
endfunction
|
|
|
|
call ale#linter#Define('java', {
|
|
\ 'name': 'javac',
|
|
\ 'output_stream': 'stderr',
|
|
\ 'executable': 'javac',
|
|
\ 'command_callback': 'ale_linters#java#javac#GetCommand',
|
|
\ 'callback': 'ale_linters#java#javac#Handle',
|
|
\})
|