Пример #1
0
        public async Task TestResolveOverridesCompletionItem_SnippetsEnabled_CaretOutOfSnippetScopeAsync()
        {
            var markup =
                @"abstract class A
{
    public abstract void M();
}

class B : A
{
    override {|caret:|}
}";

            using var testLspServer = await CreateTestLspServerAsync(markup);

            var document = testLspServer.GetCurrentSolution().Projects.First().Documents.First();

            var selectedItem = CodeAnalysis.Completion.CompletionItem.Create(displayText: "M");
            var textEdit     = await CompletionResolveHandler.GenerateTextEditAsync(
                document, new TestCaretOutOfScopeCompletionService(testLspServer.TestWorkspace.Services), selectedItem, snippetsSupported : true, CancellationToken.None).ConfigureAwait(false);

            Assert.Equal(@"public override void M()
    {
        throw new System.NotImplementedException();
    }", textEdit.NewText);
        }
        public async Task TestResolveOverridesCompletionItem_SnippetsEnabled_CaretOutOfSnippetScopeAsync()
        {
            var markup =
                @"abstract class A
{
    public abstract void M();
}

class B : A
{
    override {|caret:|}
}";

            using var testLspServer = CreateTestLspServer(markup, out var locations);
            var tags             = new string[] { "Method", "Public" };
            var completionParams = CreateCompletionParams(
                locations["caret"].Single(), LSP.VSCompletionInvokeKind.Explicit, "\0", LSP.CompletionTriggerKind.Invoked);
            var document = testLspServer.GetCurrentSolution().Projects.First().Documents.First();

            var selectedItem = CodeAnalysis.Completion.CompletionItem.Create(displayText: "M");
            var textEdit     = await CompletionResolveHandler.GenerateTextEditAsync(
                document, new TestCaretOutOfScopeCompletionService(), selectedItem, snippetsSupported : true, CancellationToken.None).ConfigureAwait(false);

            Assert.Equal(@"public override void M()
    {
        throw new System.NotImplementedException();
    }", textEdit.NewText);
        }