private void PlaceCaretAfterCompletion(
                [NotNull] ITextControl textControl, [NotNull] IReferenceExpression referenceExpression, int existingArgumentsCount, LookupItemInsertType insertType)
            {
                var referenceRange = referenceExpression.GetDocumentRange();

                textControl.Caret.MoveTo(referenceRange.TextRange.EndOffset, CaretVisualPlacement.DontScrollIfVisible);

                var invocationExpression = InvocationExpressionNavigator.GetByInvokedExpression(referenceExpression);

                if (invocationExpression == null)
                {
                    return;
                }

                var invocationRange = invocationExpression.GetDocumentRange();

                textControl.Caret.MoveTo(invocationRange.TextRange.EndOffset, CaretVisualPlacement.DontScrollIfVisible);

                var settingsStore           = referenceExpression.GetSettingsStore();
                var parenthesesInsertType   = settingsStore.GetValue(CodeCompletionSettingsAccessor.ParenthesesInsertType);
                var hasMoreParametersToPass = HasMoreParametersToPass(existingArgumentsCount);

                switch (parenthesesInsertType)
                {
                case ParenthesesInsertType.Both:
                {
                    if (hasMoreParametersToPass)
                    {
                        var rightPar = invocationExpression.RPar;
                        if (rightPar != null)
                        {
                            var rightParRange = rightPar.GetDocumentRange().TextRange;
                            textControl.Caret.MoveTo(rightParRange.StartOffset, CaretVisualPlacement.DontScrollIfVisible);
                        }
                    }

                    break;
                }

                case ParenthesesInsertType.Left:
                case ParenthesesInsertType.None:
                {
                    // if in insert mode - drop right par and set caret to it's start offest
                    if (insertType == LookupItemInsertType.Insert)
                    {
                        var rightPar = invocationExpression.RPar;
                        if (rightPar != null)
                        {
                            var rightParRange = rightPar.GetDocumentRange().TextRange;

                            invocationExpression.GetPsiServices().Transactions.Execute(
                                commandName: typeof(StaticMethodBehavior).FullName,
                                handler: () =>
                                {
                                    using (WriteLockCookie.Create())
                                        LowLevelModificationUtil.DeleteChild(rightPar);
                                });

                            textControl.Caret.MoveTo(rightParRange.StartOffset, CaretVisualPlacement.DontScrollIfVisible);
                        }
                    }

                    break;
                }
                }
            }