diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-12-14 17:42:31 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-12-14 17:42:31 +0800 |
commit | 8a28e876dd001daec94eb12cf037968f99dc4efe (patch) | |
tree | 4a3344a38462630f72c139f7a6815460c59736af | |
parent | a70dda951670e48b6fadc1263deccbbc8b948bea (diff) | |
download | lua-language-server-8a28e876dd001daec94eb12cf037968f99dc4efe.zip |
eachDef的一些想法
-rw-r--r-- | script-beta/parser/guide.lua | 8 | ||||
-rw-r--r-- | script-beta/vm/eachDef.lua | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 2592955a..7680168d 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -588,9 +588,9 @@ end ---@return string|boolean mode ---@return table|nil pathA ---@return table|nil pathB -function m.getPath(a, b) +function m.getPath(a, b, sameFunction) --- 首先测试双方在同一个函数内 - if m.getParentFunction(a) ~= m.getParentFunction(b) then + if not sameFunction and m.getParentFunction(a) ~= m.getParentFunction(b) then return false end local mode @@ -612,14 +612,14 @@ function m.getPath(a, b) for _ = 1, 1000 do objA = m.getParentBlock(objA) pathA[#pathA+1] = objA - if objA.type == 'function' or objA.type == 'main' then + if (not sameFunction and objA.type == 'function') or objA.type == 'main' then break end end for _ = 1, 1000 do objB = m.getParentBlock(objB) pathB[#pathB+1] = objB - if objB.type == 'function' or objB.type == 'main' then + if (not sameFunction and objA.type == 'function') or objB.type == 'main' then break end end diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua index 19b0f3bd..cf865384 100644 --- a/script-beta/vm/eachDef.lua +++ b/script-beta/vm/eachDef.lua @@ -27,6 +27,10 @@ local function checkPath(source, info) return true end +-- TODO +-- 只搜索本文件中的引用 +-- 跨文件时,选确定入口(main的return),然后递归搜索本文件中的引用 +-- 如果类型为setfield等,要确定tbl相同 function vm.eachDef(source, callback) local results = {} local returns = {} |