Closed albfan closed 9 years ago
Inspect the way https://github.com/majutsushi/tagbar print its stuff
For complex dict objects a parse function is needed
" Inspect variables
"
" input: variable
" level: actual level of nest
" max: maximum level of nest
function! ToJson(input, level, max)
let json = ''
try
if a:level < a:max
if type(a:input) == type({})
let parts = copy(a:input)
call map(parts, '"\"" . escape(v:key, "\"") . "\":" . ToJson(v:val, ' . (a:level+1) . ',' . a:max . ")")
let space = repeat(" ", a:level)
let json .= space . " {\r\n " . space . join(values(parts), ",\r\n " . space) . "\r\n" . space ." }"
elseif type(a:input) == type([])
let parts = map(copy(a:input), 'ToJson(v:val,' . (a:level+1) . ',' . a:max . ')')
let json .= "[" . join(parts, ",\r\n") . "]\r\n"
elseif type(a:input) == type(function("tr"))
let dictFunc = substitute(string(a:input), "function('\\(.\\+\\)')", "\\1", "")
if dictFunc+0 > 0
let funcName = '{' . dictFunc . '}'
else
let funcName = a:input
endif
let json .= '"'.escape(genutils#ExtractFuncListing(funcName, 0, 0), '"') . "\""
else
let json .= '"'.escape(a:input, '"') . "\""
endif
else
try
let json .= '"' . escape(string(a:input), '"') . "\""
catch
"string() can throw an E724 (too much nest)
let json .= '"' . escape(keys(a:input), '"') . "\""
endtry
endif
catch
let json .= " ERROR"
endtry
return json
endfunction
I'm trying it on
[DEBUG TAGBAR]
Breakpoints:
2 func <SNR>200_PrintKinds línea 15
as
:BPDEvaluate ToJson(a:typeinfo,0,6)
on real complex object like fileinfo fails (see ERROR objects
:BPDEvaluate ToJson(a:fileinfo,0,1)
:BPDEvaluate ToJson(a:fileinfo,0,2)
Anyway is supposed to use a lazy inspection on nodes
After resolve smart evaluation, only is needed to implement lazy node resolution and buffer output.
locals buffer shows correctly
TODO:
TODO:
detect parameters and variables already evaluated (behind debugging line) and show in a buffer as a tree node