示例#1
0
        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);
                }
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
 public static TAstElement Child <TAstElement>(this IAstElement parent)
     where TAstElement : IAstElement
 {
     Argument.RequireNotNull("parent", parent);
     return(parent.Children <TAstElement>().SingleOrDefault());
 }
示例#4
0
 public static IEnumerable <TAstElement> Children <TAstElement>(this IAstElement parent)
     where TAstElement : IAstElement
 {
     return(parent.Children().OfType <TAstElement>());
 }