summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/template/basic.lua1
-rw-r--r--script/core/searcher.lua28
-rw-r--r--test.lua2
-rw-r--r--test/full/projects.lua2
-rw-r--r--test/type_inference/init.lua8
5 files changed, 25 insertions, 16 deletions
diff --git a/meta/template/basic.lua b/meta/template/basic.lua
index bb1464d6..7a42ab74 100644
--- a/meta/template/basic.lua
+++ b/meta/template/basic.lua
@@ -137,7 +137,6 @@ 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 f29b6a29..935f59cb 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] and status.lock[uri] >= 3 then
+ if status.lock[uri] then
return
end
- status.lock[uri] = (status.lock[uri] or 0) + 1
+ status.lock[uri] = true
--await.delay()
if TRACE then
log.debug('crossSearch', uri, expect)
@@ -193,9 +193,9 @@ 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] = status.lock[uri] - 1
+ status.lock[uri] = nil
if TRACE then
- log.debug('crossSearch finish, back to:', uri)
+ log.debug('crossSearch finish, back to:', sourceUri)
end
if FOOTPRINT then
status.footprint[#status.footprint+1] = ('cross search finish, back to: %s'):format(sourceUri)
@@ -471,13 +471,13 @@ function m.searchRefsByID(status, uri, expect, mode)
end
local function checkGlobal(id, node, field)
- if status.crossed[id] then
+ if id:sub(1, 2) ~= 'g:' then
return
end
- status.crossed[id] = true
- --if not checkThenPushTag('forward', 'set') then
- -- return
- --end
+ if status.lock[id] then
+ return
+ end
+ status.lock[id] = true
local isCall = field and field:sub(2, 2) == noder.RETURN_INDEX
local tid = id .. (field or '')
if FOOTPRINT then
@@ -488,7 +488,6 @@ function m.searchRefsByID(status, uri, expect, mode)
if files.eq(uri, guri) then
goto CONTINUE
end
- crossed[guri] = true
crossSearch(status, guri, tid, mode, uri)
::CONTINUE::
end
@@ -512,12 +511,15 @@ function m.searchRefsByID(status, uri, expect, mode)
end
local function checkClass(id, node, field)
- if status.crossed[id] then
+ if id:sub(1, 3) ~= 'dn:' then
return
end
- status.crossed[id] = true
+ if status.lock[id] then
+ return
+ end
+ status.lock[id] = true
local tid = id .. (field or '')
- for guri in collector.each(id) do
+ for _, guri in collector.each('def:' .. id) do
if not files.eq(uri, guri) then
crossSearch(status, guri, tid, mode, uri)
end
diff --git a/test.lua b/test.lua
index b7f99590..09d98b96 100644
--- a/test.lua
+++ b/test.lua
@@ -9,7 +9,7 @@ local fs = require 'bee.filesystem'
ROOT = fs.path(rootPath)
TEST = true
DEVELOP = true
-FOOTPRINT = true
+--FOOTPRINT = true
TRACE = true
LOGPATH = LOGPATH or (ROOT .. '/log')
METAPATH = METAPATH or (ROOT .. '/meta')
diff --git a/test/full/projects.lua b/test/full/projects.lua
index 6e336df8..f59ad994 100644
--- a/test/full/projects.lua
+++ b/test/full/projects.lua
@@ -42,5 +42,5 @@ local function doProjects(pathname)
print('基准全量诊断用时:', passed)
end
-doProjects [[C:\SSSEditor\client\Output\Lua]]
+--doProjects [[C:\SSSEditor\client\Output\Lua]]
doProjects [[C:\W3-Server\script]]
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 7a968972..300a68ce 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -742,3 +742,11 @@ local <?test?> = Rct.new(Rct)
return test
]]
+
+TEST 'number' [[
+---@alias t table<number, string>
+---@type t
+local a = {}
+for <?x?>, y in pairs(a) do
+end
+]]