summaryrefslogtreecommitdiff
path: root/script/core/diagnostics/missing-global-doc.lua
blob: e104d232c683c7081e377ac940775dc829e63b0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local files   = require 'files'
local guide   = require "parser.guide"
local await   = require 'await'
local helper  = require 'core.diagnostics.helper.missing-doc-helper'

---@async
return function (uri, callback)
    local state = files.getState(uri)
    if not state then
        return
    end

    if not state.ast then
        return
    end

    ---@async
    guide.eachSourceType(state.ast, 'function', function (source)
        await.delay()

        if source.parent.type ~= 'setglobal' then
            return
        end

        helper.CheckFunction(source, callback, 'DIAG_MISSING_GLOBAL_DOC_COMMENT', 'DIAG_MISSING_GLOBAL_DOC_PARAM', 'DIAG_MISSING_GLOBAL_DOC_RETURN')
    end)
end