private SyntaxTrivia FormatDocumentComment(LineColumn lineColumn, SyntaxTrivia trivia) { var indentation = lineColumn.Column; if (trivia.IsSingleLineDocComment()) { var text = trivia.ToFullString(); // When the doc comment is parsed from source, even if it is only one // line long, the end-of-line will get included into the trivia text. // If the doc comment was parsed from a text fragment, there may not be // an end-of-line at all. We need to trim the end before we check the // number of line breaks in the text. var textWithoutFinalNewLine = text.TrimEnd(null); if (!textWithoutFinalNewLine.ContainsLineBreak()) { return(trivia); } var singleLineDocumentationCommentExteriorCommentRewriter = new DocumentationCommentExteriorCommentRewriter( true /* forceIndentation */ , indentation, 0 /* indentationDelta */ , this.Options ); var newTrivia = singleLineDocumentationCommentExteriorCommentRewriter.VisitTrivia( trivia ); return(newTrivia); } var indentationDelta = indentation - GetExistingIndentation(trivia); if (indentationDelta == 0) { return(trivia); } var multiLineDocumentationCommentExteriorCommentRewriter = new DocumentationCommentExteriorCommentRewriter( false /* forceIndentation */ , indentation, indentationDelta, this.Options ); var newMultiLineTrivia = multiLineDocumentationCommentExteriorCommentRewriter.VisitTrivia(trivia); return(newMultiLineTrivia); }
private SyntaxTrivia FormatDocumentComment(LineColumn lineColumn, SyntaxTrivia trivia) { var indentation = lineColumn.Column; if (trivia.IsSingleLineDocComment()) { var text = trivia.ToFullString(); // When the doc comment is parsed from source, even if it is only one // line long, the end-of-line will get included into the trivia text. // If the doc comment was parsed from a text fragment, there may not be // an end-of-line at all. We need to trim the end before we check the // number of line breaks in the text. var textWithoutFinalNewLine = text.TrimEnd(null); if (!textWithoutFinalNewLine.ContainsLineBreak()) { return trivia; } var singleLineDocumentationCommentExteriorCommentRewriter = new DocumentationCommentExteriorCommentRewriter( true /* forceIndentation */, indentation, 0 /* indentationDelta */, this.OptionSet); var newTrivia = singleLineDocumentationCommentExteriorCommentRewriter.VisitTrivia(trivia); return newTrivia; } var indentationDelta = indentation - GetExistingIndentation(trivia); if (indentationDelta == 0) { return trivia; } var multiLineDocumentationCommentExteriorCommentRewriter = new DocumentationCommentExteriorCommentRewriter( false /* forceIndentation */, indentation, indentationDelta, this.OptionSet); var newMultiLineTrivia = multiLineDocumentationCommentExteriorCommentRewriter.VisitTrivia(trivia); return newMultiLineTrivia; }