Пример #1
0
        private static LSP.VSCompletionItem ConvertToClientCompletionItem(LSP.CompletionItem serverCompletionItem)
        {
            var serializedItem       = JsonConvert.SerializeObject(serverCompletionItem);
            var clientCompletionItem = JsonConvert.DeserializeObject <LSP.VSCompletionItem>(serializedItem);

            return(clientCompletionItem);
        }
Пример #2
0
                static async Task AddTextEdit(
                    Document document,
                    CompletionItem item,
                    LSP.CompletionItem lspItem,
                    CompletionService completionService,
                    SourceText documentText,
                    TextSpan defaultSpan,
                    bool itemDefaultsSupported,
                    CancellationToken cancellationToken)
                {
                    var completionChange = await completionService.GetChangeAsync(
                        document, item, cancellationToken : cancellationToken).ConfigureAwait(false);

                    var completionChangeSpan = completionChange.TextChange.Span;
                    var newText = completionChange.TextChange.NewText ?? "";

                    if (itemDefaultsSupported && completionChangeSpan == defaultSpan)
                    {
                        // The span is the same as the default, we just need to store the new text as
                        // the insert text so the client can create the text edit from it and the default range.
                        lspItem.InsertText = newText;
                    }
                    else
                    {
                        var textEdit = new LSP.TextEdit()
                        {
                            NewText = newText,
                            Range   = ProtocolConversions.TextSpanToRange(completionChangeSpan, documentText),
                        };
                        lspItem.TextEdit = textEdit;
                    }
                }
Пример #3
0
 private static async Task <object> RunResolveCompletionItemAsync(
     TestLspServer testLspServer,
     LSP.CompletionItem completionItem,
     LSP.ClientCapabilities clientCapabilities = null
     )
 {
     return(await testLspServer.ExecuteRequestAsync <LSP.CompletionItem, LSP.CompletionItem>(
                LSP.Methods.TextDocumentCompletionResolveName,
                completionItem,
                clientCapabilities,
                null,
                CancellationToken.None
                ));
 }
Пример #4
0
 private static async Task <object> RunResolveCompletionItemAsync(Solution solution, LSP.CompletionItem completionItem, LSP.ClientCapabilities clientCapabilities = null)
 => await GetLanguageServer(solution).ExecuteRequestAsync <LSP.CompletionItem, LSP.CompletionItem>(LSP.Methods.TextDocumentCompletionResolveName,
                                                                                                   completionItem, clientCapabilities, null, CancellationToken.None);
Пример #5
0
 /// <summary>
 /// Answers a request to resolve a completion item.
 /// https://microsoft.github.io/language-server-protocol/specification#completionItem_resolve
 /// </summary>
 /// <param name="solution">the solution containing the document.</param>
 /// <param name="request">the completion item to resolve.</param>
 /// <param name="clientCapabilities">the client capabilities for the request.</param>
 /// <param name="cancellationToken">a cancellation token.</param>
 /// <returns>a resolved completion item.</returns>
 public Task <LSP.CompletionItem> ResolveCompletionItemAsync(Solution solution, LSP.CompletionItem request, LSP.ClientCapabilities clientCapabilities, CancellationToken cancellationToken)
 => ExecuteRequestAsync <LSP.CompletionItem, LSP.CompletionItem>(LSP.Methods.TextDocumentCompletionResolveName, solution, request, clientCapabilities, cancellationToken);
Пример #6
0
 private static async Task <LSP.CompletionItem> RunResolveCompletionItemAsync(TestLspServer testLspServer, LSP.CompletionItem completionItem)
 {
     return(await testLspServer.ExecuteRequestAsync <LSP.CompletionItem, LSP.CompletionItem>(LSP.Methods.TextDocumentCompletionResolveName,
                                                                                             completionItem, CancellationToken.None));
 }
Пример #7
0
 private static async Task <LSP.CompletionItem> RunResolveCompletionItemAsync(TestLspServer testLspServer, LSP.CompletionItem completionItem, LSP.ClientCapabilities clientCapabilities = null)
 {
     clientCapabilities ??= new LSP.VSClientCapabilities {
         SupportsVisualStudioExtensions = true
     };
     return(await testLspServer.ExecuteRequestAsync <LSP.CompletionItem, LSP.CompletionItem>(LSP.Methods.TextDocumentCompletionResolveName,
                                                                                             completionItem, clientCapabilities, null, CancellationToken.None));
 }
Пример #8
0
 private static async Task <object> RunResolveCompletionItemAsync(Solution solution, LSP.CompletionItem completionItem, LSP.ClientCapabilities clientCapabilities = null)
 => await GetLanguageServer(solution).ResolveCompletionItemAsync(solution, completionItem, clientCapabilities, CancellationToken.None);
Пример #9
0
 public Task <LSP.CompletionItem> InvokeResolveAsync(LSP.CompletionItem request, CancellationToken cancellationToken)
 => InvokeWithParametersAsync <LSP.CompletionItem>("completionItem/resolve", request, cancellationToken);