diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-06-21 17:27:21 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-06-21 17:27:21 +0800 |
commit | 693226b24fb0888c12e89e6b413bf21522eed423 (patch) | |
tree | 76e273299c5065bfc3fc958894721bcd0712d3f2 | |
parent | 600f5e09cd79585aba80ee692ca0a0995b874451 (diff) | |
download | lua-language-server-693226b24fb0888c12e89e6b413bf21522eed423.zip |
limit cross file
-rw-r--r-- | meta/template/basic.lua | 1 | ||||
-rw-r--r-- | script/core/searcher.lua | 9 | ||||
-rw-r--r-- | test.lua | 1 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 33 |
4 files changed, 41 insertions, 3 deletions
diff --git a/meta/template/basic.lua b/meta/template/basic.lua index 7a42ab74..bb1464d6 100644 --- a/meta/template/basic.lua +++ b/meta/template/basic.lua @@ -137,6 +137,7 @@ function next(table, index) end ---@param t T ---@return fun(table: table<K, V>, index?: K):K, V ---@return T +---@return nil function pairs(t) end ---#DES 'pcall' diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 79b605b5..f29b6a29 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -181,10 +181,10 @@ function m.getObjectValue(obj) end local function crossSearch(status, uri, expect, mode, sourceUri) - if status.lock[uri] then + if status.lock[uri] and status.lock[uri] >= 3 then return end - status.lock[uri] = true + status.lock[uri] = (status.lock[uri] or 0) + 1 --await.delay() if TRACE then log.debug('crossSearch', uri, expect) @@ -193,7 +193,10 @@ local function crossSearch(status, uri, expect, mode, sourceUri) status.footprint[#status.footprint+1] = ('cross search:%s %s'):format(uri, expect) end m.searchRefsByID(status, uri, expect, mode) - status.lock[uri] = nil + status.lock[uri] = status.lock[uri] - 1 + if TRACE then + log.debug('crossSearch finish, back to:', uri) + end if FOOTPRINT then status.footprint[#status.footprint+1] = ('cross search finish, back to: %s'):format(sourceUri) end @@ -10,6 +10,7 @@ ROOT = fs.path(rootPath) TEST = true DEVELOP = true FOOTPRINT = true +TRACE = true LOGPATH = LOGPATH or (ROOT .. '/log') METAPATH = METAPATH or (ROOT .. '/meta') diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index e81494ff..7c83276e 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -762,3 +762,36 @@ function f() name = 'food', description = "@*return* — this is a tab `\t`" }} + +TEST { + { + path = 'a.lua', + content = [[ +---@class string + +---@generic T: table, K, V +---@param t T +---@return fun(table: table<K, V>, index?: K):K, V +---@return T +local function pairs(t) end + +return pairs + ]] + }, + { + path = 'b.lua', + content = [[ +local pairs = require 'a' + +---@type table<string, boolean> +local t + +for <?k?>, v in pairs(t) do +end + ]] + }, + hover = { + label = [[local k: string]], + name = 'k', + } +} |