Check if a reference node is a definition name (the "name" field of its parent).
| 76 | |
| 77 | // Check if a reference node is a definition name (the "name" field of its parent). |
| 78 | static bool is_definition_name(TSNode node) { |
| 79 | TSNode parent = ts_node_parent(node); |
| 80 | if (ts_node_is_null(parent)) { |
| 81 | return false; |
| 82 | } |
| 83 | TSNode name_field = ts_node_child_by_field_name(parent, TS_FIELD("name")); |
| 84 | return !ts_node_is_null(name_field) && |
| 85 | ts_node_start_byte(name_field) == ts_node_start_byte(node) && |
| 86 | ts_node_end_byte(name_field) == ts_node_end_byte(node); |
| 87 | } |
| 88 | |
| 89 | // Try to emit a usage for a reference node. Returns early if the node should be skipped. |
| 90 | static void try_emit_usage(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec) { |