summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-11 17:51:25 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-11 17:51:25 +0800
commite66956e016a2f9ab635d00a9cb8b2d4bb99bc3a2 (patch)
tree678ab743bf720b506e931ad8ad4e2c84960f65eb /script/core
parent62dee501181ebfa374c827df5a15ea9461f38b73 (diff)
downloadlua-language-server-e66956e016a2f9ab635d00a9cb8b2d4bb99bc3a2.zip
split all reference
Diffstat (limited to 'script/core')
-rw-r--r--script/core/noder.lua1
-rw-r--r--script/core/searcher.lua37
2 files changed, 30 insertions, 8 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 277f4b94..4eb392e9 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -427,6 +427,7 @@ function m.compileNode(noders, source)
-- 参数/call禁止反向查找赋值
local valueType = valueID:match '^.-:'
if valueType ~= 'p:'
+ and valueType ~= 's:'
and valueType ~= 'c:' then
pushBackward(noders, valueID, id, 'set')
end
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index e7755598..73e9ca0f 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -430,11 +430,27 @@ function m.searchRefsByID(status, uri, expect, mode)
if not uris then
return
end
+ local isCall = id:sub(#firstID + 2, #firstID + 2) == noder.RETURN_INDEX
local tid = id .. (field or '')
- for guri in pairs(uris) do
- if not files.eq(uri, guri) then
+ for guri, def in pairs(uris) do
+ if def then
crossSearch(status, guri, tid, mode)
+ goto CONTINUE
+ end
+ if isCall then
+ goto CONTINUE
+ end
+ if not field then
+ goto CONTINUE
+ end
+ if mode == 'def' then
+ goto CONTINUE
end
+ if not files.eq(uri, guri) then
+ goto CONTINUE
+ end
+ crossSearch(status, guri, tid, mode)
+ ::CONTINUE::
end
end
@@ -486,6 +502,12 @@ function m.searchRefsByID(status, uri, expect, mode)
m.pushResult(status, mode, source, force)
end
end
+
+ if node.require then
+ checkRequire(node.require, field)
+ return true
+ end
+
if node.forward then
checkForward(id, node, field)
end
@@ -498,11 +520,7 @@ function m.searchRefsByID(status, uri, expect, mode)
checkENV(node.sources[1], field)
end
- if node.require then
- checkRequire(node.require, field)
- end
-
- checkMainReturn(id, node, field)
+ --checkMainReturn(id, node, field)
if node.call then
callStack[#callStack] = nil
@@ -522,7 +540,10 @@ function m.searchRefsByID(status, uri, expect, mode)
end
local node = noder.getNodeByID(root, id)
if node then
- searchNode(id, node, field)
+ local skip = searchNode(id, node, field)
+ if skip then
+ return
+ end
end
checkGlobal(id, node, field)
checkClass(id, node, field)