first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
@@ -1,7 +1,9 @@
use crate::index::full_source_code_embedding::chunker::{coalesce_fragments, Fragment};
use std::path::Path;
use itertools::Itertools;
use line_span::{LineSpan, LineSpans};
use std::path::Path;
use crate::index::full_source_code_embedding::chunker::{coalesce_fragments, Fragment};
/// Chunks the given file into [`Fragment`]s. Each chunk is at most `num_lines_per_chunk` lines long, and contains at most `max_bytes_per_chunk` bytes.
pub(super) fn chunk_code<'a>(
@@ -1,6 +1,7 @@
use super::*;
use std::path::Path;
use super::*;
#[test]
fn test_chunker() {
let code = "This is some text content\nthat should be chunked\nusing the naive chunker\nbecause the language isn't recognized.";
@@ -48,7 +48,11 @@ pub(super) fn chunk_code<'a>(
// of the allocator).
//
// See: https://github.com/tree-sitter/tree-sitter/issues/3129
#[cfg(all(target_os = "linux", target_env = "gnu", not(feature = "jemalloc")))]
#[cfg(all(
any(target_os = "linux", target_os = "freebsd"),
target_env = "gnu",
not(feature = "jemalloc")
))]
unsafe {
nix::libc::malloc_trim(0);
}
@@ -1,6 +1,7 @@
use std::path::Path;
use languages::language_by_filename;
use warp_util::standardized_path::StandardizedPath;
use super::*;
@@ -33,12 +34,14 @@ fn main() {
"#;
let max_chunk_size = 128;
let language_path =
StandardizedPath::try_new("/test.rs").expect("test path should be absolute");
let chunks = chunk_code(
source_code,
Path::new("test.rs"),
max_chunk_size,
&language_by_filename(Path::new("test.rs"))
&language_by_filename(&language_path)
.expect("Rust language must exist")
.grammar,
)