/// <summary> /// Determines whether a given statement is an ancestor of some other statement. /// </summary> /// <param name="stmt">An assumed ancestor</param> /// <param name="grandChild">Its assumed granchild</param> /// <returns><c>true</c> if <paramref name="stmt"/> is an ancestor of <paramref name="grandChild"/></returns> /// <remarks>A statement a is an ancestor of a statement b iff there exists a sequence /// s1, s2,... , sN of zero or more statements such that a contains s1, s1 contains s2, /// ... and sN contains b. Furthermore, each statement is per definition an ancestor /// of itself. /// </remarks> public static bool IsAncestor(this Statement stmt, Statement grandChild) { HierarchyAnalyzer ha = new HierarchyAnalyzer() { Grandchild = grandChild }; stmt.Accept(ha); return(ha.IsAncestor); }
/// <summary> /// Determines whether a given statement is an ancestor of some other statement. /// </summary> /// <param name="stmt">An assumed ancestor</param> /// <param name="grandChild">Its assumed granchild</param> /// <returns><c>true</c> if <paramref name="stmt"/> is an ancestor of <paramref name="grandChild"/></returns> /// <remarks>A statement a is an ancestor of a statement b iff there exists a sequence /// s1, s2,... , sN of zero or more statements such that a contains s1, s1 contains s2, /// ... and sN contains b. Furthermore, each statement is per definition an ancestor /// of itself. /// </remarks> public static bool IsAncestor(this Statement stmt, Statement grandChild) { HierarchyAnalyzer ha = new HierarchyAnalyzer() { Grandchild = grandChild }; stmt.Accept(ha); return ha.IsAncestor; }