示例#1
0
        public async Task <Document> RefactorAsync(
            Document document,
            DocumentationCommentTriviaSyntax comment,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();

            MemberDeclarationSyntax memberDeclaration = comment.FirstAncestor <MemberDeclarationSyntax>();

            SeparatedSyntaxList <TNode> typeParameters = GetSyntaxList(memberDeclaration);

            List <ElementInfo <TNode> > infos = GetElementInfos(comment, typeParameters);

            string newTrivia = GetNewTrivia(comment, infos);

            SyntaxTriviaList triviaList = SyntaxFactory.ParseLeadingTrivia(newTrivia);

            if (triviaList.Any())
            {
                SyntaxTrivia firstTrivia = triviaList.First();

                if (firstTrivia.HasStructure &&
                    (firstTrivia.GetStructure() is DocumentationCommentTriviaSyntax newComment))
                {
                    newComment = newComment.WithFormatterAnnotation();

                    return(await document.ReplaceNodeAsync(comment, newComment, cancellationToken).ConfigureAwait(false));
                }
            }

            Debug.Fail("");

            return(document);
        }