diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-12-08 21:45:31 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-12-08 21:45:31 +0800 |
commit | 2e15bfac358e80df819354f0e2a2ba12cc9c93cc (patch) | |
tree | 116013a37e4882123d04c48241ca851e9c5db44e /script/vm | |
parent | f3ad9225ae04dae2f9ee295709fc623587b1b4e8 (diff) | |
download | lua-language-server-2e15bfac358e80df819354f0e2a2ba12cc9c93cc.zip |
cleanup
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/global.lua | 50 | ||||
-rw-r--r-- | script/vm/ref.lua | 6 |
2 files changed, 2 insertions, 54 deletions
diff --git a/script/vm/global.lua b/script/vm/global.lua index 37b54349..15c52b44 100644 --- a/script/vm/global.lua +++ b/script/vm/global.lua @@ -7,7 +7,6 @@ local ws = require 'workspace' local vm = require 'vm.vm' ---@class vm.global.link ----@field gets parser.object[] ---@field sets parser.object[] ---@class vm.global @@ -31,20 +30,6 @@ function mt:addSet(uri, source) self.setsCache = nil end ----@param uri uri ----@param source parser.object -function mt:addGet(uri, source) - if PREVIEW then - return - end - local link = self.links[uri] - if not link.gets then - link.gets = {} - end - link.gets[#link.gets+1] = source - self.getsCache = nil -end - ---@param suri uri ---@return parser.object[] function mt:getSets(suri) @@ -96,35 +81,6 @@ function mt:getAllSets() return cache end ----@return parser.object[] -function mt:getGets(suri) - if not self.getsCache then - self.getsCache = {} - end - local scp = scope.getScope(suri) - local cacheUri = scp.uri or '<callback>' - if self.getsCache[cacheUri] then - return self.getsCache[cacheUri] - end - local clock = os.clock() - self.getsCache[cacheUri] = {} - local cache = self.getsCache[cacheUri] - for uri, link in pairs(self.links) do - if link.gets then - if scp:isVisible(uri) then - for _, source in ipairs(link.gets) do - cache[#cache+1] = source - end - end - end - end - local cost = os.clock() - clock - if cost > 0.1 then - log.warn('global-manager getGets costs', cost, self.name) - end - return cache -end - ---@param uri uri function mt:dropUri(uri) self.links[uri] = nil @@ -218,7 +174,6 @@ local compilerGlobalSwitch = util.switch() return end local global = vm.declareGlobal('variable', name, uri) - global:addGet(uri, source) source._globalNode = global local nxt = source.next @@ -276,7 +231,6 @@ local compilerGlobalSwitch = util.switch() end local uri = guide.getUri(source) local global = vm.declareGlobal('variable', name, uri) - global:addGet(uri, source) source._globalNode = global local nxt = source.next @@ -301,8 +255,6 @@ local compilerGlobalSwitch = util.switch() if source.node.special == 'rawset' then global:addSet(uri, source) source.value = source.args[3] - else - global:addGet(uri, source) end source._globalNode = global @@ -401,7 +353,6 @@ local compilerGlobalSwitch = util.switch() return end local type = vm.declareGlobal('type', name, uri) - type:addGet(uri, source) source._globalNode = type end) : case 'doc.extends.name' @@ -409,7 +360,6 @@ local compilerGlobalSwitch = util.switch() local uri = guide.getUri(source) local name = source[1] local class = vm.declareGlobal('type', name, uri) - class:addGet(uri, source) source._globalNode = class end) diff --git a/script/vm/ref.lua b/script/vm/ref.lua index 1ed176c9..2740666b 100644 --- a/script/vm/ref.lua +++ b/script/vm/ref.lua @@ -97,7 +97,7 @@ local function searchWord(source, pushResult, defMap, fileNotify) if global then local globalName = global:asKeyName() ---@async - guide.eachSourceTypes(state.ast, {'getglobal', 'setglobal', 'setfield', 'getfield', 'setmethod', 'getmethod', 'setindex', 'getindex', 'doc.type.name', 'doc.class.name', 'doc.alias.name'}, function (src) + guide.eachSourceTypes(state.ast, {'getglobal', 'setglobal', 'setfield', 'getfield', 'setmethod', 'getmethod', 'setindex', 'getindex', 'doc.type.name', 'doc.class.name', 'doc.alias.name', 'doc.extends.name'}, function (src) local myGlobal = vm.getGlobalNode(src) if myGlobal and myGlobal:asKeyName() == globalName then pushResult(src) @@ -207,6 +207,7 @@ local nodeSwitch = util.switch() : case 'doc.class' : case 'doc.enum' : case 'doc.type.name' + : case 'doc.extends.name' ---@async : call(function (source, pushResult, defMap, fileNotify) searchWord(source, pushResult, defMap, fileNotify) @@ -264,9 +265,6 @@ local function searchByGlobal(source, pushResult) for _, set in ipairs(node:getSets(uri)) do pushResult(set) end - for _, get in ipairs(node:getGets(uri)) do - pushResult(get) - end end local function searchByDef(source, pushResult) |