feat(adminui): scope + dot-member script completions
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.ScriptAnalysis;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis;
|
||||
|
||||
public sealed class CompletionTests
|
||||
{
|
||||
private static readonly ScriptAnalysisService Svc = new();
|
||||
private static async Task<IReadOnlyList<CompletionItem>> Complete(string code, int line, int col)
|
||||
=> (await Svc.CompleteAsync(new CompletionsRequest(code, line, col))).Items;
|
||||
|
||||
[Fact] public async Task Dot_after_ctx_offers_context_members()
|
||||
{
|
||||
// caret immediately after "ctx." — column is 1-based; "ctx." is 4 chars so col 5 is just past the dot.
|
||||
var labels = (await Complete("ctx.", 1, 5)).Select(i => i.Label).ToList();
|
||||
labels.ShouldContain("GetTag");
|
||||
labels.ShouldContain("SetVirtualTag");
|
||||
labels.ShouldContain("Now");
|
||||
labels.ShouldContain("Logger");
|
||||
}
|
||||
|
||||
[Fact] public async Task Scope_completion_includes_the_ctx_local()
|
||||
{
|
||||
// a partial identifier on its own line; scope completion should surface the `ctx` local.
|
||||
var labels = (await Complete("var x = c", 1, 10)).Select(i => i.Label).ToList();
|
||||
labels.ShouldContain("ctx");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user