diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/core/guide.lua | 30 | ||||
-rw-r--r-- | script/core/linker.lua | 9 |
2 files changed, 27 insertions, 12 deletions
diff --git a/script/core/guide.lua b/script/core/guide.lua index eba1301b..dd7888c6 100644 --- a/script/core/guide.lua +++ b/script/core/guide.lua @@ -121,6 +121,24 @@ function m.searchRefs(status, source, mode) pushQueueWithID(source) + local function checkForward(link) + if not link.forward then + return + end + for _, forwardSources in ipairs(link.forward) do + pushQueueWithID(forwardSources) + end + end + + local function checkBackward(link) + if not link.backward then + return + end + for _, backSources in ipairs(link.backward) do + pushQueueWithID(backSources) + end + end + for _ = 1, 1000 do if index <= 0 then break @@ -134,16 +152,8 @@ function m.searchRefs(status, source, mode) end for _, eachLink in ipairs(links) do m.pushResult(status, mode, eachLink.source) - if eachLink.forward then - for _, forwardSources in ipairs(eachLink.forward) do - pushQueueWithID(forwardSources) - end - end - if eachLink.backward then - for _, backSources in ipairs(eachLink.backward) do - pushQueueWithID(backSources) - end - end + checkForward(eachLink) + checkBackward(eachLink) end ::CONTINUE:: end diff --git a/script/core/linker.lua b/script/core/linker.lua index a064deaa..64aaef1c 100644 --- a/script/core/linker.lua +++ b/script/core/linker.lua @@ -147,11 +147,15 @@ local function getID(source) end util.revertTable(IDList) local id = table.concat(IDList, '|') - return id, current + local parentID = table.concat(IDList, '|', 1, -2) + return id, current, parentID end ---@class link +-- 当前节点的id ---@field id string +-- 父节点的id +---@field parentID string -- 语法树单元 ---@field source parser.guide.object -- 是否是局部变量 @@ -173,13 +177,14 @@ end ---@param source parser.guide.object ---@return link local function createLink(source) - local id, node = getID(source) + local id, node, parentID = getID(source) if not id then return nil end return { id = id, source = source, + parentID = parentID, loc = checkLocal(node), global = checkGlobal(node), tfield = checkTableField(node), |