From af6359bd573164ef09979263eac4a4c986b9796a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 29 Mar 2019 15:50:10 +0800 Subject: =?UTF-8?q?=E9=A6=96=E5=AD=97=E6=AF=8D=E5=B0=8F=E5=86=99=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E5=8F=98=E9=87=8F=E7=9A=84=E5=BF=AB=E9=80=9F=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=B7=BB=E5=8A=A0=E6=A0=87=E8=AE=B0=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 14 ++++++++------ server/src/method/textDocument/codeAction.lua | 25 ++++++++++++++++++++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3e0261e8..99940caf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,10 @@ { - "Lua.diagnostics.globals": [ - "TEST", - "ERR", - "OUT", - "IN" - ] + "Lua.diagnostics.globals" : [ + "TEST", + "ERR", + "OUT", + "IN", + "log", + "ac" + ] } diff --git a/server/src/method/textDocument/codeAction.lua b/server/src/method/textDocument/codeAction.lua index e2ff2e50..c61ad88f 100644 --- a/server/src/method/textDocument/codeAction.lua +++ b/server/src/method/textDocument/codeAction.lua @@ -18,11 +18,7 @@ local function disableDiagnostic(lsp, uri, data, callback) } end -local function solveUndefinedGlobal(lsp, uri, data, callback) - local vm, lines, text = lsp:getVM(uri) - if not vm then - return - end +local function addGlobal(lines, text, data, callback) local start = lines:position(data.range.start.line + 1, data.range.start.character + 1) local finish = lines:position(data.range['end'].line + 1, data.range['end'].character) local name = text:sub(start, finish) @@ -46,6 +42,22 @@ local function solveUndefinedGlobal(lsp, uri, data, callback) } end +local function solveUndefinedGlobal(lsp, uri, data, callback) + local vm, lines, text = lsp:getVM(uri) + if not vm then + return + end + addGlobal(lines, text, data, callback) +end + +local function solveLowercaseGlobal(lsp, uri, data, callback) + local vm, lines, text = lsp:getVM(uri) + if not vm then + return + end + addGlobal(lines, text, data, callback) +end + local function solveTrailingSpace(lsp, uri, data, callback) callback { title = lang.script.ACTION_REMOVE_SPACE, @@ -116,6 +128,9 @@ local function solveDiagnostic(lsp, uri, data, callback) if data.code == 'ambiguity-1' then solveAmbiguity1(lsp, uri, data, callback) end + if data.code == 'lowercase-global' then + solveLowercaseGlobal(lsp, uri, data, callback) + end disableDiagnostic(lsp, uri, data, callback) end -- cgit v1.2.3