mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-26 11:37:24 +08:00
Move all functions for fixing things to autoload/ale/fixers, and only accept the lines of input where needed.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user