@@ -170,29 +170,40 @@ function! s:_format_throwpoint(throwpoint) abort
170
170
let stack = matchstr (a: throwpoint , ' ^function \zs.*, .\{-} \d\+$' )
171
171
for line in split (stack, ' \.\.' )
172
172
let m = matchlist (line , ' ^\(.\+\)\%(\[\(\d\+\)\]\|, .\{-} \(\d\+\)\)$' )
173
- if empty (m )
174
- call add (funcs, line )
175
- continue
176
- endif
177
- let [name, lnum, lnum2] = m [1 :3 ]
178
- if empty (lnum)
179
- let lnum = lnum2
173
+ if ! empty (m )
174
+ let [name, lnum, lnum2] = m [1 :3 ]
175
+ if empty (lnum)
176
+ let lnum = lnum2
177
+ endif
178
+ let info = s: _get_func_info (name)
179
+ if ! empty (info)
180
+ call add (funcs, printf (' function %s(...) %s Line:%d (%s)' ,
181
+ \ info.funcname, join (info.attrs, ' ' ), lnum, info.filename))
182
+ continue
183
+ endif
180
184
endif
181
- let attr = ' '
182
- let file = s: _get_file_by_func_name (name)
183
- call add (funcs, printf (' function %s(...)%s Line:%d (%s)' , name, attr, lnum, file ))
185
+ " fallback when function information cannot be detected
186
+ call add (funcs, line )
184
187
endfor
185
188
return join (funcs, " \n " )
186
189
endfunction
187
190
188
- function ! s: _get_file_by_func_name (name) abort
191
+ function ! s: _get_func_info (name) abort
189
192
" If name is digits, it is anonymous-function
190
193
let name = (a: name = ~# ' ^\d\+$' ) ? printf (' {%s}' , a: name ) : a: name
194
+ if ! exists (' *' . name)
195
+ return {}
196
+ endif
191
197
let body = execute (printf (' verbose function %s' , name))
192
198
let lines = split (body, " \n " )
193
199
let signature = matchstr (lines [0 ], ' ^\s*\zs.*' )
194
200
let file = matchstr (lines [1 ], ' ^\t\%(Last set from\|.\{-}:\)\s*\zs.*$' )
195
- return substitute (file , ' [/\\]\+' , ' /' , ' g' )
201
+ return {
202
+ \ ' filename' : substitute (file , ' [/\\]\+' , ' /' , ' g' ),
203
+ \ ' funcname' : a: name ,
204
+ \ ' arguments' : split (matchstr (signature, ' (\zs.*\ze)' ), ' \s*,\s*' ),
205
+ \ ' attrs' : filter ([' dict' , ' abort' , ' range' , ' closure' ], ' signature =~# (").*" . v:val)' ),
206
+ \ }
196
207
endfunction
197
208
198
209
" s:_get_module() returns module object wihch has all script local functions.
0 commit comments