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. */
| 2103 | * extension method. The text before the parameter's type says so, whatever |
| 2104 | * shape the grammar gives the modifier. */ |
| 2105 | static 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. */ |
no test coverage detected