summaryrefslogtreecommitdiff
path: root/script-beta/vm/getClass.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-05-29 19:49:44 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-05-29 19:49:44 +0800
commit5ad119e5848e3878ed37f58f71750bc4a17720a5 (patch)
tree3283a98acfe45dcedf5dd6e1720272d05b6a009c /script-beta/vm/getClass.lua
parent35e15270a0b79e7162de78e328496e2274efedd2 (diff)
downloadlua-language-server-5ad119e5848e3878ed37f58f71750bc4a17720a5.zip
更新 hover
Diffstat (limited to 'script-beta/vm/getClass.lua')
-rw-r--r--script-beta/vm/getClass.lua33
1 files changed, 7 insertions, 26 deletions
diff --git a/script-beta/vm/getClass.lua b/script-beta/vm/getClass.lua
index 4d7ef69c..309a7693 100644
--- a/script-beta/vm/getClass.lua
+++ b/script-beta/vm/getClass.lua
@@ -1,10 +1,12 @@
-local vm = require 'vm.vm'
+local vm = require 'vm.vm'
+local guide = require 'parser.guide'
local function getClass(source, classes, deep)
if deep > 3 then
return
end
- vm.eachField(source, function (src)
+ local value = guide.getObjectValue(source) or source
+ vm.eachField(value, function (src)
local key = vm.getKeyName(src)
if not key then
return
@@ -14,39 +16,18 @@ local function getClass(source, classes, deep)
or lkey == 's|__name'
or lkey == 's|name'
or lkey == 's|class' then
- if src.value and src.value.type == 'string' then
- classes[#classes+1] = src.value[1]
+ local value = guide.getObjectValue(src)
+ if value and value.type == 'string' then
+ classes[#classes+1] = value[1]
end
end
end)
- if source.value then
- vm.eachField(source.value, function (src)
- local key = vm.getKeyName(src)
- if not key then
- return
- end
- local lkey = key:lower()
- if lkey == 's|type'
- or lkey == 's|__name'
- or lkey == 's|name'
- or lkey == 's|class' then
- if src.value and src.value.type == 'string' then
- classes[#classes+1] = src.value[1]
- end
- end
- end)
- end
if #classes ~= 0 then
return
end
vm.eachMeta(source, function (mt)
getClass(mt, classes, deep + 1)
end)
- if source.value then
- vm.eachMeta(source.value, function (mt)
- getClass(mt, classes, deep + 1)
- end)
- end
end
function vm.getClass(source)