예제 #1
0
    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()
      };
    }
예제 #2
0
        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()
            });
        }
예제 #3
0
        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());
        }
예제 #4
0
 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)));
 }
예제 #5
0
 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();
 }
예제 #6
0
 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))));
 }