Esempio n. 1
0
        internal SyntaxTrivia CreateCommentsTrivia()
        {
            var comments         = new Nodes();
            var textLiteralToken = new LiteralTextToken(lastLeadingTrivia.ToFullString());
            var indentNode       = new TextNode("");

            indentNode.AddToken(textLiteralToken);

            var firstTextToken = new LiteralTextToken(" ");
            var textNode       = new TextNode(docCommentDelimiter);

            textNode.AddToken(firstTextToken);
            comments.AddNode(textNode);
            comments.AddNodesRange(summaryComment.Nodes);

            var lastNewlineToken = new NewlineToken();
            var lastTextNode     = new TextNode(docCommentDelimiter);

            lastTextNode.AddToken(lastNewlineToken);
            comments.AddNode(lastTextNode);

            comments.AddNode(indentNode);
            XmlNodeSyntax[] nodes = comments.CreateXmlNodes();

            return(SyntaxFactory.Trivia(
                       SyntaxFactory.DocumentationCommentTrivia(
                           SyntaxKind.SingleLineDocumentationCommentTrivia,
                           SyntaxFactory.List <XmlNodeSyntax>(nodes))));
        }
        private TextNode GetTextNodeFromCommentTextNode(SyntaxNode textNode)
        {
            TextNode tNode = CreateTextNode();

            foreach (var token in textNode.ChildTokens())
            {
                switch (token.Kind())
                {
                case SyntaxKind.XmlTextLiteralNewLineToken:
                    tNode.AddToken(new NewlineToken());
                    break;

                case SyntaxKind.XmlTextLiteralToken:
                    var text             = token.ValueText.ToString();
                    var textLiteralToken = new LiteralTextToken(text);
                    tNode.AddToken(textLiteralToken);
                    break;

                default:
                    break;
                }
            }
            return(tNode);
        }