public Comment(string[] textLines, CommentCategory category, CommentPlacement placement, int lineIndexDistanceFromOwner, CommentKind kind, bool isDecorated) { this.TextLines = textLines; this.Category = category; this.Placement = placement; this.LineIndexDistanceFromOwner = lineIndexDistanceFromOwner; this.Kind = kind; this.IsDecorated = isDecorated; }
private void AddCommentToSideOfAstValue(ParseTreeNode owner, Token comment, CommentPlacement commentPlacement, int?lineIndexDistanceFromOwnerExplicit) { // first we calculate the lineIndexDistanceFromOwner, then we find a proper node with a non-null astNode to decorate (it can be in another line) int lineIndexDistanceFromOwner = lineIndexDistanceFromOwnerExplicit ?? Math.Abs(comment.Location.Line - owner.Span.Location.Line); owner = Util.Recurse(owner, GetParent).First(_parseTreeNode => _parseTreeNode.AstNode != null); object astValue = GrammarHelper.AstNodeToValue(owner.AstNode); Comments domainComments = astValue.GetComments(); if (domainComments == null) { domainComments = new Comments(); astValue.SetComments(domainComments); } var commentList = commentPlacement == CommentPlacement.OwnerLeft ? domainComments.left : domainComments.right; commentList.Add(CommentToDomainComment(comment, owner, commentPlacement, lineIndexDistanceFromOwner)); decoratedComments.Add(comment); }
private Comment CommentToDomainComment(Token comment, ParseTreeNode parseTreeNodeOwner, CommentPlacement placement, int lineIndexDistanceFromOwner) { CommentTerminal commentTerminal = (CommentTerminal)comment.Terminal; bool isDecorated; return(new Comment( CommentTextToDomainCommentTextLines(comment, out isDecorated), CommentCategoryToDomainCommentCategory(comment.Category), placement, lineIndexDistanceFromOwner, GrammarHelper.GetCommentKind(commentTerminal, GetCommentCleaner(commentTerminal).NewLine), isDecorated )); }