diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-15 18:35:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-15 18:36:33 +0800 |
commit | 54e6260b2ac36c4653a30ed5ab5e17d3e7f0abd9 (patch) | |
tree | 33b7e73feb95c8a4f810d9c5680ea4e3d0f54ec6 /script | |
parent | 251f743d8c78b2de2bad2e77657dc35bd6733d67 (diff) | |
download | lua-language-server-54e6260b2ac36c4653a30ed5ab5e17d3e7f0abd9.zip |
improve performance
Diffstat (limited to 'script')
-rw-r--r-- | script/parser/guide.lua | 2 | ||||
-rw-r--r-- | script/vm/compiler.lua | 25 |
2 files changed, 21 insertions, 6 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua index c0f33c28..884a5271 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -966,8 +966,6 @@ function m.getKeyName(obj) return obj[1] elseif tp == 'doc.type.field' then return obj.name[1] - elseif tp == 'dummy' then - return obj[1] end return m.getKeyNameOfLiteral(obj) end diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 7b6531aa..69b1ac25 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -246,9 +246,18 @@ function vm.getClassFields(suri, node, key, pushResult) local function searchGlobal(class) if class.cate == 'type' and class.name == '_G' then - local sets = globalMgr.getGlobalSets(suri, 'variable') - for _, set in ipairs(sets) do - pushResult(set) + if key == nil then + local sets = globalMgr.getGlobalSets(suri, 'variable') + for _, set in ipairs(sets) do + pushResult(set) + end + else + local global = globalMgr.getGlobal('variable', key) + if global then + for _, set in ipairs(global:getSets(suri)) do + pushResult(set) + end + end end end end @@ -1599,7 +1608,15 @@ local function compileByGlobal(source) end globalNode = vm.createNode(global) vm.setNode(root._globalBase[name], globalNode, true) - vm.setNode(source, globalNode, true) + + 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 |