ModCommand (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement element = descriptor.getPsiElement(); Context context = getContext(element); if (context == null) return ModCommand.nop(); PsiLocalVariable variable = context.myVariable; PsiExpression initializer = variable.getInitializer(); List<PsiExpression> sideEffects = initializer == null || context.myAssignment.getOperationTokenType() != JavaTokenType.EQ ? List.of() : SideEffectChecker.extractSideEffectExpressions(initializer); JoinDeclarationAndAssignmentAction action = new JoinDeclarationAndAssignmentAction(element); if (!sideEffects.isEmpty() && !ContainerUtil.exists(sideEffects, se -> variableIsUsed(variable, se))) { List<ModCommandAction> subActions = List.of( new RemoveInitializerFix.SideEffectAwareRemove(initializer, var -> JoinDeclarationAndAssignmentAction.join(var)), action); return new ModChooseAction(JavaBundle.message("inspection.join.declaration.and.assignment.fix.title"), subActions); } else { return action.perform(ActionContext.from(descriptor)); } }