2017-08-30 17:59:40 +00:00
|
|
|
Before:
|
|
|
|
Save g:ale_thrift_thrift_executable
|
|
|
|
Save g:ale_thrift_thrift_generators
|
|
|
|
Save g:ale_thrift_thrift_includes
|
|
|
|
Save g:ale_thrift_thrift_options
|
|
|
|
|
|
|
|
unlet! b:ale_thrift_thrift_executable
|
|
|
|
unlet! b:ale_thrift_thrift_generators
|
|
|
|
unlet! b:ale_thrift_thrift_includes
|
|
|
|
unlet! b:ale_thrift_thrift_options
|
|
|
|
|
|
|
|
function! GetCommand(buffer) abort
|
|
|
|
call ale#engine#InitBufferInfo(a:buffer)
|
2017-10-05 21:31:00 +00:00
|
|
|
let l:command = ale_linters#thrift#thrift#GetCommand(a:buffer)
|
2017-08-30 17:59:40 +00:00
|
|
|
call ale#engine#Cleanup(a:buffer)
|
2017-10-05 21:31:00 +00:00
|
|
|
|
|
|
|
let l:split_command = split(l:command)
|
|
|
|
let l:index = index(l:split_command, '-out')
|
|
|
|
|
|
|
|
if l:index >= 0
|
|
|
|
let l:split_command[l:index + 1] = 'TEMP'
|
|
|
|
endif
|
|
|
|
|
|
|
|
return join(l:split_command)
|
2017-08-30 17:59:40 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
runtime ale_linters/thrift/thrift.vim
|
|
|
|
|
|
|
|
After:
|
|
|
|
Restore
|
|
|
|
delfunction GetCommand
|
|
|
|
unlet! b:ale_thrift_thrift_executable
|
|
|
|
unlet! b:ale_thrift_thrift_generators
|
|
|
|
unlet! b:ale_thrift_thrift_includes
|
|
|
|
unlet! b:ale_thrift_thrift_options
|
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
Execute(The executable should be configurable):
|
|
|
|
AssertEqual 'thrift', ale_linters#thrift#thrift#GetExecutable(bufnr(''))
|
|
|
|
|
|
|
|
let b:ale_thrift_thrift_executable = 'foobar'
|
|
|
|
AssertEqual 'foobar', ale_linters#thrift#thrift#GetExecutable(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The executable should be used in the command):
|
2017-10-05 21:31:00 +00:00
|
|
|
AssertEqual
|
|
|
|
\ ale#Escape('thrift') . ' --gen cpp -strict -out TEMP %t',
|
|
|
|
\ GetCommand(bufnr('%'))
|
2017-08-30 17:59:40 +00:00
|
|
|
|
|
|
|
let b:ale_thrift_thrift_executable = 'foobar'
|
2017-10-05 21:31:00 +00:00
|
|
|
AssertEqual
|
|
|
|
\ ale#Escape('foobar') . ' --gen cpp -strict -out TEMP %t',
|
|
|
|
\ GetCommand(bufnr('%'))
|
2017-08-30 17:59:40 +00:00
|
|
|
|
|
|
|
Execute(The list of generators should be configurable):
|
|
|
|
let b:ale_thrift_thrift_generators = ['java', 'py:dynamic']
|
2017-10-05 21:31:00 +00:00
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ ale#Escape('thrift') . ' --gen java --gen py:dynamic -strict -out TEMP %t',
|
|
|
|
\ GetCommand(bufnr('%'))
|
2017-08-30 17:59:40 +00:00
|
|
|
|
|
|
|
let b:ale_thrift_thrift_generators = []
|
|
|
|
|
2017-10-05 21:31:00 +00:00
|
|
|
AssertEqual
|
|
|
|
\ ale#Escape('thrift') . ' --gen cpp -strict -out TEMP %t',
|
|
|
|
\ GetCommand(bufnr('%'))
|
2017-08-30 17:59:40 +00:00
|
|
|
|
2017-10-05 21:31:00 +00:00
|
|
|
Execute(The list of include paths should be configurable):
|
2017-08-30 17:59:40 +00:00
|
|
|
let b:ale_thrift_thrift_includes = ['included/path']
|
|
|
|
|
2017-10-05 21:31:00 +00:00
|
|
|
AssertEqual
|
|
|
|
\ ale#Escape('thrift')
|
|
|
|
\ . ' --gen cpp'
|
|
|
|
\ . ' -I included/path'
|
|
|
|
\ . ' -strict -out TEMP %t',
|
|
|
|
\ GetCommand(bufnr('%'))
|
2017-08-30 17:59:40 +00:00
|
|
|
|
2017-10-05 21:31:00 +00:00
|
|
|
Execute(The string of compiler options should be configurable):
|
2017-08-30 17:59:40 +00:00
|
|
|
let b:ale_thrift_thrift_options = '-strict --allow-64bit-consts'
|
2017-10-05 21:31:00 +00:00
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ ale#Escape('thrift')
|
|
|
|
\ . ' --gen cpp -strict --allow-64bit-consts'
|
|
|
|
\ . ' -out TEMP %t',
|
|
|
|
\ GetCommand(bufnr('%'))
|