From 69522a194a1e0c9a8263a985782d48fe1cc8690b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 15 Nov 2019 14:58:01 +0800 Subject: =?UTF-8?q?=E4=BC=98=E5=8C=96=20getLinks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/searcher/getLinks.lua | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'server-beta/src/searcher/getLinks.lua') diff --git a/server-beta/src/searcher/getLinks.lua b/server-beta/src/searcher/getLinks.lua index db1072e3..3e204e1f 100644 --- a/server-beta/src/searcher/getLinks.lua +++ b/server-beta/src/searcher/getLinks.lua @@ -3,18 +3,26 @@ local searcher = require 'searcher.searcher' local function getLinks(root) local cache = {} - guide.eachSourceType(root, 'call', function (source) - local uris = searcher.getLinkUris(source) - if uris then - for i = 1, #uris do - local uri = uris[i] - if not cache[uri] then - cache[uri] = {} + local ok + guide.eachSpecialOf(root, 'require', function (source) + local call = source.parent + if call.type == 'call' then + local uris = searcher.getLinkUris(call) + if uris then + ok = true + for i = 1, #uris do + local uri = uris[i] + if not cache[uri] then + cache[uri] = {} + end + cache[uri][#cache[uri]+1] = call end - cache[uri][#cache[uri]+1] = source end end end) + if not ok then + return nil + end return cache end -- cgit v1.2.3