/// <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) { #if R8 var declaredTypeUsageNode = _factory.CreateDeclaredTypeUsageNode(exceptionType); #else var declaredTypeUsageNode = _factory.CreateDeclaredTypeUsageNode(exceptionType, context); #endif exceptionDeclaration.SetDeclaredTypeUsage(declaredTypeUsageNode); } return(exceptionDeclaration); }