mirror of
https://github.com/dense-analysis/ale
synced 2025-01-03 12:32:05 +00:00
handle column number in javac linter (#660)
* handle column number in javac linter * Updated tests with column number for javac errors. * Updated tests with column number for javac errors.
This commit is contained in:
parent
66b9d025bb
commit
b44bd4e24f
@ -59,11 +59,14 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort
|
|||||||
" Main.java:16: error: ';' expected
|
" Main.java:16: error: ';' expected
|
||||||
|
|
||||||
let l:pattern = '\v^.*:(\d+): (.+):(.+)$'
|
let l:pattern = '\v^.*:(\d+): (.+):(.+)$'
|
||||||
|
let l:col_pattern = '\v^(\s*\^)$'
|
||||||
let l:symbol_pattern = '\v^ +symbol: *(class|method) +([^ ]+)'
|
let l:symbol_pattern = '\v^ +symbol: *(class|method) +([^ ]+)'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:symbol_pattern])
|
for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:col_pattern, l:symbol_pattern])
|
||||||
if empty(l:match[3])
|
if empty(l:match[2]) && empty(l:match[3])
|
||||||
|
let l:output[-1].col = len(l:match[1])
|
||||||
|
elseif empty(l:match[3])
|
||||||
" Add symbols to 'cannot find symbol' errors.
|
" Add symbols to 'cannot find symbol' errors.
|
||||||
if l:output[-1].text ==# 'error: cannot find symbol'
|
if l:output[-1].text ==# 'error: cannot find symbol'
|
||||||
let l:output[-1].text .= ': ' . l:match[2]
|
let l:output[-1].text .= ': ' . l:match[2]
|
||||||
|
@ -14,11 +14,13 @@ Execute(The javac handler should handle cannot find symbol errors):
|
|||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 2,
|
\ 'lnum': 2,
|
||||||
|
\ 'col': 5,
|
||||||
\ 'text': 'error: cannot find symbol: BadName',
|
\ 'text': 'error: cannot find symbol: BadName',
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 34,
|
\ 'lnum': 34,
|
||||||
|
\ 'col': 5,
|
||||||
\ 'text': 'error: cannot find symbol: BadName2',
|
\ 'text': 'error: cannot find symbol: BadName2',
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ },
|
\ },
|
||||||
@ -29,6 +31,7 @@ Execute(The javac handler should handle cannot find symbol errors):
|
|||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 42,
|
\ 'lnum': 42,
|
||||||
|
\ 'col': 11,
|
||||||
\ 'text': 'error: cannot find symbol: bar()',
|
\ 'text': 'error: cannot find symbol: bar()',
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ },
|
\ },
|
||||||
|
Loading…
Reference in New Issue
Block a user