diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-28 16:57:46 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-28 16:57:46 +0800 |
commit | ebdfb86387f51fd29ec37b6ca586a062b086f525 (patch) | |
tree | e7f84d82687c544f14ea484c067fa561f59672bf /server/src/core/hover.lua | |
parent | 08ad84a4f6c579a12e7a7e92d438f60c5c360044 (diff) | |
download | lua-language-server-ebdfb86387f51fd29ec37b6ca586a062b086f525.zip |
支持部分函数写法
Diffstat (limited to 'server/src/core/hover.lua')
-rw-r--r-- | server/src/core/hover.lua | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/server/src/core/hover.lua b/server/src/core/hover.lua index 627a64f5..ea22f1be 100644 --- a/server/src/core/hover.lua +++ b/server/src/core/hover.lua @@ -1,5 +1,6 @@ local findLib = require 'core.find_lib' local getFunctionHover = require 'core.hover_function' +local buildValueName = require 'core.hover_name' local OriginTypes = { ['any'] = true, @@ -171,55 +172,6 @@ local function buildEnum(lib) return table.concat(strs) end -local function buildValueName(result, source) - local func = result.value - local declarat = func.declarat or source - if declarat then - local key - if declarat.type == 'name' then - key = declarat[1] - elseif declarat.type == 'string' then - key = ('%q'):format(declarat[1]) - elseif declarat.type == 'number' or declarat.type == 'boolean' then - key = tostring(declarat[1]) - elseif func.type == '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 - end - return result.key or '' -end - local function getFunctionHoverAsLib(name, lib, oo, select) local args, argLabel = buildLibArgs(lib, oo, select) local returns = buildLibReturns(lib) @@ -400,7 +352,7 @@ return function (result, source, lsp, select) if lib then hover = getFunctionHoverAsLib(name, lib, oo, select) else - hover = getFunctionHover(name, result.value, source, select) + hover = getFunctionHover(name, result.value, source.object, select) end else hover = getValueHover(name, valueType, result, source, lib) |