Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions rust/rubydex/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use std::collections::HashSet;
use std::path::PathBuf;

/// Project configuration that controls indexing behavior.
#[derive(Debug, Default)]
pub struct Config {
/// Paths to exclude from file discovery during indexing.
excluded_paths: HashSet<PathBuf>,
}

impl Config {
#[must_use]
pub fn new() -> Self {
Self::default()
}

/// Adds paths to exclude from file discovery during indexing. Excluded directories will be skipped entirely during
/// directory traversal.
pub fn exclude_paths(&mut self, paths: Vec<PathBuf>) {
self.excluded_paths.extend(paths);
}

/// Returns the set of paths excluded from file discovery.
#[must_use]
pub fn excluded_paths(&self) -> &HashSet<PathBuf> {
&self.excluded_paths
}
}
1 change: 1 addition & 0 deletions rust/rubydex/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod compile_assertions;
pub mod config;
pub mod diagnostic;
pub mod dot;
pub mod errors;
Expand Down
11 changes: 6 additions & 5 deletions rust/rubydex/src/model/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::hash_map::Entry;
use std::path::PathBuf;

use crate::assert_mem_size;
use crate::config::Config;
use crate::diagnostic::Diagnostic;
use crate::indexing::local_graph::LocalGraph;
use crate::model::built_in::{OBJECT_ID, add_built_in_data};
Expand Down Expand Up @@ -85,8 +86,8 @@ pub struct Graph {
/// Drained by `take_pending_work()` before resolution.
pending_work: Vec<Unit>,

/// Paths to exclude from file discovery during indexing.
excluded_paths: HashSet<PathBuf>,
/// Project configuration
config: Config,
}
assert_mem_size!(Graph, 336);

Expand All @@ -104,7 +105,7 @@ impl Graph {
position_encoding: Encoding::default(),
name_dependents: IdentityHashMap::default(),
pending_work: Vec::default(),
excluded_paths: HashSet::new(),
config: Config::new(),
};

add_built_in_data(&mut graph);
Expand All @@ -126,13 +127,13 @@ impl Graph {
/// Adds paths to exclude from file discovery during indexing. Excluded directories will be skipped entirely during
/// directory traversal.
pub fn exclude_paths(&mut self, paths: Vec<PathBuf>) {
self.excluded_paths.extend(paths);
self.config.exclude_paths(paths);
}

/// Returns the set of paths excluded from file discovery.
#[must_use]
pub fn excluded_paths(&self) -> &HashSet<PathBuf> {
&self.excluded_paths
self.config.excluded_paths()
}

/// # Panics
Expand Down
Loading