@@ -82,7 +82,7 @@ static bool try_append_ident(const char *source, uint32_t s, int len, uint32_t *
8282/* Walk AST body, collect unique identifier text as space-separated string.
8383 * Returns arena-allocated string or NULL. */
8484static char * extract_body_ident_tokens (CBMExtractCtx * ctx , TSNode body ) {
85- enum { BT_STACK = 512 , BT_BUF = 512 , BT_MAX_IDENTS = 40 , BT_SEEN = 128 , BT_SEEN_MASK = 127 };
85+ enum { BT_STACK = 512 , BT_BUF = 2048 , BT_MAX_IDENTS = 128 , BT_SEEN = 256 , BT_SEEN_MASK = 255 };
8686 TSNode bt_stack [BT_STACK ];
8787 int bt_top = 0 ;
8888 bt_stack [bt_top ++ ] = body ;
@@ -98,9 +98,13 @@ static char *extract_body_ident_tokens(CBMExtractCtx *ctx, TSNode body) {
9898 if (nc == 0 ) {
9999 const char * k = ts_node_type (nd );
100100 if (strcmp (k , "identifier" ) == 0 || strcmp (k , "field_identifier" ) == 0 ||
101- strcmp (k , "property_identifier" ) == 0 ||
101+ strcmp (k , "property_identifier" ) == 0 || strcmp ( k , "type_identifier" ) == 0 ||
102102 strcmp (k , "objectscript_identifier" ) == 0 ||
103- strcmp (k , "identifier_segment_immediate" ) == 0 ) {
103+ strcmp (k , "objectscript_identifier_special" ) == 0 ||
104+ strcmp (k , "identifier_segment_immediate" ) == 0 ||
105+ strcmp (k , "identifier_segment_immediate_special" ) == 0 ||
106+ strcmp (k , "class_name" ) == 0 || strcmp (k , "method_name" ) == 0 ||
107+ strcmp (k , "routine_name" ) == 0 || strcmp (k , "quote_permitting_identifier" ) == 0 ) {
104108 uint32_t s = ts_node_start_byte (nd );
105109 int len = (int )(ts_node_end_byte (nd ) - s );
106110 if (len > 0 && len < CBM_SZ_64 && s < (uint32_t )ctx -> source_len ) {
@@ -130,6 +134,10 @@ static void compute_fingerprint(CBMExtractCtx *ctx, CBMDefinition *def, TSNode f
130134 if (ts_node_is_null (body )) {
131135 body = func_node ;
132136 }
137+ /* Extract raw identifier tokens from body for semantic search — before MinHash gate
138+ * so short functions still get body_tokens even without a fingerprint. */
139+ def -> body_tokens = extract_body_ident_tokens (ctx , body );
140+
133141 cbm_minhash_t result ;
134142 if (!cbm_minhash_compute (body , ctx -> source , (int )ctx -> language , & result )) {
135143 return ; /* Too short or empty — no fingerprint */
@@ -157,9 +165,6 @@ static void compute_fingerprint(CBMExtractCtx *ctx, CBMDefinition *def, TSNode f
157165 cbm_ast_profile_to_str (& profile , sp_buf , sizeof (sp_buf ));
158166 def -> structural_profile = cbm_arena_strdup (ctx -> arena , sp_buf );
159167 }
160-
161- /* Extract raw identifier tokens from body for semantic search */
162- def -> body_tokens = extract_body_ident_tokens (ctx , body );
163168}
164169
165170// Tree-sitter row is 0-based; lines are 1-based.
0 commit comments