diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-09 19:05:58 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-02-09 19:05:58 +0800 |
commit | 3f0d26ef525cc81da24d55706fb079fa5a97b56e (patch) | |
tree | 886806e5b151f80271980fed427bfd876b6fb9d3 /script/provider/diagnostic.lua | |
parent | 5ad56c9ccfef9dfbe18a8846d1303b4668077b55 (diff) | |
download | lua-language-server-3f0d26ef525cc81da24d55706fb079fa5a97b56e.zip |
cleanup
Diffstat (limited to 'script/provider/diagnostic.lua')
-rw-r--r-- | script/provider/diagnostic.lua | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index d0de0962..32b6fc6f 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -28,7 +28,7 @@ end local function buildSyntaxError(uri, err) local text = files.getText(uri) - local message = lang.script('PARSER_'..err.type, err.info) + local message = lang.script('PARSER_' .. err.type, err.info) if err.version then local version = err.info and err.info.version or config.get(uri, 'Lua.runtime.version') @@ -45,7 +45,7 @@ local function buildSyntaxError(uri, err) for _, rel in ipairs(related) do local rmessage if rel.message then - rmessage = lang.script('PARSER_'..rel.message) + rmessage = lang.script('PARSER_' .. rel.message) else rmessage = text:sub(rel.start, rel.finish) end @@ -63,8 +63,9 @@ local function buildSyntaxError(uri, err) severity = define.DiagnosticSeverity[err.level], source = lang.script.DIAG_SYNTAX_CHECK, message = message, - relatedInformation = relatedInformation, data = 'syntax', + + relatedInformation = relatedInformation, } end @@ -77,7 +78,7 @@ local function buildDiagnostic(uri, diag) if diag.related then relatedInformation = {} for _, rel in ipairs(diag.related) do - local rtext = files.getText(rel.uri) + local rtext = files.getText(rel.uri) relatedInformation[#relatedInformation+1] = { message = rel.message or rtext:sub(rel.start, rel.finish), location = converter.location(rel.uri, converter.packRange(rel.uri, rel.start, rel.finish)) @@ -93,6 +94,7 @@ local function buildDiagnostic(uri, diag) code = diag.code, tags = diag.tags, data = diag.data, + relatedInformation = relatedInformation, } end @@ -292,12 +294,17 @@ function m.refresh(uri) end await.close('diag:' .. uri) await.call(function () ---@async - m.diagnosticsScope(uri) if uri then await.setID('diag:' .. uri) await.sleep(0.1) xpcall(m.doDiagnostic, log.error, uri) end + local delay = config.get(uri, 'Lua.diagnostics.workspaceDelay') / 1000 + if delay < 0 then + return + end + await.sleep(math.max(delay, 0.2)) + m.diagnosticsScope(uri) end) end @@ -357,15 +364,10 @@ function m.diagnosticsScope(uri, force) m.clearAll() return end - local delay = config.get(uri, 'Lua.diagnostics.workspaceDelay') / 1000 - if not force and delay < 0 then - return - end local scp = scope.getScope(uri) local id = 'diagnosticsScope:' .. scp:getName() await.close(id) await.call(function () ---@async - await.sleep(math.max(delay, 0.2)) while loading.count() > 0 do await.sleep(1.0) end |