summaryrefslogtreecommitdiff
path: root/server-beta/src/core/definition.lua
blob: afd368b1c2cab79e87d2ffc23b0f303eae9c602f (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
local guide    = require 'parser.guide'
local engineer = require 'core.engineer'

return function (ast, text, offset)
    local results = {}
    local searcher = engineer(ast)
    guide.eachSource(ast.root, offset, function (source)
        searcher:eachRef(source, function (src, mode)
            if src.start == 0 then
                return
            end
            if mode == 'local' or mode == 'set' then
                results[#results+1] = {
                    uri    = ast.uri,
                    source = source,
                    target = src,
                }
            end
        end)
    end)
    if #results == 0 then
        return nil
    end
    return results
end