summaryrefslogtreecommitdiff
path: root/script-beta/vm/eachDef.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-14 16:25:27 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-14 16:25:27 +0800
commit83611b3112bd6c4bf0fe51df585549aa32e9ff51 (patch)
tree6ef3a1dace4181a5a7cf25aeb2dcf9f6c045e253 /script-beta/vm/eachDef.lua
parentbbd6f89a2a024e4b9fa7f7f1f5cd5564187c622b (diff)
downloadlua-language-server-83611b3112bd6c4bf0fe51df585549aa32e9ff51.zip
整理代码
Diffstat (limited to 'script-beta/vm/eachDef.lua')
-rw-r--r--script-beta/vm/eachDef.lua24
1 files changed, 17 insertions, 7 deletions
diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua
index 89a67369..19b0f3bd 100644
--- a/script-beta/vm/eachDef.lua
+++ b/script-beta/vm/eachDef.lua
@@ -14,6 +14,16 @@ local function checkPath(source, info)
if mode == 'before' then
return false
end
+ if mode == 'equal' then
+ if src.type == 'field'
+ or src.type == 'method'
+ or src.type == 'local'
+ or src.type == 'setglobal' then
+ return true
+ else
+ return false
+ end
+ end
return true
end
@@ -60,6 +70,13 @@ function vm.eachDef(source, callback)
end
used[src] = true
destUri = guide.getRoot(src).uri
+ -- 如果是同一个文件,则检查位置关系后放行
+ if sourceUri == destUri then
+ if checkPath(source, info) then
+ res = pushDef(info)
+ end
+ goto CONTINUE
+ end
-- 如果是global或field,则直接放行(因为无法确定顺序)
if src.type == 'setindex'
or src.type == 'setfield'
@@ -70,13 +87,6 @@ function vm.eachDef(source, callback)
res = pushDef(info)
goto CONTINUE
end
- -- 如果是同一个文件,则检查位置关系后放行
- if sourceUri == destUri then
- if checkPath(source, info) then
- res = pushDef(info)
- end
- goto CONTINUE
- end
-- 如果不是同一个文件,则必须在该文件 return 后才放行
if returns[destUri] then
res = pushDef(info)