Example #1
0
        private void Grow(int newSize)
        {
            var tmp = new Syntax.InternalSyntax.CSharpSyntaxNode[newSize];

            Array.Copy(nodes, tmp, nodes.Length);
            this.nodes = tmp;
        }
Example #2
0
 internal SyntaxTokenList(SyntaxToken token)
 {
     this.parent   = token.Parent;
     this.node     = token.Node;
     this.position = token.Position;
     this.index    = 0;
 }
Example #3
0
 internal SyntaxTriviaList(SyntaxToken token, Syntax.InternalSyntax.CSharpSyntaxNode node, int position, int index)
 {
     this.token    = token;
     this.node     = node;
     this.position = position;
     this.index    = index;
 }
Example #4
0
 internal SyntaxTriviaList(SyntaxToken token, Syntax.InternalSyntax.CSharpSyntaxNode node)
 {
     this.token    = token;
     this.node     = node;
     this.position = token.Position;
     this.index    = 0;
 }
Example #5
0
 internal SyntaxTriviaList(SyntaxTrivia trivia)
 {
     this.token    = trivia.Token;
     this.node     = trivia.UnderlyingNode;
     this.position = trivia.Position;
     this.index    = trivia.Index;
 }
Example #6
0
        private void Grow(int size)
        {
            var tmp = new Syntax.InternalSyntax.CSharpSyntaxNode[size];

            Array.Copy(_nodes, tmp, _nodes.Length);
            _nodes = tmp;
        }
Example #7
0
        internal void Add(Syntax.InternalSyntax.CSharpSyntaxNode item)
        {
            if (_nodes == null || _count >= _nodes.Length)
            {
                this.Grow(_count == 0 ? 8 : _nodes.Length * 2);
            }

            _nodes[_count++] = item;
        }
Example #8
0
        internal void Add(Syntax.InternalSyntax.CSharpSyntaxNode item)
        {
            if (nodes == null || count >= nodes.Length)
            {
                this.Grow(count == 0 ? 8 : nodes.Length * 2);
            }

            nodes[count++] = item;
        }
Example #9
0
        internal SyntaxTokenList(CSharpSyntaxNode parent, Syntax.InternalSyntax.CSharpSyntaxNode node, int position, int index)
        {
            Debug.Assert(node != null || (position == 0 && index == 0 && parent == null));
            Debug.Assert(position >= 0);

            this.parent   = parent;
            this.node     = node;
            this.position = position;
            this.index    = index;
        }
            internal Enumerator(ref SyntaxTokenList list)
            {
                this.parent           = list.parent;
                this.singleNodeOrList = list.node;
                this.baseIndex        = list.index;
                this.count            = list.Count;

                this.index    = -1;
                this.current  = null;
                this.position = list.position;
            }
Example #11
0
                public Enumerator(ref SyntaxTriviaList list)
                {
                    this.token            = list.token;
                    this.singleNodeOrList = list.node;
                    this.baseIndex        = list.index;
                    this.count            = list.Count;

                    this.index   = this.count;
                    this.current = null;

                    var last = list.LastOrDefault();

                    this.position = last.Position + last.FullWidth;
                }
Example #12
0
                public bool MoveNext()
                {
                    if (this.count == 0 || index <= 0)
                    {
                        this.current = null;
                        return(false);
                    }

                    index--;

                    this.current   = GetGreenNodeAt(this.singleNodeOrList, this.index);
                    this.position -= this.current.FullWidth;

                    return(true);
                }
            /// <summary>
            /// Move to the next item in the list.
            /// </summary>
            /// <returns></returns>
            public bool MoveNext()
            {
                if (this.count == 0 || this.count <= index + 1)
                {
                    // invalidate iterator
                    this.current = null;
                    return(false);
                }

                index++;

                // Add the length of the previous node to the offset so that
                // the next node's offset is reported correctly.
                if (current != null)
                {
                    this.position += this.current.FullWidth;
                }

                this.current = GetGreenNodeAt(this.singleNodeOrList, this.index);
                return(true);
            }
Example #14
0
        /// <summary>
        /// Counts the nodes.
        /// </summary>
        /// <param name="green">The green.</param>
        /// <returns></returns>
        private static int CountNodes(Syntax.InternalSyntax.CSharpSyntaxNode green)
        {
            int n = 0;

            for (int i = 0, s = green.SlotCount; i < s; i++)
            {
                var child = green.GetSlot(i);
                if (child != null)
                {
                    if (!child.IsList)
                    {
                        n++;
                    }
                    else
                    {
                        n += child.SlotCount;
                    }
                }
            }

            return(n);
        }
 private void Grow(int size)
 {
     var tmp = new Syntax.InternalSyntax.CSharpSyntaxNode[size];
     Array.Copy(nodes, tmp, nodes.Length);
     this.nodes = tmp;
 }
Example #16
0
 /// <summary>
 /// get the green node at the given slot
 /// </summary>
 private static Syntax.InternalSyntax.SyntaxToken GetGreenNodeAt(Syntax.InternalSyntax.CSharpSyntaxNode node, int i)
 {
     Debug.Assert(node.IsList || (i == 0 && !node.IsList));
     return((Syntax.InternalSyntax.SyntaxToken)(node.IsList ? node.GetSlot(i) : node));
 }
Example #17
0
 private void Grow(int newSize)
 {
     var tmp = new Syntax.InternalSyntax.CSharpSyntaxNode[newSize];
     Array.Copy(_nodes, tmp, _nodes.Length);
     _nodes = tmp;
 }
Example #18
0
 internal StructuredTriviaSyntax(Syntax.InternalSyntax.CSharpSyntaxNode green, SyntaxNode parent, int position)
     : base(green, position, parent == null ? null : parent.SyntaxTree)
 {
     System.Diagnostics.Debug.Assert(parent == null || position >= 0);
 }
Example #19
0
 private static int Occupancy(Syntax.InternalSyntax.CSharpSyntaxNode greenChild)
 {
     return(greenChild.IsList
         ? greenChild.SlotCount
         : 1);
 }