summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-17 14:46:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-17 14:46:38 +0800
commit5aa47d161d1c00ac019f7cf0e721f785f53f0a9b (patch)
treeb2e6bf8d25663a10adb0e699bc8e965ac2fde7ee /script
parent1386a3fec48dd68bbb1b2ad0234bcd37b1462759 (diff)
downloadlua-language-server-5aa47d161d1c00ac019f7cf0e721f785f53f0a9b.zip
cleanup
Diffstat (limited to 'script')
-rw-r--r--script/core/searcher.lua131
1 files changed, 58 insertions, 73 deletions
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 930a9890..792682cb 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -554,9 +554,6 @@ function m.searchRefsByID(status, suri, expect, mode)
---@param info node.info
local function pushThenCheckReject(uri, ward, info)
local reject = info.reject
- if not reject then
- return true
- end
local checkReject
local pushReject
if ward == 'forward' then
@@ -577,9 +574,6 @@ function m.searchRefsByID(status, suri, expect, mode)
---@param info node.info
local function popReject(uri, ward, info)
local reject = info.reject
- if not reject then
- return
- end
local popTags
if ward == 'forward' then
popTags = frejectMap[uri]
@@ -596,9 +590,6 @@ function m.searchRefsByID(status, suri, expect, mode)
---@param info node.info
local function pushInfoFilter(id, field, info)
local filter = info.filter
- if not filter then
- return
- end
local filterValid = info.filterValid
if filterValid and not filterValid(id, field) then
return
@@ -610,9 +601,6 @@ function m.searchRefsByID(status, suri, expect, mode)
---@param info node.info
local function releaseInfoFilter(id, field, info)
local filter = info.filter
- if not filter then
- return
- end
local filterValid = info.filterValid
if filterValid and not filterValid(id, field) then
return
@@ -635,37 +623,26 @@ function m.searchRefsByID(status, suri, expect, mode)
return true
end
- ---@param id string
- ---@param info node.info
- local function checkBeforeForward(uri, id, field, info)
- if info then
- pushInfoFilter(id, field, info)
- if not pushThenCheckReject(uri, 'forward', info) then
- return false
- end
- end
- if not checkInfoFilter(id, field, info) then
- return false
- end
- return true
- end
-
- ---@param id string
- ---@param info node.info
- local function releaseAfterForward(uri, id, field, info)
- if not info then
- return
- end
- popReject(uri, 'forward', info)
- releaseInfoFilter(id, field, info)
- end
-
local function checkForward(uri, id, field)
for forwardID, info in eachForward(nodersMap[uri], id) do
local targetUri, targetID
- if not checkBeforeForward(uri, forwardID, field, info) then
+
+ --#region checkBeforeForward
+ if info then
+ if info.filter then
+ pushInfoFilter(forwardID, field, info)
+ end
+ if info.reject then
+ if not pushThenCheckReject(uri, 'forward', info) then
+ goto RELEASE_THEN_CONTINUE
+ end
+ end
+ end
+ if not checkInfoFilter(forwardID, field, info) then
goto RELEASE_THEN_CONTINUE
end
+ --#endregion
+
targetUri, targetID = getUriAndID(forwardID)
if targetUri and targetUri ~= uri then
if dontCross == 0 then
@@ -674,41 +651,18 @@ function m.searchRefsByID(status, suri, expect, mode)
else
searchID(uri, targetID or forwardID, field)
end
- ::RELEASE_THEN_CONTINUE::
- releaseAfterForward(uri, id, field, info)
- end
- end
- ---@param id string
- ---@param field string
- ---@param info node.info
- local function checkBeforeBackward(uri, id, field, info)
- if info then
- if info.dontCross then
- dontCross = dontCross + 1
- end
- pushInfoFilter(id, field, info)
- if not pushThenCheckReject(uri, 'backward', info) then
- return false
+ ::RELEASE_THEN_CONTINUE::
+ --#region releaseAfterForward
+ if info then
+ if info.reject then
+ popReject(uri, 'forward', info)
+ end
+ if info.filter then
+ releaseInfoFilter(id, field, info)
+ end
end
- end
- if not checkInfoFilter(id, field, info) then
- return false
- end
- return true
- end
-
- ---@param id string
- ---@param field string
- ---@param info node.info
- local function releaseAfterBackward(uri, id, field, info)
- if not info then
- return
- end
- popReject(uri, 'backward', info)
- releaseInfoFilter(id, field, info)
- if info.dontCross then
- dontCross = dontCross - 1
+ --#endregion
end
end
@@ -728,9 +682,26 @@ function m.searchRefsByID(status, suri, expect, mode)
if info and info.deep and mode ~= 'allref' and mode ~= 'allfield' then
goto CONTINUE
end
- if not checkBeforeBackward(uri, backwardID, field, info) then
+
+ --#region checkBeforeBackward
+ if info then
+ if info.dontCross then
+ dontCross = dontCross + 1
+ end
+ if info.filter then
+ pushInfoFilter(backwardID, field, info)
+ end
+ if info.reject then
+ if not pushThenCheckReject(uri, 'backward', info) then
+ goto RELEASE_THEN_CONTINUE
+ end
+ end
+ end
+ if not checkInfoFilter(backwardID, field, info) then
goto RELEASE_THEN_CONTINUE
end
+ --#endregion
+
targetUri, targetID = getUriAndID(backwardID)
if targetUri and targetUri ~= uri then
if dontCross == 0 then
@@ -739,8 +710,22 @@ function m.searchRefsByID(status, suri, expect, mode)
else
searchID(uri, targetID or backwardID, field)
end
+
::RELEASE_THEN_CONTINUE::
- releaseAfterBackward(uri, backwardID, field, info)
+ --#region releaseAfterBackward
+ if info then
+ if info.reject then
+ popReject(uri, 'backward', info)
+ end
+ if info.filter then
+ releaseInfoFilter(backwardID, field, info)
+ end
+ if info.dontCross then
+ dontCross = dontCross - 1
+ end
+ end
+ --#endregion
+
::CONTINUE::
end
end