/// <summary>Creates a variable declaration for catch clause.</summary> /// <param name="exceptionType">The type of a created variable.</param> /// <param name="context">The context. </param> public ICatchVariableDeclaration CreateCatchVariableDeclarationNode(IDeclaredType exceptionType, ITreeNode context) { var tryStatement = _factory.CreateStatement("try {} catch(Exception e) {}") as ITryStatement; if (tryStatement == null) { return(null); } var catchClause = tryStatement.Catches[0] as ISpecificCatchClause; if (catchClause == null) { return(null); } var exceptionDeclaration = catchClause.ExceptionDeclaration; if (exceptionDeclaration == null) { return(null); } if (exceptionType != null) { var declaredTypeUsageNode = _factory.CreateTypeUsage(exceptionType, context); catchClause.SetExceptionTypeUsage(declaredTypeUsageNode); } return(exceptionDeclaration); }