|
| 1 | +local lclient = require 'lclient' |
| 2 | +local util = require 'utility' |
| 3 | +local ws = require 'workspace' |
| 4 | +local files = require 'files' |
| 5 | +local furi = require 'file-uri' |
| 6 | +local fs = require 'bee.filesystem' |
| 7 | +local await = require 'await' |
| 8 | + |
| 9 | +---@async |
| 10 | +lclient():start(function (client) |
| 11 | + client:registerFakers() |
| 12 | + |
| 13 | + client:register('workspace/configuration', function () |
| 14 | + return { |
| 15 | + { |
| 16 | + ['workspace.library'] = { '${3rd}/Jass/library' } |
| 17 | + }, |
| 18 | + } |
| 19 | + end) |
| 20 | + |
| 21 | + client:initialize() |
| 22 | + |
| 23 | + ws.awaitReady() |
| 24 | + |
| 25 | + local text = [[ |
| 26 | +local jass = require 'jass.common' |
| 27 | +
|
| 28 | +]] |
| 29 | + |
| 30 | + local clock = os.clock() |
| 31 | + |
| 32 | + client:awaitRequest('textDocument/didOpen', { |
| 33 | + textDocument = { |
| 34 | + uri = furi.encode('abc/performance-1.lua'), |
| 35 | + languageId = 'lua', |
| 36 | + version = 0, |
| 37 | + text = text, |
| 38 | + } |
| 39 | + }) |
| 40 | + |
| 41 | + await.sleep(1.0) |
| 42 | + |
| 43 | + for c in ('jass'):gmatch '.' do |
| 44 | + text = text .. c |
| 45 | + client:awaitRequest('textDocument/didChange', { |
| 46 | + textDocument = { |
| 47 | + uri = furi.encode('abc/performance-1.lua'), |
| 48 | + }, |
| 49 | + contentChanges = { |
| 50 | + { |
| 51 | + text = text, |
| 52 | + } |
| 53 | + } |
| 54 | + }) |
| 55 | + await.sleep(1.0) |
| 56 | + end |
| 57 | + |
| 58 | + local items = client:awaitRequest('textDocument/completion', { |
| 59 | + textDocument = { uri = furi.encode('abc/performance-1.lua') }, |
| 60 | + position = { line = 2, character = 4 }, |
| 61 | + }) |
| 62 | + local item = client:awaitRequest('completionItem/resolve', items.items[1]) |
| 63 | + |
| 64 | + assert(item.documentation ~= nil) |
| 65 | + |
| 66 | + print(('Benchmark [performance-1] takes [%.3f] sec.'):format(os.clock() - clock)) |
| 67 | +end) |
0 commit comments