protected override async Task <CompletionDescription> GetDescriptionWorkerAsync(Document document, CompletionItem item, CancellationToken cancellationToken) { var lspClient = _roslynLspClientServiceFactory.ActiveLanguageServerClient; if (lspClient == null) { return(await base.GetDescriptionWorkerAsync(document, item, cancellationToken).ConfigureAwait(false)); } if (!item.Properties.TryGetValue("ResolveData", out var serializedItem)) { return(await base.GetDescriptionWorkerAsync(document, item, cancellationToken).ConfigureAwait(false)); } var completionItem = JToken.Parse(serializedItem).ToObject <RoslynCompletionItem>(); var request = new LSP.LspRequest <RoslynCompletionItem, RoslynCompletionItem>(LSP.Methods.TextDocumentCompletionResolveName); var resolvedCompletionItem = await lspClient.RequestAsync(request, completionItem, cancellationToken).ConfigureAwait(false); if (resolvedCompletionItem?.Description == null) { return(await base.GetDescriptionWorkerAsync(document, item, cancellationToken).ConfigureAwait(false)); } var parts = resolvedCompletionItem.Description.Select(tt => tt.ToTaggedText()).AsImmutable(); return(CompletionDescription.Create(parts)); }
public async Task <ImmutableArray <Diagnostic> > GetDiagnosticsAsync(Document document, CancellationToken cancellationToken) { var lspClient = _roslynLspClientServiceFactory.ActiveLanguageServerClient; if (lspClient == null) { return(ImmutableArray <Diagnostic> .Empty); } var textDocumentParams = new TextDocumentParams { TextDocument = new LSP.TextDocumentIdentifier { Uri = lspClient.ProtocolConverter.ToProtocolUri(new Uri(document.FilePath)) } }; var request = new LSP.LspRequest <TextDocumentParams, RoslynDiagnostic[]>(Methods.GetDocumentDiagnosticsName); var lspDiagnostics = await lspClient.RequestAsync(request, textDocumentParams, cancellationToken).ConfigureAwait(false); if (lspDiagnostics == null) { return(ImmutableArray <Diagnostic> .Empty); } var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); var diagnostics = ImmutableArray.CreateBuilder <Diagnostic>(); foreach (var diagnostic in lspDiagnostics) { var location = Location.Create(document.FilePath, ProtocolConversions.RangeToTextSpan(diagnostic.Range, text), ProtocolConversions.RangeToLinePositionSpan(diagnostic.Range)); var severity = ToDiagnosticSeverity(diagnostic.Severity); var diag = Diagnostic.Create(diagnostic.Code ?? "VSLS", string.Empty, diagnostic.Message, severity, severity, true, severity == DiagnosticSeverity.Error ? 0 : 1, location: location, customTags: diagnostic.Tags); diagnostics.Add(diag); } return(diagnostics.ToImmutableArray()); }
public static LS.LspRequest <TIn, TOut> ToLSRequest <TIn, TOut>(this LSP.LspRequest <TIn, TOut> lspRequest) => new LS.LspRequest <TIn, TOut>(lspRequest.Name);
public static LS.LspRequest <TIn, TOut> ToLSRequest <TIn, TOut>(this LSP.LspRequest <TIn, TOut> lspRequest) { return(new LS.LspRequest <TIn, TOut>(lspRequest.Name)); }