diff --git a/source/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java b/source/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java index dcddd44c2502..d22fb1716d00 100644 --- a/source/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java +++ b/source/com/intellij/codeInsight/daemon/impl/quickfix/SimplifyBooleanExpressionFix.java @@ -105,34 +105,40 @@ public class SimplifyBooleanExpressionFix implements IntentionAction { final Boolean rConstBoolean = getConstBoolean(rOperand); if (lConstBoolean != null) { - if (JavaTokenType.ANDAND == tokenType || JavaTokenType.AND == tokenType) { - resultExpression = lConstBoolean.booleanValue() ? rOperand : falseExpression; - } - else if (JavaTokenType.OROR == tokenType || JavaTokenType.OR == tokenType) { - resultExpression = lConstBoolean.booleanValue() ? trueExpression : rOperand; - } - else if (JavaTokenType.EQEQ == tokenType) { - simplifyEquation(lConstBoolean, rOperand); - } - else if (JavaTokenType.NE == tokenType) { - resultExpression = createNegatedExpression(rOperand); - visitPrefixExpression((PsiPrefixExpression)resultExpression); - simplifyEquation(lConstBoolean, resultExpression); - } + simplifyBinary(tokenType, lConstBoolean, rOperand); } else if (rConstBoolean != null) { - if (JavaTokenType.ANDAND == tokenType || JavaTokenType.AND == tokenType) { - resultExpression = rConstBoolean.booleanValue() ? lOperand : falseExpression; - } - else if (JavaTokenType.OROR == tokenType || JavaTokenType.OR == tokenType) { - resultExpression = rConstBoolean.booleanValue() ? trueExpression : lOperand; - } - else if (JavaTokenType.EQEQ == tokenType) { - simplifyEquation(rConstBoolean, lOperand); - } - else if (JavaTokenType.NE == tokenType) { - simplifyEquation(rConstBoolean, createNegatedExpression(lOperand)); - } + simplifyBinary(tokenType, rConstBoolean, lOperand); + //if (JavaTokenType.ANDAND == tokenType || JavaTokenType.AND == tokenType) { + // resultExpression = rConstBoolean.booleanValue() ? lOperand : falseExpression; + //} + //else if (JavaTokenType.OROR == tokenType || JavaTokenType.OR == tokenType) { + // resultExpression = rConstBoolean.booleanValue() ? trueExpression : lOperand; + //} + //else if (JavaTokenType.EQEQ == tokenType) { + // simplifyEquation(rConstBoolean, lOperand); + //} + //else if (JavaTokenType.NE == tokenType) { + // simplifyEquation(rConstBoolean, createNegatedExpression(lOperand)); + //} + } + } + + private void simplifyBinary(final IElementType tokenType, final Boolean lConstBoolean, final PsiExpression rOperand) { + if (JavaTokenType.ANDAND == tokenType || JavaTokenType.AND == tokenType) { + resultExpression = lConstBoolean.booleanValue() ? rOperand : falseExpression; + } + else if (JavaTokenType.OROR == tokenType || JavaTokenType.OR == tokenType) { + resultExpression = lConstBoolean.booleanValue() ? trueExpression : rOperand; + } + else if (JavaTokenType.EQEQ == tokenType) { + simplifyEquation(lConstBoolean, rOperand); + } + else if (JavaTokenType.NE == tokenType) { + final PsiPrefixExpression negatedExpression = createNegatedExpression(rOperand); + resultExpression = negatedExpression; + visitPrefixExpression(negatedExpression); + simplifyEquation(lConstBoolean, resultExpression); } } @@ -147,6 +153,12 @@ public class SimplifyBooleanExpressionFix implements IntentionAction { } } + public void visitConditionalExpression(PsiConditionalExpression expression) { + final Boolean condition = getConstBoolean(expression.getCondition()); + if (condition == null) return; + resultExpression = condition.booleanValue() ? expression.getThenExpression() : expression.getElseExpression(); + } + private PsiPrefixExpression createNegatedExpression(final PsiExpression otherOperand) { try { return (PsiPrefixExpression)otherOperand.getManager().getElementFactory() diff --git a/source/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java b/source/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java index 5e89bbb9e603..eb9a667b38b8 100644 --- a/source/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java +++ b/source/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java @@ -338,8 +338,6 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark int yStartPosition = visibleLineToYPosition(visStartLine, myScrollBarHeight); int yEndPosition = visibleLineToYPosition(visEndLine, myScrollBarHeight); - //final int height = Math.max(yEndPosition - yStartPosition, 2); - final ErrorMarkPile prevPile = list.size() == 0 ? null : list.get(list.size() - 1); int prevPileEnd = prevPile == null ? -100 : prevPile.yEnd; if (yStartPosition - prevPileEnd < getMinHeight()) { @@ -376,15 +374,16 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark } } - private int getMinHeight() { + private static int getMinHeight() { return DaemonCodeAnalyzerSettings.getInstance().getErrorStripeMarkMinHeight(); } + // number of error marks glued together private class ErrorMarkPile { private int yStart; private int yEnd; private List markers = new ArrayList(); - private static final int MAX_TOOLTIP_LINES = 5; + private static final int MAX_TOOLTIP_LINES = 10; public ErrorMarkPile(final int yStart) { this.yStart = yStart;