diff options
Diffstat (limited to 'script-beta/core')
-rw-r--r-- | script-beta/core/hover/name.lua | 11 | ||||
-rw-r--r-- | script-beta/core/hover/return.lua | 31 |
2 files changed, 37 insertions, 5 deletions
diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua index 83c750c3..3d855ee5 100644 --- a/script-beta/core/hover/name.lua +++ b/script-beta/core/hover/name.lua @@ -27,12 +27,13 @@ local function asGlobal(source) return guide.getName(source) end +local function asLibrary(source) + return source.doc or source.name +end + local function buildName(source) - if source.doc then - return source.doc - end - if source.name then - return source.name + if source.library then + return asLibrary(source) or '' end if source.type == 'local' or source.type == 'getlocal' diff --git a/script-beta/core/hover/return.lua b/script-beta/core/hover/return.lua index c22626a6..a4d3b989 100644 --- a/script-beta/core/hover/return.lua +++ b/script-beta/core/hover/return.lua @@ -1,6 +1,34 @@ local guide = require 'parser.guide' local vm = require 'vm' +local function asLibrary(source) + if not source.returns then + return nil + end + local returns = {} + for _, rtn in ipairs(source.returns) do + local name = rtn.name + local tp = rtn.type + if name then + returns[#returns+1] = ('%s: %s'):format(name, tp) + else + returns[#returns+1] = tp + end + end + if #returns == 0 then + return nil + end + local lines = {} + for i = 1, #returns do + if i == 1 then + lines[i] = (' -> %s'):format(vm.viewType(returns[i])) + else + lines[i] = ('% 3d. %s'):format(i, returns[i]) + end + end + return table.concat(lines, '\n') +end + local function asFunction(source) if not source.returns then return nil @@ -28,6 +56,9 @@ local function asFunction(source) end return function (source) + if source.library then + return asLibrary(source) + end if source.type == 'function' then return asFunction(source) end |