diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-29 14:46:08 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-29 14:46:08 +0800 |
commit | e362be47cd394fdb197840781e371867145990b0 (patch) | |
tree | 34ea1ff9e7b4b52bf5b484cd8b098eeed56adea0 /server-beta | |
parent | 580f86d4de5a47fa4cabd362086ba44cd3bbd661 (diff) | |
download | lua-language-server-e362be47cd394fdb197840781e371867145990b0.zip |
调用返回值支持 __index
Diffstat (limited to 'server-beta')
-rw-r--r-- | server-beta/src/searcher/eachRef.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua index 7ecfa35a..b490f0a2 100644 --- a/server-beta/src/searcher/eachRef.lua +++ b/server-beta/src/searcher/eachRef.lua @@ -21,12 +21,35 @@ local function ofCall(searcher, func, index, callback) end) end +local function ofSpecialCall(searcher, call, func, index, callback) + local name = searcher:getSpecialName(func) + if name == 'setmetatable' then + if index == 1 then + local args = call.args + if args[1] then + searcher:eachRef(args[1], callback) + end + if args[2] then + searcher:eachField(args[2], function (info) + if info.key == 's|__index' then + info.searcher:eachRef(info.source, callback) + if info.value then + info.searcher:eachRef(info.value, callback) + end + end + end) + end + end + end +end + local function ofValue(searcher, value, callback) if value.type == 'select' then -- 检查函数返回值 local call = value.vararg if call.type == 'call' then ofCall(searcher, call.node, value.index, callback) + ofSpecialCall(searcher, call, call.node, value.index, callback) end return end @@ -195,5 +218,10 @@ return function (searcher, source, callback) ofGoTo(searcher, source, callback) elseif stype == 'label' then ofLabel(searcher, source, callback) + else + callback { + searcher = searcher, + source = source, + } end end |