summaryrefslogtreecommitdiff
path: root/ale_linters/java/javac.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/java/javac.vim')
-rw-r--r--ale_linters/java/javac.vim28
1 files changed, 17 insertions, 11 deletions
diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim
index 50cabacd..7ca95ba5 100644
--- a/ale_linters/java/javac.vim
+++ b/ale_linters/java/javac.vim
@@ -7,21 +7,29 @@ call ale#Set('java_javac_executable', 'javac')
call ale#Set('java_javac_options', '')
call ale#Set('java_javac_classpath', '')
-function! ale_linters#java#javac#GetImportPaths(buffer) abort
+function! ale_linters#java#javac#RunWithImportPaths(buffer) abort
+ let l:command = ''
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
if !empty(l:pom_path) && executable('mvn')
- return ale#path#CdString(fnamemodify(l:pom_path, ':h'))
+ let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h'))
\ . 'mvn dependency:build-classpath'
endif
- let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer)
+ " Try to use Gradle if Maven isn't available.
+ if empty(l:command)
+ let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
+ endif
- if !empty(l:classpath_command)
- return l:classpath_command
+ if empty(l:command)
+ return ale_linters#java#javac#GetCommand(a:buffer, [], {})
endif
- return ''
+ return ale#command#Run(
+ \ a:buffer,
+ \ l:command,
+ \ function('ale_linters#java#javac#GetCommand')
+ \)
endfunction
function! s:BuildClassPathOption(buffer, import_paths) abort
@@ -37,7 +45,7 @@ function! s:BuildClassPathOption(buffer, import_paths) abort
\ : ''
endfunction
-function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
+function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort
let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths)
let l:sp_option = ''
@@ -120,9 +128,7 @@ endfunction
call ale#linter#Define('java', {
\ 'name': 'javac',
\ 'executable': {b -> ale#Var(b, 'java_javac_executable')},
-\ 'command_chain': [
-\ {'callback': 'ale_linters#java#javac#GetImportPaths', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#java#javac#GetCommand', 'output_stream': 'stderr'},
-\ ],
+\ 'command': function('ale_linters#java#javac#RunWithImportPaths'),
+\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#java#javac#Handle',
\})