summaryrefslogtreecommitdiff
path: root/server-beta
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta')
-rw-r--r--server-beta/src/pub/pub.lua2
-rw-r--r--server-beta/src/workspace/workspace.lua17
-rw-r--r--server-beta/test.lua6
-rw-r--r--server-beta/test/crossfile/init.lua10
-rw-r--r--server-beta/test/full/example.lua11
-rw-r--r--server-beta/test/full/init.lua7
6 files changed, 24 insertions, 29 deletions
diff --git a/server-beta/src/pub/pub.lua b/server-beta/src/pub/pub.lua
index cf1eb955..f6db6d4f 100644
--- a/server-beta/src/pub/pub.lua
+++ b/server-beta/src/pub/pub.lua
@@ -132,7 +132,7 @@ function m.task(name, params)
end
--- 发布同步任务,如果任务进入了队列,会返回执行器
----|通过 jumpQueue 可以插队
+--- 通过 jumpQueue 可以插队
---@parma name string
---@param params any
---@param callback function
diff --git a/server-beta/src/workspace/workspace.lua b/server-beta/src/workspace/workspace.lua
index efe2f1cf..70334134 100644
--- a/server-beta/src/workspace/workspace.lua
+++ b/server-beta/src/workspace/workspace.lua
@@ -86,6 +86,8 @@ function m.preload()
if not m.uri then
return
end
+ local max = 0
+ local read = 0
log.info('Preload start.')
local ignore = m.getIgnoreMatcher()
@@ -111,22 +113,21 @@ function m.preload()
if not files.isLua(uri) then
return
end
+ max = max + 1
pub.syncTask('loadFile', uri, function (text)
+ read = read + 1
log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #text / 1000.0))
files.setText(uri, text)
end)
end)
+ log.info(('Found %d files.'):format(max))
while true do
- local count = 0
- for _, file in pairs(files.fileMap) do
- if file.compiling then
- task.sleep(0.1)
- goto CONTINUE
- end
- count = count + 1
+ log.info(('Loaded %d/%d files'):format(read, max))
+ if read < max then
+ task.sleep(0.1)
+ goto CONTINUE
end
- log.info(('Preloaded %d files.'):format(count))
break
::CONTINUE::
end
diff --git a/server-beta/test.lua b/server-beta/test.lua
index cf871599..32f9dc57 100644
--- a/server-beta/test.lua
+++ b/server-beta/test.lua
@@ -47,9 +47,9 @@ local function main()
--test 'completion'
--test 'signature'
--test 'document_symbol'
- --test 'crossfile'
- --test 'full'
- --test 'other'
+ test 'crossfile'
+ test 'full'
+ test 'other'
print('测试完成')
end
diff --git a/server-beta/test/crossfile/init.lua b/server-beta/test/crossfile/init.lua
index 96462fa5..b7a52a4d 100644
--- a/server-beta/test/crossfile/init.lua
+++ b/server-beta/test/crossfile/init.lua
@@ -1,5 +1,5 @@
-require 'crossfile.definition'
-require 'crossfile.hover'
-require 'crossfile.completion'
-require 'crossfile.document_symbol'
-require 'crossfile.references'
+--require 'crossfile.definition'
+--require 'crossfile.hover'
+--require 'crossfile.completion'
+--require 'crossfile.document_symbol'
+--require 'crossfile.references'
diff --git a/server-beta/test/full/example.lua b/server-beta/test/full/example.lua
index a096f83d..670bfe64 100644
--- a/server-beta/test/full/example.lua
+++ b/server-beta/test/full/example.lua
@@ -1,12 +1,9 @@
-local fs = require 'bee.filesystem'
-local core = require 'core'
+local util = require 'utility'
local parser = require 'parser'
-TEST(io.load(ROOT / 'src' / 'vm' / 'vm.lua'))
-
-- 临时
local function testIfExit(path)
- local buf = io.load(fs.path(path))
+ local buf = util.loadFile(path:string())
if buf then
local vm
@@ -26,9 +23,9 @@ local function testIfExit(path)
local clock = os.clock()
local max = 100
local need
- local lines = parser:lines(buf, 'utf8')
+ local lines = parser:lines(buf)
for i = 1, max do
- core.diagnostics(vm, lines, 'test')
+ --core.diagnostics(vm, lines, 'test')
local passed = os.clock() - clock
if passed >= 1.0 or i == max then
need = passed / i
diff --git a/server-beta/test/full/init.lua b/server-beta/test/full/init.lua
index 3d0661cb..f370671e 100644
--- a/server-beta/test/full/init.lua
+++ b/server-beta/test/full/init.lua
@@ -1,14 +1,11 @@
-local buildVM = require 'vm'
local parser = require 'parser'
rawset(_G, 'TEST', true)
function TEST(script)
- local ast = parser:parse(script, 'lua', 'Lua 5.3')
+ local ast = parser:compile(script, 'lua', 'Lua 5.3')
assert(ast)
- local vm, err = buildVM(ast)
- assert(vm, err)
- return vm
+ return ast
end
require 'full.normal'