Revert "#2132 Change (buffer, lines) fixer functions to (buffer, done, lines)"
This reverts commit f1ed654ca5
.
This commit is contained in:
parent
883978ece9
commit
89e5491862
@ -202,10 +202,10 @@ function! s:RunFixer(options) abort
|
|||||||
\ ? call(l:Function, [l:buffer, a:options.output])
|
\ ? call(l:Function, [l:buffer, a:options.output])
|
||||||
\ : call(l:Function, [l:buffer, a:options.output, copy(l:input)])
|
\ : call(l:Function, [l:buffer, a:options.output, copy(l:input)])
|
||||||
else
|
else
|
||||||
" Chained commands accept (buffer, [done, input])
|
" Chained commands accept (buffer, [input])
|
||||||
let l:result = ale#util#FunctionArgCount(l:Function) == 1
|
let l:result = ale#util#FunctionArgCount(l:Function) == 1
|
||||||
\ ? call(l:Function, [l:buffer])
|
\ ? call(l:Function, [l:buffer])
|
||||||
\ : call(l:Function, [l:buffer, v:null, copy(l:input)])
|
\ : call(l:Function, [l:buffer, copy(l:input)])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if type(l:result) is v:t_number && l:result == 0
|
if type(l:result) is v:t_number && l:result == 0
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
" Author: w0rp <devw0rp@gmail.com>
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
" Description: Generic functions for fixing files with.
|
" Description: Generic functions for fixing files with.
|
||||||
|
|
||||||
function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, done, lines) abort
|
function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort
|
||||||
let l:end_index = len(a:lines) - 1
|
let l:end_index = len(a:lines) - 1
|
||||||
|
|
||||||
while l:end_index > 0 && empty(a:lines[l:end_index])
|
while l:end_index > 0 && empty(a:lines[l:end_index])
|
||||||
@ -12,7 +12,7 @@ function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, done, lines) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Remove all whitespaces at the end of lines
|
" Remove all whitespaces at the end of lines
|
||||||
function! ale#fixers#generic#TrimWhitespace(buffer, done, lines) abort
|
function! ale#fixers#generic#TrimWhitespace(buffer, lines) abort
|
||||||
let l:index = 0
|
let l:index = 0
|
||||||
let l:lines_new = range(len(a:lines))
|
let l:lines_new = range(len(a:lines))
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
" Description: Generic fixer functions for Python.
|
" Description: Generic fixer functions for Python.
|
||||||
|
|
||||||
" Add blank lines before control statements.
|
" Add blank lines before control statements.
|
||||||
function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, done, lines) abort
|
function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, lines) abort
|
||||||
let l:new_lines = []
|
let l:new_lines = []
|
||||||
let l:last_indent_size = 0
|
let l:last_indent_size = 0
|
||||||
let l:last_line_is_blank = 0
|
let l:last_line_is_blank = 0
|
||||||
@ -41,7 +41,7 @@ endfunction
|
|||||||
|
|
||||||
" This function breaks up long lines so that autopep8 or other tools can
|
" This function breaks up long lines so that autopep8 or other tools can
|
||||||
" fix the badly-indented code which is produced as a result.
|
" fix the badly-indented code which is produced as a result.
|
||||||
function! ale#fixers#generic_python#BreakUpLongLines(buffer, done, lines) abort
|
function! ale#fixers#generic_python#BreakUpLongLines(buffer, lines) abort
|
||||||
" Default to a maximum line length of 79
|
" Default to a maximum line length of 79
|
||||||
let l:max_line_length = 79
|
let l:max_line_length = 79
|
||||||
let l:conf = ale#path#FindNearestFile(a:buffer, 'setup.cfg')
|
let l:conf = ale#path#FindNearestFile(a:buffer, 'setup.cfg')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
" Author: w0rp <devw0rp@gmail.com>
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
" Description: Generic fixer functions for Vim help documents.
|
" Description: Generic fixer functions for Vim help documents.
|
||||||
|
|
||||||
function! ale#fixers#help#AlignTags(buffer, done, lines) abort
|
function! ale#fixers#help#AlignTags(buffer, lines) abort
|
||||||
let l:new_lines = []
|
let l:new_lines = []
|
||||||
|
|
||||||
for l:line in a:lines
|
for l:line in a:lines
|
||||||
|
12
doc/ale.txt
12
doc/ale.txt
@ -578,14 +578,10 @@ The values for `g:ale_fixers` can be a list of |String|, |Funcref|, or
|
|||||||
for a function set in the ALE fixer registry.
|
for a function set in the ALE fixer registry.
|
||||||
|
|
||||||
Each function for fixing errors must accept either one argument `(buffer)` or
|
Each function for fixing errors must accept either one argument `(buffer)` or
|
||||||
three arguments `(buffer, done, lines)`, representing the buffer being fixed,
|
two arguments `(buffer, lines)`, representing the buffer being fixed and the
|
||||||
a function to call with results, and the lines to fix. The functions must
|
lines to fix. The functions must return either `0`, for changing nothing, a
|
||||||
return either `0`, for changing nothing, a |List| for new lines to set, a
|
|List| for new lines to set, or a |Dictionary| for describing a command to be
|
||||||
|Dictionary| for describing a command to be run in the background, or `v:true`
|
run in the background.
|
||||||
for indicating that results will be provided asynchronously via the `done`
|
|
||||||
callback.
|
|
||||||
|
|
||||||
NOTE: The `done` function has not been implemented yet.
|
|
||||||
|
|
||||||
Functions receiving a variable number of arguments will not receive the second
|
Functions receiving a variable number of arguments will not receive the second
|
||||||
argument `lines`. Functions should name two arguments if the `lines` argument
|
argument `lines`. Functions should name two arguments if the `lines` argument
|
||||||
|
@ -34,21 +34,21 @@ Before:
|
|||||||
call ale#test#SetFilename('test.txt')
|
call ale#test#SetFilename('test.txt')
|
||||||
call ale#linter#PreventLoading('testft')
|
call ale#linter#PreventLoading('testft')
|
||||||
|
|
||||||
function AddCarets(buffer, done, lines) abort
|
function AddCarets(buffer, lines) abort
|
||||||
" map() is applied to the original lines here.
|
" map() is applied to the original lines here.
|
||||||
" This way, we can ensure that defensive copies are made.
|
" This way, we can ensure that defensive copies are made.
|
||||||
return map(a:lines, '''^'' . v:val')
|
return map(a:lines, '''^'' . v:val')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function AddDollars(buffer, done, lines) abort
|
function AddDollars(buffer, lines) abort
|
||||||
return map(a:lines, '''$'' . v:val')
|
return map(a:lines, '''$'' . v:val')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function DoNothing(buffer, done, lines) abort
|
function DoNothing(buffer, lines) abort
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function CatLine(buffer, done, lines) abort
|
function CatLine(buffer, lines) abort
|
||||||
return {'command': 'cat - <(echo d)'}
|
return {'command': 'cat - <(echo d)'}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -56,15 +56,15 @@ Before:
|
|||||||
return {'command': 'cat - <(echo d)'}
|
return {'command': 'cat - <(echo d)'}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function ReplaceWithTempFile(buffer, done, lines) abort
|
function ReplaceWithTempFile(buffer, lines) abort
|
||||||
return {'command': 'echo x > %t', 'read_temporary_file': 1}
|
return {'command': 'echo x > %t', 'read_temporary_file': 1}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function CatWithTempFile(buffer, done, lines) abort
|
function CatWithTempFile(buffer, lines) abort
|
||||||
return {'command': 'cat %t <(echo d)'}
|
return {'command': 'cat %t <(echo d)'}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function RemoveLastLine(buffer, done, lines) abort
|
function RemoveLastLine(buffer, lines) abort
|
||||||
return ['a', 'b']
|
return ['a', 'b']
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -127,11 +127,11 @@ Before:
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" echo will output a single blank line, and we should ingore it.
|
" echo will output a single blank line, and we should ingore it.
|
||||||
function! IgnoredEmptyOutput(buffer, done, output)
|
function! IgnoredEmptyOutput(buffer, output)
|
||||||
return {'command': has('win32') ? 'echo(' : 'echo'}
|
return {'command': has('win32') ? 'echo(' : 'echo'}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! EchoLineNoPipe(buffer, done, output)
|
function! EchoLineNoPipe(buffer, output)
|
||||||
return {'command': 'echo new line', 'read_buffer': 0}
|
return {'command': 'echo new line', 'read_buffer': 0}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -438,7 +438,7 @@ Execute(ALEFix should accept lambdas):
|
|||||||
" to make the test pass.
|
" to make the test pass.
|
||||||
call setline(1, ['a', 'b', 'c', 'd'])
|
call setline(1, ['a', 'b', 'c', 'd'])
|
||||||
else
|
else
|
||||||
let g:ale_fixers.testft = [{buffer, done, lines -> lines + ['d']}]
|
let g:ale_fixers.testft = [{buffer, lines -> lines + ['d']}]
|
||||||
ALEFix
|
ALEFix
|
||||||
call ale#test#FlushJobs()
|
call ale#test#FlushJobs()
|
||||||
endif
|
endif
|
||||||
|
@ -16,7 +16,7 @@ Execute(Long lines with basic function calls should be broken up correctly):
|
|||||||
\ ' bar,',
|
\ ' bar,',
|
||||||
\ '))',
|
\ '))',
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), v:null, [
|
\ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), [
|
||||||
\ 'def foo():',
|
\ 'def foo():',
|
||||||
\ ' some_variable = this_is_a_longer_function(first_argument, second_argument, third_with_function_call(foo, bar))',
|
\ ' some_variable = this_is_a_longer_function(first_argument, second_argument, third_with_function_call(foo, bar))',
|
||||||
\ ])
|
\ ])
|
||||||
@ -33,7 +33,7 @@ Execute(Longer lines should be permitted if a configuration file allows it):
|
|||||||
\ ' a_third_long_word,',
|
\ ' a_third_long_word,',
|
||||||
\ ')'
|
\ ')'
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), v:null, [
|
\ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), [
|
||||||
\ 'x = this_line_is_between_79_and_90_characters(first, second, third, fourth, fifth)',
|
\ 'x = this_line_is_between_79_and_90_characters(first, second, third, fourth, fifth)',
|
||||||
\ 'y = this_line_is_longer_than_90_characters(much_longer_word, another_longer_word, a_third_long_word)',
|
\ 'y = this_line_is_longer_than_90_characters(much_longer_word, another_longer_word, a_third_long_word)',
|
||||||
\ ])
|
\ ])
|
||||||
|
@ -16,7 +16,7 @@ Execute(Should delete all whitespace at the end of different lines):
|
|||||||
\ ' bar,',
|
\ ' bar,',
|
||||||
\ '))',
|
\ '))',
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#fixers#generic#TrimWhitespace(bufnr(''), v:null, [
|
\ ale#fixers#generic#TrimWhitespace(bufnr(''), [
|
||||||
\ 'def foo():',
|
\ 'def foo():',
|
||||||
\ ' some_variable = this_is_a_longer_function(',
|
\ ' some_variable = this_is_a_longer_function(',
|
||||||
\ 'first_argument,',
|
\ 'first_argument,',
|
||||||
|
@ -23,7 +23,7 @@ Before:
|
|||||||
return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
|
return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function AddLine(buffer, done, lines) abort
|
function AddLine(buffer, lines) abort
|
||||||
return a:lines + ['x']
|
return a:lines + ['x']
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user