diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-04-14 14:28:27 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-04-14 14:28:27 +0800 |
commit | 864db86144b557e7d4eb8d96177d9642b4eff441 (patch) | |
tree | 7bd4191954153af2ea3aacab98b818b9d0c63312 /script | |
parent | 161e02bb631b7f5916c11119323305aa2c258775 (diff) | |
download | lua-language-server-864db86144b557e7d4eb8d96177d9642b4eff441.zip |
stash
Diffstat (limited to 'script')
-rw-r--r-- | script/core/linker.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/script/core/linker.lua b/script/core/linker.lua index 7ebff65c..d7f53fa4 100644 --- a/script/core/linker.lua +++ b/script/core/linker.lua @@ -1,4 +1,3 @@ -local guide = require 'parser.guide' local util = require 'utility' local function getKey(source) @@ -41,11 +40,18 @@ local function checkTableField(source) return nil end -local function checkFileReturn(source) +local function checkFunctionReturn(source) if source.parent - and source.parent.type == 'return' - and source.parent.parent.type == 'main' then - return true + and source.parent.type == 'return' then + if source.parent.parent.type == 'main' then + return 0 + elseif source.parent.parent.type == 'function' then + for i = 1, #source.parent do + if source.parent[i] == source then + return i + end + end + end end return nil end @@ -83,8 +89,8 @@ local function createLink(source) global = checkGlobal(node), -- 字面量表中的字段 tfield = checkTableField(node), - -- 文件的返回值 - freturn = checkFileReturn(node), + -- 返回值,文件返回值总是0,函数返回值为第几个返回值 + freturn = checkFunctionReturn(node), } end |