summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-18 17:52:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-18 17:52:37 +0800
commitbc4648dca8384b68a128ab5096ec2e36aa0546fe (patch)
treedc715a5229fa67a89c0403ac93fb5b97951874b9 /script
parentbdc34b18b2ff113734372b7932cfed62dfded0ee (diff)
downloadlua-language-server-bc4648dca8384b68a128ab5096ec2e36aa0546fe.zip
allref
Diffstat (limited to 'script')
-rw-r--r--script/core/noder.lua22
-rw-r--r--script/core/searcher.lua25
-rw-r--r--script/files.lua2
3 files changed, 37 insertions, 12 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua
index b853497e..7a1733de 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -444,6 +444,8 @@ local function bindValue(noders, source, id)
and valueType ~= 's:'
and valueType ~= 'c:' then
pushBackward(noders, valueID, id, 'set')
+ else
+ pushBackward(noders, valueID, id, 'deep')
end
end
@@ -475,14 +477,15 @@ local function compileCall(noders, call, sourceID, returnIndex)
pushForward(noders, sourceID, tblID)
pushForward(noders, sourceID, indexID)
pushBackward(noders, tblID, sourceID)
- return
--pushBackward(noders, indexID, callID)
+ return
end
if node.special == 'require' then
local arg1 = call.args and call.args[1]
if arg1 and arg1.type == 'string' then
getNode(noders, sourceID).require = arg1[1]
end
+ pushBackward(noders, callID, sourceID, 'deep')
return
end
if node.special == 'pcall'
@@ -501,7 +504,7 @@ local function compileCall(noders, call, sourceID, returnIndex)
index
)
pushForward(noders, sourceID, pfuncXID)
- --pushBackward(noders, funcXID, id)
+ pushBackward(noders, pfuncXID, sourceID, 'deep')
return
end
local funcXID = ('%s%s%s'):format(
@@ -511,6 +514,7 @@ local function compileCall(noders, call, sourceID, returnIndex)
)
getNode(noders, sourceID).call = call
pushForward(noders, sourceID, funcXID)
+ pushBackward(noders, funcXID, sourceID, 'deep')
end
---@param noders noders
@@ -542,8 +546,8 @@ function m.compileNode(noders, source)
if setmethod and ( setmethod.type == 'setmethod'
or setmethod.type == 'setfield'
or setmethod.type == 'setindex') then
- pushForward(noders, id, getID(setmethod.node), 'method')
- --pushBackward(noders, getID(setmethod.node), id, 'method')
+ pushForward(noders, id, getID(setmethod.node))
+ pushBackward(noders, getID(setmethod.node), id, 'deep')
end
end
-- 分解 @type
@@ -736,6 +740,9 @@ function m.compileNode(noders, source)
rtn.returnIndex
)
pushForward(noders, fullID, getID(rtn))
+ for _, typeUnit in ipairs(rtn.types) do
+ pushBackward(noders, getID(typeUnit), fullID, 'deep')
+ end
hasDocReturn[rtn.returnIndex] = true
end
end
@@ -786,10 +793,7 @@ function m.compileNode(noders, source)
)
for _, rtnObj in ipairs(rtnObjs) do
pushForward(noders, returnID, getID(rtnObj))
- if rtnObj.type == 'function'
- or rtnObj.type == 'call' then
- --pushBackward(noders, getID(rtnObj), returnID)
- end
+ pushBackward(noders, getID(rtnObj), returnID, 'deep')
end
end
end
@@ -810,7 +814,7 @@ function m.compileNode(noders, source)
local rtnObj = rtn[1]
if rtnObj then
pushForward(noders, 'mainreturn', getID(rtnObj))
- --pushBackward(noders, getID(rtnObj), 'mainreturn')
+ pushBackward(noders, getID(rtnObj), 'mainreturn', 'deep')
end
end
end
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 6c10f09a..05733af4 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -428,6 +428,9 @@ function m.searchRefsByID(status, uri, expect, mode)
end
for _, backwardID in ipairs(node.backward) do
local tag = node.backward[backwardID]
+ if tag == 'deep' and mode ~= 'allref' then
+ goto CONTINUE
+ end
if not checkThenPushTag('backward', tag) then
goto CONTINUE
end
@@ -521,6 +524,23 @@ function m.searchRefsByID(status, uri, expect, mode)
end
end
+ local function checkMainReturn(id, node, field)
+ if id ~= 'mainreturn' then
+ return
+ end
+ local calls = vm.getLinksTo(uri)
+ for _, call in ipairs(calls) do
+ local curi = guide.getUri(call)
+ local cid = ('%s%s'):format(
+ noder.getID(call),
+ field or ''
+ )
+ if not files.eq(curi, uri) then
+ crossSearch(status, curi, cid, mode, uri)
+ end
+ end
+ end
+
local function searchNode(id, node, field)
if node.call then
callStack[#callStack+1] = node.call
@@ -534,7 +554,6 @@ function m.searchRefsByID(status, uri, expect, mode)
if node.require then
checkRequire(node.require, field)
- return
end
local isSepcial = checkSpecial(id, node, field)
@@ -552,7 +571,9 @@ function m.searchRefsByID(status, uri, expect, mode)
checkENV(node.sources[1], field)
end
- --checkMainReturn(id, node, field)
+ if mode == 'allref' then
+ checkMainReturn(id, node, field)
+ end
if node.call then
callStack[#callStack] = nil
diff --git a/script/files.lua b/script/files.lua
index d99f6473..dffc976c 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -401,7 +401,7 @@ function m.compileState(uri, text)
if not m.notifyCache['preloadFileSize'][uri] then
m.notifyCache['preloadFileSize'][uri] = true
m.notifyCache['skipLargeFileCount'] = m.notifyCache['skipLargeFileCount'] + 1
- if m.notifyCache['skipLargeFileCount'] <= 3 then
+ if m.notifyCache['skipLargeFileCount'] <= 1 then
proto.notify('window/showMessage', {
type = 3,
message = lang.script('WORKSPACE_SKIP_LARGE_FILE'