public static IEnumerable <IAstElement> Descendants(this IAstElement ancestor) { Argument.RequireNotNull("ancestor", ancestor); foreach (var child in ancestor.Children()) { yield return(child); foreach (var descendant in child.Descendants()) { yield return(descendant); } } }
private void CollectTypesFromUsages(IAstElement parent, AstParameterDefinition parameter, ISet <IAstTypeReference> collectedTypes) { foreach (var child in parent.Children()) { var reference = child as AstParameterReference; if (reference != null && reference.Parameter == parameter) { var type = GetTypeFromUsage(parent, reference); if (type != null) { collectedTypes.Add(type); } continue; } CollectTypesFromUsages(child, parameter, collectedTypes); } }
public static TAstElement Child <TAstElement>(this IAstElement parent) where TAstElement : IAstElement { Argument.RequireNotNull("parent", parent); return(parent.Children <TAstElement>().SingleOrDefault()); }
public static IEnumerable <TAstElement> Children <TAstElement>(this IAstElement parent) where TAstElement : IAstElement { return(parent.Children().OfType <TAstElement>()); }