diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-25 17:47:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-25 17:47:55 +0800 |
commit | 2b3fad482ec76d2b63af79c6c9ba8ee62dc6dc3f (patch) | |
tree | 39b6ec7242957d9beb481c2104b7e056efab38cf /server/src/service.lua | |
parent | f74154aac067a7c9e2e4f302d69be4193a960b04 (diff) | |
download | lua-language-server-2b3fad482ec76d2b63af79c6c9ba8ee62dc6dc3f.zip |
用引用链
Diffstat (limited to 'server/src/service.lua')
-rw-r--r-- | server/src/service.lua | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/server/src/service.lua b/server/src/service.lua index 21bb6015..7092e84d 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -143,9 +143,14 @@ 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) - size = size + #obj.text + if obj then + size = size + #obj.text + end end + self._compiled = {} + local passed = os.clock() - clock if passed > 0.1 then log.debug(('\n\z @@ -171,6 +176,9 @@ function mt:needCompile(uri) if self._needCompile[uri] then return end + if self._compiled[uri] then + return + end self._needCompile[uri] = true table.insert(self._needCompile, 1, uri) end @@ -253,6 +261,15 @@ function mt:compileVM(uri) end local ast = parser:ast(obj.text) + -- 编译前清除节点信息 + if obj.parent then + for pUri in pairs(obj.parent) do + local parent = self._file[pUri] + if parent and parent.child then + parent.child[uri] = nil + end + end + end obj.vm = matcher.vm(ast, self, uri) obj.lines = parser:lines(obj.text, 'utf8') if not obj.vm then @@ -261,24 +278,13 @@ function mt:compileVM(uri) self._needDiagnostics[uri] = true if obj.child then + local list = {} for child in pairs(obj.child) do - obj.child[child] = nil - self:needCompile(child) + list[#list+1] = child end - obj.child = nil - end - - if obj.parent then - local hasParent - for parent in pairs(obj.parent) do - if self:getVM(parent) then - obj.parent[parent] = nil - else - hasParent = true - end - end - if not hasParent then - obj.parent = nil + table.sort(list) + for _, child in ipairs(list) do + self:needCompile(child) end end @@ -290,9 +296,6 @@ function mt:getVM(uri) if not obj then return nil end - if self._needCompile[uri] then - return nil - end return obj.vm end @@ -376,8 +379,10 @@ return function () _file = {}, _needCompile = {}, _needDiagnostics = {}, + _compiled = {}, _opening = {}, _clock = -100, + _version = 0, }, mt) return session end |