source_files collection evaluation; expand switch to allow file evaluations

This commit is contained in:
Ryan Fleury
2025-07-16 13:52:49 -07:00
parent f6931ef0b7
commit 5e04734444
5 changed files with 77 additions and 14 deletions
+38 -9
View File
@@ -1259,6 +1259,10 @@ ASYNC_WORK_DEF(di_search_work)
{
// NOTE(rjf): name must be determined from self_type_idx
}break;
case RDI_SectionKind_SourceFiles:
{
// NOTE(rjf): name must be determined from file path node chain
}break;
}
//- rjf: loop through table, gather matches
@@ -1288,16 +1292,41 @@ ASYNC_WORK_DEF(di_search_work)
//- rjf: get element, map to string; if empty, continue to next element
void *element = (U8 *)table_base + element_size*idx;
U32 *name_idx_ptr = (U32 *)((U8 *)element + element_name_idx_off);
if(in->section_kind == RDI_SectionKind_UDTs)
String8 name = {0};
switch(in->section_kind)
{
RDI_UDT *udt = (RDI_UDT *)element;
RDI_TypeNode *type_node = rdi_element_from_name_idx(in->rdi, TypeNodes, udt->self_type_idx);
name_idx_ptr = &type_node->user_defined.name_string_idx;
case RDI_SectionKind_UDTs:
{
RDI_UDT *udt = (RDI_UDT *)element;
RDI_TypeNode *type_node = rdi_element_from_name_idx(in->rdi, TypeNodes, udt->self_type_idx);
name_idx_ptr = &type_node->user_defined.name_string_idx;
}break;
case RDI_SectionKind_SourceFiles:
{
Temp scratch = scratch_begin(&arena, 1);
RDI_SourceFile *file = (RDI_SourceFile *)element;
String8List path_parts = {0};
for(RDI_FilePathNode *fpn = rdi_element_from_name_idx(in->rdi, FilePathNodes, file->file_path_node_idx);
fpn != rdi_element_from_name_idx(in->rdi, FilePathNodes, 0);
fpn = rdi_element_from_name_idx(in->rdi, FilePathNodes, fpn->parent_path_node))
{
String8 path_part = {0};
path_part.str = rdi_string_from_idx(in->rdi, fpn->name_string_idx, &path_part.size);
str8_list_push_front(scratch.arena, &path_parts, path_part);
}
StringJoin join = {0};
join.sep = str8_lit("/");
name = str8_list_join(arena, &path_parts, &join);
scratch_end(scratch);
}break;
default:
{
U32 name_idx = *name_idx_ptr;
U64 name_size = 0;
U8 *name_base = rdi_string_from_idx(in->rdi, name_idx, &name_size);
name = str8(name_base, name_size);
}break;
}
U32 name_idx = *name_idx_ptr;
U64 name_size = 0;
U8 *name_base = rdi_string_from_idx(in->rdi, name_idx, &name_size);
String8 name = str8(name_base, name_size);
if(name.size == 0) { continue; }
//- rjf: fuzzy match against query
@@ -1319,7 +1348,7 @@ ASYNC_WORK_DEF(di_search_work)
chunk->v[chunk->count].idx = idx;
chunk->v[chunk->count].dbgi_idx = in->dbgi_idx;
chunk->v[chunk->count].match_ranges = matches;
chunk->v[chunk->count].missed_size = (name_size > matches.total_dim) ? (name_size-matches.total_dim) : 0;
chunk->v[chunk->count].missed_size = (name.size > matches.total_dim) ? (name.size-matches.total_dim) : 0;
chunk->count += 1;
out->items.total_count += 1;
}