|
| 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 clock = os.clock() |
| 26 | + |
| 27 | + for i = 1, 10 do |
| 28 | + local text = [[ |
| 29 | +local jass = require 'jass.common' |
| 30 | +
|
| 31 | +]] |
| 32 | + |
| 33 | + client:awaitRequest('textDocument/didOpen', { |
| 34 | + textDocument = { |
| 35 | + uri = furi.encode('abc/1.lua'), |
| 36 | + languageId = 'lua', |
| 37 | + version = i, |
| 38 | + text = text, |
| 39 | + } |
| 40 | + }) |
| 41 | + |
| 42 | + for c in ('jass'):gmatch '.' do |
| 43 | + text = text .. c |
| 44 | + client:awaitRequest('textDocument/didChange', { |
| 45 | + textDocument = { |
| 46 | + uri = furi.encode('abc/1.lua'), |
| 47 | + }, |
| 48 | + contentChanges = { |
| 49 | + { |
| 50 | + text = text, |
| 51 | + } |
| 52 | + } |
| 53 | + }) |
| 54 | + end |
| 55 | + |
| 56 | + local results = client:awaitRequest('textDocument/definition', { |
| 57 | + textDocument = { uri = furi.encode('abc/1.lua') }, |
| 58 | + position = { line = 2, character = 4 }, |
| 59 | + }) |
| 60 | + |
| 61 | + assert(results[1] ~= nil) |
| 62 | + |
| 63 | + client:awaitRequest('textDocument/didClose', { |
| 64 | + textDocument = { uri = furi.encode('abc/1.lua') }, |
| 65 | + }) |
| 66 | + end |
| 67 | + |
| 68 | + print(('Benchmark [performance-jass-common] takes [%.3f] sec.'):format(os.clock() - clock)) |
| 69 | +end) |
0 commit comments