summaryrefslogtreecommitdiff
path: root/server/src/core/hover.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-28 15:39:33 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-28 15:39:33 +0800
commit9bee0cdec02c07fb5b78d3781b912b9e193f0dbd (patch)
tree8d0cbffc70ab68a420652ed74a61cb37b89499dc /server/src/core/hover.lua
parentf72976a6fa20549afe91cdb8740d6bc59332ee92 (diff)
downloadlua-language-server-9bee0cdec02c07fb5b78d3781b912b9e193f0dbd.zip
重新排序表的hover
Diffstat (limited to 'server/src/core/hover.lua')
-rw-r--r--server/src/core/hover.lua32
1 files changed, 18 insertions, 14 deletions
diff --git a/server/src/core/hover.lua b/server/src/core/hover.lua
index be60d590..7ee8c5bf 100644
--- a/server/src/core/hover.lua
+++ b/server/src/core/hover.lua
@@ -248,35 +248,39 @@ local function findClass(result)
end
local function unpackTable(result)
- local child = result.value and result.value.child
- if not child then
- return '{}'
- end
- local lines = {'{'}
- for key, field in pairs(child) do
+ local lines = {}
+ result.value:eachField(function (key, field)
local kType = type(key)
if kType == 'table' then
- key = ('[*%s]'):format(key.type)
- else
- if kType ~= 'string' then
- key = ('[%s]'):format(key)
- end
+ key = ('[*%s]'):format(key:getType())
+ elseif math.type(key) == 'integer' then
+ key = ('[%03d]'):format(key)
+ elseif kType ~= 'string' then
+ key = ('[%s]'):format(key)
end
local value = field.value
if not value then
- lines[#lines+1] = (' %s: %s,'):format(key, 'any')
+ local str = (' %s: %s,'):format(key, 'any')
+ lines[#lines+1] = str
goto CONTINUE
end
local vType = type(value:getValue())
if vType == 'boolean' or vType == 'integer' or vType == 'number' or vType == 'string' then
- lines[#lines+1] = (' %s: %s = %q,'):format(key, value:getType(), value:getValue())
+ local str = (' %s: %s = %q,'):format(key, value:getType(), value:getValue())
+ lines[#lines+1] = str
else
- lines[#lines+1] = (' %s: %s,'):format(key, value:getType())
+ local str = (' %s: %s,'):format(key, value:getType())
+ lines[#lines+1] = str
end
::CONTINUE::
+ end)
+ if #lines == 0 then
+ return '{}'
end
+ table.sort(lines)
+ table.insert(lines, 1, '{')
lines[#lines+1] = '}'
return table.concat(lines, '\r\n')
end