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 | |
parent | 6042727fc89328d66e4c63aea1e180a94b7b84f1 (diff) | |
download | lua-language-server-ed85e835a9ee6b6e4e36a8bcf8772a92c165558b.zip |
search any field
-rw-r--r-- | script/core/searcher.lua | 58 | ||||
-rw-r--r-- | test/references/init.lua | 2 |
2 files changed, 36 insertions, 24 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) diff --git a/test/references/init.lua b/test/references/init.lua index 9ac96464..cb026cbc 100644 --- a/test/references/init.lua +++ b/test/references/init.lua @@ -176,7 +176,7 @@ local y = f()() TEST [[ local t = {} t.<?x?> = 1 -t[a.b.c] = 1 +t[<!a.b.c!>] = 1 ]] TEST [[ |