Fix #1061 - Handle the filenames returned by javac
This commit is contained in:
parent
d851f399c0
commit
34674e088d
3 changed files with 57 additions and 16 deletions
|
@ -49,7 +49,10 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
|
|||
" Create .class files in a temporary directory, which we will delete later.
|
||||
let l:class_file_directory = ale#engine#CreateDirectory(a:buffer)
|
||||
|
||||
return 'javac -Xlint'
|
||||
" Always run javac from the directory the file is in, so we can resolve
|
||||
" relative paths correctly.
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'javac -Xlint'
|
||||
\ . ' ' . l:cp_option
|
||||
\ . ' ' . l:sp_option
|
||||
\ . ' -d ' . ale#Escape(l:class_file_directory)
|
||||
|
@ -63,14 +66,15 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort
|
|||
" Main.java:13: warning: [deprecation] donaught() in Testclass has been deprecated
|
||||
" Main.java:16: error: ';' expected
|
||||
|
||||
let l:pattern = '\v^.*:(\d+): (.+):(.+)$'
|
||||
let l:directory = expand('#' . a:buffer . ':p:h')
|
||||
let l:pattern = '\v^(.*):(\d+): (.+):(.+)$'
|
||||
let l:col_pattern = '\v^(\s*\^)$'
|
||||
let l:symbol_pattern = '\v^ +symbol: *(class|method) +([^ ]+)'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:col_pattern, l:symbol_pattern])
|
||||
if empty(l:match[2]) && empty(l:match[3])
|
||||
let l:output[-1].col = len(l:match[1])
|
||||
let l:output[-1].col = len(l:match[1])
|
||||
elseif empty(l:match[3])
|
||||
" Add symbols to 'cannot find symbol' errors.
|
||||
if l:output[-1].text is# 'error: cannot find symbol'
|
||||
|
@ -78,9 +82,10 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort
|
|||
endif
|
||||
else
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[2] . ':' . l:match[3],
|
||||
\ 'type': l:match[2] is# 'error' ? 'E' : 'W',
|
||||
\ 'filename': ale#path#GetAbsPath(l:directory, l:match[1]),
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[3] . ':' . l:match[4],
|
||||
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue