public void testIdentifierExpressionIntegerIndex() {
    final OgnlIndexedExpression indexedExpression = parse("identifier[1+2]");
    assertElementType(OgnlTypes.REFERENCE_EXPRESSION, indexedExpression.getReferenceQualifier());

    final OgnlExpression index = indexedExpression.getIndexExpression();
    assertElementType(OgnlTypes.BINARY_EXPRESSION, index);
    assertEquals(PsiType.INT, index.getType());
  }
  public void testIdentifierSimpleIntegerIndex() {
    final OgnlIndexedExpression indexedExpression = parse("identifier[0]");
    final OgnlExpression qualifier = indexedExpression.getReferenceQualifier();
    assertElementType(OgnlTypes.REFERENCE_EXPRESSION, qualifier);
    assertNull(qualifier.getType());

    final OgnlExpression index = indexedExpression.getIndexExpression();
    assertElementType(OgnlTypes.LITERAL_EXPRESSION, index);
    final OgnlLiteralExpression expression = assertInstanceOf(index, OgnlLiteralExpression.class);
    assertEquals("0", expression.getText());
    assertEquals(PsiType.INT, expression.getType());
  }
  public void testSimple() {
    final OgnlConditionalExpression expression = parse("true ? 0 : 1");
    assertEquals(PsiType.INT, expression.getType());

    final OgnlExpression condition = expression.getCondition();
    assertEquals("true", condition.getText());
    assertElementType(OgnlTypes.LITERAL_EXPRESSION, condition);
    assertEquals(PsiType.BOOLEAN, condition.getType());

    final OgnlExpression thenExpression = expression.getThen();
    assertNotNull(thenExpression);
    assertEquals("0", thenExpression.getText());
    assertElementType(OgnlTypes.LITERAL_EXPRESSION, thenExpression);
    final OgnlLiteralExpression thenLiteral =
        assertInstanceOf(thenExpression, OgnlLiteralExpression.class);
    assertEquals(PsiType.INT, thenLiteral.getType());
    assertEquals(0, thenLiteral.getConstantValue());

    final OgnlExpression elseExpression = expression.getElse();
    assertNotNull(elseExpression);
    assertEquals("1", elseExpression.getText());
    assertElementType(OgnlTypes.LITERAL_EXPRESSION, elseExpression);
    final OgnlLiteralExpression elseLiteral =
        assertInstanceOf(elseExpression, OgnlLiteralExpression.class);
    assertEquals(PsiType.INT, elseLiteral.getType());
    assertEquals(1, elseLiteral.getConstantValue());
  }
  private void assertConstantUnaryExpression(
      @Language(
              value = OgnlLanguage.ID,
              prefix = OgnlLanguage.EXPRESSION_PREFIX,
              suffix = OgnlLanguage.EXPRESSION_SUFFIX)
          final String expression,
      final IElementType operationSign,
      final PsiType operandType,
      final Object operandConstantValue) {
    final OgnlUnaryExpression unaryExpression = parse(expression);
    assertNotNull(unaryExpression);

    final OgnlTokenType operation = unaryExpression.getUnaryOperator();
    assertEquals(operationSign, operation);

    final OgnlExpression operand = unaryExpression.getExpression();
    assertNotNull(operand);
    assertEquals(operandType, operand.getType());

    if (operand instanceof OgnlLiteralExpression) {
      final OgnlLiteralExpression literalExpression = (OgnlLiteralExpression) operand;
      assertEquals(operandConstantValue, literalExpression.getConstantValue());
    }
  }