diff options
author | w0rp <devw0rp@gmail.com> | 2017-11-05 15:33:31 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-11-05 15:33:31 +0000 |
commit | 34674e088d7d990d21a4cee5e289200cee5f9d6c (patch) | |
tree | b7a2625e08b20699b554a7ae160b1bdc67fede8d /ale_linters/java | |
parent | d851f399c054d487232294d9f1c3a6974215f4a8 (diff) | |
download | ale-34674e088d7d990d21a4cee5e289200cee5f9d6c.zip |
Fix #1061 - Handle the filenames returned by javac
Diffstat (limited to 'ale_linters/java')
-rw-r--r-- | ale_linters/java/javac.vim | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim index d83da182..f7da560b 100644 --- a/ale_linters/java/javac.vim +++ b/ale_linters/java/javac.vim @@ -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 |