MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / AST_ToString

Function AST_ToString

src/ast/ast.c:677–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675}
676
677const 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
711cypher_parse_result_t *parse_query
712(

Callers 15

AST_PreparePathCreationFunction · 0.85
_AST_MapReferencedNodeFunction · 0.85
_AST_MapReferencedEdgeFunction · 0.85
_AR_EXP_FromASTNodeFunction · 0.85
_QueryGraphAddNodeFunction · 0.85
_QueryGraphAddEdgeFunction · 0.85
_QueryGraph_ExtractNodeFunction · 0.85
_QueryGraph_ExtractEdgeFunction · 0.85
_QueryGraph_ExtractPathFunction · 0.85
QueryGraph_AddPathFunction · 0.85

Calls 4

QueryCtx_GetQueryCtxFunction · 0.85
QueryCtx_GetASTFunction · 0.85
_create_anon_aliasFunction · 0.85

Tested by

no test coverage detected