summaryrefslogtreecommitdiff
path: root/script/core/searcher.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-09 18:09:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-09 18:09:49 +0800
commitb21f5d2cd9eaf02986ba526f58f0c5fedbd1fde3 (patch)
treefe489b14cf31612fb9e85cb2e033c841d50dbe33 /script/core/searcher.lua
parent3945d61e1a7dd20b33f7bcd4d5c9c5f09d77b510 (diff)
downloadlua-language-server-b21f5d2cd9eaf02986ba526f58f0c5fedbd1fde3.zip
improve
Diffstat (limited to 'script/core/searcher.lua')
-rw-r--r--script/core/searcher.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 2b8eed41..11e00378 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -219,7 +219,8 @@ function m.searchRefsByID(status, uri, expect, mode)
local mark = {}
local function search(id, field)
- if ignoredIDs[id] and field then
+ local firstID = noder.getFirstID(id)
+ if ignoredIDs[firstID] and (field or firstID ~= id) then
return
end
local cmark = mark[id]
@@ -348,14 +349,27 @@ function m.searchRefsByID(status, uri, expect, mode)
searchID(newID)
end
+ local forwardTag = {}
+ local backwardTag = {}
local function checkForward(id, node, field)
for _, forwardID in ipairs(node.forward) do
+ local tag = node.forward[forwardID]
+ if tag then
+ if backwardTag[tag] and backwardTag[tag] > 0 then
+ goto CONTINUE
+ end
+ forwardTag[tag] = (forwardTag[tag] or 0) + 1
+ end
local targetUri, targetID = noder.getUriAndID(forwardID)
if targetUri and not files.eq(targetUri, uri) then
crossSearch(status, targetUri, targetID .. (field or ''), mode)
else
searchID(targetID or forwardID, field)
end
+ if tag then
+ forwardTag[tag] = forwardTag[tag] - 1
+ end
+ ::CONTINUE::
end
end
@@ -364,12 +378,23 @@ function m.searchRefsByID(status, uri, expect, mode)
return
end
for _, backwardID in ipairs(node.backward) do
+ local tag = node.backward[backwardID]
+ if tag then
+ if forwardTag[tag] and forwardTag[tag] > 0 then
+ goto CONTINUE
+ end
+ backwardTag[tag] = (backwardTag[tag] or 0) + 1
+ end
local targetUri, targetID = noder.getUriAndID(backwardID)
if targetUri and not files.eq(targetUri, uri) then
crossSearch(status, targetUri, targetID .. (field or ''), mode)
else
searchID(targetID or backwardID, field)
end
+ if tag then
+ backwardTag[tag] = backwardTag[tag] - 1
+ end
+ ::CONTINUE::
end
end