Move all functions for fixing things to autoload/ale/fixers, and only accept the lines of input where needed.

This commit is contained in:
w0rp
2017-06-07 14:02:29 +01:00
parent edddb1910b
commit 7517fd8226
15 changed files with 132 additions and 98 deletions

View File

@@ -124,10 +124,8 @@ function! ale#util#GetMatches(lines, patterns) abort
return l:matches
endfunction
" Given the name of a function, a Funcref, or a lambda, return the number
" of named arguments for a function.
function! ale#util#FunctionArgCount(function) abort
let l:Function = ale#util#GetFunction(a:function)
function! s:LoadArgCount(function) abort
let l:Function = a:function
redir => l:output
silent! function Function
@@ -142,3 +140,24 @@ function! ale#util#FunctionArgCount(function) abort
return len(l:arg_list)
endfunction
" Given the name of a function, a Funcref, or a lambda, return the number
" of named arguments for a function.
function! ale#util#FunctionArgCount(function) abort
let l:Function = ale#util#GetFunction(a:function)
let l:count = s:LoadArgCount(l:Function)
" If we failed to get the count, forcibly load the autoload file, if the
" function is an autoload function. autoload functions aren't normally
" defined until they are called.
if l:count == 0
let l:function_name = matchlist(string(l:Function), 'function([''"]\(.\+\)[''"])')[1]
if l:function_name =~# '#'
execute 'runtime autoload/' . join(split(l:function_name, '#')[:-2], '/') . '.vim'
let l:count = s:LoadArgCount(l:Function)
endif
endif
return l:count
endfunction