Boo.Lang.Compiler.Ast.AstUtil.GetParentTryExceptEnsure C# (CSharp) Method

GetParentTryExceptEnsure() public static method

public static GetParentTryExceptEnsure ( Node node ) : Node
node Node
return Node
        public static Node GetParentTryExceptEnsure(Node node)
        {
            Node parent = node.ParentNode;
            while (null != parent)
            {
                switch (parent.NodeType)
                {
                    case NodeType.TryStatement:
                    case NodeType.ExceptionHandler:
                    {
                        return parent;
                    }

                    case NodeType.Block:
                    {
                        if (NodeType.TryStatement == parent.ParentNode.NodeType)
                        {
                            if (parent == ((TryStatement)parent.ParentNode).EnsureBlock)
                            {
                                return parent;
                            }
                        }
                        break;
                    }

                    case NodeType.Method:
                    {
                        return null;
                    }
                }
                parent = parent.ParentNode;
            }
            return null;
        }