summaryrefslogtreecommitdiff
path: root/ale_linters/kotlin/kotlinc.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
committerw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
commit3bebcb5d48a7150f5a318952ee309acb67fb376d (patch)
tree97edd84badca566894fd4c4f10c2a786df2fe079 /ale_linters/kotlin/kotlinc.vim
parentcdf89f8269aec31d0dfddf3a2769027d72d38155 (diff)
downloadale-3bebcb5d48a7150f5a318952ee309acb67fb376d.zip
#2132 - Replace command_chain and chain_with with ale#command#Run
Diffstat (limited to 'ale_linters/kotlin/kotlinc.vim')
-rw-r--r--ale_linters/kotlin/kotlinc.vim41
1 files changed, 22 insertions, 19 deletions
diff --git a/ale_linters/kotlin/kotlinc.vim b/ale_linters/kotlin/kotlinc.vim
index 32dcc6d1..fddd6625 100644
--- a/ale_linters/kotlin/kotlinc.vim
+++ b/ale_linters/kotlin/kotlinc.vim
@@ -11,26 +11,33 @@ let g:ale_kotlin_kotlinc_module_filename = get(g:, 'ale_kotlin_kotlinc_module_fi
let s:classpath_sep = has('unix') ? ':' : ';'
-function! ale_linters#kotlin#kotlinc#GetImportPaths(buffer) abort
+function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort
" exec maven/gradle only if classpath is not set
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# ''
- return ''
- else
- let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
+ return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {})
+ endif
- if !empty(l:pom_path) && executable('mvn')
- return ale#path#CdString(fnamemodify(l:pom_path, ':h'))
- \ . 'mvn dependency:build-classpath'
- endif
+ let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
- let l:classpath_command = ale#gradle#BuildClasspathCommand(a:buffer)
+ if !empty(l:pom_path) && executable('mvn')
+ let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h'))
+ \ . 'mvn dependency:build-classpath'
+ endif
- if !empty(l:classpath_command)
- return l:classpath_command
- endif
+ " Try to use Gradle if Maven isn't available.
+ if empty(l:command)
+ let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
+ endif
- return ''
+ if empty(l:command)
+ return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {})
endif
+
+ return ale#command#Run(
+ \ a:buffer,
+ \ l:command,
+ \ function('ale_linters#kotlin#kotlinc#GetCommand')
+ \)
endfunction
function! s:BuildClassPathOption(buffer, import_paths) abort
@@ -46,7 +53,7 @@ function! s:BuildClassPathOption(buffer, import_paths) abort
\ : ''
endfunction
-function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths) abort
+function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths, meta) abort
let l:kotlinc_opts = ale#Var(a:buffer, 'kotlin_kotlinc_options')
let l:command = 'kotlinc '
@@ -165,11 +172,7 @@ endfunction
call ale#linter#Define('kotlin', {
\ 'name': 'kotlinc',
\ 'executable': 'kotlinc',
-\ 'command_chain': [
-\ {'callback': 'ale_linters#kotlin#kotlinc#GetImportPaths', 'output_stream': 'stdout'},
-\ {'callback': 'ale_linters#kotlin#kotlinc#GetCommand', 'output_stream': 'stderr'},
-\ ],
+\ 'command': function('ale_linters#kotlin#kotlinc#RunWithImportPaths'),
\ 'callback': 'ale_linters#kotlin#kotlinc#Handle',
\ 'lint_file': 1,
\})
-