summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/core/completion.lua (renamed from server/src/matcher/completion.lua)4
-rw-r--r--server/src/core/definition.lua (renamed from server/src/matcher/definition.lua)0
-rw-r--r--server/src/core/diagnostics.lua (renamed from server/src/matcher/diagnostics.lua)0
-rw-r--r--server/src/core/document_symbol.lua (renamed from server/src/matcher/document_symbol.lua)11
-rw-r--r--server/src/core/env.lua (renamed from server/src/matcher/env.lua)0
-rw-r--r--server/src/core/find_lib.lua (renamed from server/src/matcher/find_lib.lua)0
-rw-r--r--server/src/core/find_result.lua (renamed from server/src/matcher/find_result.lua)0
-rw-r--r--server/src/core/hover.lua (renamed from server/src/matcher/hover.lua)16
-rw-r--r--server/src/core/implementation.lua (renamed from server/src/matcher/implementation.lua)0
-rw-r--r--server/src/core/init.lua16
-rw-r--r--server/src/core/library.lua (renamed from server/src/matcher/library.lua)0
-rw-r--r--server/src/core/references.lua (renamed from server/src/matcher/references.lua)2
-rw-r--r--server/src/core/rename.lua (renamed from server/src/matcher/rename.lua)2
-rw-r--r--server/src/core/signature.lua (renamed from server/src/matcher/signature.lua)2
-rw-r--r--server/src/core/vm.lua (renamed from server/src/matcher/vm.lua)4
-rw-r--r--server/src/matcher/init.lua16
-rw-r--r--server/src/method/textDocument/completion.lua4
-rw-r--r--server/src/method/textDocument/definition.lua6
-rw-r--r--server/src/method/textDocument/documentSymbol.lua4
-rw-r--r--server/src/method/textDocument/hover.lua6
-rw-r--r--server/src/method/textDocument/implementation.lua6
-rw-r--r--server/src/method/textDocument/publishDiagnostics.lua4
-rw-r--r--server/src/method/textDocument/references.lua4
-rw-r--r--server/src/method/textDocument/rename.lua4
-rw-r--r--server/src/method/textDocument/signatureHelp.lua4
-rw-r--r--server/src/service.lua4
-rw-r--r--server/test/completion/init.lua6
-rw-r--r--server/test/crossfile/completion.lua4
-rw-r--r--server/test/crossfile/definition.lua6
-rw-r--r--server/test/crossfile/hover.lua6
-rw-r--r--server/test/definition/init.lua8
-rw-r--r--server/test/diagnostics/init.lua6
-rw-r--r--server/test/document_symbol/init.lua20
-rw-r--r--server/test/find_lib/init.lua8
-rw-r--r--server/test/hover/init.lua8
-rw-r--r--server/test/main.lua2
-rw-r--r--server/test/signature/init.lua6
-rw-r--r--server/test/type_inference/init.lua6
-rw-r--r--server/test/vm/example.lua2
-rw-r--r--server/test/vm/init.lua4
40 files changed, 112 insertions, 99 deletions
diff --git a/server/src/matcher/completion.lua b/server/src/core/completion.lua
index 508c0320..cdb68580 100644
--- a/server/src/matcher/completion.lua
+++ b/server/src/core/completion.lua
@@ -1,5 +1,5 @@
-local findResult = require 'matcher.find_result'
-local hover = require 'matcher.hover'
+local findResult = require 'core.find_result'
+local hover = require 'core.hover'
local CompletionItemKind = {
Text = 1,
diff --git a/server/src/matcher/definition.lua b/server/src/core/definition.lua
index 3ca27b89..3ca27b89 100644
--- a/server/src/matcher/definition.lua
+++ b/server/src/core/definition.lua
diff --git a/server/src/matcher/diagnostics.lua b/server/src/core/diagnostics.lua
index a6672c0b..a6672c0b 100644
--- a/server/src/matcher/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
diff --git a/server/src/matcher/document_symbol.lua b/server/src/core/document_symbol.lua
index b6802c93..4dc0ebac 100644
--- a/server/src/matcher/document_symbol.lua
+++ b/server/src/core/document_symbol.lua
@@ -1,4 +1,4 @@
-local hover = require 'matcher.hover'
+local hover = require 'core.hover'
local SymbolKind = {
File = 1,
@@ -31,17 +31,18 @@ local SymbolKind = {
local function buildFunc(vm, func, nextFunction, nextFinish)
local source = func.source
- local var = vm.results.sources[source.name]
+ local var = vm.results.sources[source.name] or vm.results.sources[source]
if not var then
return
end
- local hvr = hover(var, source.name)
+ local hvr = hover(var, source.name or source)
if not hvr then
return
end
return {
name = hvr.name,
- detail = hvr.label,
+ -- 前端不支持多行
+ detail = hvr.label:gsub('[\r\n]', ''),
kind = SymbolKind.Function,
range = { source.start, source.finish },
selectionRange = { source.name.start, source.name.finish },
@@ -70,7 +71,7 @@ return function (vm)
if not func then
break
end
- symbols[1] = buildFunc(vm, func, nextFunction, nextFinish)
+ symbols[#symbols+1] = buildFunc(vm, func, nextFunction, nextFinish)
end
return symbols
diff --git a/server/src/matcher/env.lua b/server/src/core/env.lua
index ada26145..ada26145 100644
--- a/server/src/matcher/env.lua
+++ b/server/src/core/env.lua
diff --git a/server/src/matcher/find_lib.lua b/server/src/core/find_lib.lua
index c4d5bff3..c4d5bff3 100644
--- a/server/src/matcher/find_lib.lua
+++ b/server/src/core/find_lib.lua
diff --git a/server/src/matcher/find_result.lua b/server/src/core/find_result.lua
index ac8dc3f4..ac8dc3f4 100644
--- a/server/src/matcher/find_result.lua
+++ b/server/src/core/find_result.lua
diff --git a/server/src/matcher/hover.lua b/server/src/core/hover.lua
index 5239f3b8..4d64647d 100644
--- a/server/src/matcher/hover.lua
+++ b/server/src/core/hover.lua
@@ -1,4 +1,4 @@
-local findLib = require 'matcher.find_lib'
+local findLib = require 'core.find_lib'
local OriginTypes = {
['any'] = true,
@@ -219,8 +219,7 @@ local function buildValueName(result, source)
return result.key or ''
end
-local function buildValueArgs(result, source, select)
- local func = result.value
+local function buildValueArgs(func, source, select)
local names = {}
local values = {}
if func.args then
@@ -266,8 +265,7 @@ local function buildValueArgs(result, source, select)
return table.concat(strs, ', '), argLabel
end
-local function buildValueReturns(result)
- local func = result.value
+local function buildValueReturns(func)
if not func.hasReturn then
return ''
end
@@ -283,7 +281,7 @@ local function buildValueReturns(result)
return '\n -> ' .. table.concat(strs, ', ')
end
-local function getFunctionHover(name, result, source, lib, oo, select)
+local function getFunctionHover(name, func, source, lib, oo, select)
local args = ''
local returns
local enum
@@ -295,8 +293,8 @@ local function getFunctionHover(name, result, source, lib, oo, select)
enum = buildEnum(lib)
tip = lib.description
else
- args, argLabel = buildValueArgs(result, source, select)
- returns = buildValueReturns(result)
+ args, argLabel = buildValueArgs(func, source, select)
+ returns = buildValueReturns(func)
end
local title = ('function %s(%s)%s'):format(name, args, returns)
return {
@@ -470,7 +468,7 @@ return function (result, source, lsp, select)
local name = fullKey or buildValueName(result, source)
local hover
if valueType == 'function' then
- hover = getFunctionHover(name, result, source, lib, oo, select)
+ hover = getFunctionHover(name, result.value, source, lib, oo, select)
else
hover = getValueHover(name, valueType, result, source, lib)
end
diff --git a/server/src/matcher/implementation.lua b/server/src/core/implementation.lua
index 9ff3fdca..9ff3fdca 100644
--- a/server/src/matcher/implementation.lua
+++ b/server/src/core/implementation.lua
diff --git a/server/src/core/init.lua b/server/src/core/init.lua
new file mode 100644
index 00000000..31a7c1b1
--- /dev/null
+++ b/server/src/core/init.lua
@@ -0,0 +1,16 @@
+local api = {
+ definition = require 'core.definition',
+ implementation = require 'core.implementation',
+ references = require 'core.references',
+ rename = require 'core.rename',
+ hover = require 'core.hover',
+ diagnostics = require 'core.diagnostics',
+ findResult = require 'core.find_result',
+ findLib = require 'core.find_lib',
+ completion = require 'core.completion',
+ signature = require 'core.signature',
+ documentSymbol = require 'core.document_symbol',
+ vm = require 'core.vm',
+}
+
+return api
diff --git a/server/src/matcher/library.lua b/server/src/core/library.lua
index b268b368..b268b368 100644
--- a/server/src/matcher/library.lua
+++ b/server/src/core/library.lua
diff --git a/server/src/matcher/references.lua b/server/src/core/references.lua
index 71b7eb77..f4aec8ca 100644
--- a/server/src/matcher/references.lua
+++ b/server/src/core/references.lua
@@ -1,4 +1,4 @@
-local findResult = require 'matcher.find_result'
+local findResult = require 'core.find_result'
local function parseResult(result, declarat)
local positions = {}
diff --git a/server/src/matcher/rename.lua b/server/src/core/rename.lua
index 1033d331..459aabcc 100644
--- a/server/src/matcher/rename.lua
+++ b/server/src/core/rename.lua
@@ -1,4 +1,4 @@
-local findResult = require 'matcher.find_result'
+local findResult = require 'core.find_result'
local parser = require 'parser'
local function parseResult(result, source, newName)
diff --git a/server/src/matcher/signature.lua b/server/src/core/signature.lua
index dc6af15e..14d05b8b 100644
--- a/server/src/matcher/signature.lua
+++ b/server/src/core/signature.lua
@@ -1,4 +1,4 @@
-local hover = require 'matcher.hover'
+local hover = require 'core.hover'
local function isContainPos(obj, pos)
if obj.start <= pos and obj.finish + 1 >= pos then
diff --git a/server/src/matcher/vm.lua b/server/src/core/vm.lua
index 6bd7e7c3..b4948e62 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/core/vm.lua
@@ -1,5 +1,5 @@
-local env = require 'matcher.env'
-local library = require 'matcher.library'
+local env = require 'core.env'
+local library = require 'core.library'
local DefaultSource = { start = 0, finish = 0 }
diff --git a/server/src/matcher/init.lua b/server/src/matcher/init.lua
deleted file mode 100644
index cf33359a..00000000
--- a/server/src/matcher/init.lua
+++ /dev/null
@@ -1,16 +0,0 @@
-local api = {
- definition = require 'matcher.definition',
- implementation = require 'matcher.implementation',
- references = require 'matcher.references',
- rename = require 'matcher.rename',
- hover = require 'matcher.hover',
- diagnostics = require 'matcher.diagnostics',
- findResult = require 'matcher.find_result',
- findLib = require 'matcher.find_lib',
- completion = require 'matcher.completion',
- signature = require 'matcher.signature',
- documentSymbol = require 'matcher.document_symbol',
- vm = require 'matcher.vm',
-}
-
-return api
diff --git a/server/src/method/textDocument/completion.lua b/server/src/method/textDocument/completion.lua
index 9c3b00ac..a5df0276 100644
--- a/server/src/method/textDocument/completion.lua
+++ b/server/src/method/textDocument/completion.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local function posToRange(lines, start, finish)
local start_row, start_col = lines:rowcol(start)
@@ -23,7 +23,7 @@ return function (lsp, params)
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- local items = matcher.completion(vm, position)
+ local items = core.completion(vm, position)
if not items then
return nil
end
diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua
index 0df5c522..60e6bb1e 100644
--- a/server/src/method/textDocument/definition.lua
+++ b/server/src/method/textDocument/definition.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local function checkWorkSpaceComplete(lsp, result)
if result.type ~= 'field' and result.type ~= 'local' then
@@ -24,14 +24,14 @@ return function (lsp, params)
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- local result = matcher.findResult(vm, position)
+ local result = core.findResult(vm, position)
if not result then
return nil
end
checkWorkSpaceComplete(lsp, result)
- local positions = matcher.definition(vm, result)
+ local positions = core.definition(vm, result)
if not positions then
return nil
end
diff --git a/server/src/method/textDocument/documentSymbol.lua b/server/src/method/textDocument/documentSymbol.lua
index 49006f3b..fdfe832a 100644
--- a/server/src/method/textDocument/documentSymbol.lua
+++ b/server/src/method/textDocument/documentSymbol.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local function posToRange(lines, start, finish)
local start_row, start_col = lines:rowcol(start)
@@ -33,7 +33,7 @@ return function (lsp, params)
return nil
end
- local symbols = matcher.documentSymbol(vm)
+ local symbols = core.documentSymbol(vm)
for _, symbol in ipairs(symbols) do
convertRange(lines, symbol)
diff --git a/server/src/method/textDocument/hover.lua b/server/src/method/textDocument/hover.lua
index ca894797..9c98b8f0 100644
--- a/server/src/method/textDocument/hover.lua
+++ b/server/src/method/textDocument/hover.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
return function (lsp, params)
local uri = params.textDocument.uri
@@ -9,12 +9,12 @@ return function (lsp, params)
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- local result, source = matcher.findResult(vm, position)
+ local result, source = core.findResult(vm, position)
if not result then
return nil
end
- local hover = matcher.hover(result, source, lsp)
+ local hover = core.hover(result, source, lsp)
if not hover then
return nil
end
diff --git a/server/src/method/textDocument/implementation.lua b/server/src/method/textDocument/implementation.lua
index c92a8c56..4c7dfb3a 100644
--- a/server/src/method/textDocument/implementation.lua
+++ b/server/src/method/textDocument/implementation.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local function checkWorkSpaceComplete(lsp, result)
if result.value then
@@ -21,14 +21,14 @@ return function (lsp, params)
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- local result = matcher.findResult(vm, position)
+ local result = core.findResult(vm, position)
if not result then
return nil
end
checkWorkSpaceComplete(lsp, result)
- local positions = matcher.implementation(vm, result)
+ local positions = core.implementation(vm, result)
if not positions then
return nil
end
diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua
index 362851ed..e5c8b2ff 100644
--- a/server/src/method/textDocument/publishDiagnostics.lua
+++ b/server/src/method/textDocument/publishDiagnostics.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local lang = require 'language'
local DiagnosticSeverity = {
@@ -110,7 +110,7 @@ return function (lsp, params)
local diagnostics = {}
if vm then
- local datas = matcher.diagnostics(vm, lines, uri)
+ local datas = core.diagnostics(vm, lines, uri)
for _, data in ipairs(datas) do
diagnostics[#diagnostics+1] = createInfo(data, lines)
end
diff --git a/server/src/method/textDocument/references.lua b/server/src/method/textDocument/references.lua
index f9df13ed..555808ca 100644
--- a/server/src/method/textDocument/references.lua
+++ b/server/src/method/textDocument/references.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
return function (lsp, params)
local uri = params.textDocument.uri
@@ -9,7 +9,7 @@ return function (lsp, params)
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- local positions = matcher.references(vm, position, declarat)
+ local positions = core.references(vm, position, declarat)
if not positions then
return {}
end
diff --git a/server/src/method/textDocument/rename.lua b/server/src/method/textDocument/rename.lua
index 43f0f7cb..fcbdfef7 100644
--- a/server/src/method/textDocument/rename.lua
+++ b/server/src/method/textDocument/rename.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
return function (lsp, params)
local uri = params.textDocument.uri
@@ -9,7 +9,7 @@ return function (lsp, params)
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- local positions = matcher.rename(vm, position, newName)
+ local positions = core.rename(vm, position, newName)
if not positions then
return {}
end
diff --git a/server/src/method/textDocument/signatureHelp.lua b/server/src/method/textDocument/signatureHelp.lua
index 7620b542..ce72dbc7 100644
--- a/server/src/method/textDocument/signatureHelp.lua
+++ b/server/src/method/textDocument/signatureHelp.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
return function (lsp, params)
local uri = params.textDocument.uri
@@ -8,7 +8,7 @@ return function (lsp, params)
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1)
- local hovers = matcher.signature(vm, position)
+ local hovers = core.signature(vm, position)
if not hovers then
return
end
diff --git a/server/src/service.lua b/server/src/service.lua
index ae6b6714..80f2ba14 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -4,7 +4,7 @@ local thread = require 'bee.thread'
local async = require 'async'
local rpc = require 'rpc'
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
local lang = require 'language'
thread.newchannel 'proto'
@@ -328,7 +328,7 @@ function mt:compileVM(uri)
local ast = self:compileAst(obj)
self:_clearChainNode(obj, uri)
- obj.vm = matcher.vm(ast, self, uri)
+ obj.vm = core.vm(ast, self, uri)
obj.lines = parser:lines(obj.text, 'utf8')
self._needDiagnostics[uri] = true
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index 46544b36..ee4e5f30 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
local CompletionItemKind = {
@@ -64,9 +64,9 @@ function TEST(script)
local pos = script:find('@', 1, true)
local new_script = script:gsub('@', ' ')
local ast = parser:ast(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.completion(vm, pos)
+ local result = core.completion(vm, pos)
if expect then
assert(result)
assert(eq(expect, result))
diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua
index e35874b3..f136a057 100644
--- a/server/test/crossfile/completion.lua
+++ b/server/test/crossfile/completion.lua
@@ -1,7 +1,7 @@
local service = require 'service'
local workspace = require 'workspace'
local fs = require 'bee.filesystem'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -86,7 +86,7 @@ function TEST(data)
local vm = lsp:loadVM(mainUri)
assert(vm)
- local result = matcher.completion(vm, pos)
+ local result = core.completion(vm, pos)
local expect = data.completion
if expect then
assert(result)
diff --git a/server/test/crossfile/definition.lua b/server/test/crossfile/definition.lua
index dfc91c31..8d8c7569 100644
--- a/server/test/crossfile/definition.lua
+++ b/server/test/crossfile/definition.lua
@@ -1,7 +1,7 @@
local service = require 'service'
local workspace = require 'workspace'
local fs = require 'bee.filesystem'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -48,8 +48,8 @@ function TEST(data)
local sourceVM = lsp:getVM(sourceUri)
assert(sourceVM)
local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2
- local result = matcher.findResult(sourceVM, sourcePos)
- local positions = matcher.definition(sourceVM, result)
+ local result = core.findResult(sourceVM, sourcePos)
+ local positions = core.definition(sourceVM, result)
assert(positions and positions[1])
local start, finish, valueUri = positions[1][1], positions[1][2], positions[1][3]
assert(valueUri == targetUri)
diff --git a/server/test/crossfile/hover.lua b/server/test/crossfile/hover.lua
index 32fd7580..a4479280 100644
--- a/server/test/crossfile/hover.lua
+++ b/server/test/crossfile/hover.lua
@@ -1,7 +1,7 @@
local service = require 'service'
local workspace = require 'workspace'
local fs = require 'bee.filesystem'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -72,8 +72,8 @@ function TEST(data)
local sourceVM = lsp:loadVM(sourceUri)
assert(sourceVM)
local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2
- local result, source = matcher.findResult(sourceVM, sourcePos)
- local hover = matcher.hover(result, source, lsp)
+ local result, source = core.findResult(sourceVM, sourcePos)
+ local hover = core.hover(result, source, lsp)
assert(hover)
if data.hover.description then
data.hover.description = data.hover.description:gsub('%$ROOT%$', ws:uriEncode(ROOT):gsub('%%', '%%%%'))
diff --git a/server/test/definition/init.lua b/server/test/definition/init.lua
index 38201435..5ed638dd 100644
--- a/server/test/definition/init.lua
+++ b/server/test/definition/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -41,11 +41,11 @@ function TEST(script)
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:ast(new_script)
assert(ast)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.findResult(vm, pos)
- local positions = matcher.definition(vm, result)
+ local result = core.findResult(vm, pos)
+ local positions = core.definition(vm, result)
if positions then
assert(founded(target, positions))
else
diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua
index 57a54e4d..9d9c7424 100644
--- a/server/test/diagnostics/init.lua
+++ b/server/test/diagnostics/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -41,9 +41,9 @@ function TEST(script)
local ast = parser:ast(new_script)
assert(ast)
local lines = parser:lines(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local datas = matcher.diagnostics(vm, lines, 'test')
+ local datas = core.diagnostics(vm, lines, 'test')
local results = {}
for i, data in ipairs(datas) do
results[i] = { data.start, data.finish }
diff --git a/server/test/document_symbol/init.lua b/server/test/document_symbol/init.lua
index 5b1ed397..684e5449 100644
--- a/server/test/document_symbol/init.lua
+++ b/server/test/document_symbol/init.lua
@@ -1,5 +1,5 @@
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
local SymbolKind = {
File = 1,
@@ -63,9 +63,9 @@ end
function TEST(script)
return function (expect)
local ast = parser:ast(script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.documentSymbol(vm)
+ local result = core.documentSymbol(vm)
assert(eq(expect, result))
end
end
@@ -83,3 +83,17 @@ end
selectionRange = {16, 16},
}
}
+
+TEST [[
+return function ()
+end
+]]
+{
+ [1] = {
+ name = '',
+ detail = 'function f()',
+ kind = SymbolKind.Function,
+ range = {8, 22},
+ selectionRange = {8, 8},
+ }
+}
diff --git a/server/test/find_lib/init.lua b/server/test/find_lib/init.lua
index 63654b19..e55b33af 100644
--- a/server/test/find_lib/init.lua
+++ b/server/test/find_lib/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -11,10 +11,10 @@ function TEST(fullkey)
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:ast(new_script)
assert(ast)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.findResult(vm, pos)
- local _, name = matcher.findLib(result)
+ local result = core.findResult(vm, pos)
+ local _, name = core.findLib(result)
assert(name == fullkey)
end
end
diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua
index 17913039..01c571d8 100644
--- a/server/test/hover/init.lua
+++ b/server/test/hover/init.lua
@@ -1,5 +1,5 @@
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -10,10 +10,10 @@ function TEST(script)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:ast(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result, source = matcher.findResult(vm, pos)
- local hover = matcher.hover(result, source)
+ local result, source = core.findResult(vm, pos)
+ local hover = core.hover(result, source)
if expect then
assert(hover)
expect = expect:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n')
diff --git a/server/test/main.lua b/server/test/main.lua
index b7161870..cb01ca1f 100644
--- a/server/test/main.lua
+++ b/server/test/main.lua
@@ -23,7 +23,7 @@ local function main()
print(('测试[%s]用时[%.3f]'):format(name, os.clock() - clock))
end
- test 'matcher'
+ test 'core'
test 'vm'
test 'definition'
diff --git a/server/test/signature/init.lua b/server/test/signature/init.lua
index 81e002e6..86b5f05a 100644
--- a/server/test/signature/init.lua
+++ b/server/test/signature/init.lua
@@ -1,5 +1,5 @@
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -8,9 +8,9 @@ function TEST(script)
local pos = script:find('@', 1, true) + 1
local new_script = script:gsub('@', '')
local ast = parser:ast(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local hovers = matcher.signature(vm, pos)
+ local hovers = core.signature(vm, pos)
if hovers then
local hover = hovers[#hovers]
diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua
index 9f5887f1..47e94760 100644
--- a/server/test/type_inference/init.lua
+++ b/server/test/type_inference/init.lua
@@ -1,5 +1,5 @@
local parser = require 'parser'
-local matcher = require 'matcher'
+local core = require 'core'
rawset(_G, 'TEST', true)
@@ -10,9 +10,9 @@ function TEST(res)
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast = parser:ast(new_script)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
- local result = matcher.findResult(vm, pos)
+ local result = core.findResult(vm, pos)
assert(result)
assert(res == result.value.type)
end
diff --git a/server/test/vm/example.lua b/server/test/vm/example.lua
index 39ef4f4b..3b040a32 100644
--- a/server/test/vm/example.lua
+++ b/server/test/vm/example.lua
@@ -1 +1 @@
-TEST(io.load(ROOT / 'src' / 'matcher' / 'vm.lua'))
+TEST(io.load(ROOT / 'src' / 'core' / 'vm.lua'))
diff --git a/server/test/vm/init.lua b/server/test/vm/init.lua
index a95373f1..6e7dc3ac 100644
--- a/server/test/vm/init.lua
+++ b/server/test/vm/init.lua
@@ -1,4 +1,4 @@
-local matcher = require 'matcher'
+local core = require 'core'
local parser = require 'parser'
rawset(_G, 'TEST', true)
@@ -6,7 +6,7 @@ rawset(_G, 'TEST', true)
function TEST(script)
local ast = parser:ast(script)
assert(ast)
- local vm = matcher.vm(ast)
+ local vm = core.vm(ast)
assert(vm)
local results = vm.results
assert(results)