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

Function resolve_param_name

internal/cbm/extract_defs.c:4615–4652  ·  view source on GitHub ↗

Extract param_names from a parameter list node. Returns NULL-terminated arena-allocated array. Extract the parameter name from a single parameter AST node.

Source from the content-addressed store, hash-verified

4613// Returns NULL-terminated arena-allocated array.
4614// Extract the parameter name from a single parameter AST node.
4615static char *resolve_param_name(CBMArena *a, TSNode param, const char *source) {
4616 const char *pk = ts_node_type(param);
4617
4618 if (strcmp(pk, "argument") == 0 || strcmp(pk, "tag_parameter") == 0) {
4619 TSNode name = find_first_descendant_by_kind(param, "objectscript_identifier", 6);
4620 if (ts_node_is_null(name)) {
4621 name = find_first_descendant_by_kind(param, "objectscript_identifier_special", 6);
4622 }
4623 return ts_node_is_null(name) ? NULL : cbm_node_text(a, name, source);
4624 }
4625
4626 if (strcmp(pk, "parameter_declaration") == 0) {
4627 TSNode nm = ts_node_child_by_field_name(param, TS_FIELD("name"));
4628 if (!ts_node_is_null(nm)) {
4629 return cbm_node_text(a, nm, source);
4630 }
4631 return NULL;
4632 }
4633 if (strcmp(pk, "identifier") == 0) {
4634 return cbm_node_text(a, param, source);
4635 }
4636 if (strcmp(pk, "formal_parameter") == 0 || strcmp(pk, "parameter") == 0 ||
4637 strcmp(pk, "required_parameter") == 0 || strcmp(pk, "optional_parameter") == 0 ||
4638 strcmp(pk, "simple_parameter") == 0 || strcmp(pk, "typed_parameter") == 0 ||
4639 strcmp(pk, "default_parameter") == 0 || strcmp(pk, "typed_default_parameter") == 0) {
4640 TSNode nm = ts_node_child_by_field_name(param, TS_FIELD("name"));
4641 if (ts_node_is_null(nm)) {
4642 nm = ts_node_child_by_field_name(param, TS_FIELD("pattern"));
4643 }
4644 if (!ts_node_is_null(nm)) {
4645 if (strcmp(ts_node_type(nm), "identifier") == 0 ||
4646 strcmp(ts_node_type(nm), "simple_identifier") == 0) {
4647 return cbm_node_text(a, nm, source);
4648 }
4649 }
4650 }
4651 return NULL;
4652}
4653
4654static const char **extract_param_names(CBMArena *a, TSNode params, const char *source,
4655 CBMLanguage lang) {

Callers 3

extract_param_namesFunction · 0.85
signature_receiver_nameFunction · 0.85
emit_class_defFunction · 0.85

Calls 2

cbm_node_textFunction · 0.85

Tested by

no test coverage detected