MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / is_write_occurrence

Function is_write_occurrence

internal/cbm/extract_usages.c:1247–1290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1245}
1246
1247static 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
1292static bool is_argument_container_kind(const char *kind) {
1293 return kind && (strcmp(kind, "arguments") == 0 || strcmp(kind, "argument_list") == 0 ||

Callers 2

try_emit_usageFunction · 0.85
handle_usagesFunction · 0.85

Calls 10

reset_occurrence_cursorFunction · 0.85
occurrence_parentFunction · 0.85
is_value_fieldFunction · 0.85
cbm_kind_in_setFunction · 0.85
kind_in_exact_setFunction · 0.85
assignment_reads_targetFunction · 0.85
node_containsFunction · 0.85
field_contains_nodeFunction · 0.85
named_child_containsFunction · 0.85

Tested by

no test coverage detected