summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-10 18:27:26 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-10 18:27:26 +0800
commit2bef8976c5deed6e0ab00a2ef74cbb24e4b6dd46 (patch)
treecb134343c964d7610b0dac3b856647c683f53321
parent79c87da843cb747db1886e706aa0c22e85e1c46d (diff)
downloadlua-language-server-2bef8976c5deed6e0ab00a2ef74cbb24e4b6dd46.zip
再更细的颗粒上让出
-rw-r--r--script-beta/core/diagnostics/redundant-parameter.lua4
-rw-r--r--script-beta/core/diagnostics/unused-function.lua3
-rw-r--r--script-beta/files.lua6
-rw-r--r--script-beta/proto/proto.lua31
-rw-r--r--script-beta/vm/eachField.lua8
-rw-r--r--script-beta/vm/eachRef.lua7
6 files changed, 36 insertions, 23 deletions
diff --git a/script-beta/core/diagnostics/redundant-parameter.lua b/script-beta/core/diagnostics/redundant-parameter.lua
index 839dd182..b9b994b8 100644
--- a/script-beta/core/diagnostics/redundant-parameter.lua
+++ b/script-beta/core/diagnostics/redundant-parameter.lua
@@ -60,10 +60,6 @@ return function (uri, callback)
return
end
- await.delay(function ()
- return files.globalVersion
- end)
-
local func = source.node
local funcArgs
vm.eachDef(func, function (info)
diff --git a/script-beta/core/diagnostics/unused-function.lua b/script-beta/core/diagnostics/unused-function.lua
index 6c53cdf7..f5a49610 100644
--- a/script-beta/core/diagnostics/unused-function.lua
+++ b/script-beta/core/diagnostics/unused-function.lua
@@ -38,8 +38,5 @@ return function (uri, callback)
message = lang.script.DIAG_UNUSED_FUNCTION,
}
end
- await.delay(function ()
- return files.globalVersion
- end)
end)
end
diff --git a/script-beta/files.lua b/script-beta/files.lua
index 60ff73f9..f344a719 100644
--- a/script-beta/files.lua
+++ b/script-beta/files.lua
@@ -245,8 +245,10 @@ function m.findGlobals(name)
local ast = m.getAst(uri)
if ast then
local globals = vm.getGlobals(ast.ast)
- for name in pairs(globals) do
- file.globals[name] = true
+ if globals then
+ for name in pairs(globals) do
+ file.globals[name] = true
+ end
end
end
end
diff --git a/script-beta/proto/proto.lua b/script-beta/proto/proto.lua
index f3438209..af0515ec 100644
--- a/script-beta/proto/proto.lua
+++ b/script-beta/proto/proto.lua
@@ -91,21 +91,24 @@ function m.doMethod(proto)
end
await.create(function ()
log.debug('Start method:', method)
+ local ok, res, passed
+ local response <close> = util.defer(function ()
+ if passed > 0.2 then
+ log.debug(('Method [%s] takes [%.3f]sec.'):format(method, passed))
+ end
+ log.debug('Finish method:', method)
+ if not proto.id then
+ return
+ end
+ if ok then
+ m.response(proto.id, res)
+ else
+ m.responseErr(proto.id, ErrorCodes.InternalError, res)
+ end
+ end)
local clock = os.clock()
- local ok, res = xpcall(abil, log.error, proto.params)
- local passed = os.clock() - clock
- if passed > 0.2 then
- log.debug(('Method [%s] takes [%.3f]sec.'):format(method, passed))
- end
- log.debug('Finish method:', method)
- if not proto.id then
- return
- end
- if ok then
- m.response(proto.id, res)
- else
- m.responseErr(proto.id, ErrorCodes.InternalError, res)
- end
+ ok, res = xpcall(abil, log.error, proto.params)
+ passed = os.clock() - clock
end)
end
diff --git a/script-beta/vm/eachField.lua b/script-beta/vm/eachField.lua
index a707407e..16f13d64 100644
--- a/script-beta/vm/eachField.lua
+++ b/script-beta/vm/eachField.lua
@@ -1,5 +1,7 @@
local guide = require 'parser.guide'
local vm = require 'vm.vm'
+local files = require 'files'
+local await = require 'await'
local function ofTabel(value, callback)
if value.library then
@@ -145,6 +147,9 @@ end
function vm.eachField(source, callback)
local cache = vm.cache.eachField[source]
if cache then
+ await.delay(function ()
+ return files.globalVersion
+ end)
for i = 1, #cache do
local res = callback(cache[i])
if res ~= nil then
@@ -173,6 +178,9 @@ function vm.eachField(source, callback)
local src = info.source
vm.cache.eachField[src] = cache
end)
+ await.delay(function ()
+ return files.globalVersion
+ end)
for i = 1, #cache do
local res = callback(cache[i])
if res ~= nil then
diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua
index 4f653e00..8a8e4818 100644
--- a/script-beta/vm/eachRef.lua
+++ b/script-beta/vm/eachRef.lua
@@ -2,6 +2,7 @@ local guide = require 'parser.guide'
local files = require 'files'
local vm = require 'vm.vm'
local library = require 'library'
+local await = require 'await'
local function ofCall(func, index, callback, offset)
offset = offset or 0
@@ -542,6 +543,9 @@ end
function vm.eachRef(source, callback, max)
local cache = vm.cache.eachRef[source]
if cache then
+ await.delay(function ()
+ return files.globalVersion
+ end)
if max then
if max > #cache then
max = #cache
@@ -577,6 +581,9 @@ function vm.eachRef(source, callback, max)
local src = cache[i].source
vm.cache.eachRef[src] = cache
end
+ await.delay(function ()
+ return files.globalVersion
+ end)
if max then
if max > #cache then
max = #cache