summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-20 18:13:47 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-20 18:13:47 +0800
commit0cb5fa988d6030f926781ddb3facfd18df00ec14 (patch)
treea2d6656d3ad042b64a42601800b2c6cb31a03efa
parentd272b846c73c2f6a4709d7a51645eadccde27ea8 (diff)
downloadlua-language-server-0cb5fa988d6030f926781ddb3facfd18df00ec14.zip
分步合并require
-rw-r--r--server/src/matcher/vm.lua18
-rw-r--r--server/src/service.lua2
2 files changed, 10 insertions, 10 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 1891b61b..13a04e87 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -1189,13 +1189,13 @@ function mt:loadRequires()
if not self.lsp or not self.lsp.workspace then
return
end
- for value, str in ipairs(self.requires) do
+ for value, str in pairs(self.requires) do
self.requires[value] = nil
if type(str) == 'string' then
- local uri = lsp.workspace:searchPath(str)
+ local uri = self.lsp.workspace:searchPath(str)
-- 如果循环require,这里会返回nil
-- 会当场编译VM
- local destVM = lsp:loadVM(uri)
+ local destVM = self.lsp:loadVM(uri)
if destVM then
self:mergeRequire(value, destVM)
end
@@ -1207,14 +1207,14 @@ function mt:tryLoadRequires()
if not self.lsp or not self.lsp.workspace then
return
end
- for value, str in ipairs(self.requires) do
- self.requires[value] = nil
+ for value, str in pairs(self.requires) do
if type(str) == 'string' then
- local uri = lsp.workspace:searchPath(str)
- -- 如果取不到VM,则做个标记,之后再取一次
- local destVM = lsp:getVM(uri)
+ local uri = self.lsp.workspace:searchPath(str)
+ -- 如果取不到VM(不编译),则做个标记,之后再取一次
+ local destVM = self.lsp:getVM(uri)
if destVM then
self:mergeRequire(value, destVM)
+ self.requires[value] = nil
else
self.lsp:needRequires(self.uri)
end
@@ -1252,7 +1252,7 @@ local function compile(ast, lsp, uri)
vm:doActions(ast)
-- 合并
- vm:loadRequires()
+ vm:tryLoadRequires()
return vm
end
diff --git a/server/src/service.lua b/server/src/service.lua
index 43b59d52..12a6ed25 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -280,7 +280,7 @@ function mt:_loadRequires()
for uri in pairs(copy) do
local obj = self._file[uri]
if obj then
- obj.vm:loadRequires(self)
+ obj.vm:loadRequires()
self._needDiagnostics[uri] = true
end
end