diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-01-09 15:15:04 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-01-09 15:15:04 +0800 |
commit | fcafaa21f8df0423568ac67fe1c6159f6aa69173 (patch) | |
tree | 2b134ccc4d4771c82d8268b2900dad2af50e4739 /script/vm/global.lua | |
parent | 805231111f765978985a4888d9c43e973dce87ee (diff) | |
download | lua-language-server-fcafaa21f8df0423568ac67fe1c6159f6aa69173.zip |
cleanup
Diffstat (limited to 'script/vm/global.lua')
-rw-r--r-- | script/vm/global.lua | 71 |
1 files changed, 3 insertions, 68 deletions
diff --git a/script/vm/global.lua b/script/vm/global.lua index cc206b52..577a12b2 100644 --- a/script/vm/global.lua +++ b/script/vm/global.lua @@ -8,6 +8,7 @@ local vm = require 'vm.vm' ---@class parser.object ---@field package _globalBase parser.object ---@field package _globalBaseMap table<string, parser.object> +---@field global vm.global ---@class vm.global.link ---@field sets parser.object[] @@ -518,75 +519,8 @@ function vm.compileByGlobal(source) if not globalBase then return end - local globalNode = vm.getNode(source._globalBase) - if globalNode then - vm.setNode(source, globalNode, true) - return - end - local uri = guide.getUri(source) - ---@type vm.node - globalNode = vm.createNode(global) - vm.setNode(globalBase, globalNode, true) + local globalNode = vm.compileNode(globalBase) vm.setNode(source, globalNode, true) - - -- TODO:don't mix - --local sets = global.links[uri].sets or {} - --local gets = global.links[uri].gets or {} - --for _, set in ipairs(sets) do - -- vm.setNode(set, globalNode, true) - --end - --for _, get in ipairs(gets) do - -- vm.setNode(get, globalNode, true) - --end - - if global.cate == 'variable' then - local hasMarkDoc - for _, set in ipairs(global:getSets(uri)) do - if set.bindDocs and set.parent.type == 'main' then - if vm.bindDocs(set) then - globalNode:merge(vm.compileNode(set)) - hasMarkDoc = true - end - if vm.getNode(set) then - globalNode:merge(vm.compileNode(set)) - end - end - end - -- Set all globals node first to avoid recursive - for _, set in ipairs(global:getSets(uri)) do - vm.setNode(set, globalNode, true) - end - for _, set in ipairs(global:getSets(uri)) do - if set.value and set.value.type ~= 'nil' and set.parent.type == 'main' then - if not hasMarkDoc or guide.isLiteral(set.value) then - globalNode:merge(vm.compileNode(set.value)) - end - end - end - for _, set in ipairs(global:getSets(uri)) do - vm.setNode(set, globalNode, true) - end - end - if global.cate == 'type' then - for _, set in ipairs(global:getSets(uri)) do - if set.type == 'doc.class' then - if set.extends then - for _, ext in ipairs(set.extends) do - if ext.type == 'doc.type.table' then - if not vm.getGeneric(ext) then - globalNode:merge(vm.compileNode(ext)) - end - end - end - end - end - if set.type == 'doc.alias' then - if not vm.getGeneric(set.extends) then - globalNode:merge(vm.compileNode(set.extends)) - end - end - end - end end ---@param source parser.object @@ -609,6 +543,7 @@ function vm.getGlobalBase(source) root._globalBaseMap[name] = { type = 'globalbase', parent = root, + global = global, } end source._globalBase = root._globalBaseMap[name] |