ModCommand (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); PsiAssignmentExpression parentExpr = getAssignment(descriptor); if (parentExpr == null) return ModCommand.nop(); if (!ExpressionUtils.isVoidContext(parentExpr)) { return ModCommand.psiUpdate(parentExpr, p -> { PsiExpression initializer = getInitializer(p); if (initializer == null) return; PsiElement gp = p.getParent(); if (gp instanceof PsiParenthesizedExpression) { gp.replace(initializer); } else { p.replace(initializer); } }); } PsiExpression initializer = parentExpr.getRExpression(); if (initializer == null) return ModCommand.nop(); PsiElement resolve = resolveExpression(element, parentExpr); if (!(resolve instanceof PsiVariable)) return ModCommand.nop(); List<PsiExpression> sideEffects = SideEffectChecker.extractSideEffectExpressions(initializer); List<ModCommandAction> subActions; if (!sideEffects.isEmpty()) { subActions = List.of(new RemoveInitializerFix.SideEffectAwareRemove(initializer), new DeleteElementFix(parentExpr, JavaBundle.message("delete.assignment.completely"))); } else { subActions = List.of(new DeleteElementFix(parentExpr)); } return new ModChooseAction(JavaBundle.message("inspection.unused.assignment.remove.assignment.quickfix.title"), subActions); }