public TextRange[] AddInnerException(string variableName)
        {
            var ranges = new List <TextRange>();

            var objectCreationExpressionNode = Node.Exception as IObjectCreationExpression;

            if (objectCreationExpressionNode == null)
            {
                return(new TextRange[0]);
            }

            if (objectCreationExpressionNode.Arguments.Count == 0)
            {
                var messageExpression = CSharpElementFactory.GetInstance(AnalyzeUnit.GetPsiModule())
                                        .CreateExpressionAsIs("\"See the inner exception for details.\"");

                var messageArgument = CSharpElementFactory.GetInstance(AnalyzeUnit.GetPsiModule())
                                      .CreateArgument(ParameterKind.VALUE, messageExpression);

                messageArgument = objectCreationExpressionNode.AddArgumentAfter(messageArgument, null);
                ranges.Add(messageArgument.GetDocumentRange().TextRange);
            }
            else
            {
                var lastArgument = objectCreationExpressionNode.ArgumentList.Arguments.Last();

                var innerExceptionExpression = CSharpElementFactory.GetInstance(AnalyzeUnit.GetPsiModule())
                                               .CreateExpressionAsIs(variableName);

                var innerExpressionArgument = CSharpElementFactory.GetInstance(AnalyzeUnit.GetPsiModule())
                                              .CreateArgument(ParameterKind.VALUE, innerExceptionExpression);

                innerExpressionArgument = objectCreationExpressionNode.AddArgumentAfter(innerExpressionArgument, lastArgument);
                ranges.Add(innerExpressionArgument.GetDocumentRange().TextRange);
            }

            return(ranges.ToArray());
        }
 protected CSharpElementFactory GetElementFactory()
 {
     return(CSharpElementFactory.GetInstance(AnalyzeUnit.GetPsiModule()));
 }