summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-20 23:11:18 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-20 23:11:18 +0800
commit829dcb1964491f1e10afa73a4f8444cdbc487a9f (patch)
treec373da7f6c19b3fa11c23ed2d8987dbff804c2f3
parent08d38c50e06663622264ae8c64bc8dd2092f63e1 (diff)
downloadlua-language-server-829dcb1964491f1e10afa73a4f8444cdbc487a9f.zip
hover of table fields use doc first
-rw-r--r--script/core/hover/table.lua23
-rw-r--r--test/hover/init.lua20
2 files changed, 23 insertions, 20 deletions
diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua
index 02be5271..f26731be 100644
--- a/script/core/hover/table.lua
+++ b/script/core/hover/table.lua
@@ -32,7 +32,20 @@ local function getKey(src)
return ('[%s]'):format(key)
end
+local function getFieldFull(src)
+ local tp = vm.getInferType(src)
+ --local class = vm.getClass(src)
+ local literal = vm.getInferLiteral(src)
+ if type(literal) == 'string' and #literal >= 50 then
+ literal = literal:sub(1, 47) .. '...'
+ end
+ return tp, literal
+end
+
local function getFieldFast(src)
+ if src.bindDocs then
+ return getFieldFull(src)
+ end
local value = guide.getObjectValue(src) or src
if not value then
return 'any'
@@ -63,16 +76,6 @@ local function getFieldFast(src)
end
end
-local function getFieldFull(src)
- local tp = vm.getInferType(src)
- --local class = vm.getClass(src)
- local literal = vm.getInferLiteral(src)
- if type(literal) == 'string' and #literal >= 50 then
- literal = literal:sub(1, 47) .. '...'
- end
- return tp, literal
-end
-
local function getField(src, timeUp, mark, key)
if src.type == 'table'
or src.type == 'function' then
diff --git a/test/hover/init.lua b/test/hover/init.lua
index cb7d49f3..839c9311 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -793,27 +793,27 @@ TEST [[
]]
[[
global _G: _G {
- _G: table,
+ _G: _G,
_VERSION: string = "Lua 5.4",
arg: table,
assert: function,
- bit32: table,
+ bit32: bit32*,
collectgarbage: function,
- coroutine: table,
- debug: table,
+ coroutine: coroutine*,
+ debug: debug*,
dofile: function,
error: function,
getfenv: function,
getmetatable: function,
- io: table,
+ io: io*,
ipairs: function,
load: function,
loadfile: function,
loadstring: function,
- math: table,
+ math: math*,
module: function,
next: function,
- os: table,
+ os: os*,
package: table,
pairs: function,
pcall: function,
@@ -826,13 +826,13 @@ global _G: _G {
select: function,
setfenv: function,
setmetatable: function,
- string: table,
- table: table,
+ string: string*,
+ table: table*,
tonumber: function,
tostring: function,
type: function,
unpack: function,
- utf8: table,
+ utf8: utf8*,
warn: function,
xpcall: function,
}