diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-06-11 15:15:19 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-06-11 15:15:19 +0800 |
commit | e6f1dd06dbe5c70a8f8b239b73bb3e4a8caf7554 (patch) | |
tree | c119babd91098f761e54940ae016d533d363ade4 /script/core | |
parent | 50e6cd02d535e12e085eab7d8bdcb4757be857f2 (diff) | |
download | lua-language-server-e6f1dd06dbe5c70a8f8b239b73bb3e4a8caf7554.zip |
global cache
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/searcher.lua | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/script/core/searcher.lua b/script/core/searcher.lua index fc19fc80..095ff782 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -5,6 +5,7 @@ local generic = require 'core.generic' local ws = require 'workspace' local vm = require 'vm.vm' local await = require 'await' +local globals = require 'vm.globals' local NONE = {'NONE'} local LAST = {'LAST'} @@ -424,8 +425,12 @@ function m.searchRefsByID(status, uri, expect, mode) return end status.crossed[firstID] = true + local uris = globals.getUrisByID(firstID) + if not uris then + return + end local tid = id .. (field or '') - for guri in files.eachFile() do + for guri in pairs(uris) do if not files.eq(uri, guri) then crossSearch(status, guri, tid, mode) end @@ -614,10 +619,28 @@ local function searchAllGlobalByUri(status, mode, uri, fullID) end end -local function searchAllGlobals(status, mode, fullID) +local function searchAllGlobals(status, mode) for uri in files.eachFile() do + searchAllGlobalByUri(status, mode, uri) + end +end + +---查找全局变量 +---@param uri uri +---@param mode guide.searchmode +---@param name string +---@return parser.guide.object[] +function m.findGlobals(uri, mode, name) + local status = m.status(mode) + + if name then + local fullID = ('g:%q'):format(name) searchAllGlobalByUri(status, mode, uri, fullID) + else + searchAllGlobalByUri(status, mode, uri) end + + return status.results end ---搜索对象的引用 |