summaryrefslogtreecommitdiff
path: root/server/src/core/hover_name.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-08 13:58:50 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-08 13:58:50 +0800
commit82e718114a22193d586f9aaca30777bae20708e5 (patch)
tree3328667ca982f45117efa06ad5d39ee28626cc66 /server/src/core/hover_name.lua
parent94a2a89a87e7851c0336b1963fc1aa5afd988126 (diff)
downloadlua-language-server-82e718114a22193d586f9aaca30777bae20708e5.zip
只有function会使用定义时的名字
Diffstat (limited to 'server/src/core/hover_name.lua')
-rw-r--r--server/src/core/hover_name.lua80
1 files changed, 42 insertions, 38 deletions
diff --git a/server/src/core/hover_name.lua b/server/src/core/hover_name.lua
index d8e7b043..d8afe2fc 100644
--- a/server/src/core/hover_name.lua
+++ b/server/src/core/hover_name.lua
@@ -1,49 +1,53 @@
-
return function (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 declarat
+ if func.type == 'function' then
+ declarat = func.declarat or source
+ else
+ declarat = source
+ end
+ if not declarat then
+ return result.key or ''
+ end
+ 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
+ local parentName = declarat.parentName
- if not parentName then
- return key or ''
- end
+ 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
+ if parentName == '?' then
+ local parentType = result.parentValue and result.parentValue.type
+ if parentType == 'table' then
else
- if parentName then
- if declarat.index then
- return parentName .. '[' .. key .. ']'
- else
- return parentName .. '.' .. key
- end
+ parentName = '*' .. parentType
+ end
+ end
+ if source.object then
+ return parentName .. ':' .. key
+ else
+ if parentName then
+ if declarat.index then
+ return parentName .. '[' .. key .. ']'
else
- return key
+ return parentName .. '.' .. key
end
+ else
+ return key
end
end
- return result.key or ''
end