Example #1
0
 private static void Validate(SyntaxNodeOrTokenList list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         var item = list[i];
         if ((i & 1) == 0)
         {
             Debug.Assert(item.IsNode, "Node missing in separated list.");
         }
         else
         {
             Debug.Assert(item.IsToken, "Separator token missing in separated list.");
         }
     }
 }
Example #2
0
        internal SeparatedSyntaxList(SyntaxNodeOrTokenList list)
            : this()
        {
            Validate(list);

            // calculating counts is very cheap when list interleaves nodes and tokens
            // so lets just do it here.

            int allCount = list.Count;

            _count          = (allCount + 1) >> 1;
            _separatorCount = allCount >> 1;

            _list = list;
        }