diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-05 16:46:08 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-05 16:46:08 +0800 |
commit | c9b94234048a9608a732e85251757d02fcf19c8a (patch) | |
tree | dc95e70c233ab72e46e8bcb1fe7b9d8f6731886e /script/provider | |
parent | 2877f084943ba30a9970cbe9a5cb0be844a2ec64 (diff) | |
download | lua-language-server-c9b94234048a9608a732e85251757d02fcf19c8a.zip |
cleanup
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/diagnostic.lua | 53 |
1 files changed, 4 insertions, 49 deletions
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 |