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

Function cs_first_param_this

internal/cbm/doclink_cs.c:2105–2127  ·  view source on GitHub ↗

True when the first parameter of `params` is written with `this`: an * extension method. The text before the parameter's type says so, whatever * shape the grammar gives the modifier. */

Source from the content-addressed store, hash-verified

2103 * extension method. The text before the parameter's type says so, whatever
2104 * shape the grammar gives the modifier. */
2105static bool cs_first_param_this(const cs_scan_t *s, TSNode params) {
2106 static const char word[] = "this";
2107 if (ts_node_is_null(params)) {
2108 return false;
2109 }
2110 TSNode p = cs_child_of_kind(params, "parameter");
2111 if (ts_node_is_null(p)) {
2112 return false;
2113 }
2114 TSNode ty = cs_field(p, "type");
2115 const char *src = s->ctx->source;
2116 uint32_t a = ts_node_start_byte(p);
2117 uint32_t b = ts_node_is_null(ty) ? ts_node_end_byte(p) : ts_node_start_byte(ty);
2118 uint32_t wl = (uint32_t)(sizeof(word) - SKIP_ONE);
2119 for (uint32_t i = a; i + wl <= b; i++) {
2120 if (memcmp(src + i, word, wl) == 0 &&
2121 (i == a || !cs_word_char((unsigned char)src[i - SKIP_ONE])) &&
2122 (i + wl == b || !cs_word_char((unsigned char)src[i + wl]))) {
2123 return true;
2124 }
2125 }
2126 return false;
2127}
2128
2129/* True for a member `using static` brings in: one declared `static` or
2130 * `const`, an enum's member -- and no extension method. */

Callers 1

cs_member_staticFunction · 0.85

Calls 3

cs_child_of_kindFunction · 0.85
cs_fieldFunction · 0.85
cs_word_charFunction · 0.85

Tested by

no test coverage detected