| 675 | } |
| 676 | |
| 677 | const char *AST_ToString |
| 678 | ( |
| 679 | const cypher_astnode_t *node |
| 680 | ) { |
| 681 | QueryCtx *ctx = QueryCtx_GetQueryCtx(); |
| 682 | AST *ast = QueryCtx_GetAST(); |
| 683 | AnnotationCtx *to_string_ctx = AST_AnnotationCtxCollection_GetToStringCtx(ast->anot_ctx_collection); |
| 684 | |
| 685 | char *str = (char *)cypher_astnode_get_annotation(to_string_ctx, node); |
| 686 | if(str == NULL) { |
| 687 | cypher_astnode_type_t t = cypher_astnode_type(node); |
| 688 | const cypher_astnode_t *ast_identifier = NULL; |
| 689 | if(t == CYPHER_AST_NODE_PATTERN) { |
| 690 | ast_identifier = cypher_ast_node_pattern_get_identifier(node); |
| 691 | } else if(t == CYPHER_AST_REL_PATTERN) { |
| 692 | ast_identifier = cypher_ast_rel_pattern_get_identifier(node); |
| 693 | } else { |
| 694 | struct cypher_input_range range = cypher_astnode_range(node); |
| 695 | uint length = range.end.offset - range.start.offset + 1; |
| 696 | str = malloc(sizeof(char) * length); |
| 697 | strncpy(str, ctx->query_data.query_no_params + range.start.offset, length - 1); |
| 698 | str[length - 1] = '\0'; |
| 699 | } |
| 700 | if(ast_identifier) { |
| 701 | // Graph entity has a user-defined alias return it. |
| 702 | return cypher_ast_identifier_get_name(ast_identifier); |
| 703 | } else if(str == NULL) { |
| 704 | str = _create_anon_alias(ast->anot_ctx_collection->anon_count++); |
| 705 | } |
| 706 | cypher_astnode_attach_annotation(to_string_ctx, node, (void *)str, NULL); |
| 707 | } |
| 708 | return str; |
| 709 | } |
| 710 | |
| 711 | cypher_parse_result_t *parse_query |
| 712 | ( |
no test coverage detected