compresses multiple consecutive SET clauses into a single SET clause
| 167 | |
| 168 | // compresses multiple consecutive SET clauses into a single SET clause |
| 169 | static void _replace_set_clause |
| 170 | ( |
| 171 | cypher_astnode_t *root, // ast root |
| 172 | cypher_astnode_t **clauses, // clause being replaced |
| 173 | int scope_start, // beginning of scope |
| 174 | int scope_end, // ending of scope |
| 175 | replace_func replace // replace function pointer |
| 176 | ) { |
| 177 | uint count = array_len(clauses); |
| 178 | |
| 179 | struct cypher_input_range range = cypher_astnode_range(clauses[0]); |
| 180 | cypher_astnode_t **items = array_new(cypher_astnode_t *, count); |
| 181 | |
| 182 | for (uint i = 0; i < count; i++) { |
| 183 | uint nitems = cypher_ast_set_nitems(clauses[i]); |
| 184 | for(uint j = 0; j < nitems; j++) { |
| 185 | const cypher_astnode_t *item = |
| 186 | cypher_ast_set_get_item(clauses[i], j); |
| 187 | array_append(items, cypher_ast_clone(item)); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // build the replacement clause |
| 192 | cypher_astnode_t *new_clause = cypher_ast_set(items, array_len(items), |
| 193 | items, array_len(items), range); |
| 194 | |
| 195 | // replace original clause with the new one |
| 196 | replace(root, new_clause, scope_start, scope_end); |
| 197 | |
| 198 | array_free(items); |
| 199 | } |
| 200 | |
| 201 | // compresses multiple consecutive REMOVE clauses into a single REMOVE clause |
| 202 | static void _replace_remove_clause |
no test coverage detected