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

Function js_process_call

internal/cbm/extract_channels.c:314–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314static void js_process_call(CBMExtractCtx *ctx, TSNode call, const chan_const_table_t *consts) {
315 TSNode func = ts_node_child_by_field_name(call, TS_FIELD("function"));
316 if (ts_node_is_null(func) || strcmp(ts_node_type(func), "member_expression") != 0) {
317 return;
318 }
319 TSNode object = ts_node_child_by_field_name(func, TS_FIELD("object"));
320 TSNode property = ts_node_child_by_field_name(func, TS_FIELD("property"));
321 if (ts_node_is_null(object) || ts_node_is_null(property)) {
322 return;
323 }
324
325 char *method = cbm_node_text(ctx->arena, property, ctx->source);
326 const char *transport = js_classify_receiver(ctx, object);
327 if (!transport) {
328 return;
329 }
330
331 CBMChannelDirection direction;
332 if (strcmp(transport, "kafka") == 0) {
333 if (js_is_kafka_send(method)) {
334 direction = CBM_CHANNEL_EMIT;
335 } else if (js_is_kafka_listen(method)) {
336 direction = CBM_CHANNEL_LISTEN;
337 } else {
338 return;
339 }
340 } else if (strcmp(transport, "rabbitmq") == 0) {
341 if (js_is_amqp_send(method)) {
342 direction = CBM_CHANNEL_EMIT;
343 } else if (js_is_amqp_listen(method)) {
344 direction = CBM_CHANNEL_LISTEN;
345 } else {
346 return;
347 }
348 } else {
349 /* socketio / event_emitter */
350 if (js_is_emit_method(method)) {
351 direction = CBM_CHANNEL_EMIT;
352 } else if (js_is_listen_method(method)) {
353 direction = CBM_CHANNEL_LISTEN;
354 } else {
355 return;
356 }
357 }
358
359 TSNode args = ts_node_child_by_field_name(call, TS_FIELD("arguments"));
360 if (ts_node_is_null(args)) {
361 return;
362 }
363 const char *channel_name = extract_channel_name(ctx, args, consts);
364 if (!channel_name) {
365 return;
366 }
367 push_channel(ctx, channel_name, transport, direction, call);
368}
369
370static void extract_channels_js(CBMExtractCtx *ctx) {
371 chan_const_table_t consts = {0};

Callers 1

extract_channels_jsFunction · 0.85

Calls 10

cbm_node_textFunction · 0.85
js_classify_receiverFunction · 0.85
js_is_kafka_sendFunction · 0.85
js_is_kafka_listenFunction · 0.85
js_is_amqp_sendFunction · 0.85
js_is_amqp_listenFunction · 0.85
js_is_emit_methodFunction · 0.85
js_is_listen_methodFunction · 0.85
extract_channel_nameFunction · 0.85
push_channelFunction · 0.85

Tested by

no test coverage detected