@Nullable
  private static LocalQuickFix createSimplifyBooleanExpressionFix(
      PsiElement element, final boolean value) {
    SimplifyBooleanExpressionFix fix = createIntention(element, value);
    if (fix == null) return null;
    final String text = fix.getText();
    return new LocalQuickFix() {
      @Override
      @NotNull
      public String getName() {
        return text;
      }

      @Override
      public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
        final PsiElement psiElement = descriptor.getPsiElement();
        if (psiElement == null) return;
        final SimplifyBooleanExpressionFix fix = createIntention(psiElement, value);
        if (fix == null) return;
        try {
          LOG.assertTrue(psiElement.isValid());
          fix.applyFix();
        } catch (IncorrectOperationException e) {
          LOG.error(e);
        }
      }

      @Override
      @NotNull
      public String getFamilyName() {
        return InspectionsBundle.message(
            "inspection.data.flow.simplify.boolean.expression.quickfix");
      }
    };
  }
 private static SimplifyBooleanExpressionFix createIntention(PsiElement element, boolean value) {
   if (!(element instanceof PsiExpression)) return null;
   final PsiExpression expression = (PsiExpression) element;
   while (element.getParent() instanceof PsiExpression) {
     element = element.getParent();
   }
   final SimplifyBooleanExpressionFix fix = new SimplifyBooleanExpressionFix(expression, value);
   // simplify intention already active
   if (!fix.isAvailable()
       || SimplifyBooleanExpressionFix.canBeSimplified((PsiExpression) element)) {
     return null;
   }
   return fix;
 }
 @Override
 public void invoke(@NotNull Project project, Editor editor, PsiFile file)
     throws IncorrectOperationException {
   if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
   PsiExpression expression = getExpressionToSimplify(editor, file);
   SimplifyBooleanExpressionFix.simplifyExpression(expression);
 }
 @Override
 public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
   PsiExpression expression = getExpressionToSimplify(editor, file);
   return expression != null && SimplifyBooleanExpressionFix.canBeSimplified(expression);
 }