summaryrefslogtreecommitdiff
path: root/server-beta/test/crossfile
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-10-22 15:40:02 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-10-22 15:40:02 +0800
commit4b3d9412560935d11e63487d6be7d3bfb8b11b91 (patch)
tree408ffe09d74bd48912f5ede6b5cb8837d37f7ea5 /server-beta/test/crossfile
parent917d721acdf86ff69728fae89662019c519ea561 (diff)
downloadlua-language-server-4b3d9412560935d11e63487d6be7d3bfb8b11b91.zip
打开跨文件def测试
Diffstat (limited to 'server-beta/test/crossfile')
-rw-r--r--server-beta/test/crossfile/definition.lua37
-rw-r--r--server-beta/test/crossfile/init.lua2
2 files changed, 14 insertions, 25 deletions
diff --git a/server-beta/test/crossfile/definition.lua b/server-beta/test/crossfile/definition.lua
index c765d98a..630539d2 100644
--- a/server-beta/test/crossfile/definition.lua
+++ b/server-beta/test/crossfile/definition.lua
@@ -1,8 +1,6 @@
-local service = require 'service'
-local workspace = require 'workspace'
-local fs = require 'bee.filesystem'
-local core = require 'core'
-local uric = require 'uri'
+local files = require 'files'
+local furi = require 'file-uri'
+local core = require 'core.definition'
rawset(_G, 'TEST', true)
@@ -43,30 +41,27 @@ local function founded(targets, results)
end
function TEST(datas)
- local lsp = service()
- local ws = workspace(lsp, 'test')
- lsp.workspace = ws
+ files.removeAll()
- local compiled = {}
local targetList = {}
- local sourceList, sourceUri
-
+ local sourceList
+ local sourceUri
for i, data in ipairs(datas) do
- local uri = uric.encode(fs.path(data.path))
+ local uri = furi.encode(data.path)
local new, list = catch_target(data.content, '!')
if new ~= data.content or data.target then
if data.target then
targetList[#targetList+1] = {
data.target[1],
data.target[2],
- uri
+ uri,
}
else
for _, position in ipairs(list) do
targetList[#targetList+1] = {
position[1],
position[2],
- uri
+ uri,
}
end
end
@@ -74,23 +69,17 @@ function TEST(datas)
end
new, list = catch_target(data.content, '?')
if new ~= data.content then
- compiled[i] = new
sourceList = list
sourceUri = uri
data.content = new
end
- lsp:saveText(uri, 1, data.content)
- ws:addFile(uric.decode(uri))
- end
-
- while lsp._needCompile[1] do
- lsp:compileVM(lsp._needCompile[1])
+ files.setText(uri, data.content)
end
- local sourceVM = lsp:getVM(sourceUri)
- assert(sourceVM)
+ local sourceAst = files.getAst(sourceUri)
+ assert(sourceAst)
local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2
- local positions = core.definition(sourceVM, sourcePos, 'definition')
+ local positions = core(sourceAst, sourcePos)
if positions then
assert(founded(targetList, positions))
else
diff --git a/server-beta/test/crossfile/init.lua b/server-beta/test/crossfile/init.lua
index b7a52a4d..836d201c 100644
--- a/server-beta/test/crossfile/init.lua
+++ b/server-beta/test/crossfile/init.lua
@@ -1,4 +1,4 @@
---require 'crossfile.definition'
+require 'crossfile.definition'
--require 'crossfile.hover'
--require 'crossfile.completion'
--require 'crossfile.document_symbol'