Exemplo n.º 1
0
        public SyntaxListBuilder AddRange <TNode>(SyntaxList <TNode> list, int offset, int length) where TNode : SyntaxNode
        {
            EnsureAdditionalCapacity(length - offset);
            var oldCount = this._count;

            for (var i = offset; i < offset + length; i++)
            {
                AddUnsafe(list.ItemUntyped(i));
            }

            this.Validate(oldCount, this._count);
            return(this);
        }
Exemplo n.º 2
0
        public static bool ContainsWhitespaceTrivia(this SyntaxNode node)
        {
            if (node == null)
            {
                return(false);
            }

            var trivia = new SyntaxList <SyntaxNode>(node);

            for (var i = 0; i < trivia.Count; i++)
            {
                var kind = trivia.ItemUntyped(i).Kind;
                if (kind == SyntaxKind.WhitespaceTrivia || kind == SyntaxKind.EndOfLineTrivia)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        // In order to handle creating SkippedTokens trivia correctly, we need to know if any structured
        // trivia is present in a trivia list (because structured trivia can't contain structured trivia).
        public static bool TriviaListContainsStructuredTrivia(this SyntaxNode triviaList)
        {
            if (triviaList == null)
            {
                return(false);
            }

            var trivia = new SyntaxList <SyntaxNode>(triviaList);

            for (var i = 0; i < trivia.Count; i++)
            {
                switch (trivia.ItemUntyped(i).Kind)
                {
                case SyntaxKind.XmlDocument:
                case SyntaxKind.SkippedTokensTrivia:
                    return(true);
                }
            }

            return(false);
        }