summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/service.lua1
-rw-r--r--server/test/crossfile/definition.lua57
2 files changed, 44 insertions, 14 deletions
diff --git a/server/src/service.lua b/server/src/service.lua
index f15c351e..84be9832 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -164,6 +164,7 @@ function mt:readText(uri, path, buf)
self._file[uri] = {
version = -1,
text = text,
+ uri = uri,
}
self:needCompile(uri)
end
diff --git a/server/test/crossfile/definition.lua b/server/test/crossfile/definition.lua
index a0df15a4..3fdd1854 100644
--- a/server/test/crossfile/definition.lua
+++ b/server/test/crossfile/definition.lua
@@ -22,26 +22,40 @@ local function catch_target(script, sep)
return new_script, list
end
-function TEST(data)
+function TEST(datas)
local lsp = service()
local ws = workspace(lsp, 'test')
lsp.workspace = ws
- local targetScript, targetList = catch_target(data[1].content, '!')
- local targetUri = ws:uriEncode(fs.path(data[1].path))
- if data[1].target then
- targetList = data[1].target
- else
- targetList = targetList[1]
- end
+ local compiled = {}
+ local targetList, targetUri, sourceList, sourceUri
- local sourceScript, sourceList = catch_target(data[2].content, '?')
- local sourceUri = ws:uriEncode(fs.path(data[2].path))
+ for i, data in ipairs(datas) do
+ local uri = ws:uriEncode(fs.path(data.path))
+ local new, list = catch_target(data.content, '!')
+ if new ~= data.content or data.target then
+ if data.target then
+ targetList = data.target
+ else
+ targetList = list[1]
+ end
+ targetUri = uri
+ lsp:saveText(uri, 1, new)
+ goto CONTINUE
+ end
+ new, list = catch_target(data.content, '?')
+ if new ~= data.content then
+ compiled[i] = new
+ sourceList = list
+ sourceUri = uri
+ lsp:saveText(uri, 1, new)
+ goto CONTINUE
+ end
+ lsp:saveText(uri, 1, data.content)
+ ::CONTINUE::
+ ws:addFile(uri)
+ end
- lsp:saveText(sourceUri, 1, sourceScript)
- ws:addFile(sourceUri)
- lsp:saveText(targetUri, 1, targetScript)
- ws:addFile(targetUri)
while lsp._needCompile[1] do
lsp:compileVM(lsp._needCompile[1])
end
@@ -168,3 +182,18 @@ TEST {
]]
}
}
+
+--TEST {
+-- {
+-- path = 'a.lua',
+-- content = [[
+-- <!global!> = 1
+-- ]],
+-- },
+-- {
+-- path = 'b.lua',
+-- content = [[
+-- print(<?global?>)
+-- ]],
+-- }
+--}