summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-01 15:23:55 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-01 15:23:55 +0800
commit7360b34f9a6f9bf51a5843b065431f7f4eeef42b (patch)
tree6600bbc267ebd4e632a9b457714b0c9bc0b540b9 /script/core
parentfea133554b47ac6aef9a55d53e3f694311b10fcd (diff)
downloadlua-language-server-7360b34f9a6f9bf51a5843b065431f7f4eeef42b.zip
generic cross files
Diffstat (limited to 'script/core')
-rw-r--r--script/core/generic.lua5
-rw-r--r--script/core/noder.lua3
-rw-r--r--script/core/searcher.lua17
3 files changed, 19 insertions, 6 deletions
diff --git a/script/core/generic.lua b/script/core/generic.lua
index 78c3eff9..15950974 100644
--- a/script/core/generic.lua
+++ b/script/core/generic.lua
@@ -1,4 +1,6 @@
+local guide = require 'parser.guide'
local noder = require "core.noder"
+
---@class generic.value
---@field type string
---@field closure generic.closure
@@ -143,6 +145,9 @@ local function buildValue(road, key, proto, param, upvalues)
if not paramID then
return
end
+ local myUri = guide.getUri(param)
+ local myHead = noder.URI_CHAR .. myUri .. noder.URI_CHAR
+ paramID = myHead .. paramID
if not upvalues[key] then
upvalues[key] = {}
end
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 5805aafc..e1c07afc 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -257,7 +257,7 @@ local function checkMode(source)
if source.type == 'generic.value' then
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
+ id = id .. URI_CHAR .. guide.getUri(source.closure.call)
end
return id
end
@@ -374,6 +374,7 @@ m.RETURN_INDEX = RETURN_INDEX
m.PARAM_INDEX = PARAM_INDEX
m.TABLE_KEY = TABLE_KEY
m.ANY_FIELD = ANY_FIELD
+m.URI_CHAR = URI_CHAR
--- 寻找doc的主体
---@param obj parser.guide.object
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 9208032c..121e90c6 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -349,7 +349,12 @@ function m.searchRefsByID(status, uri, expect, mode)
local function checkForward(id, node, field)
for _, forwardID in ipairs(node.forward) do
- searchID(forwardID, field)
+ local targetUri, targetID = noder.getUriAndID(forwardID)
+ if targetUri and not files.eq(targetUri, uri) then
+ crossSearch(status, targetUri, targetID .. (field or ''), mode)
+ else
+ searchID(targetID or forwardID, field)
+ end
end
end
@@ -358,7 +363,12 @@ function m.searchRefsByID(status, uri, expect, mode)
return
end
for _, backwardID in ipairs(node.backward) do
- searchID(backwardID, field)
+ local targetUri, targetID = noder.getUriAndID(backwardID)
+ if targetUri and not files.eq(targetUri, uri) then
+ crossSearch(status, targetUri, targetID .. (field or ''), mode)
+ else
+ searchID(targetID or backwardID, field)
+ end
end
end
@@ -471,9 +481,6 @@ function m.searchRefsByID(status, uri, expect, mode)
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)