diff options
-rw-r--r-- | script/core/diagnostics/undefined-env-child.lua | 3 | ||||
-rw-r--r-- | script/core/highlight.lua | 2 | ||||
-rw-r--r-- | script/core/hover/label.lua | 2 | ||||
-rw-r--r-- | script/core/infer.lua | 7 | ||||
-rw-r--r-- | script/core/searcher.lua | 40 | ||||
-rw-r--r-- | script/vm/getDocs.lua | 2 |
6 files changed, 9 insertions, 47 deletions
diff --git a/script/core/diagnostics/undefined-env-child.lua b/script/core/diagnostics/undefined-env-child.lua index c97c3fe8..ea9d1c4c 100644 --- a/script/core/diagnostics/undefined-env-child.lua +++ b/script/core/diagnostics/undefined-env-child.lua @@ -2,6 +2,7 @@ local files = require 'files' local searcher = require 'core.searcher' local guide = require 'parser.guide' local lang = require 'language' +local vm = require "vm.vm" return function (uri, callback) local ast = files.getAst(uri) @@ -13,7 +14,7 @@ return function (uri, callback) if source.node.tag == '_ENV' then return end - local defs = searcher.requestDefinition(source) + local defs = vm.getDefs(source) if #defs > 0 then return end diff --git a/script/core/highlight.lua b/script/core/highlight.lua index 45001134..d75c12c4 100644 --- a/script/core/highlight.lua +++ b/script/core/highlight.lua @@ -7,7 +7,7 @@ local util = require 'utility' local guide = require 'parser.guide' local function eachRef(source, callback) - local results = searcher.requestReference(source) + local results = vm.getRefs(source) for i = 1, #results do callback(results[i]) end diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua index 032f19c0..d96b149c 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -32,7 +32,7 @@ local function asDocFunction(source) end local function asDocTypeName(source) - local defs = searcher.requestDefinition(source) + local defs = vm.getDefs(source) for _, doc in ipairs(defs) do if doc.type == 'doc.class.name' then return 'class ' .. doc[1] diff --git a/script/core/infer.lua b/script/core/infer.lua index 77236811..15f5f13c 100644 --- a/script/core/infer.lua +++ b/script/core/infer.lua @@ -2,6 +2,7 @@ local searcher = require 'core.searcher' local config = require 'config' local noder = require 'core.noder' local util = require 'utility' +local vm = require "vm.vm" local STRING_OR_TABLE = {'STRING_OR_TABLE'} local BE_RETURN = {'BE_RETURN'} @@ -488,7 +489,7 @@ function m.searchInfers(source, field) if not source then return nil end - local defs = searcher.requestDefinition(source, field) + local defs = vm.getDefs(source, field) local infers = {} local mark = {} if not field then @@ -547,7 +548,7 @@ end ---@param field? string ---@return table function m.searchLiterals(source, field) - local defs = searcher.requestDefinition(source, field) + local defs = vm.getDefs(source, field) local literals = {} local mark = {} if not field then @@ -618,7 +619,7 @@ function m.getClass(source) return nil end local infers = {} - local defs = searcher.requestDefinition(source) + local defs = vm.getDefs(source) for _, def in ipairs(defs) do if def.type == 'doc.class.name' then infers[def[1]] = true diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 99f3150e..ad4928cc 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -495,48 +495,8 @@ function m.searchRefsByID(status, uri, expect, mode) end end - local function checkCrossUri(id, field) - local targetUri, newID = noder.getUriAndID(id) - if not targetUri then - return false - end - crossSearch(status, targetUri, newID .. (field or ''), mode) - return true - end - - local function checkCache(id, field) - if field then - return false - end - local cachedResults = cache[id] - if not cachedResults then - cache[id] = status - return false - end - log.debug('cache', id) - if mode == 'def' then - -- TODO - do return false end - local idIndex = cachedResults[id] - for _, res in ipairs(cachedResults) do - local index = cachedResults[res] - if index > idIndex then - m.pushResult(status, mode, res, true) - end - end - else - for _, res in ipairs(cachedResults) do - m.pushResult(status, mode, res, true) - end - end - return true - end - local stepCount = 0 function searchStep(id, field) - --if checkCache(id, field) then - -- return - --end stepCount = stepCount + 1 if stepCount > 1000 then error('too large') diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua index dbb8b4fd..e712c6f7 100644 --- a/script/vm/getDocs.lua +++ b/script/vm/getDocs.lua @@ -35,7 +35,7 @@ function vm.getDocEnums(doc) if not doc then return nil end - local defs = searcher.requestDefinition(doc) + local defs = vm.getDefs(doc) local results = {} for _, def in ipairs(defs) do |