summaryrefslogtreecommitdiff
path: root/server-beta/src/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-04 10:27:28 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-04 10:27:28 +0800
commita9af7f7bc869466da14ef2c4b7fb07ed589f7a09 (patch)
tree9779f0b94013c3b3a15f1ce32701e2585cea7472 /server-beta/src/core
parent196bad7bbd13c5423035881341a15847fad5227d (diff)
downloadlua-language-server-a9af7f7bc869466da14ef2c4b7fb07ed589f7a09.zip
整理代码
Diffstat (limited to 'server-beta/src/core')
-rw-r--r--server-beta/src/core/definition.lua23
1 files changed, 12 insertions, 11 deletions
diff --git a/server-beta/src/core/definition.lua b/server-beta/src/core/definition.lua
index f9ba00d1..30ce5dec 100644
--- a/server-beta/src/core/definition.lua
+++ b/server-beta/src/core/definition.lua
@@ -1,8 +1,9 @@
local guide = require 'parser.guide'
local workspace = require 'workspace'
local files = require 'files'
+local searcher = require 'searcher'
-local function findDef(searcher, source, callback)
+local function findDef(sch, source, callback)
if source.type ~= 'local'
and source.type ~= 'getlocal'
and source.type ~= 'setlocal'
@@ -16,12 +17,12 @@ local function findDef(searcher, source, callback)
and source.type ~= 'goto' then
return
end
- searcher:eachRef(source, function (info)
+ searcher.eachRef(source, function (info)
if info.mode == 'declare'
- or info.mode == 'set'
+ or info.mode == 'set'
or info.mode == 'return' then
local src = info.source
- local uri = info.searcher.uri
+ local uri = info.uri
if src.type == 'setfield'
or src.type == 'getfield'
or src.type == 'tablefield' then
@@ -40,8 +41,8 @@ local function findDef(searcher, source, callback)
end)
end
----@param searcher engineer
-local function checkRequire(searcher, source, offset, callback)
+---@param sch searcher
+local function checkRequire(sch, source, offset, callback)
if source.type ~= 'call' then
return
end
@@ -57,7 +58,7 @@ local function checkRequire(searcher, source, offset, callback)
if type(literal) ~= 'string' then
return
end
- local name = searcher:getSpecialName(func)
+ local name = searcher.getSpecialName(func)
if name == 'require' then
local result = workspace.findUrisByRequirePath(literal, true)
for _, uri in ipairs(result) do
@@ -73,12 +74,12 @@ local function checkRequire(searcher, source, offset, callback)
end
return function (uri, offset)
- local results = {}
- local searcher = files.getSearcher(uri)
- if not searcher then
+ local ast = files.getAst(uri)
+ if not ast then
return nil
end
- guide.eachSourceContain(searcher.ast, offset, function (source)
+ local results = {}
+ guide.eachSourceContain(ast.ast, offset, function (source)
checkRequire(searcher, source, offset, function (uri)
results[#results+1] = {
uri = files.getOriginUri(uri),