public void AddOrphanedEndTag(TagNode tag) { if (OrphanedEndTagsCollection == null) { OrphanedEndTagsCollection = new TextRangeCollection <TagNode>(); } OrphanedEndTagsCollection.Add(tag); }
public override void ShiftStartingFrom(int start, int offset) { // Root node does not have start or end tags, only children for (int i = 0; i < Children.Count; i++) { Children[i].ShiftStartingFrom(start, offset); } if (OrphanedEndTagsCollection != null) { OrphanedEndTagsCollection.ShiftStartingFrom(start, offset); } }
/// <summary>Shifts node start, end and all child elements by the specified offset.</summary> public override void Shift(int offset) { StartTag.Shift(offset); if (EndTag != null) { EndTag.Shift(offset); } if (OrphanedEndTagsCollection != null) { OrphanedEndTagsCollection.Shift(offset); } VirtualEnd += offset; for (int i = 0; i < Children.Count; i++) { Children[i].Shift(offset); } }
/// <summary> /// Shifts node components that are located at or beyond given start point by the specified range /// </summary> /// <param name="start">Start point</param> /// <param name="offset">Offset to shift by</param> public override void ShiftStartingFrom(int start, int offset) { // short-circuit in the case where the shift starts after our end if (start > End) { return; } // if tag is not closed and change is right at the end, // e need to grow start tag rather than element inner range if (StartTag.Contains(start) || StartTag.Start >= start || (!StartTag.IsClosed && start == StartTag.End)) { StartTag.ShiftStartingFrom(start, offset); } if (EndTag != null && (EndTag.Contains(start) || EndTag.Start >= start)) { EndTag.ShiftStartingFrom(start, offset); } if (OrphanedEndTagsCollection != null) { OrphanedEndTagsCollection.ShiftStartingFrom(start, offset); } if (VirtualEnd >= start) { VirtualEnd = Math.Max(start, VirtualEnd + offset); } int count = Children.Count; for (int i = 0; i < count; i++) { Children[i].ShiftStartingFrom(start, offset); } }