blob: 32de102ca696f35394623ff9475bfc7c0ad431e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
local guide = require 'parser.guide'
return function (ast, offset, accept)
local len = math.huge
local result
guide.eachSourceContain(ast.ast, offset, function (source)
local start, finish = guide.getStartFinish(source)
if finish - start < len and accept[source.type] then
result = source
len = finish - start
end
end)
return result
end
|