summaryrefslogtreecommitdiff
path: root/server/src/matcher/diagnostics.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/matcher/diagnostics.lua')
-rw-r--r--server/src/matcher/diagnostics.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/server/src/matcher/diagnostics.lua b/server/src/matcher/diagnostics.lua
index d347d9ab..e5daea31 100644
--- a/server/src/matcher/diagnostics.lua
+++ b/server/src/matcher/diagnostics.lua
@@ -72,6 +72,26 @@ local function searchUnusedLabel(results, callback)
end
end
+local function serachSpaces(lines, callback)
+ for i = 1, #lines do
+ local line = lines:line(i)
+
+ if line:find '^[ \t]+$' then
+ local start, finish = lines:range(i)
+ callback(start, finish, 'Line with spaces only') -- LOCALE
+ goto NEXT_LINE
+ end
+
+ local pos = line:find '[ \t]+$'
+ if pos then
+ local start, finish = lines:range(i)
+ callback(start + pos - 1, finish, 'Line with postspace') -- LOCALE
+ goto NEXT_LINE
+ end
+ ::NEXT_LINE::
+ end
+end
+
return function (ast, results, lines)
local datas = {}
-- 搜索未使用的局部变量
@@ -104,5 +124,14 @@ return function (ast, results, lines)
message = 'Unused label', -- LOCALE
}
end)
+ -- 所搜只有空格与制表符的行,以及后置了空格的行
+ serachSpaces(lines, function (start, finish, message)
+ datas[#datas+1] = {
+ start = start,
+ finish = finish,
+ level = 'Warning',
+ message = message,
+ }
+ end)
return datas
end