diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-25 19:43:01 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-25 19:43:01 +0800 |
commit | ce158c82b0de9f7dd700ed4eabea6e9e26f491da (patch) | |
tree | 13ad06ca3320ab3cd2ae89b2ed3d407bed457c75 /script/vm | |
parent | 123d904a16f49764f36cabef97c2be0f2acca34c (diff) | |
download | lua-language-server-ce158c82b0de9f7dd700ed4eabea6e9e26f491da.zip |
cleanup
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/eachDef.lua | 46 | ||||
-rw-r--r-- | script/vm/eachField.lua | 109 | ||||
-rw-r--r-- | script/vm/eachRef.lua | 45 | ||||
-rw-r--r-- | script/vm/getDocs.lua | 2 | ||||
-rw-r--r-- | script/vm/getLibrary.lua | 4 | ||||
-rw-r--r-- | script/vm/init.lua | 1 |
6 files changed, 7 insertions, 200 deletions
diff --git a/script/vm/eachDef.lua b/script/vm/eachDef.lua index e6af8d99..6f7af295 100644 --- a/script/vm/eachDef.lua +++ b/script/vm/eachDef.lua @@ -1,49 +1,7 @@ ---@type vm local vm = require 'vm.vm' local searcher = require 'core.searcher' -local files = require 'files' -local util = require 'utility' -local await = require 'await' -local config = require 'config' -local function getDefs(source, deep) - local results = {} - local lock = vm.lock('eachDef', source) - if not lock then - return results - end - - await.delay() - - deep = config.config.intelliSense.searchDepth + (deep or 0) - - local clock = os.clock() - local myResults, count = searcher.requestDefinition(source, vm.interface, deep) - if DEVELOP and os.clock() - clock > 0.1 then - log.warn('requestDefinition', count, os.clock() - clock, searcher.getUri(source), util.dump(source, { deep = 1 })) - end - vm.mergeResults(results, myResults) - - lock() - - return results -end - -function vm.getDefs(source, deep) - deep = deep or -999 - if false and searcher.isGlobal(source) then - local key = searcher.getKeyName(source) - if not key then - return {} - end - return vm.getGlobalSets(key) - else - local cache = vm.getCache('eachDef')[source] - if not cache or cache.deep < deep then - cache = getDefs(source, deep) - cache.deep = deep - --vm.getCache('eachDef')[source] = cache - end - return cache - end +function vm.getDefs(source, field) + return searcher.requestDefinition(source, field) end diff --git a/script/vm/eachField.lua b/script/vm/eachField.lua deleted file mode 100644 index 7718f41e..00000000 --- a/script/vm/eachField.lua +++ /dev/null @@ -1,109 +0,0 @@ ----@type vm -local vm = require 'vm.vm' -local searcher= require 'core.searcher' -local await = require 'await' -local config = require 'config' - -local function getFields(source, deep, filterKey) - local unlock = vm.lock('eachField', source) - if not unlock then - return {} - end - - while source.type == 'paren' do - source = source.exp - if not source then - return {} - end - end - deep = config.config.intelliSense.searchDepth + (deep or 0) - - await.delay() - local results = searcher.requestFields(source, filterKey) - - unlock() - return results -end - -local function getDefFields(source, deep, filterKey) - local unlock = vm.lock('eachDefField', source) - if not unlock then - return {} - end - - while source.type == 'paren' do - source = source.exp - if not source then - return {} - end - end - deep = config.config.intelliSense.searchDepth + (deep or 0) - - await.delay() - local results = searcher.requestDefFields(source, vm.interface, deep, filterKey) - - unlock() - return results -end - -local function getFieldsBySource(source, deep, filterKey) - deep = deep or -999 - local cache = vm.getCache('eachField')[source] - if not cache or cache.deep < deep then - cache = getFields(source, deep, filterKey) - cache.deep = deep - if not filterKey then - vm.getCache('eachField')[source] = cache - end - end - return cache -end - -local function getDefFieldsBySource(source, deep, filterKey) - deep = deep or -999 - local cache = vm.getCache('eachDefField')[source] - if not cache or cache.deep < deep then - cache = getDefFields(source, deep, filterKey) - cache.deep = deep - if not filterKey then - vm.getCache('eachDefField')[source] = cache - end - end - return cache -end - -function vm.getFields(source, deep) - if source.special == '_G' then - return vm.getGlobals '*' - end - if searcher.isGlobal(source) then - local name = searcher.getKeyName(source) - if not name then - return {} - end - local cache = vm.getCache('eachFieldOfGlobal')[name] - or getFieldsBySource(source, deep) - vm.getCache('eachFieldOfGlobal')[name] = cache - return cache - else - return getFieldsBySource(source, deep) - end -end - -function vm.getDefFields(source, deep) - if source.special == '_G' then - return vm.getGlobalSets '*' - end - if searcher.isGlobal(source) then - local name = searcher.getKeyName(source) - if not name then - return {} - end - local cache = vm.getCache('eachDefFieldOfGlobal')[name] - or getDefFieldsBySource(source, deep) - vm.getCache('eachDefFieldOfGlobal')[name] = cache - return cache - else - return getDefFieldsBySource(source, deep) - end -end diff --git a/script/vm/eachRef.lua b/script/vm/eachRef.lua index 7ac523ee..5aca198e 100644 --- a/script/vm/eachRef.lua +++ b/script/vm/eachRef.lua @@ -1,48 +1,7 @@ ---@type vm local vm = require 'vm.vm' local searcher = require 'core.searcher' -local util = require 'utility' -local await = require 'await' -local config = require 'config' -local function getRefs(source, deep) - local results = {} - local lock = vm.lock('eachRef', source) - if not lock then - return results - end - - await.delay() - - deep = config.config.intelliSense.searchDepth + (deep or 0) - - local clock = os.clock() - local myResults, count = searcher.requestReference(source, vm.interface, deep) - if DEVELOP and os.clock() - clock > 0.1 then - log.warn('requestReference', count, os.clock() - clock, searcher.getUri(source), util.dump(source, { deep = 1 })) - end - vm.mergeResults(results, myResults) - - lock() - - return results -end - -function vm.getRefs(source, deep) - deep = deep or -999 - if false and searcher.isGlobal(source) then - local key = searcher.getKeyName(source) - if not key then - return {} - end - return vm.getGlobals(key) - else - local cache = vm.getCache('eachRef')[source] - if not cache or cache.deep < deep then - cache = getRefs(source, deep) - cache.deep = deep - vm.getCache('eachRef')[source] = cache - end - return cache - end +function vm.getRefs(source, field) + return searcher.requestReference(source, field) end diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua index 54ddbe02..09bbd964 100644 --- a/script/vm/getDocs.lua +++ b/script/vm/getDocs.lua @@ -212,7 +212,7 @@ end function vm.isDeprecated(value, deep) if deep then - local defs = vm.getDefs(value, 0) + local defs = vm.getDefs(value) if #defs == 0 then return false end diff --git a/script/vm/getLibrary.lua b/script/vm/getLibrary.lua index 16e2bd51..a3c8feb0 100644 --- a/script/vm/getLibrary.lua +++ b/script/vm/getLibrary.lua @@ -1,11 +1,11 @@ ---@type vm local vm = require 'vm.vm' -function vm.getLibraryName(source, deep) +function vm.getLibraryName(source) if source.special then return source.special end - local defs = vm.getDefs(source, deep) + local defs = vm.getDefs(source) for _, def in ipairs(defs) do if def.special then return def.special diff --git a/script/vm/init.lua b/script/vm/init.lua index 586236f3..6eb2941d 100644 --- a/script/vm/init.lua +++ b/script/vm/init.lua @@ -3,7 +3,6 @@ require 'vm.getGlobals' require 'vm.getDocs' require 'vm.getLibrary' require 'vm.getMeta' -require 'vm.eachField' require 'vm.eachDef' require 'vm.eachRef' require 'vm.getLinks' |