From 992f004bf31e8902744d86dee595305907144ff1 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 09:43:55 +0330 Subject: lsp: complete a module path one level at a time (std. lists groups, std.File. and std.Io. their members) --- tests/drivers/completion_test.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/drivers/completion_test.js') diff --git a/tests/drivers/completion_test.js b/tests/drivers/completion_test.js index f1ee5e6..4b767a1 100644 --- a/tests/drivers/completion_test.js +++ b/tests/drivers/completion_test.js @@ -104,4 +104,15 @@ assert.match(get(r.items, 'map').documentation.value, /transform.*each element/) assert.ok(!r.items.some(c => ['push', 'pop', 'resize'].includes(c.label)), 'library algorithms do not make a fixed array growable'); r = complete('include rt; fn main() { int[?] items = {}; items.| }'); assert.ok(!r.items.some(c => ['map', 'filter'].includes(c.label)), 'library methods require an explicit import'); -console.log('ok completion: signatures, docs, fuzzy ranking, scope, array members, shadowing and consumed lifetimes'); +r = complete('include std; fn main() { std.| }'); +for (const name of ['File', 'Io', 'Text', 'Host', 'argv', 'bnew']) get(r.items, name); +assert.ok(!r.items.some(c => c.label.includes('.')), 'module completion lists one level: ' + r.items.filter(c => c.label.includes('.')).map(c => c.label)); +r = complete('include std; fn main() { std.File.| }'); +for (const name of ['read', 'write']) get(r.items, name); +assert.ok(!r.items.some(c => ['Io', 'File', 'main', 'int'].includes(c.label)), 'group completion lists only its members'); +r = complete('include std; fn main() { std.Io.| }'); +for (const name of ['print', 'println', 'put_n', 'put_f', 'getline']) get(r.items, name); +assert.ok(!r.items.some(c => ['write', 'itoa', 'main', 'int'].includes(c.label)), 'std.Io. lists only Io members'); +r = complete('include std; fn main() { std.Io.pr| }'); +assert.deepStrictEqual(r.items.map(c => c.label).sort(), ['print', 'println']); +console.log('ok completion: signatures, docs, fuzzy ranking, scope, array members, shadowing, consumed lifetimes and one level of a module path'); -- cgit v1.2.3