summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/core/hover.lua32
-rw-r--r--server/test/hover/init.lua10
2 files changed, 23 insertions, 19 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
diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua
index 159264db..a0a8475f 100644
--- a/server/test/hover/init.lua
+++ b/server/test/hover/init.lua
@@ -285,12 +285,12 @@ local <?t?> = {
]]
[[
local t: {
- a: number = 1,
- [1]: number = 2,
- [true]: number = 3,
- [5.5]: number = 4,
- [*table]: number = 5,
[*function]: number = 6,
+ [*table]: number = 5,
+ [001]: number = 2,
+ [5.5]: number = 4,
+ [true]: number = 3,
+ a: number = 1,
}
]]