private async Task <(ExcerptResult, SourceText)> ExcerptAsync(SourceText sourceText, DocumentSpan documentSpan) { var excerptService = documentSpan.Document.Services.GetService <IDocumentExcerptService>(); if (excerptService != null) { var result = await excerptService.TryExcerptAsync(documentSpan.Document, documentSpan.SourceSpan, ExcerptMode.SingleLine, CancellationToken).ConfigureAwait(false); if (result != null) { return(result.Value, AbstractDocumentSpanEntry.GetLineContainingPosition(result.Value.Content, result.Value.MappedSpan.Start)); } } var classificationResult = await ClassifiedSpansAndHighlightSpanFactory.ClassifyAsync(documentSpan, CancellationToken).ConfigureAwait(false); // need to fix the span issue tracking here - https://github.com/dotnet/roslyn/issues/31001 var excerptResult = new ExcerptResult( sourceText, classificationResult.HighlightSpan, classificationResult.ClassifiedSpans, documentSpan.Document, documentSpan.SourceSpan); return(excerptResult, AbstractDocumentSpanEntry.GetLineContainingPosition(sourceText, documentSpan.SourceSpan.Start)); }
private async Task <Entry?> TryCreateEntryAsync( RoslynDefinitionBucket definitionBucket, DefinitionItem definition ) { var documentSpan = definition.SourceSpans[0]; var(guid, projectName, _) = GetGuidAndProjectInfo(documentSpan.Document); var sourceText = await documentSpan.Document .GetTextAsync(CancellationToken) .ConfigureAwait(false); var lineText = AbstractDocumentSpanEntry.GetLineContainingPosition( sourceText, documentSpan.SourceSpan.Start ); var mappedDocumentSpan = await AbstractDocumentSpanEntry .TryMapAndGetFirstAsync(documentSpan, sourceText, CancellationToken) .ConfigureAwait(false); if (mappedDocumentSpan == null) { // this will be removed from the result return(null); } return(new DefinitionItemEntry( this, definitionBucket, projectName, guid, lineText, mappedDocumentSpan.Value )); }