summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-04-15 20:10:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-04-15 20:10:37 +0800
commitf09d553bc1570112d8e405fb0e89491fc7380bcd (patch)
tree4a1291be2c3125697063509f0c390a2f35685548 /script
parent7f1d5adae4b59857282afc969a63147618afa710 (diff)
downloadlua-language-server-f09d553bc1570112d8e405fb0e89491fc7380bcd.zip
stash
Diffstat (limited to 'script')
-rw-r--r--script/core/guide.lua30
-rw-r--r--script/core/linker.lua9
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),