(conn: &Connection, repo_path: &Path)
| 134 | |
| 135 | #[cfg(not(feature = "tree-sitter-ast"))] |
| 136 | fn 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 | |
| 165 | fn ensure_table(conn: &Connection) -> Result<()> { |
| 166 | conn.execute_batch(CREATE_SYMBOLS_TABLE)?; |
no test coverage detected