Пример #1
0
 private CommentRemover(SyntaxNode node, CommentRemoveOptions removeOptions, TextSpan span)
     : base(visitIntoStructuredTrivia: true)
 {
     Node          = node;
     RemoveOptions = removeOptions;
     Span          = span;
 }
Пример #2
0
        public static CommentRemover Create(SyntaxNode node, CommentRemoveOptions removeOptions, TextSpan span)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            return(new CommentRemover(node, removeOptions, span));
        }
Пример #3
0
        public static TNode RemoveComments <TNode>(TNode node, CommentRemoveOptions removeOptions, TextSpan?span = null) where TNode : SyntaxNode
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            var remover = new CommentRemover(node, removeOptions, span ?? node.FullSpan);

            return((TNode)remover.Visit(node));
        }
Пример #4
0
        private static async Task <Document> RemoveCommentAsync(
            Document document,
            CommentRemoveOptions removeOptions,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            SyntaxNode newRoot = SyntaxRemover.RemoveComment(root, removeOptions)
                                 .WithFormatterAnnotation();

            return(document.WithSyntaxRoot(newRoot));
        }
Пример #5
0
        public static async Task <Document> RemoveCommentsAsync(
            Document document,
            CommentRemoveOptions removeOptions,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            SyntaxNode newRoot = RemoveComments(root, removeOptions)
                                 .WithFormatterAnnotation();

            return(document.WithSyntaxRoot(newRoot));
        }
Пример #6
0
 public static TNode RemoveComments <TNode>(TNode node, CommentRemoveOptions removeOptions, TextSpan span) where TNode : SyntaxNode
 {
     return(CommentRemover.RemoveComments(node, removeOptions, span));
 }
Пример #7
0
 private CommentRemover(SyntaxNode node, CommentRemoveOptions removeOptions)
     : this(node, removeOptions, node.FullSpan)
 {
 }
Пример #8
0
        public static TNode RemoveComment <TNode>(TNode node, CommentRemoveOptions removeOptions, TextSpan span) where TNode : SyntaxNode
        {
            CommentRemover remover = CommentRemover.Create(node, removeOptions, span);

            return((TNode)remover.Visit(node));
        }