diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-22 15:02:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-22 15:02:25 +0800 |
commit | fbd1394858972c92439d927fa30dabcfd55dc705 (patch) | |
tree | 38b6b0aaa4b7760f68bd1d10a1c0d02f23a42b10 /server-beta/src | |
parent | dc7275ac9b56f26923c80c1e8bbce185c2d147a4 (diff) | |
download | lua-language-server-fbd1394858972c92439d927fa30dabcfd55dc705.zip |
修正一个引用计算的bug
Diffstat (limited to 'server-beta/src')
-rw-r--r-- | server-beta/src/vm/eachRef.lua | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/server-beta/src/vm/eachRef.lua b/server-beta/src/vm/eachRef.lua index 465b1267..cfb2bef8 100644 --- a/server-beta/src/vm/eachRef.lua +++ b/server-beta/src/vm/eachRef.lua @@ -6,11 +6,8 @@ local function ofCall(func, index, callback) vm.eachRef(func, function (info) local src = info.source local returns - if info.mode == 'main' then + if src.type == 'main' or src.type == 'function' then returns = src.returns - else - local funcDef = src.value - returns = funcDef and funcDef.returns end if returns then -- 搜索函数第 index 个返回值 @@ -52,7 +49,26 @@ local function ofReturn(rtn, index, callback) end -- 搜索函数调用的第 index 个接收值 if func.type == 'main' then - vm.eachRef(func, callback) + local myUri = func.uri + local uris = files.findLinkTo(myUri) + if not uris then + return + end + for _, uri in ipairs(uris) do + local ast = files.getAst(uri) + if ast then + local links = vm.getLinks(ast.ast) + if links then + for linkUri, calls in pairs(links) do + if files.eq(linkUri, myUri) then + for i = 1, #calls do + ofCallSelect(calls[i], 1, callback) + end + end + end + end + end + end else vm.eachRef(func, function (info) local source = info.source @@ -390,26 +406,6 @@ local function ofMain(source, callback) source = source, mode = 'main', } - local myUri = source.uri - local uris = files.findLinkTo(myUri) - if not uris then - return - end - for _, uri in ipairs(uris) do - local ast = files.getAst(uri) - if ast then - local links = vm.getLinks(ast.ast) - if links then - for linkUri, calls in pairs(links) do - if files.eq(linkUri, myUri) then - for i = 1, #calls do - ofCallSelect(calls[i], 1, callback) - end - end - end - end - end - end end local function eachRef(source, callback) |