public virtual InsertedUtokens GetUtokensBetweenCommentAndOwner(UnparsableAst owner, Comment comment, int commentIndex, int commentCount, IEnumerable <Comment> commentsBetweenThisAndOwner) { if (comment.LineIndexDistanceFromOwner > 0) { int newLinesCount; if (comment.Placement == CommentPlacement.OwnerLeft) { newLinesCount = comment.LineIndexDistanceFromOwner - (comment.TextLines.Length - 1); Comment nextComment = commentsBetweenThisAndOwner.FirstOrDefault(); if (nextComment != null) { newLinesCount -= nextComment.LineIndexDistanceFromOwner; } } else { newLinesCount = comment.LineIndexDistanceFromOwner; Comment prevComment = commentsBetweenThisAndOwner.FirstOrDefault(); if (prevComment != null) { newLinesCount -= prevComment.LineIndexDistanceFromOwner + (prevComment.TextLines.Length - 1); } } if (comment.Placement == CommentPlacement.OwnerLeft && comment.Kind == CommentKind.SingleLine) { /* * We have already yielded a NewLine in Unparser.UnparseComment (see comment there), * thus we have to yield one less "formatting" NewLine here. * */ newLinesCount--; } return(new UtokenRepeat(UtokenWhitespace.NewLine(), newLinesCount)); } else { return(UtokenWhitespace.Space()); } }
public static UtokenInsert Space() { return(UtokenWhitespace.Space()); }