diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-01-23 16:59:03 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-01-23 16:59:03 +0800 |
commit | 7d23f084f713b372649e1e4dfb993c8997076686 (patch) | |
tree | 194645740e116914f36a8817c0c1aa9a089bd854 | |
parent | 0a5fbd8a8889599b2216c674819569eda754ef05 (diff) | |
download | lua-language-server-7d23f084f713b372649e1e4dfb993c8997076686.zip |
更新
-rw-r--r-- | script-beta/vm/eachRef.lua | 22 | ||||
-rw-r--r-- | script-beta/vm/getMeta.lua | 2 |
2 files changed, 21 insertions, 3 deletions
diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index 6d34d28b..507b713d 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -2,9 +2,27 @@ local guide = require 'parser.guide' local files = require 'files' local vm = require 'vm.vm' +local function ofParentMT(func, callback) + if not func or func.type ~= 'function' then + return + end + local parent = func.parent + if not parent or parent.type ~= 'setmethod' then + return + end + local node = parent.node + if not node then + return + end + vm.eachRef(node, callback) +end + local function ofLocal(loc, callback) -- 方法中的 self 使用了一个虚拟的定义位置 - if loc.tag ~= 'self' then + if loc.tag == 'self' then + local func = guide.getParentFunction(loc) + ofParentMT(func, callback) + else callback(loc) end local refs = loc.ref @@ -191,7 +209,7 @@ end --- 获取所有的引用 --- 可以穿透函数返回值 -function vm.eachRef(source, callback, max) +function vm.eachRef(source, callback) local mark = {} eachRef(source, function (src) if mark[src] then diff --git a/script-beta/vm/getMeta.lua b/script-beta/vm/getMeta.lua index 4915f616..49e9cf34 100644 --- a/script-beta/vm/getMeta.lua +++ b/script-beta/vm/getMeta.lua @@ -26,7 +26,7 @@ local function eachMetaOfRecv(source, callback) if special ~= 'setmetatable' then return end - vm.eachFieldInTable(call.args[1]) + vm.eachFieldInTable(call.args[1], callback) local mt = call.args[2] if mt then callback(mt) |