ExtractWhileLoopConditionToIfStatementIntention: disable for "true" literal only

Review ID: IDEA-CR-28930
This commit is contained in:
Tagir Valeev
2018-02-16 10:12:20 +07:00
parent 4698ad9416
commit 1dfdc5e3f9
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.BlockUtils;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.util.PsiUtil;
import com.siyeh.ig.psiutils.BoolUtils;
import com.siyeh.ig.psiutils.ExpressionUtils;
import com.siyeh.ipp.base.Intention;
@@ -32,7 +33,8 @@ public class ExtractWhileLoopConditionToIfStatementIntention extends Intention {
protected PsiElementPredicate getElementPredicate() {
WhileLoopPredicate predicate = new WhileLoopPredicate();
return e -> predicate.satisfiedBy(e) &&
!(ExpressionUtils.computeConstantExpression(((PsiWhileStatement)e.getParent()).getCondition()) instanceof Boolean);
!(ExpressionUtils
.isLiteral(PsiUtil.skipParenthesizedExprDown(((PsiWhileStatement)e.getParent()).getCondition()), Boolean.TRUE));
}
@Override