diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-24 17:20:26 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-24 17:20:26 +0800 |
commit | ceb30f6413cf1132ab7fb20355aa4f5a61edc7b6 (patch) | |
tree | 00b08302aad5f3e1b05d6c2e2b22e09be86aee95 /server/src/core/hover.lua | |
parent | fb736f9479b66838da46fc4c002360a1a90761a4 (diff) | |
download | lua-language-server-ceb30f6413cf1132ab7fb20355aa4f5a61edc7b6.zip |
整理代码
Diffstat (limited to 'server/src/core/hover.lua')
-rw-r--r-- | server/src/core/hover.lua | 12 |
1 files changed, 6 insertions, 6 deletions
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 |