summaryrefslogtreecommitdiff
path: root/server/src/core/hover.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-28 16:57:46 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-28 16:57:46 +0800
commitebdfb86387f51fd29ec37b6ca586a062b086f525 (patch)
treee7f84d82687c544f14ea484c067fa561f59672bf /server/src/core/hover.lua
parent08ad84a4f6c579a12e7a7e92d438f60c5c360044 (diff)
downloadlua-language-server-ebdfb86387f51fd29ec37b6ca586a062b086f525.zip
支持部分函数写法
Diffstat (limited to 'server/src/core/hover.lua')
-rw-r--r--server/src/core/hover.lua52
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)