void (@NotNull Environment env, Project project, Editor editor, PsiExpression expression) { String varName; do { varName = env.generateValue(Generator.asciiIdentifiers(), null); } while (!PsiNameHelper.getInstance(project).isIdentifier(varName)); boolean replaceAll = env.generateValue(Generator.booleans(), null); boolean declareFinal = env.generateValue(Generator.booleans(), null); boolean declareVar = env.generateValue(Generator.booleans(), null); boolean replaceLValues = env.generateValue(Generator.booleans(), null); String flags = EntryStream.of("replaceAll", replaceAll, "declareFinal", declareFinal, "declareVar", declareVar, "replaceLValues", replaceLValues) .filterValues(x -> x).keys().joining(" | "); env.logMessage(String.format("Introduce variable; flags: %s; expression: %s at %d", flags, expression.getText(), expression.getTextRange().getStartOffset())); IntroduceVariableBase handler = new MockIntroduceVariableHandler(varName, replaceAll, declareFinal, declareVar, replaceLValues); try { handler.invoke(project, expression, editor); } catch (CommonRefactoringUtil.RefactoringErrorHintException hint) { env.logMessage("Introduce variable failed gracefully with: " + hint.getMessage()); } }