diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-04 11:33:24 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-04 11:33:24 +0800 |
commit | e9e66c789b6d2b4fb57d639f1143ea84fe40019b (patch) | |
tree | bf52fa6c97af79d8eb00a537c7c39fe1678beee5 /server-beta/src/searcher/eachRef.lua | |
parent | da08423453d5b2e0c60fbee50b86ce1a7e03ba82 (diff) | |
download | lua-language-server-e9e66c789b6d2b4fb57d639f1143ea84fe40019b.zip |
支持 require
Diffstat (limited to 'server-beta/src/searcher/eachRef.lua')
-rw-r--r-- | server-beta/src/searcher/eachRef.lua | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua index b7c108d8..41a1d6cd 100644 --- a/server-beta/src/searcher/eachRef.lua +++ b/server-beta/src/searcher/eachRef.lua @@ -1,7 +1,7 @@ -local guide = require 'parser.guide' -local files = require 'files' +local guide = require 'parser.guide' +local files = require 'files' local workspace = require 'workspace' -local searcher = require 'searcher.searcher' +local searcher = require 'searcher.searcher' local function ofCall(func, index, callback) searcher.eachRef(func, function (info) @@ -52,7 +52,7 @@ local function ofSpecialCall(call, func, index, callback) for _, uri in ipairs(result) do local ast = files.getAst(uri) if ast then - local other = files.getSearcher(uri) + searcher.eachRef(ast.ast, callback) end end end @@ -271,6 +271,21 @@ local function ofLabel(source, callback) end +local function ofMain(source, callback) + if source.returns then + for _, rtn in ipairs(source.returns) do + local val = rtn[1] + if val then + callback { + source = val, + mode = 'return', + } + searcher.eachRef(val, callback) + end + end + end +end + local function eachRef(source, callback) local stype = source.type if stype == 'local' then @@ -299,11 +314,10 @@ local function eachRef(source, callback) ofGoTo(source, callback) elseif stype == 'label' then ofLabel(source, callback) - else - callback { - source = source, - mode = 'value', - } + elseif stype == 'table' then + ofValue(source, callback) + elseif stype == 'main' then + ofMain(source, callback) end asArg(source, callback) end |