Compare commits

...

3 Commits

4 changed files with 18 additions and 23 deletions

View File

@ -208,20 +208,6 @@ code_index_unlock(void){
system_mutex_release(global_code_index.mutex);
}
function void
code_index__hash_file(Code_Index_File *file){
// TODO(PS): @RemoveWholeFileHashing - this isn't necessary since, to support incremental updates
// we insert nodes into the hash table when the node is created
#if 0
for (Code_Index_Note *node = file->note_list.first;
node != 0;
node = node->next){
Code_Index_Note_List_New *list = code_index__list_from_string(node->text);
code_index_note_list_hash_insert(list, list->sentinel_last.prev_in_hash, node);
}
#endif
}
function void
code_index__clear_file(Code_Index_File *file){
for (Code_Index_Note *node = file->note_list.first;
@ -249,8 +235,6 @@ code_index_set_file(Buffer_ID buffer, Arena arena, Code_Index_File *index){
}
storage->arena = arena;
storage->file = index;
code_index__hash_file(index);
}
function void
@ -387,8 +371,6 @@ code_index_shift_list(Code_Index_Note_List *list, Range_i64 old_range, u64 new_s
function void
code_index_shift(Code_Index_File *file, Range_i64 old_range, u64 new_size)
{
// TODO(PS): @DontShiftNestList - This is unnecessary now that nest_list just gets fully rebuilt each edit
code_index_shift_list(&file->nest_list, old_range, new_size);
code_index_shift_list(&file->scope_delim_list, old_range, new_size);
code_index_shift_list(&file->note_list, old_range, new_size);
}

View File

@ -35,9 +35,8 @@ BUFFER_HOOK_SIG(custom_begin_buffer){
if (treat_as_code)
{
// TODO(PS): @AsyncrifyThis???
tree_sitter_parse_incremental(app, buffer_id);
tree_sitter_code_index_update_full_file(app, buffer_id);
Async_Task* parse_task_ptr = scope_attachment(app, scope, buffer_parse_task, Async_Task);
*parse_task_ptr = async_task_no_dep(&global_async_system, tree_sitter_parse_full_file_async, make_data_struct(&buffer_id));
}
String_Const_u8 buffer_name = push_buffer_base_name(app, scratch, buffer_id);

View File

@ -325,6 +325,10 @@ tree_sitter_parse_full_file_async(Async_Context* actx, String_Const_u8 data)
ts_tree_delete(old_buffer_tree);
}
tree_sitter_parse_state_destroy(&parse_state);
Managed_Scope scope = buffer_get_managed_scope(app, buffer_id);
Async_Task* code_index_update_task_ptr = scope_attachment(app, scope, buffer_update_code_index_task, Async_Task);
*code_index_update_task_ptr = async_task_no_dep(&global_async_system, tree_sitter_code_index_update_async, make_data_struct(&buffer_id));
}
function void
@ -779,6 +783,16 @@ tree_sitter_code_index_update_tick(Application_Links* app)
ProfileScope(app, "Incremental Parse");
Buffer_ID buffer_id = modified_node->buffer;
Managed_Scope buffer_scope = buffer_get_managed_scope(app, buffer_id);
Async_Task* async_parse_task = scope_attachment(app, buffer_scope, buffer_parse_task, Async_Task);
Async_Task* async_code_index_update_task = scope_attachment(app, buffer_scope, buffer_update_code_index_task, Async_Task);
if (async_task_is_running_or_pending(&global_async_system, *async_parse_task)) {
async_task_wait(app, &global_async_system, *async_parse_task);
}
if (async_task_is_running_or_pending(&global_async_system, *async_code_index_update_task)) {
async_task_wait(app, &global_async_system, *async_code_index_update_task);
}
Buffer_Tree_Sitter_Data* tree_data = scope_attachment(app, buffer_scope, buffer_tree_sitter_data_id, Buffer_Tree_Sitter_Data);
if (!tree_data || !tree_data->tree) continue;

View File

@ -105,8 +105,8 @@ struct Tree_Sitter_Code_Index_Update_State
global Tree_Sitter_Languages tree_sitter_languages;
CUSTOM_ID(attachment, buffer_tree_sitter_data_id);
CUSTOM_ID(attachment, buffer_tree_sitter_parse_task_id);
CUSTOM_ID(attachment, buffer_tree_sitter_update_code_index_task_id);
CUSTOM_ID(attachment, buffer_parse_task);
CUSTOM_ID(attachment, buffer_update_code_index_task);
b8 use_tree_sitter_code_indexing = true;
b8 use_tree_sitter_token_coloring = true;