mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 05:24:46 +08:00
Remove ProcessChain code we do not need now
This commit is contained in:
@@ -462,53 +462,49 @@ function! ale#engine#ProcessChain(buffer, executable, linter, chain_index, input
|
|||||||
let l:chain_index = a:chain_index
|
let l:chain_index = a:chain_index
|
||||||
let l:input = a:input
|
let l:input = a:input
|
||||||
|
|
||||||
if has_key(a:linter, 'command_chain')
|
while l:chain_index < len(a:linter.command_chain)
|
||||||
while l:chain_index < len(a:linter.command_chain)
|
" Run a chain of commands, one asynchronous command after the other,
|
||||||
" Run a chain of commands, one asynchronous command after the other,
|
" so that many programs can be run in a sequence.
|
||||||
" so that many programs can be run in a sequence.
|
let l:chain_item = a:linter.command_chain[l:chain_index]
|
||||||
let l:chain_item = a:linter.command_chain[l:chain_index]
|
|
||||||
|
|
||||||
if l:chain_index == 0
|
if l:chain_index == 0
|
||||||
" The first callback in the chain takes only a buffer number.
|
" The first callback in the chain takes only a buffer number.
|
||||||
let l:command = ale#util#GetFunction(l:chain_item.callback)(
|
let l:command = ale#util#GetFunction(l:chain_item.callback)(
|
||||||
\ a:buffer
|
\ a:buffer
|
||||||
\)
|
\)
|
||||||
else
|
else
|
||||||
" The second callback in the chain takes some input too.
|
" The second callback in the chain takes some input too.
|
||||||
let l:command = ale#util#GetFunction(l:chain_item.callback)(
|
let l:command = ale#util#GetFunction(l:chain_item.callback)(
|
||||||
\ a:buffer,
|
\ a:buffer,
|
||||||
\ l:input
|
\ l:input
|
||||||
\)
|
\)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" If we have a command to run, execute that.
|
||||||
|
if !empty(l:command)
|
||||||
|
" The chain item can override the output_stream option.
|
||||||
|
if has_key(l:chain_item, 'output_stream')
|
||||||
|
let l:output_stream = l:chain_item.output_stream
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If we have a command to run, execute that.
|
" The chain item can override the read_buffer option.
|
||||||
if !empty(l:command)
|
if has_key(l:chain_item, 'read_buffer')
|
||||||
" The chain item can override the output_stream option.
|
let l:read_buffer = l:chain_item.read_buffer
|
||||||
if has_key(l:chain_item, 'output_stream')
|
elseif l:chain_index != len(a:linter.command_chain) - 1
|
||||||
let l:output_stream = l:chain_item.output_stream
|
" Don't read the buffer for commands besides the last one
|
||||||
endif
|
" in the chain by default.
|
||||||
|
let l:read_buffer = 0
|
||||||
" The chain item can override the read_buffer option.
|
|
||||||
if has_key(l:chain_item, 'read_buffer')
|
|
||||||
let l:read_buffer = l:chain_item.read_buffer
|
|
||||||
elseif l:chain_index != len(a:linter.command_chain) - 1
|
|
||||||
" Don't read the buffer for commands besides the last one
|
|
||||||
" in the chain by default.
|
|
||||||
let l:read_buffer = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
break
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Command chain items can return an empty string to indicate that
|
break
|
||||||
" a command should be skipped, so we should try the next item
|
endif
|
||||||
" with no input.
|
|
||||||
let l:input = []
|
" Command chain items can return an empty string to indicate that
|
||||||
let l:chain_index += 1
|
" a command should be skipped, so we should try the next item
|
||||||
endwhile
|
" with no input.
|
||||||
else
|
let l:input = []
|
||||||
let l:command = ale#linter#GetCommand(a:buffer, a:linter)
|
let l:chain_index += 1
|
||||||
endif
|
endwhile
|
||||||
|
|
||||||
return [l:command, {
|
return [l:command, {
|
||||||
\ 'executable': a:executable,
|
\ 'executable': a:executable,
|
||||||
|
|||||||
@@ -67,40 +67,6 @@ Execute(Engine invocation should return the command for the fourth item correctl
|
|||||||
AssertEqual 'fourth', g:result.command
|
AssertEqual 'fourth', g:result.command
|
||||||
AssertEqual 4, g:result.next_chain_index
|
AssertEqual 4, g:result.next_chain_index
|
||||||
|
|
||||||
Execute(Engine invocation should return the command for a single callback correctly):
|
|
||||||
unlet g:linter.command_chain
|
|
||||||
let g:linter.command_callback = 'FirstChainFunction'
|
|
||||||
|
|
||||||
let g:result = ProcessIndex(0)
|
|
||||||
|
|
||||||
AssertEqual 'first', g:result.command
|
|
||||||
|
|
||||||
Execute(Engine invocation should return the command for a command string correctly):
|
|
||||||
unlet g:linter.command_chain
|
|
||||||
let g:linter.command = 'foo bar'
|
|
||||||
|
|
||||||
let g:result = ProcessIndex(0)
|
|
||||||
|
|
||||||
AssertEqual 'foo bar', g:result.command
|
|
||||||
|
|
||||||
Execute(Engine invocation should process read_buffer correctly for simple commands):
|
|
||||||
unlet g:linter.command_chain
|
|
||||||
let g:linter.command = 'foo bar'
|
|
||||||
let g:linter.read_buffer = 0
|
|
||||||
|
|
||||||
let g:result = ProcessIndex(0)
|
|
||||||
|
|
||||||
AssertEqual 'foo bar', g:result.command
|
|
||||||
AssertEqual 0, g:result.read_buffer
|
|
||||||
|
|
||||||
let g:linter.command_callback = 'FirstChainFunction'
|
|
||||||
unlet g:linter.command
|
|
||||||
|
|
||||||
let g:result = ProcessIndex(0)
|
|
||||||
|
|
||||||
AssertEqual 'first', g:result.command
|
|
||||||
AssertEqual 0, g:result.read_buffer
|
|
||||||
|
|
||||||
Execute(Engine invocation should allow read_buffer to be enabled for a command in the middle of a chain):
|
Execute(Engine invocation should allow read_buffer to be enabled for a command in the middle of a chain):
|
||||||
let g:linter.command_chain[2].read_buffer = 1
|
let g:linter.command_chain[2].read_buffer = 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user