/// <summary>Determines whether the specified throw statement is caught.</summary> /// <param name="throwStatement">The throw statement.</param> /// <returns><c>true</c> if the specified throw statement is caught; otherwise, <c>false</c>.</returns> private static bool IsExceptionCaught(IThrowStatement throwStatement) { ITreeNode node = throwStatement.ToTreeNode(); if (node == null) { return true; } while (node != null) { var tryStatement = node as ITryStatement; if (tryStatement != null) { if (IsCatchStatement(throwStatement, tryStatement)) { return true; } } node = node.Parent; } return false; }
/// <summary> /// Gets the exception. /// </summary> /// <param name="statement"> /// The statement. /// </param> /// <returns> /// The exception. /// </returns> private static IType GetExceptionType(IThrowStatement statement) { if (statement.Exception != null) { // TODO: may throw exception return statement.Exception.Type(); } ITreeNode node = statement.ToTreeNode(); while (node != null && !(node is ICatchClause)) { node = node.Parent; } var catchClause = node as ICatchClause; if (catchClause == null) { return null; } return catchClause.ExceptionType; }