New word complete

master
Allen Webster 2019-07-14 15:18:59 -07:00
parent 706370b553
commit 8c54e8345e
6 changed files with 207 additions and 982 deletions

View File

@ -32,10 +32,10 @@
#include "4coder_lib/4coder_string.h"
#include "4coder_lib/4coder_utf8.h"
#include "4coder_lib/4cpp_lexer.h"
#include "4coder_table.h"
#include "4coder_api_transition_30_31.h"
#include "4coder_string_match.cpp"
#include "4coder_helper.h"
#include "4coder_insertion.h"
#include "4coder_fancy.h"
@ -54,8 +54,10 @@
#include "4coder_scope_commands.h"
#include "4coder_combined_write_commands.h"
#include "4coder_buffer_seek_constructors.cpp"
#include "4coder_hash_functions.cpp"
#include "4coder_table.cpp"
#include "4coder_string_match.cpp"
#include "4coder_buffer_seek_constructors.cpp"
#include "4coder_api_transition_30_31.cpp"

View File

@ -405,17 +405,17 @@ static Command_Metadata fcoder_metacmd_table[237] = {
{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 555 },
{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 565 },
{ PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 575 },
{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 29, 164 },
{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 29, 170 },
{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\4coder_search.cpp", 29, 176 },
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 29, 182 },
{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 188 },
{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 194 },
{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 200 },
{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 206 },
{ PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\4coder_search.cpp", 29, 212 },
{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 29, 220 },
{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 229 },
{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 29, 162 },
{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 29, 168 },
{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\4coder_search.cpp", 29, 174 },
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 29, 180 },
{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 186 },
{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 192 },
{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 198 },
{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 204 },
{ PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\4coder_search.cpp", 29, 210 },
{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 29, 218 },
{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 372 },
{ PROC_LINKS(goto_jump_at_cursor_direct, 0), "goto_jump_at_cursor_direct", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 8 },
{ PROC_LINKS(goto_jump_at_cursor_same_panel_direct, 0), "goto_jump_at_cursor_same_panel_direct", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list..", 168, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 31 },
{ PROC_LINKS(goto_next_jump_direct, 0), "goto_next_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 52 },

View File

@ -1074,6 +1074,15 @@ enclose_pos_alpha_numeric_underscore(Application_Links *app, Buffer_ID buffer, i
return(enclose_boundary(app, buffer, Ii64(pos), boundary_alpha_numeric_underscore));
}
static Range_i64
enclose_alpha_numeric_underscore_utf8(Application_Links *app, Buffer_ID buffer, Range_i64 range){
return(enclose_boundary(app, buffer, range, boundary_alpha_numeric_underscore_utf8));
}
static Range_i64
enclose_pos_alpha_numeric_underscore_utf8(Application_Links *app, Buffer_ID buffer, i64 pos){
return(enclose_boundary(app, buffer, Ii64(pos), boundary_alpha_numeric_underscore_utf8));
}
static Range_i64
enclose_alpha_numeric_camel(Application_Links *app, Buffer_ID buffer, Range_i64 range){
return(enclose_boundary(app, buffer, range, boundary_alpha_numeric_camel));
@ -1485,6 +1494,12 @@ find_all_matches_all_buffers(Application_Links *app, Arena *arena, String_Const_
return(all_matches);
}
internal String_Match_List
find_all_matches_all_buffers(Application_Links *app, Arena *arena, String_Const_u8 pattern, String_Match_Flag must_have_flags, String_Match_Flag must_not_have_flags){
String_Const_u8_Array array = {&pattern, 1};
return(find_all_matches_all_buffers(app, arena, array, must_have_flags, must_not_have_flags));
}
////////////////////////////////
static void

File diff suppressed because it is too large Load Diff

View File

@ -7,111 +7,19 @@
#if !defined(FCODER_SEARCH_H)
#define FCODER_SEARCH_H
/* TODO(allen):
Time to rewrite _ALL_ of this s***f.
[x] 1. String matching optimization study
[x] 2. Redesign and reimplement find_all_in_range
[x] 3. Filtering and reversing string lists
[ ] 4. Clean prefix match iterator
[ ] 5. Reimplement commands in 4coder_search.cpp
[ ] 6. Ditch all the old s***f we don't want anymore
[ ] 7. Reorganize, rename, etc.
*/
#define Migrate__Match_Iterator 1
////////////////////////////////
typedef u32 List_All_Locations_Flag;
enum{
ListAllLocationsFlag_CaseSensitive = 1,
ListAllLocationsFlag_MatchSubstring = 2,
};
////////////////////////////////
#if !Migrate__Match_Iterator
// TODO(allen): deprecate all this
typedef i32 Seek_Potential_Match_Direction;
enum{
SeekPotentialMatch_Forward = 0,
SeekPotentialMatch_Backward = 1,
};
enum{
FindResult_None,
FindResult_FoundMatch,
FindResult_PastEnd,
};
typedef i32 Search_Range_Type;
enum{
SearchRange_FrontToBack = 0,
SearchRange_BackToFront = 1,
SearchRange_Wave = 2,
};
typedef u32 Search_Range_Flag;
enum{
SearchFlag_MatchWholeWord = 0x0000,
SearchFlag_MatchWordPrefix = 0x0001,
SearchFlag_MatchSubstring = 0x0002,
SearchFlag_MatchMask = 0x00FF,
SearchFlag_CaseInsensitive = 0x0100,
};
struct Search_Range{
Search_Range_Type type;
Search_Range_Flag flags;
Buffer_ID buffer;
i32 start;
i32 size;
i32 mid_start;
i32 mid_size;
};
struct Search_Set{
Search_Range *ranges;
i32 count;
i32 max;
};
struct Search_Key{
u8 *base;
umem base_size;
umem min_size;
String_Const_u8 words[16];
i32 count;
};
struct Search_Iter{
Search_Key key;
i32 pos;
i32 back_pos;
i32 i;
i32 range_initialized;
};
struct Search_Match{
Buffer_ID buffer;
i32 start;
i32 end;
i32 match_word_index;
i32 found_match;
};
struct Word_Complete_State{
Search_Set set;
Search_Iter iter;
Table hits;
String_Space str;
i32 word_start;
i32 word_end;
i32 initialized;
b32 initialized;
String_Const_u8 needle;
Range_i64 range;
List_String_Const_u8 list;
Node_String_Const_u8 *iterator;
};
#endif
#endif

View File

@ -33,6 +33,12 @@ make_table_u64_u64(Base_Allocator *allocator, u32 slot_count){
return(table);
}
internal void
table_free(Table_u64_u64 *table){
base_free(table->allocator, table->memory);
block_zero_struct(table);
}
internal Table_Lookup
table_lookup(Table_u64_u64 *table, u64 key){
Table_Lookup result = {};
@ -128,7 +134,7 @@ table_insert(Table_u64_u64 *table, u64 key, u64 val){
}
Table_u64_u64 new_table = make_table_u64_u64(table->allocator, new_slot_count);
table_rehash(&new_table, table);
base_free(table->allocator, table->memory);
table_free(table);
*table = new_table;
lookup = table_lookup(table, key);
Assert(lookup.found_empty_slot);
@ -171,6 +177,12 @@ make_table_Data_u64(Base_Allocator *allocator, u32 slot_count){
return(table);
}
internal void
table_free(Table_Data_u64 *table){
base_free(table->allocator, table->memory);
block_zero_struct(table);
}
internal Table_Lookup
table_lookup(Table_Data_u64 *table, Data key){
u64 *hashes = table->hashes;
@ -266,7 +278,7 @@ table_insert(Table_Data_u64 *table, Data key, u64 val){
}
Table_Data_u64 new_table = make_table_Data_u64(table->allocator, new_slot_count);
table_rehash(&new_table, table);
base_free(table->allocator, table->memory);
table_free(table);
*table = new_table;
lookup = table_lookup(table, key);
Assert(lookup.found_empty_slot);
@ -309,6 +321,12 @@ make_table_u64_Data(Base_Allocator *allocator, u32 slot_count){
return(table);
}
internal void
table_free(Table_u64_Data *table){
base_free(table->allocator, table->memory);
block_zero_struct(table);
}
internal Table_Lookup
table_lookup(Table_u64_Data *table, u64 key){
Table_Lookup result = {};
@ -404,7 +422,7 @@ table_insert(Table_u64_Data *table, u64 key, Data val){
}
Table_u64_Data new_table = make_table_u64_Data(table->allocator, new_slot_count);
table_rehash(&new_table, table);
base_free(table->allocator, table->memory);
table_free(table);
*table = new_table;
lookup = table_lookup(table, key);
Assert(lookup.found_empty_slot);
@ -447,6 +465,12 @@ make_table_Data_Data(Base_Allocator *allocator, u32 slot_count){
return(table);
}
internal void
table_free(Table_Data_Data *table){
base_free(table->allocator, table->memory);
block_zero_struct(table);
}
internal Table_Lookup
table_lookup(Table_Data_Data *table, Data key){
u64 *hashes = table->hashes;
@ -542,7 +566,7 @@ table_insert(Table_Data_Data *table, Data key, Data val){
}
Table_Data_Data new_table = make_table_Data_Data(table->allocator, new_slot_count);
table_rehash(&new_table, table);
base_free(table->allocator, table->memory);
table_free(table);
*table = new_table;
lookup = table_lookup(table, key);
Assert(lookup.found_empty_slot);