From 9bee0cdec02c07fb5b78d3781b912b9e193f0dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 28 Jan 2019 15:39:33 +0800 Subject: =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=8E=92=E5=BA=8F=E8=A1=A8=E7=9A=84h?= =?UTF-8?q?over?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/hover.lua | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'server/src/core/hover.lua') 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 -- cgit v1.2.3