summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/code-action.lua26
-rw-r--r--script/core/command/removeSpace.lua15
-rw-r--r--script/core/command/solve.lua9
-rw-r--r--script/core/completion.lua98
-rw-r--r--script/core/definition.lua14
-rw-r--r--script/core/diagnostics/ambiguity-1.lua8
-rw-r--r--script/core/diagnostics/circle-doc-class.lua11
-rw-r--r--script/core/diagnostics/close-non-object.lua9
-rw-r--r--script/core/diagnostics/code-after-break.lua10
-rw-r--r--script/core/diagnostics/count-down-loop.lua8
-rw-r--r--script/core/diagnostics/deprecated.lua18
-rw-r--r--script/core/diagnostics/duplicate-doc-class.lua13
-rw-r--r--script/core/diagnostics/duplicate-index.lua12
-rw-r--r--script/core/diagnostics/duplicate-set-field.lua11
-rw-r--r--script/core/diagnostics/empty-block.lua8
-rw-r--r--script/core/diagnostics/global-in-nil-env.lua12
-rw-r--r--script/core/diagnostics/lowercase-global.lua6
-rw-r--r--script/core/diagnostics/newfield-call.lua8
-rw-r--r--script/core/diagnostics/newline-call.lua8
-rw-r--r--script/core/diagnostics/no-implicit-any.lua4
-rw-r--r--script/core/diagnostics/redefined-local.lua6
-rw-r--r--script/core/diagnostics/redundant-parameter.lua4
-rw-r--r--script/core/diagnostics/trailing-space.lua4
-rw-r--r--script/core/diagnostics/unbalanced-assignments.lua4
-rw-r--r--script/core/diagnostics/undefined-doc-class.lua2
-rw-r--r--script/core/diagnostics/undefined-doc-name.lua4
-rw-r--r--script/core/diagnostics/undefined-doc-param.lua2
-rw-r--r--script/core/diagnostics/undefined-env-child.lua6
-rw-r--r--script/core/diagnostics/undefined-field.lua8
-rw-r--r--script/core/diagnostics/undefined-global.lua6
-rw-r--r--script/core/diagnostics/unused-function.lua6
-rw-r--r--script/core/diagnostics/unused-label.lua4
-rw-r--r--script/core/diagnostics/unused-local.lua4
-rw-r--r--script/core/diagnostics/unused-vararg.lua4
-rw-r--r--script/core/document-symbol.lua10
-rw-r--r--script/core/find-source.lua2
-rw-r--r--script/core/folding.lua6
-rw-r--r--script/core/highlight.lua12
-rw-r--r--script/core/hint.lua18
-rw-r--r--script/core/hover/arg.lua4
-rw-r--r--script/core/hover/description.lua8
-rw-r--r--script/core/hover/init.lua4
-rw-r--r--script/core/hover/label.lua8
-rw-r--r--script/core/hover/name.lua16
-rw-r--r--script/core/hover/return.lua4
-rw-r--r--script/core/hover/table.lua10
-rw-r--r--script/core/keyword.lua8
-rw-r--r--script/core/linker.lua72
-rw-r--r--script/core/reference.lua9
-rw-r--r--script/core/rename.lua12
-rw-r--r--script/core/searcher.lua (renamed from script/core/guide.lua)17
-rw-r--r--script/core/semantic-tokens.lua4
-rw-r--r--script/core/signature.lua6
-rw-r--r--script/core/type-formatting.lua4
-rw-r--r--script/core/workspace-symbol.lua4
-rw-r--r--script/vm/eachDef.lua20
-rw-r--r--script/vm/eachField.lua14
-rw-r--r--script/vm/eachRef.lua18
-rw-r--r--script/vm/getClass.lua12
-rw-r--r--script/vm/getGlobals.lua4
-rw-r--r--script/vm/getInfer.lua14
-rw-r--r--script/vm/getLinks.lua8
-rw-r--r--script/vm/guideInterface.lua6
-rw-r--r--test.lua2
-rw-r--r--test/basic/linker.lua2
-rw-r--r--test/references/init.lua2
66 files changed, 330 insertions, 382 deletions
diff --git a/script/core/code-action.lua b/script/core/code-action.lua
index bae3df81..1ec2aa8b 100644
--- a/script/core/code-action.lua
+++ b/script/core/code-action.lua
@@ -1,10 +1,10 @@
-local files = require 'files'
-local lang = require 'language'
-local define = require 'proto.define'
-local guide = require 'core.guide'
-local util = require 'utility'
-local sp = require 'bee.subprocess'
-local vm = require 'vm'
+local files = require 'files'
+local lang = require 'language'
+local define = require 'proto.define'
+local searcher = require 'core.searcher'
+local util = require 'utility'
+local sp = require 'bee.subprocess'
+local vm = require 'vm'
local function checkDisableByLuaDocExits(uri, row, mode, code)
local lines = files.getLines(uri)
@@ -59,7 +59,7 @@ end
local function disableDiagnostic(uri, code, start, results)
local lines = files.getLines(uri)
- local row = guide.positionOf(lines, start)
+ local row = searcher.positionOf(lines, start)
results[#results+1] = {
title = lang.script('ACTION_DISABLE_DIAG', code),
kind = 'quickfix',
@@ -137,12 +137,12 @@ end
local function solveUndefinedGlobal(uri, diag, results)
local ast = files.getAst(uri)
local offset = files.offsetOfWord(uri, diag.range.start)
- guide.eachSourceContain(ast.ast, offset, function (source)
+ searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type ~= 'getglobal' then
return
end
- local name = guide.getKeyName(source)
+ local name = searcher.getKeyName(source)
markGlobal(uri, name, results)
end)
@@ -156,12 +156,12 @@ end
local function solveLowercaseGlobal(uri, diag, results)
local ast = files.getAst(uri)
local offset = files.offsetOfWord(uri, diag.range.start)
- guide.eachSourceContain(ast.ast, offset, function (source)
+ searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type ~= 'setglobal' then
return
end
- local name = guide.getKeyName(source)
+ local name = searcher.getKeyName(source)
markGlobal(uri, name, results)
end)
end
@@ -357,7 +357,7 @@ local function checkSwapParams(results, uri, start, finish)
return
end
local args = {}
- guide.eachSourceBetween(ast.ast, start, finish, function (source)
+ searcher.eachSourceBetween(ast.ast, start, finish, function (source)
if source.type == 'callargs'
or source.type == 'funcargs' then
local targetIndex
diff --git a/script/core/command/removeSpace.lua b/script/core/command/removeSpace.lua
index 527af8d5..ba1ee8eb 100644
--- a/script/core/command/removeSpace.lua
+++ b/script/core/command/removeSpace.lua
@@ -1,11 +1,10 @@
-local files = require 'files'
-local define = require 'proto.define'
-local guide = require 'core.guide'
-local proto = require 'proto'
-local lang = require 'language'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local proto = require 'proto'
+local lang = require 'language'
local function isInString(ast, offset)
- return guide.eachSourceContain(ast.ast, offset, function (source)
+ return searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type == 'string' then
return true
end
@@ -23,10 +22,10 @@ return function (data)
local textEdit = {}
for i = 1, #lines do
- local line = guide.lineContent(lines, text, i, true)
+ local line = searcher.lineContent(lines, text, i, true)
local pos = line:find '[ \t]+$'
if pos then
- local start, finish = guide.lineRange(lines, i, true)
+ local start, finish = searcher.lineRange(lines, i, true)
start = start + pos - 1
if isInString(ast, start) then
goto NEXT_LINE
diff --git a/script/core/command/solve.lua b/script/core/command/solve.lua
index 995a2109..c2cc103e 100644
--- a/script/core/command/solve.lua
+++ b/script/core/command/solve.lua
@@ -1,8 +1,7 @@
-local files = require 'files'
-local define = require 'proto.define'
-local guide = require 'core.guide'
-local proto = require 'proto'
-local lang = require 'language'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local proto = require 'proto'
+local lang = require 'language'
local opMap = {
['+'] = true,
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 59bba005..3ed2b070 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1,6 +1,6 @@
local define = require 'proto.define'
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local matchKey = require 'core.matchkey'
local vm = require 'vm'
local getLabel = require 'core.hover.label'
@@ -59,7 +59,7 @@ end
local function findNearestSource(ast, offset)
local source
- guide.eachSourceContain(ast.ast, offset, function (src)
+ searcher.eachSourceContain(ast.ast, offset, function (src)
source = src
end)
return source
@@ -87,7 +87,7 @@ local function findParent(ast, text, offset)
if not anyPos then
return nil, nil
end
- local parent = guide.eachSourceContain(ast.ast, anyPos, function (source)
+ local parent = searcher.eachSourceContain(ast.ast, anyPos, function (source)
if source.finish == anyPos then
return source
end
@@ -102,8 +102,8 @@ end
local function findParentInStringIndex(ast, text, offset)
local near, nearStart
- guide.eachSourceContain(ast.ast, offset, function (source)
- local start = guide.getStartFinish(source)
+ searcher.eachSourceContain(ast.ast, offset, function (source)
+ local start = searcher.getStartFinish(source)
if not start then
return
end
@@ -161,9 +161,9 @@ local function getSnip(source)
end
local defs = vm.getRefs(source, 0)
for _, def in ipairs(defs) do
- def = guide.getObjectValue(def) or def
+ def = searcher.getObjectValue(def) or def
if def ~= source and def.type == 'function' then
- local uri = guide.getUri(def)
+ local uri = searcher.getUri(def)
local text = files.getText(uri)
local lines = files.getLines(uri)
if not text then
@@ -172,7 +172,7 @@ local function getSnip(source)
if vm.isMetaFile(uri) then
goto CONTINUE
end
- local row = guide.positionOf(lines, def.start)
+ local row = searcher.positionOf(lines, def.start)
local firstRow = lines[row]
local lastRow = lines[math.min(row + context - 1, #lines)]
local snip = text:sub(firstRow.start, lastRow.finish)
@@ -215,7 +215,7 @@ local function buildFunction(results, source, oop, data)
end
local function buildInsertRequire(ast, targetUri, stemName)
- local uri = guide.getUri(ast.ast)
+ local uri = searcher.getUri(ast.ast)
local lines = files.getLines(uri)
local text = files.getText(uri)
local start = 1
@@ -245,7 +245,7 @@ local function buildInsertRequire(ast, targetUri, stemName)
end
local function isSameSource(ast, source, pos)
- if not files.eq(guide.getUri(source), guide.getUri(ast.ast)) then
+ if not files.eq(searcher.getUri(source), searcher.getUri(ast.ast)) then
return false
end
if source.type == 'field'
@@ -256,7 +256,7 @@ local function isSameSource(ast, source, pos)
end
local function checkLocal(ast, word, offset, results)
- local locals = guide.getVisibleLocals(ast.ast, offset)
+ local locals = searcher.getVisibleLocals(ast.ast, offset)
for name, source in pairs(locals) do
if isSameSource(ast, source, offset) then
goto CONTINUE
@@ -292,9 +292,9 @@ local function checkLocal(ast, word, offset, results)
end
local function checkModule(ast, word, offset, results)
- local locals = guide.getVisibleLocals(ast.ast, offset)
+ local locals = searcher.getVisibleLocals(ast.ast, offset)
for uri in files.eachFile() do
- if files.eq(uri, guide.getUri(ast.ast)) then
+ if files.eq(uri, searcher.getUri(ast.ast)) then
goto CONTINUE
end
local originUri = files.getOriginUri(uri)
@@ -353,7 +353,7 @@ local function checkFieldFromFieldToIndex(name, parent, word, start, offset)
return nil
end
local textEdit, additionalTextEdits
- local uri = guide.getUri(parent)
+ local uri = searcher.getUri(parent)
local text = files.getText(uri)
local wordStart
if word == '' then
@@ -398,7 +398,7 @@ local function checkFieldFromFieldToIndex(name, parent, word, start, offset)
end
local function checkFieldThen(name, src, word, start, offset, parent, oop, results)
- local value = guide.getObjectValue(src) or src
+ local value = searcher.getObjectValue(src) or src
local kind = define.CompletionItemKind.Field
if value.type == 'function' then
if oop then
@@ -422,7 +422,7 @@ local function checkFieldThen(name, src, word, start, offset, parent, oop, resul
if oop then
return
end
- local literal = guide.getLiteral(value)
+ local literal = searcher.getLiteral(value)
if literal ~= nil then
kind = define.CompletionItemKind.Enum
end
@@ -495,7 +495,7 @@ local function checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, res
end
local function checkGlobal(ast, word, start, offset, parent, oop, results)
- local locals = guide.getVisibleLocals(ast.ast, offset)
+ local locals = searcher.getVisibleLocals(ast.ast, offset)
local refs = vm.getGlobalSets '*'
checkFieldOfRefs(refs, ast, word, start, offset, parent, oop, results, locals, 'global')
end
@@ -511,7 +511,7 @@ local function checkField(ast, word, start, offset, parent, oop, results)
end
local function checkTableField(ast, word, start, results)
- local source = guide.eachSourceContain(ast.ast, start, function (source)
+ local source = searcher.eachSourceContain(ast.ast, start, function (source)
if source.start == start
and source.parent
and source.parent.type == 'table' then
@@ -522,7 +522,7 @@ local function checkTableField(ast, word, start, results)
return
end
local used = {}
- guide.eachSourceType(ast.ast, 'tablefield', function (src)
+ searcher.eachSourceType(ast.ast, 'tablefield', function (src)
if not src.field then
return
end
@@ -627,7 +627,7 @@ local function checkCommon(myUri, word, text, offset, results)
end
local function isInString(ast, offset)
- return guide.eachSourceContain(ast.ast, offset, function (source)
+ return searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type == 'string' then
return true
end
@@ -643,7 +643,7 @@ local function checkKeyWord(ast, text, start, offset, word, hasSpace, afterLocal
isExp = isExp,
text = text,
start = start,
- uri = guide.getUri(ast.ast),
+ uri = searcher.getUri(ast.ast),
offset = offset,
ast = ast,
}
@@ -707,7 +707,7 @@ end
local function checkProvideLocal(ast, word, start, results)
local block
- guide.eachSourceContain(ast.ast, start, function (source)
+ searcher.eachSourceContain(ast.ast, start, function (source)
if source.type == 'function'
or source.type == 'main' then
block = source
@@ -717,7 +717,7 @@ local function checkProvideLocal(ast, word, start, results)
return
end
local used = {}
- guide.eachSourceType(block, 'getglobal', function (source)
+ searcher.eachSourceType(block, 'getglobal', function (source)
if source.start > start
and not used[source[1]]
and matchKey(word, source[1]) then
@@ -728,7 +728,7 @@ local function checkProvideLocal(ast, word, start, results)
}
end
end)
- guide.eachSourceType(block, 'getlocal', function (source)
+ searcher.eachSourceType(block, 'getlocal', function (source)
if source.start > start
and not used[source[1]]
and matchKey(word, source[1]) then
@@ -742,7 +742,7 @@ local function checkProvideLocal(ast, word, start, results)
end
local function checkFunctionArgByDocParam(ast, word, start, results)
- local func = guide.eachSourceContain(ast.ast, start, function (source)
+ local func = searcher.eachSourceContain(ast.ast, start, function (source)
if source.type == 'function' then
return source
end
@@ -793,8 +793,8 @@ end
local function checkUri(ast, text, offset, results)
local collect = {}
- local myUri = guide.getUri(ast.ast)
- guide.eachSourceContain(ast.ast, offset, function (source)
+ local myUri = searcher.getUri(ast.ast)
+ searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type ~= 'string' then
return
end
@@ -807,7 +807,7 @@ local function checkUri(ast, text, offset, results)
end
local call = callargs.parent
local func = call.node
- local literal = guide.getLiteral(source)
+ local literal = searcher.getLiteral(source)
local libName = vm.getLibraryName(func)
if not libName then
return
@@ -914,7 +914,7 @@ local function checkUri(ast, text, offset, results)
end
local function checkLenPlusOne(ast, text, offset, results)
- guide.eachSourceContain(ast.ast, offset, function (source)
+ searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type == 'getindex'
or source.type == 'setindex' then
local _, pos = text:find('%s*%[%s*%#', source.node.finish)
@@ -926,7 +926,7 @@ local function checkLenPlusOne(ast, text, offset, results)
if not matchKey(writingText, nodeText) then
return
end
- if source.parent == guide.getParentBlock(source) then
+ if source.parent == searcher.getParentBlock(source) then
-- state
local label = text:match('%#[ \t]*', pos) .. nodeText .. '+1'
local eq = text:find('^%s*%]?%s*%=', source.finish)
@@ -1026,7 +1026,7 @@ local function checkEqualEnumLeft(ast, text, offset, source, results)
if not source then
return
end
- local str = guide.eachSourceContain(ast.ast, offset, function (src)
+ local str = searcher.eachSourceContain(ast.ast, offset, function (src)
if src.type == 'string' then
return src
end
@@ -1061,7 +1061,7 @@ local function checkEqualEnum(ast, text, offset, results)
end
local function checkEqualEnumInString(ast, text, offset, results)
- local source = guide.eachSourceContain(ast.ast, offset, function (source)
+ local source = searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type == 'binary' then
if source.op.type == '=='
or source.op.type == '~=' then
@@ -1092,7 +1092,7 @@ local function checkEqualEnumInString(ast, text, offset, results)
end
local function isFuncArg(ast, offset)
- return guide.eachSourceContain(ast.ast, offset, function (source)
+ return searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type == 'funcargs' then
return true
end
@@ -1154,7 +1154,7 @@ local function tryWord(ast, text, offset, results)
else
checkLocal(ast, word, start, results)
checkTableField(ast, word, start, results)
- local env = guide.getENV(ast.ast, start)
+ local env = searcher.getENV(ast.ast, start)
checkGlobal(ast, word, start, offset, env, false, results)
checkModule(ast, word, start, results)
end
@@ -1228,7 +1228,7 @@ local function getCallEnums(source, index)
end
for _, unit in ipairs(vm.getDocTypeUnits(doc.extends) or {}) do
if unit.type == 'doc.type.function' then
- local text = files.getText(guide.getUri(unit))
+ local text = files.getText(searcher.getUri(unit))
enums[#enums+1] = {
label = text:sub(unit.start, unit.finish),
description = doc.comment,
@@ -1256,7 +1256,7 @@ end
local function findCall(ast, text, offset)
local call
- guide.eachSourceContain(ast.ast, offset, function (src)
+ searcher.eachSourceContain(ast.ast, offset, function (src)
if src.type == 'call' then
if not call or call.start < src.start then
call = src
@@ -1295,14 +1295,14 @@ local function checkTableLiteralField(ast, text, offset, tbl, fields, results)
for _, field in ipairs(tbl) do
if field.type == 'tablefield'
or field.type == 'tableindex' then
- local name = guide.getKeyName(field)
+ local name = searcher.getKeyName(field)
if name then
mark[name] = true
end
end
end
table.sort(fields, function (a, b)
- return guide.getKeyName(a) < guide.getKeyName(b)
+ return searcher.getKeyName(a) < searcher.getKeyName(b)
end)
-- {$}
local left = lookBackward.findWord(text, offset)
@@ -1315,12 +1315,12 @@ local function checkTableLiteralField(ast, text, offset, tbl, fields, results)
end
if left then
for _, field in ipairs(fields) do
- local name = guide.getKeyName(field)
- if not mark[name] and matchKey(left, guide.getKeyName(field)) then
+ local name = searcher.getKeyName(field)
+ if not mark[name] and matchKey(left, searcher.getKeyName(field)) then
results[#results+1] = {
- label = guide.getKeyName(field),
+ label = searcher.getKeyName(field),
kind = define.CompletionItemKind.Property,
- insertText = ('%s = $0'):format(guide.getKeyName(field)),
+ insertText = ('%s = $0'):format(searcher.getKeyName(field)),
id = stack(function ()
return {
detail = buildDetail(field),
@@ -1355,14 +1355,14 @@ local function checkTableLiteralFieldByCall(ast, text, offset, call, defs, index
return
end
for _, def in ipairs(defs) do
- local func = guide.getObjectValue(def) or def
+ local func = searcher.getObjectValue(def) or def
local param = getFuncParamByCallIndex(func, index)
if not param then
goto CONTINUE
end
local defs = vm.getDefFields(param, 0)
for _, field in ipairs(defs) do
- local name = guide.getKeyName(field)
+ local name = searcher.getKeyName(field)
if name and not mark[name] then
mark[name] = true
fields[#fields+1] = field
@@ -1385,7 +1385,7 @@ local function tryCallArg(ast, text, offset, results)
end
local defs = vm.getDefs(call.node, 0)
for _, def in ipairs(defs) do
- def = guide.getObjectValue(def) or def
+ def = searcher.getObjectValue(def) or def
local enums = getCallEnums(def, argIndex)
if enums then
mergeEnums(myResults, enums, arg)
@@ -1415,7 +1415,7 @@ local function tryTable(ast, text, offset, results)
end
local defs = vm.getDefFields(tbl, 0)
for _, field in ipairs(defs) do
- local name = guide.getKeyName(field)
+ local name = searcher.getKeyName(field)
if name and not mark[name] then
mark[name] = true
fields[#fields+1] = field
@@ -1471,7 +1471,7 @@ end
local function getLuaDocByContain(ast, offset)
local result
local range = math.huge
- guide.eachSourceContain(ast.ast.docs, offset, function (src)
+ searcher.eachSourceContain(ast.ast.docs, offset, function (src)
if not src.start then
return
end
@@ -1548,7 +1548,7 @@ local function tryLuaDocBySource(ast, offset, source, results)
return true
elseif source.type == 'doc.param.name' then
local funcs = {}
- guide.eachSourceBetween(ast.ast, offset, math.huge, function (src)
+ searcher.eachSourceBetween(ast.ast, offset, math.huge, function (src)
if src.type == 'function' and src.start > offset then
funcs[#funcs+1] = src
end
@@ -1624,7 +1624,7 @@ local function tryLuaDocByErr(ast, offset, err, docState, results)
end
elseif err.type == 'LUADOC_MISS_PARAM_NAME' then
local funcs = {}
- guide.eachSourceBetween(ast.ast, offset, math.huge, function (src)
+ searcher.eachSourceBetween(ast.ast, offset, math.huge, function (src)
if src.type == 'function' and src.start > offset then
funcs[#funcs+1] = src
end
diff --git a/script/core/definition.lua b/script/core/definition.lua
index b26bb922..eff55771 100644
--- a/script/core/definition.lua
+++ b/script/core/definition.lua
@@ -1,4 +1,4 @@
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local workspace = require 'workspace'
local files = require 'files'
local vm = require 'vm'
@@ -7,8 +7,8 @@ local findSource = require 'core.find-source'
local function sortResults(results)
-- 先按照顺序排序
table.sort(results, function (a, b)
- local u1 = guide.getUri(a.target)
- local u2 = guide.getUri(b.target)
+ local u1 = searcher.getUri(a.target)
+ local u2 = searcher.getUri(b.target)
if u1 == u2 then
return a.target.start < b.target.start
else
@@ -20,7 +20,7 @@ local function sortResults(results)
for i = #results, 1, -1 do
local res = results[i].target
local f = res.finish
- local uri = guide.getUri(res)
+ local uri = searcher.getUri(res)
if lf and f > lf and uri == lu then
table.remove(results, i)
else
@@ -66,7 +66,7 @@ local function checkRequire(source, offset)
end
local call = callargs.parent
local func = call.node
- local literal = guide.getLiteral(source)
+ local literal = searcher.getLiteral(source)
local libName = vm.getLibraryName(func)
if not libName then
return nil
@@ -130,7 +130,7 @@ return function (uri, offset)
local defs = vm.getDefs(source, 0)
local values = {}
for _, src in ipairs(defs) do
- local value = guide.getObjectValue(src)
+ local value = searcher.getObjectValue(src)
if value and value ~= src then
values[value] = true
end
@@ -143,7 +143,7 @@ return function (uri, offset)
if values[src] then
goto CONTINUE
end
- local root = guide.getRoot(src)
+ local root = searcher.getRoot(src)
if not root then
goto CONTINUE
end
diff --git a/script/core/diagnostics/ambiguity-1.lua b/script/core/diagnostics/ambiguity-1.lua
index 19bb4f97..0b8385d8 100644
--- a/script/core/diagnostics/ambiguity-1.lua
+++ b/script/core/diagnostics/ambiguity-1.lua
@@ -1,6 +1,6 @@
-local files = require 'files'
-local guide = require 'core.guide'
-local lang = require 'language'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local lang = require 'language'
local opMap = {
['+'] = true,
@@ -30,7 +30,7 @@ return function (uri, callback)
return
end
local text = files.getText(uri)
- guide.eachSourceType(ast.ast, 'binary', function (source)
+ searcher.eachSourceType(ast.ast, 'binary', function (source)
if source.op.type ~= 'or' then
return
end
diff --git a/script/core/diagnostics/circle-doc-class.lua b/script/core/diagnostics/circle-doc-class.lua
index 702cd904..3d32324d 100644
--- a/script/core/diagnostics/circle-doc-class.lua
+++ b/script/core/diagnostics/circle-doc-class.lua
@@ -1,8 +1,7 @@
-local files = require 'files'
-local guide = require 'core.guide'
-local lang = require 'language'
-local define = require 'proto.define'
-local vm = require 'vm'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local lang = require 'language'
+local vm = require 'vm'
return function (uri, callback)
local state = files.getAst(uri)
@@ -19,7 +18,7 @@ return function (uri, callback)
if not doc.extends then
goto CONTINUE
end
- local myName = guide.getKeyName(doc)
+ local myName = searcher.getKeyName(doc)
local list = { doc }
local mark = {}
for i = 1, 999 do
diff --git a/script/core/diagnostics/close-non-object.lua b/script/core/diagnostics/close-non-object.lua
index d1983c42..11c2b820 100644
--- a/script/core/diagnostics/close-non-object.lua
+++ b/script/core/diagnostics/close-non-object.lua
@@ -1,7 +1,6 @@
-local files = require 'files'
-local guide = require 'core.guide'
-local lang = require 'language'
-local define = require 'proto.define'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local lang = require 'language'
return function (uri, callback)
local state = files.getAst(uri)
@@ -9,7 +8,7 @@ return function (uri, callback)
return
end
- guide.eachSourceType(state.ast, 'local', function (source)
+ searcher.eachSourceType(state.ast, 'local', function (source)
if not source.attrs then
return
end
diff --git a/script/core/diagnostics/code-after-break.lua b/script/core/diagnostics/code-after-break.lua
index f23755ea..dc7226ae 100644
--- a/script/core/diagnostics/code-after-break.lua
+++ b/script/core/diagnostics/code-after-break.lua
@@ -1,7 +1,7 @@
-local files = require 'files'
-local guide = require 'core.guide'
-local lang = require 'language'
-local define = require 'proto.define'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local lang = require 'language'
+local define = require 'proto.define'
return function (uri, callback)
local state = files.getAst(uri)
@@ -10,7 +10,7 @@ return function (uri, callback)
end
local mark = {}
- guide.eachSourceType(state.ast, 'break', function (source)
+ searcher.eachSourceType(state.ast, 'break', function (source)
local list = source.parent
if mark[list] then
return
diff --git a/script/core/diagnostics/count-down-loop.lua b/script/core/diagnostics/count-down-loop.lua
index 65099af8..f682ec3c 100644
--- a/script/core/diagnostics/count-down-loop.lua
+++ b/script/core/diagnostics/count-down-loop.lua
@@ -1,6 +1,6 @@
-local files = require "files"
-local guide = require "core.guide"
-local lang = require 'language'
+local files = require "files"
+local searcher = require "core.searcher"
+local lang = require 'language'
return function (uri, callback)
local state = files.getAst(uri)
@@ -9,7 +9,7 @@ return function (uri, callback)
return
end
- guide.eachSourceType(state.ast, 'loop', function (source)
+ searcher.eachSourceType(state.ast, 'loop', function (source)
if not source.loc or not source.loc.value then
return
end
diff --git a/script/core/diagnostics/deprecated.lua b/script/core/diagnostics/deprecated.lua
index 60d60946..d6bccc10 100644
--- a/script/core/diagnostics/deprecated.lua
+++ b/script/core/diagnostics/deprecated.lua
@@ -1,10 +1,10 @@
-local files = require 'files'
-local vm = require 'vm'
-local lang = require 'language'
-local guide = require 'core.guide'
-local config = require 'config'
-local define = require 'proto.define'
-local await = require 'await'
+local files = require 'files'
+local vm = require 'vm'
+local lang = require 'language'
+local searcher = require 'core.searcher'
+local config = require 'config'
+local define = require 'proto.define'
+local await = require 'await'
return function (uri, callback)
local ast = files.getAst(uri)
@@ -12,7 +12,7 @@ return function (uri, callback)
return
end
- guide.eachSource(ast.ast, function (src)
+ searcher.eachSource(ast.ast, function (src)
if src.type ~= 'getglobal'
and src.type ~= 'getfield'
and src.type ~= 'getindex'
@@ -20,7 +20,7 @@ return function (uri, callback)
return
end
if src.type == 'getglobal' then
- local key = guide.getKeyName(src)
+ local key = searcher.getKeyName(src)
if not key then
return
end
diff --git a/script/core/diagnostics/duplicate-doc-class.lua b/script/core/diagnostics/duplicate-doc-class.lua
index 8c6696a9..c625d234 100644
--- a/script/core/diagnostics/duplicate-doc-class.lua
+++ b/script/core/diagnostics/duplicate-doc-class.lua
@@ -1,8 +1,7 @@
-local files = require 'files'
-local guide = require 'core.guide'
-local lang = require 'language'
-local define = require 'proto.define'
-local vm = require 'vm'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local lang = require 'language'
+local vm = require 'vm'
return function (uri, callback)
local state = files.getAst(uri)
@@ -18,7 +17,7 @@ return function (uri, callback)
for _, doc in ipairs(state.ast.docs) do
if doc.type == 'doc.class'
or doc.type == 'doc.alias' then
- local name = guide.getKeyName(doc)
+ local name = searcher.getKeyName(doc)
if not cache[name] then
local docs = vm.getDocTypes(name)
cache[name] = {}
@@ -28,7 +27,7 @@ return function (uri, callback)
cache[name][#cache[name]+1] = {
start = otherDoc.start,
finish = otherDoc.finish,
- uri = guide.getUri(otherDoc),
+ uri = searcher.getUri(otherDoc),
}
end
end
diff --git a/script/core/diagnostics/duplicate-index.lua b/script/core/diagnostics/duplicate-index.lua
index 5e63d39e..65fb00cd 100644
--- a/script/core/diagnostics/duplicate-index.lua
+++ b/script/core/diagnostics/duplicate-index.lua
@@ -1,8 +1,8 @@
-local files = require 'files'
-local guide = require 'core.guide'
-local lang = require 'language'
-local define = require 'proto.define'
-local vm = require 'vm'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local lang = require 'language'
+local define = require 'proto.define'
+local vm = require 'vm'
return function (uri, callback)
local ast = files.getAst(uri)
@@ -10,7 +10,7 @@ return function (uri, callback)
return
end
- guide.eachSourceType(ast.ast, 'table', function (source)
+ searcher.eachSourceType(ast.ast, 'table', function (source)
local mark = {}
for _, obj in ipairs(source) do
if obj.type == 'tablefield'
diff --git a/script/core/diagnostics/duplicate-set-field.lua b/script/core/diagnostics/duplicate-set-field.lua
index c1e2285a..ff915217 100644
--- a/script/core/diagnostics/duplicate-set-field.lua
+++ b/script/core/diagnostics/duplicate-set-field.lua
@@ -1,8 +1,7 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
local define = require 'proto.define'
-local vm = require 'vm'
return function (uri, callback)
local ast = files.getAst(uri)
@@ -10,7 +9,7 @@ return function (uri, callback)
return
end
- guide.eachSourceType(ast.ast, 'local', function (source)
+ searcher.eachSourceType(ast.ast, 'local', function (source)
if not source.ref then
return
end
@@ -26,11 +25,11 @@ return function (uri, callback)
if nxt.type == 'setfield'
or nxt.type == 'setmethod'
or nxt.type == 'setindex' then
- local name = guide.getKeyName(nxt)
+ local name = searcher.getKeyName(nxt)
if not name then
goto CONTINUE
end
- local value = guide.getObjectValue(nxt)
+ local value = searcher.getObjectValue(nxt)
if not value or value.type ~= 'function' then
goto CONTINUE
end
@@ -47,7 +46,7 @@ return function (uri, callback)
end
local blocks = {}
for _, value in ipairs(values) do
- local block = guide.getBlock(value)
+ local block = searcher.getBlock(value)
if not blocks[block] then
blocks[block] = {}
end
diff --git a/script/core/diagnostics/empty-block.lua b/script/core/diagnostics/empty-block.lua
index 690a4ca2..abd20bde 100644
--- a/script/core/diagnostics/empty-block.lua
+++ b/script/core/diagnostics/empty-block.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
local define = require 'proto.define'
@@ -11,7 +11,7 @@ return function (uri, callback)
return
end
- guide.eachSourceType(ast.ast, 'if', function (source)
+ searcher.eachSourceType(ast.ast, 'if', function (source)
for _, block in ipairs(source) do
if #block > 0 then
return
@@ -24,7 +24,7 @@ return function (uri, callback)
message = lang.script.DIAG_EMPTY_BLOCK,
}
end)
- guide.eachSourceType(ast.ast, 'loop', function (source)
+ searcher.eachSourceType(ast.ast, 'loop', function (source)
if #source > 0 then
return
end
@@ -35,7 +35,7 @@ return function (uri, callback)
message = lang.script.DIAG_EMPTY_BLOCK,
}
end)
- guide.eachSourceType(ast.ast, 'in', function (source)
+ searcher.eachSourceType(ast.ast, 'in', function (source)
if #source > 0 then
return
end
diff --git a/script/core/diagnostics/global-in-nil-env.lua b/script/core/diagnostics/global-in-nil-env.lua
index de23bc76..02cd4f3f 100644
--- a/script/core/diagnostics/global-in-nil-env.lua
+++ b/script/core/diagnostics/global-in-nil-env.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
-- TODO: 检查路径是否可达
@@ -12,8 +12,8 @@ return function (uri, callback)
if not ast then
return
end
- local root = guide.getRoot(ast.ast)
- local env = guide.getENV(root)
+ local root = searcher.getRoot(ast.ast)
+ local env = searcher.getENV(root)
local nilDefs = {}
if not env.ref then
@@ -36,7 +36,7 @@ return function (uri, callback)
if node.tag == '_ENV' then
local ok
for _, nilDef in ipairs(nilDefs) do
- local mode, pathA = guide.getPath(nilDef, source)
+ local mode, pathA = searcher.getPath(nilDef, source)
if mode == 'before'
and mayRun(pathA) then
ok = nilDef
@@ -61,6 +61,6 @@ return function (uri, callback)
end
end
- guide.eachSourceType(ast.ast, 'getglobal', check)
- guide.eachSourceType(ast.ast, 'setglobal', check)
+ searcher.eachSourceType(ast.ast, 'getglobal', check)
+ searcher.eachSourceType(ast.ast, 'setglobal', check)
end
diff --git a/script/core/diagnostics/lowercase-global.lua b/script/core/diagnostics/lowercase-global.lua
index 9c094701..aaeb2c94 100644
--- a/script/core/diagnostics/lowercase-global.lua
+++ b/script/core/diagnostics/lowercase-global.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
local config = require 'config'
local vm = require 'vm'
@@ -28,8 +28,8 @@ return function (uri, callback)
definedGlobal[name] = true
end
- guide.eachSourceType(ast.ast, 'setglobal', function (source)
- local name = guide.getKeyName(source)
+ searcher.eachSourceType(ast.ast, 'setglobal', function (source)
+ local name = searcher.getKeyName(source)
if definedGlobal[name] then
return
end
diff --git a/script/core/diagnostics/newfield-call.lua b/script/core/diagnostics/newfield-call.lua
index 0727c2fd..a71ae3e1 100644
--- a/script/core/diagnostics/newfield-call.lua
+++ b/script/core/diagnostics/newfield-call.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
return function (uri, callback)
@@ -11,15 +11,15 @@ return function (uri, callback)
local lines = files.getLines(uri)
local text = files.getText(uri)
- guide.eachSourceType(ast.ast, 'table', function (source)
+ searcher.eachSourceType(ast.ast, 'table', function (source)
for i = 1, #source do
local field = source[i]
if field.type == 'call' then
local func = field.node
local args = field.args
if args then
- local funcLine = guide.positionOf(lines, func.finish)
- local argsLine = guide.positionOf(lines, args.start)
+ local funcLine = searcher.positionOf(lines, func.finish)
+ local argsLine = searcher.positionOf(lines, args.start)
if argsLine > funcLine then
callback {
start = field.start,
diff --git a/script/core/diagnostics/newline-call.lua b/script/core/diagnostics/newline-call.lua
index 807f76a2..31a8d09f 100644
--- a/script/core/diagnostics/newline-call.lua
+++ b/script/core/diagnostics/newline-call.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
return function (uri, callback)
@@ -10,7 +10,7 @@ return function (uri, callback)
return
end
- guide.eachSourceType(ast.ast, 'call', function (source)
+ searcher.eachSourceType(ast.ast, 'call', function (source)
local node = source.node
local args = source.args
if not args then
@@ -26,8 +26,8 @@ return function (uri, callback)
return
end
- local nodeRow = guide.positionOf(lines, node.finish)
- local argRow = guide.positionOf(lines, args.start)
+ local nodeRow = searcher.positionOf(lines, node.finish)
+ local argRow = searcher.positionOf(lines, args.start)
if nodeRow == argRow then
return
end
diff --git a/script/core/diagnostics/no-implicit-any.lua b/script/core/diagnostics/no-implicit-any.lua
index ffaab821..23af570a 100644
--- a/script/core/diagnostics/no-implicit-any.lua
+++ b/script/core/diagnostics/no-implicit-any.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
local define = require 'proto.define'
local vm = require 'vm'
@@ -10,7 +10,7 @@ return function (uri, callback)
return
end
- guide.eachSource(ast.ast, function (source)
+ searcher.eachSource(ast.ast, function (source)
if source.type ~= 'local'
and source.type ~= 'setlocal'
and source.type ~= 'setglobal'
diff --git a/script/core/diagnostics/redefined-local.lua b/script/core/diagnostics/redefined-local.lua
index 857d80d2..4922831b 100644
--- a/script/core/diagnostics/redefined-local.lua
+++ b/script/core/diagnostics/redefined-local.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
return function (uri, callback)
@@ -7,13 +7,13 @@ return function (uri, callback)
if not ast then
return
end
- guide.eachSourceType(ast.ast, 'local', function (source)
+ searcher.eachSourceType(ast.ast, 'local', function (source)
local name = source[1]
if name == '_'
or name == ast.ENVMode then
return
end
- local exist = guide.getLocal(source, name, source.start-1)
+ local exist = searcher.getLocal(source, name, source.start-1)
if exist then
callback {
start = source.start,
diff --git a/script/core/diagnostics/redundant-parameter.lua b/script/core/diagnostics/redundant-parameter.lua
index c5bcd5a5..a6907bda 100644
--- a/script/core/diagnostics/redundant-parameter.lua
+++ b/script/core/diagnostics/redundant-parameter.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local vm = require 'vm'
local lang = require 'language'
local define = require 'proto.define'
@@ -74,7 +74,7 @@ return function (uri, callback)
local cache = vm.getCache 'redundant-parameter'
- guide.eachSourceType(ast.ast, 'call', function (source)
+ searcher.eachSourceType(ast.ast, 'call', function (source)
local callArgs = countCallArgs(source)
if callArgs == 0 then
return
diff --git a/script/core/diagnostics/trailing-space.lua b/script/core/diagnostics/trailing-space.lua
index 0a4b1d57..6ee92d26 100644
--- a/script/core/diagnostics/trailing-space.lua
+++ b/script/core/diagnostics/trailing-space.lua
@@ -1,10 +1,10 @@
local files = require 'files'
local lang = require 'language'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local function isInString(ast, offset)
local result = false
- guide.eachSourceType(ast, 'string', function (source)
+ searcher.eachSourceType(ast, 'string', function (source)
if offset >= source.start and offset <= source.finish then
result = true
end
diff --git a/script/core/diagnostics/unbalanced-assignments.lua b/script/core/diagnostics/unbalanced-assignments.lua
index b2b2800c..006223db 100644
--- a/script/core/diagnostics/unbalanced-assignments.lua
+++ b/script/core/diagnostics/unbalanced-assignments.lua
@@ -1,7 +1,7 @@
local files = require 'files'
local define = require 'proto.define'
local lang = require 'language'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
return function (uri, callback, code)
local ast = files.getAst(uri)
@@ -31,7 +31,7 @@ return function (uri, callback, code)
end
end
- guide.eachSource(ast.ast, function (source)
+ searcher.eachSource(ast.ast, function (source)
if source.type == 'local'
or source.type == 'setlocal'
or source.type == 'setglobal'
diff --git a/script/core/diagnostics/undefined-doc-class.lua b/script/core/diagnostics/undefined-doc-class.lua
index a91cfa7f..991b5849 100644
--- a/script/core/diagnostics/undefined-doc-class.lua
+++ b/script/core/diagnostics/undefined-doc-class.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
local define = require 'proto.define'
local vm = require 'vm'
diff --git a/script/core/diagnostics/undefined-doc-name.lua b/script/core/diagnostics/undefined-doc-name.lua
index d8a4363b..54f08ee6 100644
--- a/script/core/diagnostics/undefined-doc-name.lua
+++ b/script/core/diagnostics/undefined-doc-name.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
local define = require 'proto.define'
local vm = require 'vm'
@@ -44,7 +44,7 @@ return function (uri, callback)
return true
end
- guide.eachSource(state.ast.docs, function (source)
+ searcher.eachSource(state.ast.docs, function (source)
if source.type ~= 'doc.extends.name'
and source.type ~= 'doc.type.name' then
return
diff --git a/script/core/diagnostics/undefined-doc-param.lua b/script/core/diagnostics/undefined-doc-param.lua
index 0bf371e5..4a97947d 100644
--- a/script/core/diagnostics/undefined-doc-param.lua
+++ b/script/core/diagnostics/undefined-doc-param.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
local define = require 'proto.define'
local vm = require 'vm'
diff --git a/script/core/diagnostics/undefined-env-child.lua b/script/core/diagnostics/undefined-env-child.lua
index 89efb8c7..a32ad306 100644
--- a/script/core/diagnostics/undefined-env-child.lua
+++ b/script/core/diagnostics/undefined-env-child.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local vm = require 'vm'
local lang = require 'language'
@@ -8,12 +8,12 @@ return function (uri, callback)
if not ast then
return
end
- guide.eachSourceType(ast.ast, 'getglobal', function (source)
+ searcher.eachSourceType(ast.ast, 'getglobal', function (source)
-- 单独验证自己是否在重载过的 _ENV 中有定义
if source.node.tag == '_ENV' then
return
end
- local defs = guide.requestDefinition(source)
+ local defs = searcher.requestDefinition(source)
if #defs > 0 then
return
end
diff --git a/script/core/diagnostics/undefined-field.lua b/script/core/diagnostics/undefined-field.lua
index b10c9ab0..1f88740e 100644
--- a/script/core/diagnostics/undefined-field.lua
+++ b/script/core/diagnostics/undefined-field.lua
@@ -2,7 +2,7 @@ local files = require 'files'
local vm = require 'vm'
local lang = require 'language'
local config = require 'config'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local define = require 'proto.define'
return function (uri, callback)
@@ -87,7 +87,7 @@ return function (uri, callback)
end
local function checkUndefinedField(src)
- local fieldName = guide.getKeyName(src)
+ local fieldName = searcher.getKeyName(src)
local allDocClass = getAllDocClassFromInfer(src.node)
if (not allDocClass) or (#allDocClass == 0) then
@@ -118,6 +118,6 @@ return function (uri, callback)
end
end
end
- guide.eachSourceType(ast.ast, 'getfield', checkUndefinedField);
- guide.eachSourceType(ast.ast, 'getmethod', checkUndefinedField);
+ searcher.eachSourceType(ast.ast, 'getfield', checkUndefinedField);
+ searcher.eachSourceType(ast.ast, 'getmethod', checkUndefinedField);
end
diff --git a/script/core/diagnostics/undefined-global.lua b/script/core/diagnostics/undefined-global.lua
index 161d8856..3c7f02d1 100644
--- a/script/core/diagnostics/undefined-global.lua
+++ b/script/core/diagnostics/undefined-global.lua
@@ -2,7 +2,7 @@ local files = require 'files'
local vm = require 'vm'
local lang = require 'language'
local config = require 'config'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local define = require 'proto.define'
local requireLike = {
@@ -19,8 +19,8 @@ return function (uri, callback)
end
-- 遍历全局变量,检查所有没有 set 模式的全局变量
- guide.eachSourceType(ast.ast, 'getglobal', function (src)
- local key = guide.getKeyName(src)
+ searcher.eachSourceType(ast.ast, 'getglobal', function (src)
+ local key = searcher.getKeyName(src)
if not key then
return
end
diff --git a/script/core/diagnostics/unused-function.lua b/script/core/diagnostics/unused-function.lua
index b6f92e60..2d224e5e 100644
--- a/script/core/diagnostics/unused-function.lua
+++ b/script/core/diagnostics/unused-function.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local vm = require 'vm'
local define = require 'proto.define'
local lang = require 'language'
@@ -45,7 +45,7 @@ return function (uri, callback)
local refs = vm.getRefs(source)
for _, src in ipairs(refs) do
if vm.isGet(src) then
- local func = guide.getParentFunction(src)
+ local func = searcher.getParentFunction(src)
if not checkFunction(func) then
hasGet = true
break
@@ -75,7 +75,7 @@ return function (uri, callback)
end
-- 只检查局部函数
- guide.eachSourceType(ast.ast, 'function', function (source)
+ searcher.eachSourceType(ast.ast, 'function', function (source)
checkFunction(source)
end)
end
diff --git a/script/core/diagnostics/unused-label.lua b/script/core/diagnostics/unused-label.lua
index e2d5e49a..5d9488a1 100644
--- a/script/core/diagnostics/unused-label.lua
+++ b/script/core/diagnostics/unused-label.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local define = require 'proto.define'
local lang = require 'language'
@@ -9,7 +9,7 @@ return function (uri, callback)
return
end
- guide.eachSourceType(ast.ast, 'label', function (source)
+ searcher.eachSourceType(ast.ast, 'label', function (source)
if not source.ref then
callback {
start = source.start,
diff --git a/script/core/diagnostics/unused-local.lua b/script/core/diagnostics/unused-local.lua
index fde90cb8..4e3c8217 100644
--- a/script/core/diagnostics/unused-local.lua
+++ b/script/core/diagnostics/unused-local.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local define = require 'proto.define'
local lang = require 'language'
@@ -81,7 +81,7 @@ return function (uri, callback)
if not ast then
return
end
- guide.eachSourceType(ast.ast, 'local', function (source)
+ searcher.eachSourceType(ast.ast, 'local', function (source)
local name = source[1]
if name == '_'
or name == ast.ENVMode then
diff --git a/script/core/diagnostics/unused-vararg.lua b/script/core/diagnostics/unused-vararg.lua
index ec0a05fb..301394c3 100644
--- a/script/core/diagnostics/unused-vararg.lua
+++ b/script/core/diagnostics/unused-vararg.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local define = require 'proto.define'
local lang = require 'language'
@@ -9,7 +9,7 @@ return function (uri, callback)
return
end
- guide.eachSourceType(ast.ast, 'function', function (source)
+ searcher.eachSourceType(ast.ast, 'function', function (source)
local args = source.args
if not args then
return
diff --git a/script/core/document-symbol.lua b/script/core/document-symbol.lua
index cc87e3ca..be16e8e0 100644
--- a/script/core/document-symbol.lua
+++ b/script/core/document-symbol.lua
@@ -1,8 +1,8 @@
-local await = require 'await'
-local files = require 'files'
-local guide = require 'core.guide'
-local define = require 'proto.define'
-local util = require 'utility'
+local await = require 'await'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local define = require 'proto.define'
+local util = require 'utility'
local function buildName(source, text)
if source.type == 'setmethod'
diff --git a/script/core/find-source.lua b/script/core/find-source.lua
index b36306b6..edbb1e2c 100644
--- a/script/core/find-source.lua
+++ b/script/core/find-source.lua
@@ -1,4 +1,4 @@
-local guide = require 'core.guide'
+local guide = require 'parser.guide'
local function isValidFunctionPos(source, offset)
for i = 1, #source.keyword // 2 do
diff --git a/script/core/folding.lua b/script/core/folding.lua
index 77cb39e7..d089b816 100644
--- a/script/core/folding.lua
+++ b/script/core/folding.lua
@@ -1,5 +1,5 @@
-local files = require "files"
-local guide = require "core.guide"
+local files = require "files"
+local searcher = require "core.searcher"
local Care = {
['function'] = function (source, text, results)
@@ -151,7 +151,7 @@ return function (uri)
local regions = {}
local status = {}
- guide.eachSource(ast.ast, function (source)
+ searcher.eachSource(ast.ast, function (source)
local tp = source.type
if Care[tp] then
Care[tp](source, text, regions)
diff --git a/script/core/highlight.lua b/script/core/highlight.lua
index e79bb797..75adcb1f 100644
--- a/script/core/highlight.lua
+++ b/script/core/highlight.lua
@@ -1,11 +1,11 @@
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local files = require 'files'
local vm = require 'vm'
local define = require 'proto.define'
local findSource = require 'core.find-source'
local function eachRef(source, callback)
- local results = guide.requestReference(source)
+ local results = searcher.requestReference(source)
for i = 1, #results do
callback(results[i])
end
@@ -15,11 +15,11 @@ local function eachField(source, callback)
if not source then
return
end
- local isGlobal = guide.isGlobal(source)
- local results = guide.requestReference(source)
+ local isGlobal = searcher.isGlobal(source)
+ local results = searcher.requestReference(source)
for i = 1, #results do
local res = results[i]
- if isGlobal == guide.isGlobal(res) then
+ if isGlobal == searcher.isGlobal(res) then
callback(res)
end
end
@@ -106,7 +106,7 @@ local function makeIf(source, text, callback)
end
local function findKeyWord(ast, text, offset, callback)
- guide.eachSourceContain(ast.ast, offset, function (source)
+ searcher.eachSourceContain(ast.ast, offset, function (source)
if source.type == 'do'
or source.type == 'function'
or source.type == 'loop'
diff --git a/script/core/hint.lua b/script/core/hint.lua
index 13d01dc7..9c0d9cf0 100644
--- a/script/core/hint.lua
+++ b/script/core/hint.lua
@@ -1,7 +1,7 @@
-local files = require 'files'
-local guide = require 'core.guide'
-local vm = require 'vm'
-local config = require 'config'
+local files = require 'files'
+local searcher = require 'core.searcher'
+local vm = require 'vm'
+local config = require 'config'
local function typeHint(uri, edits, start, finish)
local ast = files.getAst(uri)
@@ -9,7 +9,7 @@ local function typeHint(uri, edits, start, finish)
return
end
local mark = {}
- guide.eachSourceBetween(ast.ast, start, finish, function (source)
+ searcher.eachSourceBetween(ast.ast, start, finish, function (source)
if source.type ~= 'local'
and source.type ~= 'setglobal'
and source.type ~= 'tablefield'
@@ -21,7 +21,7 @@ local function typeHint(uri, edits, start, finish)
if source[1] == '_' then
return
end
- if source.value and guide.isLiteral(source.value) then
+ if source.value and searcher.isLiteral(source.value) then
return
end
if source.parent.type == 'funcargs' then
@@ -84,7 +84,7 @@ local function hasLiteralArgInCall(call)
return false
end
for _, arg in ipairs(call.args) do
- if guide.isLiteral(arg) then
+ if searcher.isLiteral(arg) then
return true
end
end
@@ -100,7 +100,7 @@ local function paramName(uri, edits, start, finish)
return
end
local mark = {}
- guide.eachSourceBetween(ast.ast, start, finish, function (source)
+ searcher.eachSourceBetween(ast.ast, start, finish, function (source)
if source.type ~= 'call' then
return
end
@@ -130,7 +130,7 @@ local function paramName(uri, edits, start, finish)
table.remove(args, 1)
end
for i, arg in ipairs(source.args) do
- if not mark[arg] and guide.isLiteral(arg) then
+ if not mark[arg] and searcher.isLiteral(arg) then
mark[arg] = true
if args[i] and args[i] ~= '' then
edits[#edits+1] = {
diff --git a/script/core/hover/arg.lua b/script/core/hover/arg.lua
index 324d28af..b8c9eba0 100644
--- a/script/core/hover/arg.lua
+++ b/script/core/hover/arg.lua
@@ -1,4 +1,4 @@
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local vm = require 'vm'
local function optionalArg(arg)
@@ -29,7 +29,7 @@ local function asFunction(source, oop)
if arg.dummy then
goto CONTINUE
end
- local name = arg.name or guide.getKeyName(arg)
+ local name = arg.name or searcher.getKeyName(arg)
if name then
args[#args+1] = ('%s%s: %s'):format(
name,
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 14da4fcf..33cae0a6 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -2,7 +2,7 @@ local vm = require 'vm'
local ws = require 'workspace'
local furi = require 'file-uri'
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local markdown = require 'provider.markdown'
local config = require 'config'
local lang = require 'language'
@@ -72,7 +72,7 @@ local function asStringView(source, literal)
end
local function asString(source)
- local literal = guide.getLiteral(source)
+ local literal = searcher.getLiteral(source)
if type(literal) ~= 'string' then
return nil
end
@@ -127,7 +127,7 @@ local function tryDocClassComment(source)
for _, def in ipairs(vm.getDefs(source, 0)) do
if def.type == 'doc.class.name'
or def.type == 'doc.alias.name' then
- local class = guide.getDocState(def)
+ local class = searcher.getDocState(def)
local comment = getBindComment(class, class.bindGroup, class)
if comment then
return comment
@@ -180,7 +180,7 @@ local function isFunction(source)
if source.type == 'function' then
return true
end
- local value = guide.getObjectValue(source)
+ local value = searcher.getObjectValue(source)
if not value then
return false
end
diff --git a/script/core/hover/init.lua b/script/core/hover/init.lua
index 81285ef2..86c5b992 100644
--- a/script/core/hover/init.lua
+++ b/script/core/hover/init.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local vm = require 'vm'
local getLabel = require 'core.hover.label'
local getDesc = require 'core.hover.description'
@@ -48,7 +48,7 @@ local function getHoverAsFunction(source)
local other = 0
local mark = {}
for _, def in ipairs(values) do
- def = guide.getObjectValue(def) or def
+ def = searcher.getObjectValue(def) or def
if def.type == 'function'
or def.type == 'doc.type.function' then
eachFunctionAndOverload(def, function (value)
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua
index d93b14e3..da07200f 100644
--- a/script/core/hover/label.lua
+++ b/script/core/hover/label.lua
@@ -4,7 +4,7 @@ local buildReturn = require 'core.hover.return'
local buildTable = require 'core.hover.table'
local vm = require 'vm'
local util = require 'utility'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local lang = require 'language'
local config = require 'config'
local files = require 'files'
@@ -139,13 +139,13 @@ local function asDocField(source)
if not class then
return ('field ?.%s: %s'):format(
name,
- guide.viewInferType(infers)
+ searcher.viewInferType(infers)
)
end
return ('field %s.%s: %s'):format(
class.class[1],
name,
- guide.viewInferType(infers)
+ searcher.viewInferType(infers)
)
end
@@ -177,7 +177,7 @@ local function asNumber(source)
if type(num) ~= 'number' then
return nil
end
- local uri = guide.getUri(source)
+ local uri = searcher.getUri(source)
local text = files.getText(uri)
if not text then
return nil
diff --git a/script/core/hover/name.lua b/script/core/hover/name.lua
index d583f1e1..fe0f2ffb 100644
--- a/script/core/hover/name.lua
+++ b/script/core/hover/name.lua
@@ -1,10 +1,10 @@
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local vm = require 'vm'
local buildName
local function asLocal(source)
- local name = guide.getKeyName(source)
+ local name = searcher.getKeyName(source)
if not source.attrs then
return name
end
@@ -21,8 +21,8 @@ local function asField(source, oop)
if source.node.type ~= 'getglobal' then
class = vm.getClass(source.node, 0)
end
- local node = class or guide.getKeyName(source.node) or '?'
- local method = guide.getKeyName(source)
+ local node = class or searcher.getKeyName(source.node) or '?'
+ local method = searcher.getKeyName(source)
if oop then
return ('%s:%s'):format(node, method)
else
@@ -34,16 +34,16 @@ local function asTableField(source)
if not source.field then
return
end
- return guide.getKeyName(source.field)
+ return searcher.getKeyName(source.field)
end
local function asGlobal(source)
- return guide.getKeyName(source)
+ return searcher.getKeyName(source)
end
local function asDocFunction(source)
- local doc = guide.getParentType(source, 'doc.type')
- or guide.getParentType(source, 'doc.overload')
+ local doc = searcher.getParentType(source, 'doc.type')
+ or searcher.getParentType(source, 'doc.overload')
if not doc or not doc.bindSources then
return ''
end
diff --git a/script/core/hover/return.lua b/script/core/hover/return.lua
index c3e9656d..0825e77d 100644
--- a/script/core/hover/return.lua
+++ b/script/core/hover/return.lua
@@ -1,11 +1,11 @@
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local vm = require 'vm'
local function mergeTypes(returns)
if type(returns) == 'string' then
return returns
end
- return guide.mergeTypes(returns)
+ return searcher.mergeTypes(returns)
end
local function getReturnDualByDoc(source)
diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua
index edb7751b..137c4f6b 100644
--- a/script/core/hover/table.lua
+++ b/script/core/hover/table.lua
@@ -1,6 +1,6 @@
local vm = require 'vm'
local util = require 'utility'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local config = require 'config'
local lang = require 'language'
@@ -20,7 +20,7 @@ local function getKey(src)
end
return '[any]'
end
- if guide.getKeyType(src) == 'string' then
+ if searcher.getKeyType(src) == 'string' then
if key:match '^[%a_][%w_]*$' then
return key
else
@@ -31,7 +31,7 @@ local function getKey(src)
end
local function getFieldFull(src)
- local value = guide.getObjectValue(src) or src
+ local value = searcher.getObjectValue(src) or src
local tp = vm.getInferType(value, 0)
--local class = vm.getClass(src)
local literal = vm.getInferLiteral(value)
@@ -45,7 +45,7 @@ local function getFieldFast(src)
if src.bindDocs then
return getFieldFull(src)
end
- local value = guide.getObjectValue(src) or src
+ local value = searcher.getObjectValue(src) or src
if not value then
return 'any'
end
@@ -193,7 +193,7 @@ local function mergeTypes(types)
end
end
end
- return guide.mergeTypes(results)
+ return searcher.mergeTypes(results)
end
local function clearClasses(classes)
diff --git a/script/core/keyword.lua b/script/core/keyword.lua
index 71ea4969..538936f0 100644
--- a/script/core/keyword.lua
+++ b/script/core/keyword.lua
@@ -1,5 +1,5 @@
local define = require 'proto.define'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local files = require 'files'
local keyWordMap = {
@@ -24,7 +24,7 @@ end",
end
return true
end, function (info)
- return guide.eachSourceContain(info.ast.ast, info.start, function (source)
+ return searcher.eachSourceContain(info.ast.ast, info.start, function (source)
if source.type == 'while'
or source.type == 'in'
or source.type == 'loop' then
@@ -275,8 +275,8 @@ until $1"
if first == 'end'
or first == 'else'
or first == 'elseif' then
- local startRow = guide.positionOf(lines, info.start)
- local finishRow = guide.positionOf(lines, pos)
+ local startRow = searcher.positionOf(lines, info.start)
+ local finishRow = searcher.positionOf(lines, pos)
local startSp = info.text:match('^%s*', lines[startRow].start)
local finishSp = info.text:match('^%s*', lines[finishRow].start)
if startSp == finishSp then
diff --git a/script/core/linker.lua b/script/core/linker.lua
index b0083468..b97fc9bf 100644
--- a/script/core/linker.lua
+++ b/script/core/linker.lua
@@ -126,38 +126,21 @@ local function checkFunctionReturn(source)
return nil
end
-local TempList1 = {}
-local TempList2 = {}
+local TempList = {}
---前进
---@param source parser.guide.object
---@return parser.guide.object[]
local function checkForward(source)
- local list1 = TempList1
- local list2 = TempList2
+ local list = TempList
local parent = source.parent
if source.value then
-- x = y : x -> y
- list1[#list1+1] = source.value
+ list[#list+1] = source.value
elseif source.type == 'table' then
-- x = {y = 1} : x -> x.y
for _, keyvalue in ipairs(source) do
- list1[#list1+1] = keyvalue
- end
- elseif source.type == 'doc.type.name'
- or source.type == 'doc.class.name'
- or source.type == 'doc.alias.name' then
- list2[#list2+1] = function ()
- return vm.getDocNames(source[1], 'class')
- end
- list2[#list2+1] = function ()
- return vm.getDocNames(source[1], 'type')
- end
- list2[#list2+1] = function ()
- return vm.getDocNames(source[1], 'alias')
- end
- list2[#list2+1] = function ()
- return vm.getDocNames(source[1], 'extends')
+ list[#list+1] = keyvalue
end
end
-- mt:f -> self
@@ -167,52 +150,41 @@ local function checkForward(source)
if func then
local self = func.locals[1]
if self.tag == 'self' then
- list1[#list1+1] = self
+ list[#list+1] = self
end
end
end
- if #list1 == 0 then
- list1 = nil
- else
- TempList1 = {}
- end
- if #list2 == 0 then
- list2 = nil
+ if #list == 0 then
+ return nil
else
- TempList2 = {}
+ TempList = {}
+ return list
end
- return list1, list2
end
---后退
---@param source parser.guide.object
---@return parser.guide.object[]
local function checkBackward(source)
- local list1 = TempList1
- local list2 = TempList2
+ local list = TempList
local parent = source.parent
if parent.value == source then
- list1[#list1+1] = parent
+ list[#list+1] = parent
end
-- self -> mt:xx
if source.tag == 'self' then
local func = guide.getParentFunction(source)
local setmethod = func.parent
if setmethod and setmethod.type == 'setmethod' then
- list1[#list1+1] = setmethod.node
+ list[#list+1] = setmethod.node
end
end
- if #list1 == 0 then
- list1 = nil
- else
- TempList1 = {}
- end
- if #list2 == 0 then
- list2 = nil
+ if #list == 0 then
+ return nil
else
- TempList2 = {}
+ TempList = {}
+ return list
end
- return list1, list2
end
local IDList = {}
@@ -275,10 +247,6 @@ end
---@field forward parser.guide.object[]
-- 后退的关联单元
---@field backward parser.guide.object[]
--- 前进的关联函数,调用此函数获取单元
----@field fforward function[]
--- 后退的关联函数,调用此函数获取单元
----@field fbackward function[]
-- 缓存的关联links
---@field _links link[]
@@ -290,17 +258,13 @@ local function createLink(source)
if not id then
return nil
end
- local forward, fforward = checkForward(source)
- local backward, fbackward = checkBackward(source)
return {
id = id,
source = source,
lastID = lastID,
freturn = checkFunctionReturn(node),
- forward = forward,
- fforward = fforward,
- backward = backward,
- fbackward = fbackward,
+ forward = checkForward(source),
+ backward = checkBackward(source),
}
end
diff --git a/script/core/reference.lua b/script/core/reference.lua
index 7620b09e..efeb28b6 100644
--- a/script/core/reference.lua
+++ b/script/core/reference.lua
@@ -1,4 +1,5 @@
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
+local guide = require 'parser.guide'
local files = require 'files'
local vm = require 'vm'
local findSource = require 'core.find-source'
@@ -6,8 +7,8 @@ local findSource = require 'core.find-source'
local function sortResults(results)
-- 先按照顺序排序
table.sort(results, function (a, b)
- local u1 = guide.getUri(a.target)
- local u2 = guide.getUri(b.target)
+ local u1 = searcher.getUri(a.target)
+ local u2 = searcher.getUri(b.target)
if u1 == u2 then
return a.target.start < b.target.start
else
@@ -19,7 +20,7 @@ local function sortResults(results)
for i = #results, 1, -1 do
local res = results[i].target
local f = res.finish
- local uri = guide.getUri(res)
+ local uri = searcher.getUri(res)
if lf and f > lf and uri == lu then
table.remove(results, i)
else
diff --git a/script/core/rename.lua b/script/core/rename.lua
index da82b0a6..0851f191 100644
--- a/script/core/rename.lua
+++ b/script/core/rename.lua
@@ -1,6 +1,6 @@
local files = require 'files'
local vm = require 'vm'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local proto = require 'proto'
local define = require 'proto.define'
local util = require 'utility'
@@ -185,7 +185,7 @@ local function renameField(source, newname, callback)
end
callback(source, source.start, source.finish, newname)
elseif parent.type == 'setmethod' then
- local uri = guide.getUri(source)
+ local uri = searcher.getUri(source)
local text = files.getText(uri)
local func = parent.value
-- function mt:name () end --> mt['newname'] = function (self) end
@@ -284,7 +284,7 @@ local function ofFieldThen(key, src, newname, callback)
end
local function ofField(source, newname, callback)
- local key = guide.getKeyName(source)
+ local key = searcher.getKeyName(source)
local node
if source.type == 'tablefield'
or source.type == 'tableindex' then
@@ -298,7 +298,7 @@ local function ofField(source, newname, callback)
end
local function ofGlobal(source, newname, callback)
- local key = guide.getKeyName(source)
+ local key = searcher.getKeyName(source)
for _, src in ipairs(vm.getRefs(source, 0)) do
ofFieldThen(key, src, newname, callback)
end
@@ -325,7 +325,7 @@ end
local function ofDocParamName(source, newname, callback)
callback(source, source.start, source.finish, newname)
- local doc = guide.getDocState(source)
+ local doc = searcher.getDocState(source)
if doc.bindSources then
for _, src in ipairs(doc.bindSources) do
if src.type == 'local'
@@ -452,7 +452,7 @@ function m.rename(uri, pos, newname)
local mark = {}
rename(source, newname, function (target, start, finish, text)
- local turi = files.getOriginUri(guide.getUri(target))
+ local turi = files.getOriginUri(searcher.getUri(target))
if not turi then
return
end
diff --git a/script/core/guide.lua b/script/core/searcher.lua
index bfbb941c..da00f46a 100644
--- a/script/core/guide.lua
+++ b/script/core/searcher.lua
@@ -4,19 +4,6 @@ local files = require 'files'
local m = {}
--- TODO: compatible
-m.getRoot = guide.getRoot
-m.eachSource = guide.eachSource
-m.eachSourceType = guide.eachSourceType
-m.eachSourceContain = guide.eachSourceContain
-m.eachSourceBetween = guide.eachSourceBetween
-m.getStartFinish = guide.getStartFinish
-m.isLiteral = guide.isLiteral
-m.positionOf = guide.positionOf
-m.offsetOf = guide.offsetOf
-m.lineRange = guide.lineRange
-m.lineData = guide.lineData
-
---@alias guide.searchmode '"ref"'|'"def"'|'"field"'
---添加结果
@@ -68,7 +55,7 @@ function m.getUri(obj)
if obj.uri then
return obj.uri
end
- local root = m.getRoot(obj)
+ local root = guide.getRoot(obj)
if root then
return root.uri
end
@@ -226,6 +213,8 @@ function m.searchRefsByID(status, uri, expect, mode)
stackCount = stackCount - 1
end
+ search(expect)
+
end
---搜索对象的引用
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index f8feaa09..5e9ee9b1 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local await = require 'await'
local define = require 'proto.define'
local vm = require 'vm'
@@ -221,7 +221,7 @@ return function (uri, start, finish)
local results = {}
local count = 0
- guide.eachSourceBetween(ast.ast, start, finish, function (source)
+ searcher.eachSourceBetween(ast.ast, start, finish, function (source)
local method = Care[source.type]
if not method then
return
diff --git a/script/core/signature.lua b/script/core/signature.lua
index a35f3593..7d391c94 100644
--- a/script/core/signature.lua
+++ b/script/core/signature.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local vm = require 'vm'
local hoverLabel = require 'core.hover.label'
local hoverDesc = require 'core.hover.description'
@@ -7,7 +7,7 @@ local hoverDesc = require 'core.hover.description'
local function findNearCall(uri, ast, pos)
local text = files.getText(uri)
local nearCall
- guide.eachSourceContain(ast.ast, pos, function (src)
+ searcher.eachSourceContain(ast.ast, pos, function (src)
if src.type == 'call'
or src.type == 'table'
or src.type == 'function' then
@@ -96,7 +96,7 @@ local function makeSignatures(call, pos)
local defs = vm.getDefs(node, 0)
local mark = {}
for _, src in ipairs(defs) do
- src = guide.getObjectValue(src) or src
+ src = searcher.getObjectValue(src) or src
if src.type == 'function'
or src.type == 'doc.type.function' then
if not mark[src] then
diff --git a/script/core/type-formatting.lua b/script/core/type-formatting.lua
index c2290ef3..79dccc8f 100644
--- a/script/core/type-formatting.lua
+++ b/script/core/type-formatting.lua
@@ -1,11 +1,11 @@
local files = require 'files'
local lookBackward = require 'core.look-backward'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local function insertIndentation(uri, offset, edits)
local lines = files.getLines(uri)
local text = files.getOriginText(uri)
- local row = guide.positionOf(lines, offset)
+ local row = searcher.positionOf(lines, offset)
local line = lines[row]
local indent = text:sub(line.start, line.finish):match '^%s*'
for _, edit in ipairs(edits) do
diff --git a/script/core/workspace-symbol.lua b/script/core/workspace-symbol.lua
index ae420d32..2df23a4d 100644
--- a/script/core/workspace-symbol.lua
+++ b/script/core/workspace-symbol.lua
@@ -1,5 +1,5 @@
local files = require 'files'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local matchKey = require 'core.matchkey'
local define = require 'proto.define'
local await = require 'await'
@@ -52,7 +52,7 @@ local function searchFile(uri, key, results)
return
end
- guide.eachSource(ast.ast, function (source)
+ searcher.eachSource(ast.ast, function (source)
buildSource(uri, source, key, results)
end)
end
diff --git a/script/vm/eachDef.lua b/script/vm/eachDef.lua
index d72c8f01..a00b61bb 100644
--- a/script/vm/eachDef.lua
+++ b/script/vm/eachDef.lua
@@ -1,10 +1,10 @@
---@type vm
-local vm = require 'vm.vm'
-local guide = require 'core.guide'
-local files = require 'files'
-local util = require 'utility'
-local await = require 'await'
-local config = require 'config'
+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 = {}
@@ -18,9 +18,9 @@ local function getDefs(source, deep)
deep = config.config.intelliSense.searchDepth + (deep or 0)
local clock = os.clock()
- local myResults, count = guide.requestDefinition(source, vm.interface, deep)
+ 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, guide.getUri(source), util.dump(source, { deep = 1 }))
+ log.warn('requestDefinition', count, os.clock() - clock, searcher.getUri(source), util.dump(source, { deep = 1 }))
end
vm.mergeResults(results, myResults)
@@ -31,8 +31,8 @@ end
function vm.getDefs(source, deep)
deep = deep or -999
- if guide.isGlobal(source) then
- local key = guide.getKeyName(source)
+ if searcher.isGlobal(source) then
+ local key = searcher.getKeyName(source)
if not key then
return {}
end
diff --git a/script/vm/eachField.lua b/script/vm/eachField.lua
index 59f35f0c..9a40fb1c 100644
--- a/script/vm/eachField.lua
+++ b/script/vm/eachField.lua
@@ -1,6 +1,6 @@
---@type vm
local vm = require 'vm.vm'
-local guide = require 'core.guide'
+local searcher= require 'core.searcher'
local await = require 'await'
local config = require 'config'
@@ -19,7 +19,7 @@ local function getFields(source, deep, filterKey)
deep = config.config.intelliSense.searchDepth + (deep or 0)
await.delay()
- local results = guide.requestFields(source, vm.interface, deep, filterKey)
+ local results = searcher.requestFields(source, vm.interface, deep, filterKey)
unlock()
return results
@@ -40,7 +40,7 @@ local function getDefFields(source, deep, filterKey)
deep = config.config.intelliSense.searchDepth + (deep or 0)
await.delay()
- local results = guide.requestDefFields(source, vm.interface, deep, filterKey)
+ local results = searcher.requestDefFields(source, vm.interface, deep, filterKey)
unlock()
return results
@@ -76,8 +76,8 @@ function vm.getFields(source, deep)
if source.special == '_G' then
return vm.getGlobals '*'
end
- if guide.isGlobal(source) then
- local name = guide.getKeyName(source)
+ if searcher.isGlobal(source) then
+ local name = searcher.getKeyName(source)
if not name then
return {}
end
@@ -94,8 +94,8 @@ function vm.getDefFields(source, deep)
if source.special == '_G' then
return vm.getGlobalSets '*'
end
- if guide.isGlobal(source) then
- local name = guide.getKeyName(source)
+ if searcher.isGlobal(source) then
+ local name = searcher.getKeyName(source)
if not name then
return {}
end
diff --git a/script/vm/eachRef.lua b/script/vm/eachRef.lua
index 9d0f061c..0556a6a3 100644
--- a/script/vm/eachRef.lua
+++ b/script/vm/eachRef.lua
@@ -1,9 +1,9 @@
---@type vm
-local vm = require 'vm.vm'
-local guide = require 'core.guide'
-local util = require 'utility'
-local await = require 'await'
-local config = require 'config'
+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 = {}
@@ -17,9 +17,9 @@ local function getRefs(source, deep)
deep = config.config.intelliSense.searchDepth + (deep or 0)
local clock = os.clock()
- local myResults, count = guide.requestReference(source, vm.interface, deep)
+ 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, guide.getUri(source), util.dump(source, { deep = 1 }))
+ log.warn('requestReference', count, os.clock() - clock, searcher.getUri(source), util.dump(source, { deep = 1 }))
end
vm.mergeResults(results, myResults)
@@ -30,8 +30,8 @@ end
function vm.getRefs(source, deep)
deep = deep or -999
- if guide.isGlobal(source) then
- local key = guide.getKeyName(source)
+ if searcher.isGlobal(source) then
+ local key = searcher.getKeyName(source)
if not key then
return {}
end
diff --git a/script/vm/getClass.lua b/script/vm/getClass.lua
index 5c68e0bb..fbd50fc8 100644
--- a/script/vm/getClass.lua
+++ b/script/vm/getClass.lua
@@ -1,13 +1,13 @@
---@type vm
-local vm = require 'vm.vm'
-local guide = require 'core.guide'
+local vm = require 'vm.vm'
+local searcher = require 'core.searcher'
local function lookUpDocClass(source)
local infers = vm.getInfers(source, 0)
for _, infer in ipairs(infers) do
if infer.source.type == 'doc.class'
or infer.source.type == 'doc.type' then
- return guide.viewInferType(infers)
+ return searcher.viewInferType(infers)
end
end
return nil
@@ -22,7 +22,7 @@ local function getClass(source, classes, depth, deep)
if depth > 3 then
return
end
- local value = guide.getObjectValue(source) or source
+ local value = searcher.getObjectValue(source) or source
if not deep then
if value and value.type == 'string' then
classes[value[1]] = true
@@ -38,7 +38,7 @@ local function getClass(source, classes, depth, deep)
or lkey == '__name'
or lkey == 'name'
or lkey == 'class' then
- local value = guide.getObjectValue(src)
+ local value = searcher.getObjectValue(src)
if value and value.type == 'string' then
classes[value[1]] = true
end
@@ -60,5 +60,5 @@ function vm.getClass(source, deep)
if not next(classes) then
return nil
end
- return guide.mergeTypes(classes)
+ return searcher.mergeTypes(classes)
end
diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua
index 75512a75..08f9d049 100644
--- a/script/vm/getGlobals.lua
+++ b/script/vm/getGlobals.lua
@@ -265,7 +265,7 @@ files.watch(function (ev, uri)
end
needUpdateGlobals[uri] = true
elseif ev == 'create' then
- getGlobalsOfFile(uri)
- getGlobalSetsOfFile(uri)
+ --getGlobalsOfFile(uri)
+ --getGlobalSetsOfFile(uri)
end
end)
diff --git a/script/vm/getInfer.lua b/script/vm/getInfer.lua
index 5447ca23..be9a66ab 100644
--- a/script/vm/getInfer.lua
+++ b/script/vm/getInfer.lua
@@ -1,6 +1,6 @@
---@type vm
local vm = require 'vm.vm'
-local guide = require 'core.guide'
+local searcher= require 'core.searcher'
local util = require 'utility'
local await = require 'await'
local config = require 'config'
@@ -12,7 +12,7 @@ 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
+ local value = searcher.getObjectValue(def) or def
if value.type == type then
return true
end
@@ -34,7 +34,7 @@ end
function vm.getInferType(source, deep)
local infers = vm.getInfers(source, deep)
- return guide.viewInferType(infers)
+ return searcher.viewInferType(infers)
end
function vm.getInferLiteral(source, deep)
@@ -67,9 +67,9 @@ local function getInfers(source, deep)
await.delay()
local clock = os.clock()
- local myResults, count = guide.requestInfer(source, vm.interface, deep)
+ local myResults, count = searcher.requestInfer(source, vm.interface, deep)
if DEVELOP and os.clock() - clock > 0.1 then
- log.warn('requestInfer', count, os.clock() - clock, guide.getUri(source), util.dump(source, { deep = 1 }))
+ log.warn('requestInfer', count, os.clock() - clock, searcher.getUri(source), util.dump(source, { deep = 1 }))
end
vm.mergeResults(results, myResults)
@@ -92,8 +92,8 @@ end
--- 获取对象的值
--- 会尝试穿透函数调用
function vm.getInfers(source, deep)
- if guide.isGlobal(source) then
- local name = guide.getKeyName(source)
+ if searcher.isGlobal(source) then
+ local name = searcher.getKeyName(source)
local cache = vm.getCache('getInfersOfGlobal')[name]
or getInfersBySource(source, deep)
vm.getCache('getInfersOfGlobal')[name] = cache
diff --git a/script/vm/getLinks.lua b/script/vm/getLinks.lua
index 91a5f1a0..86a38cfc 100644
--- a/script/vm/getLinks.lua
+++ b/script/vm/getLinks.lua
@@ -1,7 +1,7 @@
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
---@type vm
-local vm = require 'vm.vm'
-local files = require 'files'
+local vm = require 'vm.vm'
+local files = require 'files'
local function getFileLinks(uri)
local ws = require 'workspace'
@@ -11,7 +11,7 @@ local function getFileLinks(uri)
return links
end
tracy.ZoneBeginN('getFileLinks')
- guide.eachSpecialOf(ast.ast, 'require', function (source)
+ searcher.eachSpecialOf(ast.ast, 'require', function (source)
local call = source.parent
if not call or call.type ~= 'call' then
return
diff --git a/script/vm/guideInterface.lua b/script/vm/guideInterface.lua
index b966d5c9..e59fc6e3 100644
--- a/script/vm/guideInterface.lua
+++ b/script/vm/guideInterface.lua
@@ -2,7 +2,7 @@
local vm = require 'vm.vm'
local files = require 'files'
local ws = require 'workspace'
-local guide = require 'core.guide'
+local searcher = require 'core.searcher'
local await = require 'await'
local config = require 'config'
@@ -27,7 +27,7 @@ function m.require(args, index)
return nil
end
local results = {}
- local myUri = guide.getUri(args[1])
+ local myUri = searcher.getUri(args[1])
local uris = ws.findUrisByRequirePath(reqName)
for _, uri in ipairs(uris) do
if not files.eq(myUri, uri) then
@@ -47,7 +47,7 @@ function m.dofile(args, index)
return
end
local results = {}
- local myUri = guide.getUri(args[1])
+ local myUri = searcher.getUri(args[1])
local uris = ws.findUrisByFilePath(reqName)
for _, uri in ipairs(uris) do
if not files.eq(myUri, uri) then
diff --git a/test.lua b/test.lua
index bbc5f208..7be3498f 100644
--- a/test.lua
+++ b/test.lua
@@ -80,7 +80,7 @@ end
local function main()
debug.setcstacklimit(1000)
- require 'core.guide'.debugMode = true
+ require 'core.searcher'.debugMode = true
require 'language' 'zh-cn'
require 'utility'.enableCloseFunction()
diff --git a/test/basic/linker.lua b/test/basic/linker.lua
index 28292bd9..d658c782 100644
--- a/test/basic/linker.lua
+++ b/test/basic/linker.lua
@@ -1,7 +1,7 @@
local linker = require 'core.linker'
local files = require 'files'
local util = require 'utility'
-local guide = require 'core.guide'
+local guide = require 'parser.guide'
local function getSource(pos)
local ast = files.getAst('')
diff --git a/test/references/init.lua b/test/references/init.lua
index 06bcdd78..31aa0cb7 100644
--- a/test/references/init.lua
+++ b/test/references/init.lua
@@ -1,4 +1,4 @@
-local core = require 'core.reference'
+local core = require 'core.reference'
local files = require 'files'
local function catch_target(script)