summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-05 16:46:08 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-05 16:46:08 +0800
commitc9b94234048a9608a732e85251757d02fcf19c8a (patch)
treedc95e70c233ab72e46e8bcb1fe7b9d8f6731886e /script
parent2877f084943ba30a9970cbe9a5cb0be844a2ec64 (diff)
downloadlua-language-server-c9b94234048a9608a732e85251757d02fcf19c8a.zip
cleanup
Diffstat (limited to 'script')
-rw-r--r--script/core/diagnostics/init.lua8
-rw-r--r--script/provider/diagnostic.lua53
2 files changed, 7 insertions, 54 deletions
diff --git a/script/core/diagnostics/init.lua b/script/core/diagnostics/init.lua
index 4e2a4976..50233559 100644
--- a/script/core/diagnostics/init.lua
+++ b/script/core/diagnostics/init.lua
@@ -19,7 +19,7 @@ table.sort(diagList, function (a, b)
return (diagSort[a] or 0) < (diagSort[b] or 0)
end)
-local function check(uri, name, results)
+local function check(uri, name, response)
if config.get(uri, 'Lua.diagnostics.disable')[name] then
return
end
@@ -53,7 +53,7 @@ local function check(uri, name, results)
mark[result.start] = true
result.level = severity or result.level
result.code = name
- results[#results+1] = result
+ response(result)
end, name)
local passed = os.clock() - clock
if passed >= 0.5 then
@@ -77,8 +77,6 @@ return function (uri, response)
for _, name in ipairs(diagList) do
await.delay()
- local results = {}
- check(uri, name, results)
- response(results)
+ check(uri, name, response)
end
end
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index 3b99b6b0..30b9cd2f 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -15,7 +15,6 @@ local converter = require 'proto.converter'
local m = {}
m.cache = {}
m.sleepRest = 0.0
-m.coroutineUri = setmetatable({}, { __mode = 'k' })
local function concat(t, sep)
if type(t) ~= 'table' then
@@ -173,18 +172,13 @@ function m.diagnostics(uri, diags)
return
end
- xpcall(core, log.error, uri, function (results)
- if #results == 0 then
- return
- end
- for i = 1, #results do
- diags[#diags+1] = buildDiagnostic(uri, results[i])
- end
+ xpcall(core, log.error, uri, function (result)
+ diags[#diags+1] = buildDiagnostic(uri, result)
end)
end
---@async
-function m.doDiagnostic(uri)
+function m.doDiagnostic(uri, isScopeDiag)
if not config.get(uri, 'Lua.diagnostics.enable') then
return
end
@@ -249,25 +243,8 @@ function m.doDiagnostic(uri)
end
end
- m.coroutineUri[coroutine.running()] = uri
-
- if await.hasID('diagnosticsScope:' .. scp.uri) then
- scp:set('diagStepPush', nil)
- else
- local clock = os.clock()
- scp:set('diagStepPush', function ()
- if os.clock() - clock >= 0.2 then
- pushResult()
- clock = os.clock()
- end
- end)
- end
-
m.diagnostics(uri, diags)
- await.sleep(1.0)
- await.sleep(1.0)
pushResult()
- scp:set('diagStepPush', nil)
end
function m.refresh(uri)
@@ -365,7 +342,7 @@ function m.diagnosticsScope(uri, force)
for i, uri in ipairs(uris) do
bar:setMessage(('%d/%d'):format(i, #uris))
bar:setPercentage(i / #uris * 100)
- xpcall(m.doDiagnostic, log.error, uri)
+ xpcall(m.doDiagnostic, log.error, uri, true)
await.delay()
if cancelled then
log.debug('Break workspace diagnostics')
@@ -377,17 +354,6 @@ function m.diagnosticsScope(uri, force)
end, 'files.version', ('diagnosticsScope:' .. uri))
end
-function m.checkStepResult(uri)
- local scp = ws.getScope(uri)
- if await.hasID('diagnosticsScope:' .. scp.uri) then
- return
- end
- local stepPush = scp:get 'diagStepPush'
- if stepPush then
- stepPush()
- end
-end
-
---@async
function m.checkWorkspaceDiag(uri)
if not await.hasID('diagnosticsScope:' .. uri) then
@@ -440,17 +406,6 @@ files.watch(function (ev, uri) ---@async
end
end)
-await.watch(function (ev, co) ---@async
- if ev == 'delay' then
- local uri = m.coroutineUri[co]
- if not uri then
- return
- end
- m.checkStepResult(uri)
- return m.checkWorkspaceDiag(uri)
- end
-end)
-
config.watch(function (uri, key, value, oldValue)
if key:find 'Lua.diagnostics' then
if value ~= oldValue then