summaryrefslogtreecommitdiff
path: root/server-beta
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta')
-rw-r--r--server-beta/src/core/definition.lua10
-rw-r--r--server-beta/test/definition/init.lua7
2 files changed, 10 insertions, 7 deletions
diff --git a/server-beta/src/core/definition.lua b/server-beta/src/core/definition.lua
index c6596268..0647572e 100644
--- a/server-beta/src/core/definition.lua
+++ b/server-beta/src/core/definition.lua
@@ -1,11 +1,9 @@
local guide = require 'parser.guide'
-local engineer = require 'core.engineer'
-return function (ast, text, offset)
+return function (file, offset)
local results = {}
- guide.eachSourceContain(ast.ast, offset, function (source)
- local searcher = engineer(ast)
- searcher:eachDef(source, function (src)
+ guide.eachSourceContain(file.ast.ast, offset, function (source)
+ file.searcher:eachDef(source, function (src)
if src.type == 'setfield'
or src.type == 'getfield'
or src.type == 'tablefield' then
@@ -19,7 +17,7 @@ return function (ast, text, offset)
src = src.method
end
results[#results+1] = {
- uri = ast.uri,
+ uri = file.uri,
source = source,
target = src,
}
diff --git a/server-beta/test/definition/init.lua b/server-beta/test/definition/init.lua
index cc8c584b..f5a663cf 100644
--- a/server-beta/test/definition/init.lua
+++ b/server-beta/test/definition/init.lua
@@ -1,4 +1,5 @@
local core = require 'core.definition'
+local engineer = require 'core.engineer'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -41,8 +42,12 @@ function TEST(script)
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:compile(new_script, 'lua', 'Lua 5.3')
assert(ast)
+ local file = {
+ ast = ast,
+ searcher = engineer(ast),
+ }
- local results = core(ast, new_script, pos)
+ local results = core(file, pos)
if results then
local positions = {}
for i, result in ipairs(results) do