From f41b764aa1b6ff6708da9ce84468839635e6720c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 23 Jan 2019 14:30:31 +0800 Subject: =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service.lua | 1 + server/test/crossfile/definition.lua | 57 +++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 14 deletions(-) (limited to 'server') 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 = [[ +-- = 1 +-- ]], +-- }, +-- { +-- path = 'b.lua', +-- content = [[ +-- print() +-- ]], +-- } +--} -- cgit v1.2.3