コード例 #1
0
 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 boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
   PsiExpression expression = getExpressionToSimplify(editor, file);
   return expression != null && SimplifyBooleanExpressionFix.canBeSimplified(expression);
 }