private static async Task <Document> RefactorAsync( Document document, SyntaxTrivia trivia, string exceptionName, CancellationToken cancellationToken) { SourceText sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); int lineIndex = trivia.GetSpanStartLine(cancellationToken); string newText = new string(' ', trivia.FullSpan.Start - sourceText.Lines[lineIndex].Start) + $"/// <exception cref=\"{exceptionName}\"></exception>" + Environment.NewLine; SourceText newSourceText = sourceText.WithChanges( new TextChange(new TextSpan(trivia.FullSpan.End, 0), newText)); return(document.WithText(newSourceText)); }
private static string GetIndent(SyntaxTrivia trivia, SourceText sourceText, CancellationToken cancellationToken) { int lineIndex = trivia.GetSpanStartLine(cancellationToken); return(new string(' ', trivia.FullSpan.Start - sourceText.Lines[lineIndex].Start)); }