summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/method/textDocument/publishDiagnostics.lua14
-rw-r--r--server/src/parser/ast.lua2
-rw-r--r--server/src/service.lua5
3 files changed, 9 insertions, 12 deletions
diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua
index b006932e..5f71d475 100644
--- a/server/src/method/textDocument/publishDiagnostics.lua
+++ b/server/src/method/textDocument/publishDiagnostics.lua
@@ -80,16 +80,12 @@ return function (lsp, params)
local lines = params.lines
local uri = params.uri
- local datas = matcher.diagnostics(vm, lines, uri)
-
- if not datas then
- -- 返回空表以清空之前的结果
- return {}
- end
-
local diagnostics = {}
- for i, data in ipairs(datas) do
- diagnostics[i] = createInfo(data, lines)
+ if vm then
+ local datas = matcher.diagnostics(vm, lines, uri)
+ for _, data in ipairs(datas) do
+ diagnostics[#diagnostics+1] = createInfo(data, lines)
+ end
end
return diagnostics
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua
index 0cef46a1..b02daefa 100644
--- a/server/src/parser/ast.lua
+++ b/server/src/parser/ast.lua
@@ -419,7 +419,7 @@ return function (self, lua, mode)
return nil, res
end
if not res then
- return nil, err
+ return nil, {err}
end
return res
end
diff --git a/server/src/service.lua b/server/src/service.lua
index 165de434..b8546665 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -273,6 +273,7 @@ end
function mt:compileAst(obj)
local ast, err = parser:ast(obj.text)
+ obj.astErr = nil
if not ast then
if type(err) == 'string' then
local message = lang.script('PARSER_CRASH', err)
@@ -331,14 +332,14 @@ function mt:compileVM(uri)
obj.vm = matcher.vm(ast, self, uri)
obj.lines = parser:lines(obj.text, 'utf8')
+
+ self._needDiagnostics[uri] = true
if not obj.vm then
return obj
end
self:_compileChain(obj, compiled)
- self._needDiagnostics[uri] = true
-
return obj
end