diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-25 18:01:34 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-25 18:01:34 +0800 |
commit | e03f85e6d3efe491b816b12dfd43ade269bc8d59 (patch) | |
tree | 902a83ada3606388472618136ff8e4bbe134fbd0 /server/src/service.lua | |
parent | 2b3fad482ec76d2b63af79c6c9ba8ee62dc6dc3f (diff) | |
download | lua-language-server-e03f85e6d3efe491b816b12dfd43ade269bc8d59.zip |
阻止循环引用
Diffstat (limited to 'server/src/service.lua')
-rw-r--r-- | server/src/service.lua | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/server/src/service.lua b/server/src/service.lua index 7092e84d..3d530e4d 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -143,13 +143,11 @@ function mt:compileAll() local size = 0 local clock = os.clock() for _, uri in ipairs(list) do - self._compiled[uri] = true local obj = self:compileVM(uri) if obj then size = size + #obj.text end end - self._compiled = {} local passed = os.clock() - clock if passed > 0.1 then @@ -172,14 +170,17 @@ function mt:read(mode) return self._input(mode) end -function mt:needCompile(uri) +function mt:needCompile(uri, compiled) if self._needCompile[uri] then return end - if self._compiled[uri] then + if not compiled then + compiled = {} + end + if compiled[uri] then return end - self._needCompile[uri] = true + self._needCompile[uri] = compiled table.insert(self._needCompile, 1, uri) end @@ -230,8 +231,9 @@ function mt:isOpen(uri) end function mt:reCompile() + local compiled = {} for uri in pairs(self._opening) do - self:needCompile(uri) + self:needCompile(uri, compiled) end end @@ -252,7 +254,11 @@ function mt:compileVM(uri) if not self._needCompile[uri] then return nil end - self._needCompile[uri] = nil + local compiled = self._needCompile[uri] + if compiled then + compiled[uri] = true + self._needCompile[uri] = nil + end for i, u in ipairs(self._needCompile) do if u == uri then table.remove(self._needCompile, i) @@ -278,13 +284,16 @@ function mt:compileVM(uri) self._needDiagnostics[uri] = true if obj.child then + if not compiled then + compiled = {} + end local list = {} for child in pairs(obj.child) do list[#list+1] = child end table.sort(list) for _, child in ipairs(list) do - self:needCompile(child) + self:needCompile(child, compiled) end end @@ -379,7 +388,6 @@ return function () _file = {}, _needCompile = {}, _needDiagnostics = {}, - _compiled = {}, _opening = {}, _clock = -100, _version = 0, |