diff options
Diffstat (limited to 'server/src/core')
-rw-r--r-- | server/src/core/hover.lua | 31 | ||||
-rw-r--r-- | server/src/core/hover_function.lua | 12 | ||||
-rw-r--r-- | server/src/core/hover_name.lua | 44 |
3 files changed, 36 insertions, 51 deletions
diff --git a/server/src/core/hover.lua b/server/src/core/hover.lua index 120d65f5..06e95379 100644 --- a/server/src/core/hover.lua +++ b/server/src/core/hover.lua @@ -352,10 +352,25 @@ local function getStringHover(result, lsp) } end -local function hoverAsValue(result, source, lsp, select) - if result:getType() == 'string' then - return getStringHover(result, lsp) +local function hoverAsValue(source, lsp, select) + local lib, fullkey, isObject = findLib(source) + local value = source:bindValue() + local name = fullkey or buildValueName(source) + + local hover + if value:getType() == 'function' then + if lib then + else + hover = getFunctionHover(name, value:getFunction(), source:getFlag 'object', select) + end + else end + + if not hover then + return nil + end + hover.name = name + return hover end local function hoverAsVar(result, source, lsp, select) @@ -399,13 +414,11 @@ local function hoverAsVar(result, source, lsp, select) return hover end -return function (result, source, lsp, select) - if not result then +return function (source, lsp, select) + if not source then return nil end - if result.type == 'value' then - return hoverAsValue(result, source, lsp, select) - else - return hoverAsVar(result, source, lsp, select) + if source:bindValue() then + return hoverAsValue(source, lsp, select) end end diff --git a/server/src/core/hover_function.lua b/server/src/core/hover_function.lua index 68818028..d877a0d8 100644 --- a/server/src/core/hover_function.lua +++ b/server/src/core/hover_function.lua @@ -1,9 +1,9 @@ -local function buildValueArgs(func, oo, select) +local function buildValueArgs(func, object, select) local names = {} local values = {} if func.args then for i, arg in ipairs(func.args) do - names[i] = arg.key + names[i] = arg:getName() end end if func.argValues then @@ -13,7 +13,7 @@ local function buildValueArgs(func, oo, select) end local strs = {} local start = 1 - if oo then + if object then start = 2 if select then select = select + 1 @@ -43,7 +43,7 @@ local function buildValueArgs(func, oo, select) strs[#strs+1] = '@ARG' end end - if func.hasDots then + if func:hasDots() then if max > 0 then strs[#strs+1] = ', ' end @@ -84,8 +84,8 @@ local function buildValueReturns(func) return '\n -> ' .. table.concat(strs, ', ') end -return function (name, func, oo, select) - local args, argLabel = buildValueArgs(func, oo, select) +return function (name, func, object, select) + local args, argLabel = buildValueArgs(func, object, select) local returns = buildValueReturns(func) local headLen = #('function %s('):format(name) local title = ('function %s(%s)%s'):format(name, args, returns) diff --git a/server/src/core/hover_name.lua b/server/src/core/hover_name.lua index 5e358820..119a9349 100644 --- a/server/src/core/hover_name.lua +++ b/server/src/core/hover_name.lua @@ -1,14 +1,16 @@ -return function (result, source) - local func = result.value +return function (source) + local value = source:bindValue() + local func = value:getFunction() local declarat - if func:getType() == 'function' then - declarat = func:getDeclarat() or source + if func then + declarat = func.source.name else declarat = source end if not declarat then - return result.key or '' + return source:getName() or '' end + local key if declarat.type == 'name' then key = declarat[1] @@ -16,38 +18,8 @@ return function (result, source) key = ('%q'):format(declarat[1]) elseif declarat.type == 'number' or declarat.type == 'boolean' then key = tostring(declarat[1]) - elseif func:getType() == 'function' then - key = '' - elseif type(result.key) == 'string' then - key = result.key else key = '' end - - local parentName = declarat.parentName - - if not parentName then - return key or '' - end - - if parentName == '?' then - local parentType = result.parentValue and result.parentValue.type - if parentType == 'table' then - else - parentName = '*' .. parentType - end - end - if source.object then - return parentName .. ':' .. key - else - if parentName then - if declarat.index then - return parentName .. '[' .. key .. ']' - else - return parentName .. '.' .. key - end - else - return key - end - end + return key end |