public static boolean checkForReturnFromMethod(GrExpression replacedNewExpression) {
    final PsiElement parent = PsiUtil.skipParentheses(replacedNewExpression.getParent(), true);
    final GrMethod method = PsiTreeUtil.getParentOfType(replacedNewExpression, GrMethod.class, true, GrClosableBlock.class);
    if (method == null) return false;

    if (!(parent instanceof GrReturnStatement)) { //check for return expression
      final List<GrStatement> returns = ControlFlowUtils.collectReturns(method.getBlock());
      final PsiElement expr = PsiUtil.skipParentheses(replacedNewExpression, true);
      if (!(returns.contains(expr))) return false;
    }
    return !(!ApplicationManager.getApplication().isUnitTestMode() && Messages.showYesNoDialog(replacedNewExpression.getProject(),
                                                                                               GroovyBundle.message(
                                                                                                 "do.you.want.to.change.method.return.type",
                                                                                                 method.getName()),
                                                                                               GroovyIntentionsBundle
                                                                                                 .message(
                                                                                                   "convert.map.to.class.intention.name"),
                                                                                               Messages.getQuestionIcon()) != Messages.YES);
  }
public static boolean checkForReturnFromMethod(GrExpression replacedNewExpression)