diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-15 15:42:43 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-15 15:42:43 +0800 |
commit | ed85e835a9ee6b6e4e36a8bcf8772a92c165558b (patch) | |
tree | 63bdaf70139c320980c9e0ebd202ea79223c8f9d /script/core | |
parent | 6042727fc89328d66e4c63aea1e180a94b7b84f1 (diff) | |
download | lua-language-server-ed85e835a9ee6b6e4e36a8bcf8772a92c165558b.zip |
search any field
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/searcher.lua | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 10a6a537..4af50da6 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -209,6 +209,7 @@ function m.searchRefsByID(status, uri, expect, mode) newField = newField .. field end search(lastID, newField) + return lastID end local function searchID(id, field) @@ -292,7 +293,7 @@ function m.searchRefsByID(status, uri, expect, mode) return end end - local id = linker.getID(closure) + local id = linker.getID(closure) searchID(id, field) end @@ -311,6 +312,31 @@ function m.searchRefsByID(status, uri, expect, mode) end end + local function searchLink(id, link, field) + if link.call then + callStack[#callStack+1] = link.call + end + if field == nil and link.sources then + for _, source in ipairs(link.sources) do + m.pushResult(status, mode, source) + end + end + if link.forward then + checkForward(id, link, field) + end + if link.backward then + checkBackward(id, link, field) + end + + if link.sources then + checkGeneric(link.sources[1], field) + end + + if link.call then + callStack[#callStack] = nil + end + end + local stepCount = 0 function searchStep(id, field) stepCount = stepCount + 1 @@ -319,30 +345,16 @@ function m.searchRefsByID(status, uri, expect, mode) end local link = linker.getLinkByID(root, id) if link then - if link.call then - callStack[#callStack+1] = link.call - end - if field == nil and link.sources then - for _, source in ipairs(link.sources) do - m.pushResult(status, mode, source) - end - end - if link.forward then - checkForward(id, link, field) - end - if link.backward then - checkBackward(id, link, field) - end - - if link.sources then - checkGeneric(link.sources[1], field) - end - - if link.call then - callStack[#callStack] = nil + searchLink(id, link, field) + end + local lastID = checkLastID(id, field) + if lastID then + local anyFieldID = lastID .. linker.ANY_FIELD + local anyFieldLink = linker.getLinkByID(root, anyFieldID) + if anyFieldLink then + searchLink(anyFieldID, anyFieldLink, field) end end - checkLastID(id, field) end search(expect) |