summaryrefslogtreecommitdiff
path: root/server-beta/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/core')
-rw-r--r--server-beta/src/core/definition.lua23
-rw-r--r--server-beta/src/core/engineer.lua3
2 files changed, 16 insertions, 10 deletions
diff --git a/server-beta/src/core/definition.lua b/server-beta/src/core/definition.lua
index 2fe726e0..039effd5 100644
--- a/server-beta/src/core/definition.lua
+++ b/server-beta/src/core/definition.lua
@@ -1,22 +1,23 @@
local guide = require 'parser.guide'
local engineer = require 'core.engineer'
local workspace = require 'workspace'
+local files = require 'files'
local function findDef(searcher, source, callback)
- searcher:eachDef(source, function (src)
+ searcher:eachDef(source, function (src, uri)
if src.type == 'setfield'
or src.type == 'getfield'
or src.type == 'tablefield' then
- callback(src.field)
+ callback(src.field, uri)
elseif src.type == 'setindex'
or src.type == 'getindex'
or src.type == 'tableindex' then
- callback(src.index)
+ callback(src.index, uri)
elseif src.type == 'getmethod'
or src.type == 'setmethod' then
- callback(src.method)
+ callback(src.method, uri)
else
- callback(src)
+ callback(src, uri)
end
end)
end
@@ -53,9 +54,13 @@ local function checkRequire(searcher, source, offset, callback)
end
end
-return function (ast, offset)
+return function (uri, offset)
local results = {}
- local searcher = engineer(ast)
+ local ast = files.getAst(uri)
+ if not ast then
+ return nil
+ end
+ local searcher = engineer(ast, uri)
guide.eachSourceContain(ast.ast, offset, function (source)
checkRequire(searcher, source, offset, function (uri)
results[#results+1] = {
@@ -67,9 +72,9 @@ return function (ast, offset)
}
}
end)
- findDef(searcher, source, function (src)
+ findDef(searcher, source, function (src, uri)
results[#results+1] = {
- uri = ast.uri,
+ uri = uri,
source = source,
target = src,
}
diff --git a/server-beta/src/core/engineer.lua b/server-beta/src/core/engineer.lua
index a52bddc2..8404bee5 100644
--- a/server-beta/src/core/engineer.lua
+++ b/server-beta/src/core/engineer.lua
@@ -313,10 +313,11 @@ function mt:childMode(source)
return nil, nil
end
-return function (ast)
+return function (ast, uri)
local self = setmetatable({
step = 0,
ast = ast.ast,
+ uri = uri,
cache = {
def = {},
ref = {},