summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/matcher/vm.lua3
-rw-r--r--server/src/service.lua41
-rw-r--r--server/test/crossfile/init.lua2
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'