@Override
  public void invoke(@NotNull PsiElement element) {
    final PsiJavaToken token;
    if (element instanceof PsiJavaToken) {
      token = (PsiJavaToken)element;
    }
    else {
      final PsiElement prevSibling = element.getPrevSibling();
      if (prevSibling instanceof PsiJavaToken) {
        token = (PsiJavaToken)prevSibling;
      }
      else {
        throw new AssertionError();
      }
    }
    final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)element.getParent();
    final PsiPolyadicExpression subexpression = ConstantSubexpressionPredicate.getSubexpression(polyadicExpression, token);
    if (subexpression == null) {
      return;
    }
    final Object value = ExpressionUtils.computeConstantExpression(subexpression);
    final @NonNls StringBuilder newExpressionText = new StringBuilder();
    final PsiExpression[] operands = polyadicExpression.getOperands();
    PsiExpression prevOperand = null;
    PsiJavaToken prevToken = null;
    CommentTracker commentTracker = new CommentTracker();
    for (PsiExpression operand : operands) {
      final PsiJavaToken currentToken = polyadicExpression.getTokenBeforeOperand(operand);
      if (prevToken != null) {
        newExpressionText.append(prevToken.getText());
      }
      if (token == currentToken) {
        if (newExpressionText.length() > 0) {
          newExpressionText.append(' ');
        }
        if (value instanceof Long) {
          newExpressionText.append(value).append('L');
        }
        else if (value instanceof Double) {
          final double v = ((Double)value).doubleValue();
          if (Double.isNaN(v)) {
            newExpressionText.append("java.lang.Double.NaN");
          }
          else if (Double.isInfinite(v)) {
            if (v > 0.0) {
              newExpressionText.append("java.lang.Double.POSITIVE_INFINITY");
            }
            else {
              newExpressionText.append("java.lang.Double.NEGATIVE_INFINITY");
            }
          }
          else {
            newExpressionText.append(v);
          }
        }
        else if (value instanceof Float) {
          final float v = ((Float)value).floatValue();
          if (Float.isNaN(v)) {
            newExpressionText.append("java.lang.Float.NaN");
          }
          else if (Float.isInfinite(v)) {
            if (v > 0.0F) {
              newExpressionText.append("java.lang.Float.POSITIVE_INFINITY");
            }
            else {
              newExpressionText.append("java.lang.Float.NEGATIVE_INFINITY");
            }
          }
          else {
            newExpressionText.append(v).append('f');
          }
        }
        else {
          newExpressionText.append(value);
        }
        prevOperand = null;
        prevToken = null;
      }
      else {
        if (prevOperand != null) {
          newExpressionText.append(commentTracker.text(prevOperand));
        }
        prevOperand = operand;
        prevToken = currentToken;
      }
    }
    if (prevToken != null) {
      newExpressionText.append(prevToken.getText());
    }
    if (prevOperand != null) {
      newExpressionText.append(commentTracker.text(prevOperand));
    }

    PsiReplacementUtil.replaceExpression(polyadicExpression, newExpressionText.toString(), commentTracker);
  }
@Override
  public void invoke(@NotNull PsiElement element)