| 1245 | } |
| 1246 | |
| 1247 | static bool is_write_occurrence(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec, |
| 1248 | WalkState *state) { |
| 1249 | const CBMOccurrenceSpec *occurrence = &occurrence_specs[ctx->language]; |
| 1250 | TSNode current = node; |
| 1251 | TSTreeCursor *cursor = reset_occurrence_cursor(state, node); |
| 1252 | while (!ts_node_is_null(current)) { |
| 1253 | TSNode parent; |
| 1254 | const char *field; |
| 1255 | if (!occurrence_parent(cursor, current, &parent, &field)) { |
| 1256 | break; |
| 1257 | } |
| 1258 | if (is_value_field(field)) { |
| 1259 | return false; |
| 1260 | } |
| 1261 | bool assignment = |
| 1262 | (spec->assignment_node_types && cbm_kind_in_set(parent, spec->assignment_node_types)) || |
| 1263 | kind_in_exact_set(ts_node_type(parent), occurrence->write_nodes); |
| 1264 | if (ctx->language == CBM_LANG_ELIXIR && |
| 1265 | strcmp(ts_node_type(parent), "binary_operator") == 0) { |
| 1266 | assignment = elixir_binary_operator_binds(ctx, parent); |
| 1267 | } |
| 1268 | if (assignment) { |
| 1269 | if (assignment_reads_target(parent)) { |
| 1270 | return false; |
| 1271 | } |
| 1272 | if (ctx->language == CBM_LANG_LINKERSCRIPT && |
| 1273 | strcmp(ts_node_type(parent), "assignment") == 0) { |
| 1274 | /* This grammar's assignment production has no field map. Its |
| 1275 | * first direct child is the lhs, even when that child is the |
| 1276 | * anonymous location-counter token `.`. */ |
| 1277 | return ts_node_child_count(parent) > 0 && |
| 1278 | node_contains(ts_node_child(parent, 0), node); |
| 1279 | } |
| 1280 | TSNode left = ts_node_child_by_field_name(parent, TS_FIELD("left")); |
| 1281 | if (node_contains(left, node) || field_contains_node(parent, "target", node) || |
| 1282 | field_contains_node(parent, "destination", node)) { |
| 1283 | return true; |
| 1284 | } |
| 1285 | return occurrence->first_named_child_is_write && named_child_contains(parent, 0, node); |
| 1286 | } |
| 1287 | current = parent; |
| 1288 | } |
| 1289 | return false; |
| 1290 | } |
| 1291 | |
| 1292 | static bool is_argument_container_kind(const char *kind) { |
| 1293 | return kind && (strcmp(kind, "arguments") == 0 || strcmp(kind, "argument_list") == 0 || |
no test coverage detected