From ceb30f6413cf1132ab7fb20355aa4f5a61edc7b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 24 Jan 2019 17:20:26 +0800 Subject: =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/hover.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'server/src/core/hover.lua') diff --git a/server/src/core/hover.lua b/server/src/core/hover.lua index b40c6fa4..7c3623fd 100644 --- a/server/src/core/hover.lua +++ b/server/src/core/hover.lua @@ -212,19 +212,19 @@ end local function findClass(result) -- 根据部分字段尝试找出自定义类型 local metatable = result.value.metatable - if not metatable or not metatable.child then + if not metatable then return nil end -- 查找meta表的 __name 字段 - local name = metatable.child['__name'] + local name = metatable:rawGetField('__name') -- 值必须是字符串 if name and name.value and type(name.value.value) == 'string' then return name.value.value end -- 查找meta表 __index 里的字段 - local index = metatable.child['__index'] - if index and index.value and index.value.child then - for key, field in pairs(index.value.child) do + local index = metatable:rawGetField('__index') + if index and index.value then + index.value:eachField(function (key, field) -- 键值类型必须均为字符串 if type(key) ~= 'string' then goto CONTINUE @@ -247,7 +247,7 @@ local function findClass(result) return field.value.value end ::CONTINUE:: - end + end) end return nil end -- cgit v1.2.3