void (Editor editor, PsiLambdaExpression lambdaExpression) { if (lambdaExpression != null && lambdaExpression.isValid()) { final PsiElement body = lambdaExpression.getBody(); PsiExpression methodCall = LambdaUtil.extractSingleExpressionFromBody(body); PsiExpression qualifierExpression = null; if (methodCall instanceof PsiMethodCallExpression) { qualifierExpression = ((PsiMethodCallExpression)methodCall).getMethodExpression().getQualifierExpression(); } else if (methodCall instanceof PsiNewExpression) { qualifierExpression = ((PsiNewExpression)methodCall).getQualifier(); } if (qualifierExpression != null) { final List<PsiElement> sideEffects = new ArrayList<>(); if (ExpressionUtils.isNewObject(qualifierExpression)) { sideEffects.add(qualifierExpression); } else { SideEffectChecker.checkSideEffects(qualifierExpression, sideEffects); } if (!sideEffects.isEmpty()) { if (ApplicationManager.getApplication().isUnitTestMode() || Messages.showYesNoDialog(lambdaExpression.getProject(), JavaRefactoringBundle.message("lambda.to.reference.side.effect.warning.message"), JavaRefactoringBundle.message("side.effects.detected.title"), Messages.getQuestionIcon()) == Messages.YES) { //ensure introduced before lambda qualifierExpression.putUserData(ElementToWorkOn.PARENT, lambdaExpression); RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.INSTANCE.forLanguage(JavaLanguage.INSTANCE); JavaIntroduceVariableHandlerBase handler = (JavaIntroduceVariableHandlerBase)supportProvider.getIntroduceVariableHandler(); assert handler != null; handler.invoke(qualifierExpression.getProject(), editor, qualifierExpression); } } } } }