private static int getExpressionPriority(ASTNode expr) {
    IElementType i = expr.getElementType();
    if (i == JavaElementType.ASSIGNMENT_EXPRESSION) {
      return 0;
    }
    else if (i == JavaElementType.CONDITIONAL_EXPRESSION) {
      return 1;
    }
    else if (i == JavaElementType.BINARY_EXPRESSION || i == JavaElementType.POLYADIC_EXPRESSION) {
      PsiElement element = SourceTreeToPsiMap.treeElementToPsi(expr);
      IElementType opType = ((PsiPolyadicExpression)element).getOperationTokenType();
      if (opType == JavaTokenType.OROR) {
        return 2;
      }
      else if (opType == JavaTokenType.ANDAND) {
        return 3;
      }
      else if (opType == JavaTokenType.OR) {
        return 4;
      }
      else if (opType == JavaTokenType.XOR) {
        return 5;
      }
      else if (opType == JavaTokenType.AND) {
        return 6;
      }
      else if (opType == JavaTokenType.EQEQ || opType == JavaTokenType.NE) {
        return 7;
      }
      else if (opType == JavaTokenType.LT || opType == JavaTokenType.GT || opType == JavaTokenType.LE || opType == JavaTokenType.GE) {
        return 8;
      }
      else if (ExpressionParser.SHIFT_OPS.contains(opType)) {
        return 9;
      }
      else if (ExpressionParser.ADDITIVE_OPS.contains(opType)) {
        return 10;
      }
      else if (ExpressionParser.MULTIPLICATIVE_OPS.contains(opType)) {
        return 11;
      }
      return 8;
    }
    else if (i == JavaElementType.INSTANCE_OF_EXPRESSION) {
      return 8;
    }
    else if (i == JavaElementType.PREFIX_EXPRESSION || i == JavaElementType.TYPE_CAST_EXPRESSION) {
      return 12;
    }
    else if (i == JavaElementType.POSTFIX_EXPRESSION || i == JavaElementType.SWITCH_EXPRESSION) {
      return 13;
    }
    else if (i == JavaElementType.LITERAL_EXPRESSION ||
             i == JavaElementType.REFERENCE_EXPRESSION ||
             i == JavaElementType.THIS_EXPRESSION ||
             i == JavaElementType.SUPER_EXPRESSION ||
             i == JavaElementType.PARENTH_EXPRESSION ||
             i == JavaElementType.METHOD_CALL_EXPRESSION ||
             i == JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION ||
             i == JavaElementType.NEW_EXPRESSION ||
             i == JavaElementType.ARRAY_ACCESS_EXPRESSION ||
             i == JavaElementType.ARRAY_INITIALIZER_EXPRESSION ||
             i == JavaElementType.JAVA_CODE_REFERENCE ||
             i == JavaElementType.METHOD_REF_EXPRESSION ||
             i == JavaElementType.LAMBDA_EXPRESSION ||
             i == JavaElementType.EMPTY_EXPRESSION ||
             i == JavaElementType.TEMPLATE_EXPRESSION) {
      return 14;
    }
    else {
      return -1;
    }
  }
private static int getExpressionPriority(ASTNode expr)