parse_directory_with_filter

Function parse_directory_with_filter 

Source
pub async fn parse_directory_with_filter(
    dir_path: &str,
    file_filter: &FileFilter,
    options: ParseOptions,
) -> Result<ParsedProject, Error>
Expand description

Parse a project directory with custom file filtering

This function provides advanced filtering capabilities for selecting which files to parse within a directory structure. It combines the standard parsing options with custom filtering criteria.

§Arguments

  • dir_path - Path to the root directory to parse
  • file_filter - Custom filter criteria for file selection
  • options - Configuration options controlling parsing behavior

§Returns

Returns a ParsedProject containing results from all files that match the filter criteria.

§Examples

use tree_parser::{parse_directory_with_filter, ParseOptions, FileFilter, Language};
use std::sync::Arc;
 
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let filter = FileFilter {
        languages: Some(vec![Language::Rust, Language::Python]),
        extensions: None,
        min_size_bytes: Some(100),
        max_size_bytes: Some(100_000),
        custom_predicate: Some(Arc::new(|path| {
            !path.to_string_lossy().contains("test")
        })),
    };
     
    let options = ParseOptions::default();
    let project = parse_directory_with_filter("./src", &filter, options).await?;
     
    println!("Parsed {} filtered files", project.total_files_processed);
    Ok(())
}