summaryrefslogtreecommitdiff
path: root/server-beta/src/core/definition.lua
blob: 8b8d0b8e7d38a805cebe29cedd8d5e1cfbbd787c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local guide    = require 'parser.guide'
local engineer = require 'core.engineer'

return function (ast, text, offset)
    local results = {}
    guide.eachSourceContain(ast.ast, offset, function (source)
        local searcher = engineer(ast)
        searcher:eachDef(source, function (src, mode)
            results[#results+1] = {
                uri    = ast.uri,
                source = source,
                target = src,
            }
        end)
    end)
    if #results == 0 then
        return nil
    end
    return results
end