summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-29 15:50:10 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-29 15:50:10 +0800
commitaf6359bd573164ef09979263eac4a4c986b9796a (patch)
tree07f47f8e2df63bb204631b4dbfb33dcd228be331 /server
parente2dd5f62ffe0b80a3313ddaa5829d93fefd162a8 (diff)
downloadlua-language-server-af6359bd573164ef09979263eac4a4c986b9796a.zip
首字母小写全局变量的快速修复添加标记全局变量
Diffstat (limited to 'server')
-rw-r--r--server/src/method/textDocument/codeAction.lua25
1 files changed, 20 insertions, 5 deletions
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