diff options
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/definition.lua | 9 | ||||
-rw-r--r-- | script-beta/core/hover/table.lua | 7 | ||||
-rw-r--r-- | script-beta/vm/eachDef.lua | 2 | ||||
-rw-r--r-- | script-beta/vm/eachField.lua | 2 | ||||
-rw-r--r-- | script-beta/vm/eachRef.lua | 2 | ||||
-rw-r--r-- | script-beta/vm/getInfer.lua | 8 |
6 files changed, 16 insertions, 14 deletions
diff --git a/script-beta/core/definition.lua b/script-beta/core/definition.lua index 37d4e115..eb8f2715 100644 --- a/script-beta/core/definition.lua +++ b/script-beta/core/definition.lua @@ -125,21 +125,22 @@ return function (uri, offset) end vm.setSearchLevel(10) - vm.eachDef(source, function (src) + for _, src in ipairs(vm.getDefs(source, 'deep')) do local root = guide.getRoot(src) if not root then - return + goto CONTINUE end src = src.field or src.method or src.index or src if src.type == 'table' and src.parent.type ~= 'return' then - return + goto CONTINUE end results[#results+1] = { target = src, uri = files.getOriginUri(root.uri), source = source, } - end) + ::CONTINUE:: + end if #results == 0 then return nil diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua index 314d0b42..d5761e17 100644 --- a/script-beta/core/hover/table.lua +++ b/script-beta/core/hover/table.lua @@ -172,10 +172,10 @@ end return function (source) local literals = {} local classes = {} - vm.eachField(source, function (src) + for _, src in ipairs(vm.getFields(source, 'deep')) do local key = getKey(src) if not key then - return + goto CONTINUE end local class, literal = getField(src) if not classes[key] then @@ -186,7 +186,8 @@ return function (source) end classes[key][#classes[key]+1] = class literals[key][#literals[key]+1] = literal - end) + ::CONTINUE:: + end clearClasses(classes) diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua index 8b3c6a9b..46d1887e 100644 --- a/script-beta/vm/eachDef.lua +++ b/script-beta/vm/eachDef.lua @@ -33,7 +33,7 @@ function vm.getDefs(source, deep) or eachDef(source, deep) vm.getCache('eachDefOfGlobal')[name] = cache return cache - elseif deep then + elseif not deep then return eachDef(source, deep) else local cache = vm.getCache('eachDef')[source] diff --git a/script-beta/vm/eachField.lua b/script-beta/vm/eachField.lua index 9075bf36..b644cbd9 100644 --- a/script-beta/vm/eachField.lua +++ b/script-beta/vm/eachField.lua @@ -54,7 +54,7 @@ function vm.getFields(source, deep) or eachField(source, deep) vm.getCache('eachFieldOfGlobal')[name] = cache return cache - elseif deep then + elseif not deep then return eachField(source, deep) else local cache = vm.getCache('eachField')[source] diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index 8391d89d..8df45c67 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -32,7 +32,7 @@ function vm.getRefs(source, deep) or getRefs(source, deep) vm.getCache('eachRefOfGlobal')[name] = cache return cache - elseif deep then + elseif not deep then return getRefs(source, deep) else local cache = vm.getCache('eachRef')[source] diff --git a/script-beta/vm/getInfer.lua b/script-beta/vm/getInfer.lua index db3b240c..c0f2d118 100644 --- a/script-beta/vm/getInfer.lua +++ b/script-beta/vm/getInfer.lua @@ -5,8 +5,8 @@ local util = require 'utility' NIL = setmetatable({'<nil>'}, { __tostring = function () return 'nil' end }) --- 是否包含某种类型 -function vm.hasType(source, type) - local defs = vm.getDefs(source) +function vm.hasType(source, type, deep) + local defs = vm.getDefs(source, deep) for i = 1, #defs do local def = defs[i] local value = guide.getObjectValue(def) or def @@ -18,8 +18,8 @@ function vm.hasType(source, type) end --- 是否包含某种类型 -function vm.hasInferType(source, type) - local infers = vm.getInfers(source) +function vm.hasInferType(source, type, deep) + local infers = vm.getInfers(source, deep) for i = 1, #infers do local infer = infers[i] if infer.type == type then |