void BuildTreeChildren (Gtk.TreeStore store, Gtk.TreeIter parent, XContainer p, IList<Block> blocks) { foreach (XNode node in p.Nodes) { var el = node as XElement; if (el == null) { var startLoc = node.Region.Begin; var endLoc = node.Region.End; var doc = defaultDocument.Editor.Document; var blocksBetween = blocks.Where (n => n.Start.AbsoluteIndex >= doc.GetOffset (startLoc) && n.Start.AbsoluteIndex <= doc.GetOffset (endLoc)); foreach (var block in blocksBetween) { var outlineNode = new OutlineNode (block) { Location = new DomRegion (doc.OffsetToLocation (block.Start.AbsoluteIndex), doc.OffsetToLocation (block.Start.AbsoluteIndex + block.Length)) }; if (!parent.Equals (Gtk.TreeIter.Zero)) store.AppendValues (parent, outlineNode); else store.AppendValues (outlineNode); } continue; } Gtk.TreeIter childIter; if (!parent.Equals (Gtk.TreeIter.Zero)) childIter = store.AppendValues (parent, new OutlineNode(el)); else childIter = store.AppendValues (new OutlineNode(el)); BuildTreeChildren (store, childIter, el, blocks); } }
void SelectNode (OutlineNode n) { EditorSelect (n.Location); }
void BuildTreeChildren (Gtk.TreeStore store, Gtk.TreeIter parent, ParentNode p, IList<Block> blocks) { foreach (Node node in p) { if (!(node is TagNode)) { var startLoc = new TextLocation (node.Location.BeginLine, node.Location.BeginColumn); var endLoc = new TextLocation (node.Location.EndLine, node.Location.EndColumn); var doc = defaultDocument.Editor.Document; var blocksBetween = blocks.Where (n => n.Start.AbsoluteIndex >= doc.GetOffset (startLoc) && n.Start.AbsoluteIndex <= doc.GetOffset (endLoc)); foreach (var block in blocksBetween) { var outlineNode = new OutlineNode (block) { Location = new DomRegion (doc.OffsetToLocation (block.Start.AbsoluteIndex), doc.OffsetToLocation (block.Start.AbsoluteIndex + block.Length)) }; if (!parent.Equals (Gtk.TreeIter.Zero)) store.AppendValues (parent, outlineNode); else store.AppendValues (outlineNode); } continue; } Gtk.TreeIter childIter; if (!parent.Equals (Gtk.TreeIter.Zero)) childIter = store.AppendValues (parent, new OutlineNode(node as TagNode)); else childIter = store.AppendValues (new OutlineNode(node as TagNode)); ParentNode pChild = node as ParentNode; if (pChild != null) BuildTreeChildren (store, childIter, pChild, blocks); } }