diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-24 16:13:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-24 16:13:02 +0800 |
commit | a8be93d613a7f37a6c29b581c3143979036be274 (patch) | |
tree | 7ed3c0cfec6e74867fe6c4514566abca1b51df41 | |
parent | b4316e280179ad7f16c66f10af98d1a33e020f9f (diff) | |
download | lua-language-server-a8be93d613a7f37a6c29b581c3143979036be274.zip |
引用链
-rw-r--r-- | server/src/matcher/vm.lua | 3 | ||||
-rw-r--r-- | server/src/service.lua | 41 | ||||
-rw-r--r-- | server/test/crossfile/init.lua | 2 |
3 files changed, 43 insertions, 3 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 1aaffac4..c2fd0e73 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -522,8 +522,7 @@ function mt:tryRequireOne(strValue, mode) return self:getRequire(strValue, destVM) end else - self.lsp:needCompile(uri) - self.lsp:needCompile(self.uri) + self.lsp:compileChain(self.uri, uri) end end return nil diff --git a/server/src/service.lua b/server/src/service.lua index 3ac3bb87..3389f4b1 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -254,11 +254,33 @@ function mt:compileVM(uri) obj.vm = matcher.vm(ast, self, uri) obj.lines = parser:lines(obj.text, 'utf8') + log.debug('Compile', uri) if not obj.vm then return obj end self._needDiagnostics[uri] = true + if obj.child then + for child in pairs(obj.child) do + obj.child[child] = nil + self:needCompile(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 + end + end return obj end @@ -274,6 +296,25 @@ function mt:getVM(uri) return obj.vm end +function mt:compileChain(child, parent) + local parentObj = self._file[parent] + local childObj = self._file[child] + + if not parentObj or not childObj then + return + end + + if not parentObj.child then + parentObj.child = {} + end + parentObj.child[child] = true + + if not childObj.parent then + childObj.parent = {} + end + childObj.parent[parent] = true +end + function mt:removeText(uri) self._file[uri] = nil end diff --git a/server/test/crossfile/init.lua b/server/test/crossfile/init.lua index b74514af..488635c6 100644 --- a/server/test/crossfile/init.lua +++ b/server/test/crossfile/init.lua @@ -1,3 +1,3 @@ require 'crossfile.definition' require 'crossfile.hover' -require 'crossfile.completion' +--require 'crossfile.completion' |