private static async Task ValidateOffset(ILanguageClient client, DocumentUri uri, SyntaxTree tree, int offset, FunctionSymbol?symbol, bool expectDecorator) { var position = PositionHelper.GetPosition(tree.LineStarts, offset); var initial = await RequestSignatureHelp(client, position, uri); if (symbol != null) { // real function should have valid signature help AssertValidSignatureHelp(initial, symbol, expectDecorator); if (initial !.Signatures.Count() >= 2) { // update index to 1 to mock user changing active signature initial.ActiveSignature = 1; var shouldRemember = await RequestSignatureHelp(client, position, uri, new SignatureHelpContext { ActiveSignatureHelp = initial, IsRetrigger = true, TriggerKind = SignatureHelpTriggerKind.ContentChange }); // we passed the same signature help as content with a different active index // should get the same index back AssertValidSignatureHelp(shouldRemember, symbol, expectDecorator); shouldRemember !.ActiveSignature.Should().Be(1); } } else { // not a real function - no signature help expected initial.Should().BeNull(); } }
private static async Task ValidateOffset(ILanguageClient client, DocumentUri uri, BicepFile bicepFile, int offset, FunctionSymbol?symbol, bool expectDecorator) { var position = PositionHelper.GetPosition(bicepFile.LineStarts, offset); var initial = await RequestSignatureHelp(client, position, uri); // fancy method to give us some annotated source code to look at if any assertions fail :) using (new AssertionScope().WithVisualCursor(bicepFile, new TextSpan(offset, 0))) { if (symbol is not null) { // real function should have valid signature help AssertValidSignatureHelp(initial, symbol, expectDecorator); if (initial !.Signatures.Count() >= 2) { // update index to 1 to mock user changing active signature const int ExpectedActiveSignatureIndex = 1; var modified = initial with { ActiveSignature = ExpectedActiveSignatureIndex }; var shouldRemember = await RequestSignatureHelp(client, position, uri, new SignatureHelpContext { ActiveSignatureHelp = modified, IsRetrigger = true, TriggerKind = SignatureHelpTriggerKind.ContentChange }); // we passed the same signature help as content with a different active index // should get the same index back AssertValidSignatureHelp(shouldRemember, symbol, expectDecorator); shouldRemember !.ActiveSignature.Should().Be(ExpectedActiveSignatureIndex); } } else { // not a real function - no signature help expected initial.Should().BeNull(); } } }