mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
feat: Use stdin/redirection for astyle
This commit is contained in:
@@ -18,10 +18,10 @@ endfunction
|
|||||||
|
|
||||||
function! ale#fixers#astyle#Fix(buffer) abort
|
function! ale#fixers#astyle#Fix(buffer) abort
|
||||||
let l:executable = ale#fixers#astyle#Var(a:buffer, 'executable')
|
let l:executable = ale#fixers#astyle#Var(a:buffer, 'executable')
|
||||||
let l:command = ' %t'
|
let l:filename = ale#Escape(bufname(a:buffer))
|
||||||
|
let l:command = ' --stdin=' . l:filename
|
||||||
|
|
||||||
return {
|
return {
|
||||||
\ 'command': ale#Escape(l:executable) . l:command,
|
\ 'command': ale#Escape(l:executable) . l:command
|
||||||
\ 'read_temporary_file': 1,
|
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Before:
|
|||||||
|
|
||||||
" Use an invalid global executable, so we don't match it.
|
" Use an invalid global executable, so we don't match it.
|
||||||
let g:ale_c_astyle_executable = 'xxxinvalid'
|
let g:ale_c_astyle_executable = 'xxxinvalid'
|
||||||
|
let g:ale_cpp_astyle_executable = 'invalidpp'
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|
||||||
@@ -13,24 +14,24 @@ After:
|
|||||||
|
|
||||||
Execute(The astyle callback should return the correct default values):
|
Execute(The astyle callback should return the correct default values):
|
||||||
call ale#test#SetFilename('../c_files/testfile.c')
|
call ale#test#SetFilename('../c_files/testfile.c')
|
||||||
|
let targetfile = '/testplugin/test/c_files/testfile.c'
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ {
|
\ {
|
||||||
\ 'read_temporary_file': 1,
|
\ 'command': ale#Escape(g:ale_c_astyle_executable)
|
||||||
\ 'command': ale#Escape('xxxinvalid')
|
\ . ' --stdin=' . ale#Escape(targetfile)
|
||||||
\ . ' %t',
|
|
||||||
\ },
|
\ },
|
||||||
\ ale#fixers#astyle#Fix(bufnr(''))
|
\ ale#fixers#astyle#Fix(bufnr(''))
|
||||||
|
|
||||||
Execute(The astyle callback should support cpp files):
|
Execute(The astyle callback should support cpp files):
|
||||||
call ale#test#SetFilename('../cpp_files/dummy.cpp')
|
call ale#test#SetFilename('../cpp_files/dummy.cpp')
|
||||||
let g:ale_cpp_astyle_executable = 'xxxinvalid'
|
let targetfile = '/testplugin/test/cpp_files/dummy.cpp'
|
||||||
set filetype=cpp " The test fails without this
|
set filetype=cpp " The test fails without this
|
||||||
|
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ {
|
\ {
|
||||||
\ 'read_temporary_file': 1,
|
\ 'command': ale#Escape(g:ale_cpp_astyle_executable)
|
||||||
\ 'command': ale#Escape('xxxinvalid')
|
\ . ' --stdin=' . ale#Escape(targetfile)
|
||||||
\ . ' %t',
|
|
||||||
\ },
|
\ },
|
||||||
\ ale#fixers#astyle#Fix(bufnr(''))
|
\ ale#fixers#astyle#Fix(bufnr(''))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user