MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / new

Method new

atomic-repository/src/content_search.rs:291–328  ·  view source on GitHub ↗
(
        paths: impl IntoIterator<Item = &'path str>,
        pattern: &str,
        opts: ContentSearchOptions,
    )

Source from the content-addressed store, hash-verified

289 Ok(result)
290 }
291 pub(crate) fn new<'path>(
292 paths: impl IntoIterator<Item = &'path str>,
293 pattern: &str,
294 opts: ContentSearchOptions,
295 ) -> Result<Self, ContentSearchError> {
296 // Compile even for empty scopes and zero display limits.
297 let re = regex::bytes::RegexBuilder::new(pattern)
298 .case_insensitive(opts.case_insensitive)
299 .size_limit(RECORDED_CONTENT_LIMIT)
300 .dfa_size_limit(RECORDED_CONTENT_LIMIT)
301 .build()
302 .map_err(|error| ContentSearchError::InvalidPattern(error.to_string()))?;
303 let mut paths: Vec<_> = paths.into_iter().map(std::path::PathBuf::from).collect();
304 paths.sort();
305 let index = syntext::path::PathIndex::build(&paths);
306 let filter = syntext::path::filter::build_filter(
307 &index,
308 opts.file_type.as_deref(),
309 opts.exclude_type.as_deref(),
310 opts.path_filter.as_deref(),
311 );
312 let mut paths: Vec<_> = paths
313 .into_iter()
314 .enumerate()
315 .filter(|(id, _)| {
316 filter
317 .as_ref()
318 .is_none_or(|filter| filter.file_ids.contains(*id as u32))
319 })
320 .map(|(_, path)| path.to_string_lossy().into_owned())
321 .collect();
322 paths.sort_by(|a, b| recorded_path_order(a, b));
323 Ok(Self {
324 re,
325 paths,
326 display_limit: opts.max_results.unwrap_or(50),
327 })
328 }
329
330 pub(crate) fn run<E>(
331 self,

Callers

nothing calls this directly

Calls 8

recorded_path_orderFunction · 0.85
sortMethod · 0.80
as_refMethod · 0.80
buildFunction · 0.50
buildMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected