summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/unused-label.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/core/diagnostics/unused-label.lua')
-rw-r--r--script/core/diagnostics/unused-label.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/script/core/diagnostics/unused-label.lua b/script/core/diagnostics/unused-label.lua
new file mode 100644
index 00000000..e6d998ba
--- /dev/null
+++ b/script/core/diagnostics/unused-label.lua
@@ -0,0 +1,22 @@
+local files = require 'files'
+local guide = require 'parser.guide'
+local define = require 'proto.define'
+local lang = require 'language'
+
+return function (uri, callback)
+ local ast = files.getAst(uri)
+ if not ast then
+ return
+ end
+
+ guide.eachSourceType(ast.ast, 'label', function (source)
+ if not source.ref then
+ callback {
+ start = source.start,
+ finish = source.finish,
+ tags = { define.DiagnosticTag.Unnecessary },
+ message = lang.script('DIAG_UNUSED_LABEL', source[1]),
+ }
+ end
+ end)
+end