public BooParseTreeNodeList FlattenFrom(IBooParseTreeNode node) { BooParseTreeNodeList flattened = new IntellisenseNodeList(); // add anything "below" the scope (e.g. locals in a method, methods in a class) flattened.AddRange(FlattenDown(node.Children)); // add anything "above" the scope (e.g. classes in a method) // also walks sideways (e.g. other methods in same class if scope is a method) flattened.AddRange(FlattenUp(node)); return flattened; }
private IList<IBooParseTreeNode> FlattenDown(IList<IBooParseTreeNode> nodes) { BooParseTreeNodeList flattened = new IntellisenseNodeList(); foreach (IBooParseTreeNode node in nodes) { flattened.Add(node); flattened.AddRange(FlattenDown(node.Children)); } return flattened; }