diff options
Diffstat (limited to 'script-beta/core/hover')
-rw-r--r-- | script-beta/core/hover/arg.lua | 17 | ||||
-rw-r--r-- | script-beta/core/hover/init.lua | 10 | ||||
-rw-r--r-- | script-beta/core/hover/label.lua | 15 | ||||
-rw-r--r-- | script-beta/core/hover/name.lua | 21 |
4 files changed, 31 insertions, 32 deletions
diff --git a/script-beta/core/hover/arg.lua b/script-beta/core/hover/arg.lua index 9d557e3b..dc8db16c 100644 --- a/script-beta/core/hover/arg.lua +++ b/script-beta/core/hover/arg.lua @@ -1,7 +1,7 @@ local guide = require 'parser.guide' local vm = require 'vm' -local function asFunction(source, caller) +local function asFunction(source, oop) if not source.args then return '' end @@ -15,28 +15,21 @@ local function asFunction(source, caller) args[i] = ('%s'):format(vm.getType(arg)) end end - local methodDef, methodCall + local methodDef local parent = source.parent if parent and parent.type == 'setmethod' then methodDef = true end - if caller then - if caller.type == 'method' - or caller.type == 'getmethod' - or caller.type == 'setmethod' then - methodCall = true - end - end - if not methodDef and methodCall then + if not methodDef and oop then return table.concat(args, ', ', 2) else return table.concat(args, ', ') end end -return function (source, caller) +return function (source, oop) if source.type == 'function' then - return asFunction(source, caller) + return asFunction(source, oop) end return '' end diff --git a/script-beta/core/hover/init.lua b/script-beta/core/hover/init.lua index 63129c3e..47d4c5a6 100644 --- a/script-beta/core/hover/init.lua +++ b/script-beta/core/hover/init.lua @@ -11,9 +11,12 @@ local function getHoverAsFunction(source) local defs = 0 local protos = 0 local other = 0 + local oop = source.type == 'method' + or source.type == 'getmethod' + or source.type == 'setmethod' for _, value in ipairs(values) do if value.type == 'function' then - local label = getLabel(value.source, source) + local label = getLabel(value.source, oop) defs = defs + 1 labels[label] = (labels[label] or 0) + 1 if labels[label] == 1 then @@ -54,7 +57,10 @@ local function getHoverAsFunction(source) end local function getHoverAsValue(source) - local label = getLabel(source, source) + local oop = source.type == 'method' + or source.type == 'getmethod' + or source.type == 'setmethod' + local label = getLabel(source, oop) local desc = getDesc(source) return { label = label, diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index dd25d42e..21330b17 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -6,9 +6,9 @@ local getClass = require 'core.hover.class' local vm = require 'vm' local util = require 'utility' -local function asFunction(source, caller) - local name = buildName(source, caller) - local arg = buildArg(source, caller) +local function asFunction(source, oop) + local name = buildName(source, oop) + local arg = buildArg(source, oop) local rtn = buildReturn(source) local lines = {} lines[1] = ('function %s(%s)'):format(name, arg) @@ -28,7 +28,10 @@ local function asValue(source, title) type = nil end if lib then - name = ('%s<%s>'):format(name, buildName(lib)) + local libName = buildName(lib) + if name ~= libName then + name = ('%s<%s>'):format(name, buildName(lib)) + end end local pack = {} pack[#pack+1] = title @@ -108,9 +111,9 @@ local function asString(source) end end -return function (source, caller) +return function (source, oop) if source.type == 'function' then - return asFunction(source, caller) + return asFunction(source, oop) elseif source.type == 'local' or source.type == 'getlocal' or source.type == 'setlocal' then diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua index 917bf96d..ea1906ed 100644 --- a/script-beta/core/hover/name.lua +++ b/script-beta/core/hover/name.lua @@ -5,14 +5,14 @@ local function asLocal(source) return guide.getName(source) end -local function asMethod(source, caller) +local function asMethod(source) local class = getClass(source.node) local node = class or guide.getName(source.node) or '?' local method = guide.getName(source) return ('%s:%s'):format(node, method) end -local function asField(source, caller) +local function asField(source) local class = getClass(source.node) local node = class or guide.getName(source.node) or '?' local method = guide.getName(source) @@ -27,12 +27,9 @@ local function asGlobal(source) return guide.getName(source) end -local function asLibrary(source, caller) +local function asLibrary(source, oop) local p - if caller - and (caller.type == 'method' - or caller.type == 'getmethod' - or caller.type == 'setmethod') then + if oop then if source.parent then for _, parent in ipairs(source.parent) do if parent.type == 'object' then @@ -58,9 +55,9 @@ local function asLibrary(source, caller) end end -local function buildName(source, caller) +local function buildName(source, oop) if source.library then - return asLibrary(source, caller) or '' + return asLibrary(source, oop) or '' end if source.type == 'local' or source.type == 'getlocal' @@ -73,18 +70,18 @@ local function buildName(source, caller) end if source.type == 'setmethod' or source.type == 'getmethod' then - return asMethod(source, caller) or '' + return asMethod(source) or '' end if source.type == 'setfield' or source.type == 'getfield' then - return asField(source, caller) or '' + return asField(source) or '' end if source.type == 'tablefield' then return asTableField(source) or '' end local parent = source.parent if parent then - return buildName(parent, caller) + return buildName(parent, oop) end return '' end |