summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-11 18:50:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-11 18:50:49 +0800
commitf6af139891a40eaadc8197202b198a3965a05c3b (patch)
tree724fb6bef9dac5b57d44f495f72d0c82f3e599bf /script-beta
parent9d8602cedb35b2e6954b9ccbf26311c1662a2ff0 (diff)
downloadlua-language-server-f6af139891a40eaadc8197202b198a3965a05c3b.zip
暂存
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/parser/guide.lua68
1 files changed, 39 insertions, 29 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua
index 3a2d516d..fbbd154b 100644
--- a/script-beta/parser/guide.lua
+++ b/script-beta/parser/guide.lua
@@ -1434,37 +1434,10 @@ function m.searchSameFields(status, simple, mode)
end
end
-function m.searchRefsAsFunctionReturn(status, obj, mode)
- status.results[#status.results+1] = obj
- -- 搜索所在函数
- local currentFunc = m.getParentFunction(obj)
- if currentFunc.type == 'main' then
- return
- end
- local returns = currentFunc.returns
- if not returns then
- return
- end
- -- 看看他是第几个返回值
- local index
- for i = 1, #returns do
- local rtn = returns[i]
- if m.isContain(rtn, obj.start) then
- for j = 1, #rtn do
- if obj == rtn[j] then
- index = j
- goto BREAK
- end
- end
- end
- end
- ::BREAK::
- if not index then
- return
- end
+function m.getCallerInSameFile(status, func, index)
-- 搜索所有所在函数的调用者
local funcRefs = m.status(status)
- m.searchRefOfValue(funcRefs, currentFunc)
+ m.searchRefOfValue(funcRefs, func)
if #funcRefs.results == 0 then
return
@@ -1496,7 +1469,44 @@ function m.searchRefsAsFunctionReturn(status, obj, mode)
end
end
end
+ return selects
+end
+
+function m.searchRefsAsFunctionReturn(status, obj, mode)
+ status.results[#status.results+1] = obj
+ -- 搜索所在函数
+ local currentFunc = m.getParentFunction(obj)
+ local returns = currentFunc.returns
+ if not returns then
+ return
+ end
+ -- 看看他是第几个返回值
+ local index
+ for i = 1, #returns do
+ local rtn = returns[i]
+ if m.isContain(rtn, obj.start) then
+ for j = 1, #rtn do
+ if obj == rtn[j] then
+ index = j
+ goto BREAK
+ end
+ end
+ end
+ end
+ ::BREAK::
+ if not index then
+ return
+ end
+ local selects
+ if currentFunc.type == 'main' then
+ selects = m.getCallerCrossFiles(status, currentFunc, index)
+ else
+ selects = m.getCallerInSameFile(status, currentFunc, index)
+ end
-- 搜索调用者的引用
+ if not selects then
+ return
+ end
for i = 1, #selects do
m.searchRefs(status, selects[i])
end