void UpdateChildren(DelphiFile[] path) { var nextNode = path.ElementAtOrDefault(current + 1); if (nextNode == null) return; var pathTreeNode = Children.OfType<PathTreeNode>().FirstOrDefault(n => n.node == nextNode); if (pathTreeNode == null) { pathTreeNode = new PathTreeNode(path, current + 1); Children.OrderedInsert(pathTreeNode, NodeTextComparer); } else { pathTreeNode.AddPath(path); } }
protected override void LoadChildren() { foreach (var result in results) { List<DelphiFile> path = new List<DelphiFile>(); var currentFile = result.Item1; DelphiFile parentFile; path.Add(currentFile); while (result.Item2.TryGetValue(currentFile, out parentFile)) { currentFile = parentFile; if (currentFile == target) break; Debug.Assert(!path.Contains(currentFile), "unresolved loop found!"); path.Add(currentFile); } path.Reverse(); int current = Math.Min(1, path.Count - 1); if (current > 0) { // currently ignore paths that have only one node PathTreeNode pathTreeNode = Children.OfType<PathTreeNode>().FirstOrDefault(n => n.Node == path[current]); var array = path.ToArray(); if (pathTreeNode == null) { pathTreeNode = new PathTreeNode(array, current); Children.OrderedInsert(pathTreeNode, PathTreeNode.NodeTextComparer); } else { pathTreeNode.AddPath(array); } } } }