summaryrefslogtreecommitdiff
path: root/server-beta/src/core/definition.lua
blob: 087ef948662a42c9f3ce365a20f65703ee8f84e9 (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:eachRef(source, 'def', 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