MCPcopy Create free account
hub / github.com/douglance/devsql / load_with_regex

Function load_with_regex

crates/devsql/src/providers/symbols.rs:136–163  ·  view source on GitHub ↗
(conn: &Connection, repo_path: &Path)

Source from the content-addressed store, hash-verified

134
135#[cfg(not(feature = "tree-sitter-ast"))]
136fn load_with_regex(conn: &Connection, repo_path: &Path) -> Result<()> {
137 ensure_table(conn)?;
138 let files = walk_source_files(repo_path);
139
140 conn.execute_batch("BEGIN")?;
141 let mut insert_stmt = conn.prepare(INSERT_SYMBOL_SQL)?;
142 let mut next_id: i64 = 1;
143
144 for file_info in &files {
145 if file_info.size > MAX_FILE_SIZE {
146 continue;
147 }
148 let language = detect_language(&file_info.extension);
149 let abs_path = repo_path.join(&file_info.path);
150 let Ok(content) = std::fs::read_to_string(&abs_path) else {
151 continue;
152 };
153 let rows = extract_symbols_with_regex(language, &content, &file_info.path, language, &mut next_id);
154 for row in rows {
155 insert_symbol(&mut insert_stmt, &row)?;
156 }
157 }
158
159 drop(insert_stmt);
160 conn.execute_batch("COMMIT")?;
161 create_indexes(conn)?;
162 Ok(())
163}
164
165fn ensure_table(conn: &Connection) -> Result<()> {
166 conn.execute_batch(CREATE_SYMBOLS_TABLE)?;

Callers 1

loadFunction · 0.85

Calls 6

walk_source_filesFunction · 0.85
detect_languageFunction · 0.85
insert_symbolFunction · 0.85
ensure_tableFunction · 0.70
create_indexesFunction · 0.70

Tested by

no test coverage detected