summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/noder.lua19
-rw-r--r--script/core/searcher.lua16
2 files changed, 31 insertions, 4 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua
index e6c7581f..5805aafc 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -8,9 +8,11 @@ local LAST_REGEX = SPLIT_CHAR .. '[^' .. SPLIT_CHAR .. ']*$'
local FIRST_REGEX = '^[^' .. SPLIT_CHAR .. ']*'
local ANY_FIELD_CHAR = '*'
local RETURN_INDEX = SPLIT_CHAR .. '#'
-local PARAM_INDEX = SPLIT_CHAR .. '@'
+local PARAM_INDEX = SPLIT_CHAR .. '&'
local TABLE_KEY = SPLIT_CHAR .. '<'
local ANY_FIELD = SPLIT_CHAR .. ANY_FIELD_CHAR
+local URI_CHAR = '@'
+local URI_REGEX = URI_CHAR .. '([^' .. URI_CHAR .. ']*)' .. URI_CHAR .. '(.*)'
---@class node
-- 当前节点的id
@@ -253,7 +255,11 @@ local function checkMode(source)
return 'gc:'
end
if source.type == 'generic.value' then
- return 'gv:'
+ local id = 'gv:'
+ if guide.getUri(source.closure.call) ~= guide.getUri(source.proto) then
+ id = URI_CHAR .. guide.getUri(source.closure.call) .. URI_CHAR .. id
+ end
+ return id
end
if isGlobal(source) then
return 'g:'
@@ -836,6 +842,15 @@ function m.getLastID(id)
return lastID
end
+---把形如 `@file:\\\XXXXX@gv:1|1`拆分成uri与id
+---@param id string
+---@return uri? string
+---@return string id
+function m.getUriAndID(id)
+ local uri, newID = id:match(URI_REGEX)
+ return uri, newID
+end
+
---是否是全局变量(包括 _G.XXX 形式)
---@param source parser.guide.object
---@return boolean
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 4063426d..9208032c 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -24,7 +24,7 @@ local ignoredIDs = {
local m = {}
----@alias guide.searchmode '"ref"'|'"def"'|'"field"'
+---@alias guide.searchmode '"ref"'|'"def"'
---添加结果
---@param status guide.status
@@ -227,7 +227,7 @@ function m.searchRefsByID(status, uri, expect, mode)
mark[id] = cmark
end
log.debug('search:', id, field)
- if field then
+ if field then
if cmark[field] then
return
end
@@ -456,12 +456,24 @@ function m.searchRefsByID(status, uri, expect, mode)
end
end
+ local function checkCrossUri(id, field)
+ local targetUri, newID = noder.getUriAndID(id)
+ if not targetUri then
+ return false
+ end
+ crossSearch(status, targetUri, newID .. (field or ''), mode)
+ return true
+ end
+
local stepCount = 0
function searchStep(id, field)
stepCount = stepCount + 1
if stepCount > 1000 then
error('too large')
end
+ if checkCrossUri(id, field) then
+ return
+ end
local node = noder.getNodeByID(root, id)
if node then
searchNode(id, node, field)