summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-07-16 15:55:47 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-07-16 15:55:47 +0800
commitbdd5d388f5f45d48a14fefece2826809e6f25d3a (patch)
tree25a89a518863521ebe805a8a0162ebe1bc4fcd36 /script/core
parent458d20d53f331a8de0a07d4322a3eae2551d1763 (diff)
downloadlua-language-server-bdd5d388f5f45d48a14fefece2826809e6f25d3a.zip
检查修改了循环变量
Diffstat (limited to 'script/core')
-rw-r--r--script/core/diagnostics.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/script/core/diagnostics.lua b/script/core/diagnostics.lua
index 0a9d339d..f488dba5 100644
--- a/script/core/diagnostics.lua
+++ b/script/core/diagnostics.lua
@@ -855,6 +855,27 @@ function mt:searchSetConstLocal(callback)
end)
end
+function mt:searchSetForState(callback)
+ local locs = {}
+ self.vm:eachSource(function (source)
+ if source.type == 'loop' then
+ locs[#locs+1] = source.arg:bindLocal()
+ elseif source.type == 'in' then
+ self.vm:forList(source.arg, function (arg)
+ locs[#locs+1] = arg:bindLocal()
+ end)
+ end
+ end)
+ for i = 1, #locs do
+ local loc = locs[i]
+ loc:eachInfo(function (info, src)
+ if info.type == 'set' then
+ callback(src.start, src.finish)
+ end
+ end)
+ end
+end
+
function mt:doDiagnostics(func, code, callback)
if config.config.diagnostics.disable[code] then
return
@@ -1051,5 +1072,11 @@ return function (vm, lines, uri)
message = lang.script.DIAG_SET_CONST
}
end)
+ -- 检查修改for的内置变量
+ session:doDiagnostics(session.searchSetForState, 'set-for-state', function ()
+ return {
+ message = lang.script.DIAG_SET_FOR_STATE,
+ }
+ end)
return session.datas
end