diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-04 20:58:05 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-04 20:58:05 +0800 |
commit | e1acf151c0da1aa01c39d10d0fab885f4c98f6cd (patch) | |
tree | 1bf61511f3d799396c4a42286f29ff448d656918 | |
parent | 562376ad77404ef43b795f45e8dc7513109c1b8d (diff) | |
download | lua-language-server-e1acf151c0da1aa01c39d10d0fab885f4c98f6cd.zip |
update
-rw-r--r-- | script/core/collector.lua | 25 | ||||
-rw-r--r-- | script/core/searcher.lua | 5 |
2 files changed, 28 insertions, 2 deletions
diff --git a/script/core/collector.lua b/script/core/collector.lua index 5ccbcaee..2f29fc37 100644 --- a/script/core/collector.lua +++ b/script/core/collector.lua @@ -1,4 +1,5 @@ local scope = require 'workspace.scope' +local ws = require 'workspace' local collect = {} local subscribed = {} @@ -88,4 +89,28 @@ function m.each(uri, name) return getNext end +--- 迭代某个名字的引用订阅 +---@param uri uri +---@param name string +function m.eachRef(uri, name) + local nameCollect = collect[name] + if not nameCollect then + return DUMMY_FUNCTION + end + ---@type scope + if scope.getFolder(uri) then + return m.each(uri, name) + end + + local curi, value + local function getNext() + curi, value = next(nameCollect, curi) + if not curi then + return nil, nil + end + + return value, curi + end + return getNext +end return m diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 6c832155..558dc96b 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -27,6 +27,7 @@ local getUri = guide.getUri local getRoot = guide.getRoot local ceach = collector.each +local ceachref = collector.eachRef local getState = files.getState @@ -844,7 +845,7 @@ function m.searchRefsByID(status, suri, expect, mode) ::CONTINUE:: end else - for _, guri in ceach(suri, id) do + for _, guri in ceachref(suri, id) do if crossed[guri] then goto CONTINUE end @@ -880,7 +881,7 @@ function m.searchRefsByID(status, suri, expect, mode) ::CONTINUE:: end else - for _, guri in ceach(suri, id) do + for _, guri in ceachref(suri, id) do if crossed[guri] then goto CONTINUE end |