diff options
Diffstat (limited to 'script/core/diagnostics/unused-function.lua')
-rw-r--r-- | script/core/diagnostics/unused-function.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/script/core/diagnostics/unused-function.lua b/script/core/diagnostics/unused-function.lua index f0bca613..1463d081 100644 --- a/script/core/diagnostics/unused-function.lua +++ b/script/core/diagnostics/unused-function.lua @@ -5,6 +5,18 @@ local define = require 'proto.define' local lang = require 'language' local await = require 'await' +local function isToBeClosed(source) + if not source.attrs then + return false + end + for _, attr in ipairs(source.attrs) do + if attr[1] == 'close' then + return true + end + end + return false +end + return function (uri, callback) local ast = files.getAst(uri) if not ast then @@ -20,6 +32,9 @@ return function (uri, callback) and parent.type ~= 'setlocal' then return end + if isToBeClosed(source) then + return + end local hasGet local refs = vm.getRefs(source) for _, src in ipairs(refs) do |