diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/core/noder.lua | 22 | ||||
-rw-r--r-- | script/core/searcher.lua | 18 |
2 files changed, 37 insertions, 3 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua index c3a9c5bb..1f8005e3 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -50,6 +50,7 @@ local URI_REGEX = URI_CHAR .. '([^' .. URI_CHAR .. ']*)' .. URI_CHAR .. '(. ---@field deep? boolean ---@field filter? node.filter ---@field filterValid? node.filter +---@field dontCross? boolean ---创建source的链接信息 ---@param noders noders @@ -983,7 +984,8 @@ function m.compileNode(noders, source) pushForward(noders, fullID, getID(rtn)) for _, typeUnit in ipairs(rtn.types) do pushBackward(noders, getID(typeUnit), fullID, { - deep = true, + deep = true, + dontCross = true, }) end hasDocReturn[rtn.returnIndex] = true @@ -1043,7 +1045,8 @@ function m.compileNode(noders, source) for _, rtnObj in ipairs(rtnObjs) do pushForward(noders, returnID, getID(rtnObj)) pushBackward(noders, getID(rtnObj), returnID, { - deep = true, + deep = true, + dontCross = true, }) end end @@ -1228,6 +1231,21 @@ function m.getUriAndID(id) return uri, newID end +---是否是普通的field,例如数字或字符串,而不是函数返回值等 +---@param field any +function m.isCommonField(field) + if not field then + return false + end + if field:sub(1, #RETURN_INDEX) == RETURN_INDEX then + return false + end + if field:sub(1, #PARAM_INDEX) == PARAM_INDEX then + return false + end + return true +end + ---获取source的ID ---@param source parser.guide.object ---@return string diff --git a/script/core/searcher.lua b/script/core/searcher.lua index f6146b27..f5e2361e 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -223,6 +223,9 @@ local function footprint(status, ...) end local function crossSearch(status, uri, expect, mode, sourceUri) + if status.dontCross > 0 then + return + end if checkLock(status, uri, expect) then return end @@ -556,20 +559,32 @@ function m.searchRefsByID(status, uri, expect, mode) end end + ---@param id string + ---@param field string + ---@param info node.info local function checkInfoBeforeBackward(id, field, info) - if info.deep and mode ~= 'allref' and mode ~= 'alldef' then + if info.deep and mode ~= 'allref' then return false end if not checkThenPushReject('backward', info) then return false end pushInfoFilter(id, field, info) + if info.dontCross then + status.dontCross = status.dontCross + 1 + end return true end + ---@param id string + ---@param field string + ---@param info node.info local function releaseInfoAfterBackward(id, field, info) popReject('backward', info) releaseInfoFilter(id, field, info) + if info.dontCross then + status.dontCross = status.dontCross - 1 + end end local function checkBackward(id, node, field) @@ -1032,6 +1047,7 @@ function m.status(mode) count = 0, ftag = {}, btag = {}, + dontCross = 0, cache = vm.getCache('searcher:' .. mode) } return status |