public TNode this[int index] { get { if (_node == null) { return(null); } else if (_node.IsList) { Debug.Assert(index >= 0); Debug.Assert(index <= _node.SlotCount); return((TNode)_node.GetSlot(index)); } else if (index == 0) { return((TNode)_node); } else { throw ExceptionUtilities.Unreachable; } } }
public void Add(CSharpSyntaxNode item) { if (item == null) { return; } if (item.IsList) { int slotCount = item.SlotCount; // Necessary, but not sufficient (e.g. for nested lists). EnsureAdditionalCapacity(slotCount); for (int i = 0; i < slotCount; i++) { this.Add((CSharpSyntaxNode)item.GetSlot(i)); } } else { EnsureAdditionalCapacity(1); _nodes[Count++].Value = item; } }
private void VisitChildren(Syntax.InternalSyntax.CSharpSyntaxNode node) { var childCnt = node.SlotCount; for (int i = 0; i < childCnt; i++) { var child = node.GetSlot(i); if (child != null && child.SlotCount != 0) { if (child.IsList) { VisitChildren((Syntax.InternalSyntax.CSharpSyntaxNode)child); } else { ((Syntax.InternalSyntax.CSharpSyntaxNode)child).Accept(this); } } } }