Skip to content

Commit

Permalink
core/SciTE: display function argument list or helpinfo for variables
Browse files Browse the repository at this point in the history
  • Loading branch information
davidm committed Aug 11, 2010
1 parent 00c6e0a commit 08db1cb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.txt
Expand Up @@ -133,6 +133,7 @@ Peter Odding for VIM editor support [2]
20100811
SciTE: autocomplete functions arguments when cursor after '('
core: fix signatures for os library
core/SciTE: display function argument list or helpinfo for variables

20100810
SciTE: improved "inspect variable" command, supports browsing nested tables.
Expand Down
20 changes: 19 additions & 1 deletion luainspectlib/luainspect/init.lua
Expand Up @@ -382,7 +382,7 @@ function M.infer_values(top_ast, tokenlist)
local val = function() x=nil end
local fpos = LA.ast_pos_range(ast, tokenlist)
local source = ast.lineinfo.first[4] -- a HACK? relies on AST lineinfo
M.debuginfo[val] = {fpos=fpos, source="@" .. source, fast=ast}
M.debuginfo[val] = {fpos=fpos, source="@" .. source, fast=ast, tokenlist=tokenlist}
ast.value = val
end
ast.valueknown = true
Expand Down Expand Up @@ -713,4 +713,22 @@ function M.names_in_prefixexp(ids, pos, ast, tokenlist)
return names
end


-- Gets signature (function argument string or helpinfo string) on variable ast.
-- Returns nil on not found.
function M.get_signature(ast)
if ast.valueknown then
local info = M.debuginfo[ast.value] -- first try this
if info and info.fast then
local fidx, lidx = LA.ast_idx_range_in_tokenlist(info.tokenlist, info.fast[1])
local ts = {}
for i=fidx,lidx do ts[#ts+1] = info.tokenlist[i][1] end
local sig = 'function(' .. table.concat(ts, ' ') .. ')'
return sig
end
local sig = LS.value_signatures[ast.value] -- else try this
return sig
end
end

return M
5 changes: 5 additions & 0 deletions luainspectlib/luainspect/scite.lua
Expand Up @@ -219,6 +219,11 @@ local function formatvariabledetails(token)
info = info .. "\nWARNING: " .. note .. " "
end

local sig = LI.get_signature(vast)
if sig then
info = info .. "\nsignature: " .. sig .. " "
end

return info
end

Expand Down

0 comments on commit 08db1cb

Please sign in to comment.