summaryrefslogtreecommitdiff
path: root/script/vm/compiler.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-23 03:32:57 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-23 03:32:57 +0800
commit420812ce4e77ff4143437b2893dd77fc729c7622 (patch)
tree92293fc9ab871147060130e432819ea3c3e6f6b9 /script/vm/compiler.lua
parent838ce36fdd7abdff0b4cab5e67c2500325178805 (diff)
downloadlua-language-server-420812ce4e77ff4143437b2893dd77fc729c7622.zip
update
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r--script/vm/compiler.lua23
1 files changed, 20 insertions, 3 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 27ba6273..70a4ea92 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -253,7 +253,11 @@ local searchFieldSwitch = util.switch()
end
end)
-
+---@param suri uri
+---@param object vm.global
+---@param key string|vm.global
+---@param ref boolean
+---@param pushResult fun(field: vm.object, isMark?: boolean)
function vm.getClassFields(suri, object, key, ref, pushResult)
local mark = {}
@@ -376,7 +380,7 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
for _, set in ipairs(sets) do
pushResult(set)
end
- else
+ elseif type(key) == 'string' then
local global = vm.getGlobal('variable', key)
if global then
for _, set in ipairs(global:getSets(suri)) do
@@ -677,7 +681,7 @@ local function bindAs(source)
end
---@param source vm.node
----@param key? any
+---@param key? string|vm.global
---@param pushResult fun(source: parser.object)
function vm.compileByParentNode(source, key, ref, pushResult)
local parentNode = vm.compileNode(source)
@@ -1380,12 +1384,25 @@ local compilerSwitch = util.switch()
return
end
if type(key) == 'table' then
+ ---@cast key vm.node
local uri = guide.getUri(source)
local value = vm.getTableValue(uri, vm.compileNode(source.node), key)
if value then
vm.setNode(source, value):removeOptional()
end
+ for k in key:eachObject() do
+ if k.type == 'global' and k.cate == 'type' then
+ ---@cast k vm.global
+ vm.compileByParentNode(source.node, k, false, function (src)
+ vm.setNode(source, vm.compileNode(src))
+ if src.value then
+ vm.setNode(source, vm.compileNode(src.value)):removeOptional()
+ end
+ end)
+ end
+ end
else
+ ---@cast key string
vm.compileByParentNode(source.node, key, false, function (src)
vm.setNode(source, vm.compileNode(src))
if src.value then