ModCommand (@NotNull ActionContext context, @NotNull PsiExpression expression) { List<PsiExpression> sideEffects = myExtractSideEffects == ThreeState.NO ? List.of() : SideEffectChecker.extractSideEffectExpressions(expression); CodeBlockSurrounder surrounder = CodeBlockSurrounder.forExpression(expression); if (surrounder == null) { sideEffects = List.of(); } if (sideEffects.isEmpty()) { return ModCommand.psiUpdate(expression, expr -> applyFix(expr, PsiStatement.EMPTY_ARRAY)); } if (myExtractSideEffects == ThreeState.UNSURE) { return new ModChooseAction(JavaAnalysisBundle.message("replace.with.constant.value.title"), List.of( new ReplaceWithConstantValueFix(expression, myPresentableName, myReplacementText, true), new ReplaceWithConstantValueFix(expression, myPresentableName, myReplacementText, false) )); } PsiStatement[] statements = StatementExtractor.generateStatements(sideEffects, expression); return ModCommand.psiUpdate(expression, (expr, updater) -> applyFix(expr, statements)); }