public FormatLinesResult FormatLines(ExtendSpanResult span) { var indent = GetCommentBlockIndent(span); if (indent < 0) throw new ArgumentException("Line range does not contains a block comment."); var commentText = GetCommentBlockText(span); return new FormatLinesResult { CommentType = span.CommentType, SnapshotSpan = new SnapshotSpan(span.StartLine.Snapshot, new Span(span.StartLine.Start, span.EndLine.End - span.StartLine.Start)), Indent = indent, Lines = FormatCommentText(commentText, _maxColumn - span.CommentType.TextPrefix.Length - indent).ToList() }; }
public FormatLinesResult FormatLines(ExtendSpanResult span) { var indent = GetCommentBlockIndent(span); if (indent < 0) { throw new ArgumentException("Line range does not contains a block comment."); } var commentText = GetCommentBlockText(span); return(new FormatLinesResult { CommentType = span.CommentType, SnapshotSpan = new SnapshotSpan(span.StartLine.Snapshot, new Span(span.StartLine.Start, span.EndLine.End - span.StartLine.Start)), Indent = indent, Lines = FormatCommentText(commentText, _maxColumn - span.CommentType.TextPrefix.Length - indent).ToList() }); }
private string GetCommentBlockText(ExtendSpanResult span) { var sb = new StringBuilder(); for (var i = span.StartLine.LineNumber; i <= span.EndLine.LineNumber; i++) { var commentText = GetCommentText(span.CommentType, span.StartLine.Snapshot.GetLineFromLineNumber(i)); if (commentText.Length > 0) { if (sb.Length > 0) { sb.Append(' '); } sb.Append(commentText); } } return(sb.ToString()); }
private int GetCommentBlockIndent(ExtendSpanResult span) { return Enumerable .Range(span.StartLine.LineNumber, span.EndLine.LineNumber - span.StartLine.LineNumber + 1) .Min(n => GetCommentIndent(span.CommentType, span.StartLine.Snapshot.GetLineFromLineNumber(n))); }
private string GetCommentBlockText(ExtendSpanResult span) { var sb = new StringBuilder(); for (var i = span.StartLine.LineNumber; i <= span.EndLine.LineNumber; i++) { var commentText = GetCommentText(span.CommentType, span.StartLine.Snapshot.GetLineFromLineNumber(i)); if (commentText.Length > 0) { if (sb.Length > 0) sb.Append(' '); sb.Append(commentText); } } return sb.ToString(); }
private int GetCommentBlockIndent(ExtendSpanResult span) { return(Enumerable .Range(span.StartLine.LineNumber, span.EndLine.LineNumber - span.StartLine.LineNumber + 1) .Min(n => GetCommentIndent(span.CommentType, span.StartLine.Snapshot.GetLineFromLineNumber(n)))); }