diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-10-29 20:43:01 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-10-29 20:43:01 +0800 |
commit | d5ecec7f362db69879e5097e41bd334d76260783 (patch) | |
tree | 1b14ddf979adfb684a49d7db9d640b35d224c338 | |
parent | e98483d89ac38463cf5b717a3b19861baf8f3e94 (diff) | |
download | lua-language-server-d5ecec7f362db69879e5097e41bd334d76260783.zip |
整理代码
-rw-r--r-- | script-beta/core/hover/init.lua | 2 | ||||
-rw-r--r-- | script-beta/core/hover/label.lua | 2 | ||||
-rw-r--r-- | script-beta/parser/guide.lua | 7 | ||||
-rw-r--r-- | script-beta/vm/eachDef.lua | 12 | ||||
-rw-r--r-- | script-beta/vm/eachField.lua | 8 | ||||
-rw-r--r-- | script-beta/vm/eachRef.lua | 8 |
6 files changed, 20 insertions, 19 deletions
diff --git a/script-beta/core/hover/init.lua b/script-beta/core/hover/init.lua index 77f9d6d9..ab8bd566 100644 --- a/script-beta/core/hover/init.lua +++ b/script-beta/core/hover/init.lua @@ -80,7 +80,7 @@ end local function getHover(source) vm.setSearchLevel(5) - local isFunction = vm.hasInferType(source, 'function') + local isFunction = vm.hasInferType(source, 'function', 'deep') if isFunction then return getHoverAsFunction(source) else diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index 67faefe6..2c0bdcd1 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -36,7 +36,7 @@ local function asValue(source, title) local class = vm.getClass(source) local literal = vm.getInferLiteral(source) local cont - if vm.hasInferType(source, 'table') then + if vm.hasInferType(source, 'table', 'deep') then cont = buildTable(source) end local pack = {} diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 1d375d89..7144ebbe 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1186,7 +1186,7 @@ function m.status(parentStatus, interface) deep = parentStatus and parentStatus.deep, results = {}, } - if status.depth >= 3 then + if status.depth >= 5 then status.deep = false end status.lock = status.locks[status.depth] or {} @@ -1319,7 +1319,7 @@ function m.searchFields(status, obj, key, interface, deep) return results else local newStatus = m.status(status, interface) - --newStatus.deep = deep + newStatus.deep = deep local simple = m.getSimple(obj) if not simple then return {} @@ -2221,7 +2221,8 @@ end function m.getRefCache(status, obj, mode) local cache, globalCache - if status.depth == 1 then + if status.depth == 1 + and status.deep then globalCache = status.interface.cache and status.interface.cache() or {} end cache = status.cache.refCache or {} diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua index 46d1887e..5d1aa566 100644 --- a/script-beta/vm/eachDef.lua +++ b/script-beta/vm/eachDef.lua @@ -4,7 +4,7 @@ local files = require 'files' local util = require 'utility' local await = require 'await' -local function eachDef(source, simple) +local function eachDef(source, deep) local results = {} local lock = vm.lock('eachDef', source) if not lock then @@ -14,7 +14,7 @@ local function eachDef(source, simple) await.delay() local clock = os.clock() - local myResults, count = guide.requestDefinition(source, vm.interface, simple) + local myResults, count = guide.requestDefinition(source, vm.interface, deep) if DEVELOP and os.clock() - clock > 0.1 then log.warn('requestDefinition', count, os.clock() - clock, guide.getUri(source), util.dump(source, { deep = 1 })) end @@ -30,15 +30,15 @@ function vm.getDefs(source, deep) local name = guide.getKeyName(source) local cache = vm.getCache('eachDefOfGlobal')[name] or vm.getCache('eachDef')[source] - or eachDef(source, deep) + or eachDef(source, 'deep') vm.getCache('eachDefOfGlobal')[name] = cache return cache - elseif not deep then - return eachDef(source, deep) else local cache = vm.getCache('eachDef')[source] or eachDef(source, deep) - vm.getCache('eachDef')[source] = cache + if deep then + vm.getCache('eachDef')[source] = cache + end return cache end end diff --git a/script-beta/vm/eachField.lua b/script-beta/vm/eachField.lua index b644cbd9..90892f03 100644 --- a/script-beta/vm/eachField.lua +++ b/script-beta/vm/eachField.lua @@ -51,15 +51,15 @@ function vm.getFields(source, deep) local name = guide.getKeyName(source) local cache = vm.getCache('eachFieldOfGlobal')[name] or vm.getCache('eachField')[source] - or eachField(source, deep) + or eachField(source, 'deep') vm.getCache('eachFieldOfGlobal')[name] = cache return cache - elseif not deep then - return eachField(source, deep) else local cache = vm.getCache('eachField')[source] or eachField(source, deep) - vm.getCache('eachField')[source] = cache + if deep then + vm.getCache('eachField')[source] = cache + end return cache end end diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index 8df45c67..ea46c9ee 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -29,15 +29,15 @@ function vm.getRefs(source, deep) local name = guide.getKeyName(source) local cache = vm.getCache('eachRefOfGlobal')[name] or vm.getCache('eachRef')[source] - or getRefs(source, deep) + or getRefs(source, 'deep') vm.getCache('eachRefOfGlobal')[name] = cache return cache - elseif not deep then - return getRefs(source, deep) else local cache = vm.getCache('eachRef')[source] or getRefs(source, deep) - vm.getCache('eachRef')[source] = cache + if deep then + vm.getCache('eachRef')[source] = cache + end return cache end end |