Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
86b2032
docs: clarify docs
squidfunk Mar 23, 2026
e6124f5
docs: harmonize docs and tests
squidfunk Mar 23, 2026
971dfe9
docs: add examples
squidfunk Mar 23, 2026
d8cf067
chore: fix doctests
squidfunk Mar 23, 2026
d2ac737
refactor: move `convert` exports to containing modules
squidfunk Mar 23, 2026
6c02f57
style: re-organize exports
squidfunk Mar 23, 2026
f17629f
docs: add doctests
squidfunk Mar 23, 2026
f91316c
docs: add doc comment to `Specificity`
squidfunk Mar 23, 2026
f81e1ba
chore: update dependencies
squidfunk Mar 23, 2026
eb372f6
docs: fix doc comments
squidfunk Mar 23, 2026
a817004
feature: add `Specified` for ordering values by `Specificity`
squidfunk Mar 24, 2026
155315e
docs: improve doc comments
squidfunk Mar 24, 2026
1fd37da
fix: `Specificity` is consumed by `Specified::specificity` accessor
squidfunk Mar 24, 2026
499d66b
feature: add `PartialEq` and `Eq` impls to `Expression` and `Operand`
squidfunk Mar 24, 2026
fadb8c0
docs: add note on ordering to `Specified`
squidfunk Mar 24, 2026
ba22db9
feature: add `Default` impl for `Expression`
squidfunk Mar 24, 2026
e092ce4
fix: always order all-zero `Specificity` first
squidfunk Mar 24, 2026
6293bde
chore: replace `cmp::min` with `Specificity::min`
squidfunk Mar 24, 2026
11b62f1
feature: add `Default` impl for `Specified`
squidfunk Mar 25, 2026
624c4dc
docs: fix comment
squidfunk Mar 25, 2026
2522c17
refactor: store `Character` class as raw string slices
squidfunk Mar 29, 2026
aa9c937
refactor: replace `u32` cast with explicit conversion
squidfunk Mar 29, 2026
941b5ce
docs: improve doc comments
squidfunk Mar 30, 2026
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
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pedantic = { level = "warn", priority = -1 }

[workspace.dependencies]
zrx-diagnostic = { version = "0.0.1", path = "crates/zrx-diagnostic" }
zrx-event = { version = "0.0.1", path = "crates/zrx-event" }
zrx-executor = { version = "0.0.3", path = "crates/zrx-executor" }
zrx-graph = { version = "0.0.10", path = "crates/zrx-graph" }
zrx-id = { version = "0.0.11", path = "crates/zrx-id" }
Expand All @@ -54,7 +53,7 @@ file-id = "0.2.3"
globset = "0.4.18"
notify = "8.2.0"
percent-encoding = "2.3.2"
slab = "0.4.11"
thiserror = "2.0.17"
slab = "0.4.12"
thiserror = "2.0.18"
tracing = "0.1.41"
walkdir = "2.5.0"
2 changes: 1 addition & 1 deletion crates/zrx-graph/src/graph/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl PartialEq for Topology {
/// builder.add_edge(a, b)?;
/// builder.add_edge(b, c)?;
///
/// // Create topology
/// // Create and compare topologies
/// let topology = Topology::new(builder.len(), builder.edges());
/// assert_eq!(topology, topology.clone());
/// # Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/zrx-id/src/id/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub use terms::Terms;
///
/// // Create filter builder and insert expression
/// let mut builder = Filter::builder();
/// builder.insert(Expression::any(|expr| {
/// builder.insert(Expression::all(|expr| {
/// expr.with(selector!(location = "**/*.md")?)?
/// .with(selector!(provider = "file")?)
/// })?);
Expand Down
19 changes: 9 additions & 10 deletions crates/zrx-id/src/id/filter/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use super::Filter;
/// after all modifications were made.
#[derive(Debug, Default)]
pub struct Builder {
/// Conditions.
/// Condition set.
conditions: Slab<Condition>,
}

Expand Down Expand Up @@ -119,8 +119,8 @@ impl Builder {
/// // Create filter builder and insert expression
/// let mut builder = Filter::builder();
/// builder.insert(Expression::any(|expr| {
/// expr.with(selector!(location = "**/*.png")?)?
/// .with(selector!(location = "**/*.jpg")?)
/// expr.with(selector!(location = "**/*.jpg")?)?
/// .with(selector!(location = "**/*.png")?)
/// })?);
/// # Ok(())
/// # }
Expand All @@ -146,8 +146,8 @@ impl Builder {
/// // Create filter builder and insert expression
/// let mut builder = Filter::builder();
/// builder.insert(Expression::any(|expr| {
/// expr.with(selector!(location = "**/*.png")?)?
/// .with(selector!(location = "**/*.jpg")?)
/// expr.with(selector!(location = "**/*.jpg")?)?
/// .with(selector!(location = "**/*.png")?)
/// })?);
///
/// // Remove expression
Expand Down Expand Up @@ -178,16 +178,15 @@ impl Builder {
/// // Create filter builder and insert expression
/// let mut builder = Filter::builder();
/// builder.insert(Expression::any(|expr| {
/// expr.with(selector!(location = "**/*.png")?)?
/// .with(selector!(location = "**/*.jpg")?)
/// expr.with(selector!(location = "**/*.jpg")?)?
/// .with(selector!(location = "**/*.png")?)
/// })?);
///
/// // Create filter from builder
/// let filter = builder.build()?;
/// # Ok(())
/// # }
/// ```
#[allow(clippy::cast_possible_truncation)]
pub fn build(self) -> Result<Filter> {
let mut builder = Matcher::builder();

Expand All @@ -198,7 +197,7 @@ impl Builder {
// Add all terms of each condition to the mapping and matcher
for (index, condition) in &self.conditions {
for term in condition.terms() {
mapping.push(index as u32);
mapping.push(u32::try_from(index)?);
match term {
Term::Id(id) => builder.add(id)?,
Term::Selector(selector) => builder.add(selector)?,
Expand All @@ -209,7 +208,7 @@ impl Builder {
// to the list of negations, so it's always checked when matching
let mut iter = condition.instructions().iter();
if iter.any(|instruction| instruction.operator() == Operator::Not) {
negations.push(index as u32);
negations.push(u32::try_from(index)?);
}
}

Expand Down
30 changes: 15 additions & 15 deletions crates/zrx-id/src/id/filter/candidates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Filter {
///
/// // Create filter builder and insert expression
/// let mut builder = Filter::builder();
/// builder.insert(Expression::any(|expr| {
/// builder.insert(Expression::all(|expr| {
/// expr.with(selector!(location = "**/*.md")?)?
/// .with(selector!(provider = "file")?)
/// })?);
Expand Down Expand Up @@ -200,13 +200,13 @@ mod tests {
fn handles_any() -> Result {
let mut builder = Filter::builder();
let _ = builder.insert(Expression::any(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
})?);
let filter = builder.build()?;
for (id, check) in [
("zri:file:::docs:image.png:", vec![0]),
("zri:file:::docs:image.jpg:", vec![0]),
("zri:file:::docs:image.png:", vec![0]),
("zri:file:::docs:image.gif:", vec![]),
] {
assert_eq!(
Expand Down Expand Up @@ -242,14 +242,14 @@ mod tests {
fn handles_not() -> Result {
let mut builder = Filter::builder();
let _ = builder.insert(Expression::not(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
})?);
let filter = builder.build()?;
for (id, check) in [
("zri:file:::docs:index.md:", vec![0]),
("zri:file:::docs:image.png:", vec![]),
("zri:file:::docs:image.jpg:", vec![]),
("zri:file:::docs:image.png:", vec![]),
] {
assert_eq!(
filter.candidates(&id)?.collect::<Vec<_>>(), // fmt
Expand All @@ -265,18 +265,18 @@ mod tests {
let _ = builder.insert(Expression::all(|expr| {
expr.with(selector!(provider = "file")?)?
.with(Expression::any(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
}))
})?);
let filter = builder.build()?;
for (id, check) in [
("zri:file:::docs:index.md:", vec![]),
("zri:file:::docs:image.png:", vec![0]),
("zri:file:::docs:image.jpg:", vec![0]),
("zri:file:::docs:image.png:", vec![0]),
("zri:file:::docs:image.gif:", vec![]),
("zri:git:::docs:image.png:", vec![]),
("zri:git:::docs:image.jpg:", vec![]),
("zri:git:::docs:image.png:", vec![]),
] {
assert_eq!(
filter.candidates(&id)?.collect::<Vec<_>>(), // fmt
Expand All @@ -294,20 +294,20 @@ mod tests {
.with(Expression::any(|expr| {
expr.with(selector!(context = "docs")?)? // fmt
.with(Expression::not(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
}),
)
}))
})?);
let filter = builder.build()?;
for (id, check) in [
("zri:file:::docs:index.md:", vec![0]),
("zri:file:::docs:image.png:", vec![0]),
("zri:file:::docs:image.jpg:", vec![0]),
("zri:file:::docs:image.png:", vec![0]),
("zri:file:::docs:image.gif:", vec![0]),
("zri:git:::docs:image.png:", vec![]),
("zri:git:::docs:image.jpg:", vec![]),
("zri:git:::docs:image.png:", vec![]),
] {
assert_eq!(
filter.candidates(&id)?.collect::<Vec<_>>(), // fmt
Expand Down
32 changes: 16 additions & 16 deletions crates/zrx-id/src/id/filter/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ mod tests {
#[test]
fn handles_any() -> Result {
let expr = Expression::any(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
})?;
let condition = Condition::builder(expr).build();
for (matches, check) in [
Expand All @@ -162,8 +162,8 @@ mod tests {
#[test]
fn handles_any_optimized() -> Result {
let expr = Expression::any(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
})?;
let condition = Condition::builder(expr).optimize().build();
for (matches, check) in [
Expand Down Expand Up @@ -222,8 +222,8 @@ mod tests {
#[test]
fn handles_not() -> Result {
let expr = Expression::not(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
})?;
let condition = Condition::builder(expr).build();
for (matches, check) in [
Expand All @@ -242,8 +242,8 @@ mod tests {
#[test]
fn handles_not_optimized() -> Result {
let expr = Expression::not(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
})?;
let condition = Condition::builder(expr).optimize().build();
for (matches, check) in [
Expand All @@ -264,8 +264,8 @@ mod tests {
let expr = Expression::all(|expr| {
expr.with(selector!(provider = "file")?)?
.with(Expression::any(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
}))
})?;
let condition = Condition::builder(expr).build();
Expand All @@ -289,8 +289,8 @@ mod tests {
let expr = Expression::all(|expr| {
expr.with(selector!(provider = "file")?)?
.with(Expression::any(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
}))
})?;
let condition = Condition::builder(expr).optimize().build();
Expand All @@ -316,8 +316,8 @@ mod tests {
.with(Expression::any(|expr| {
expr.with(selector!(context = "docs")?)? // fmt
.with(Expression::not(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
}),
)
}))
Expand Down Expand Up @@ -347,8 +347,8 @@ mod tests {
.with(Expression::any(|expr| {
expr.with(selector!(context = "docs")?)? // fmt
.with(Expression::not(|expr| {
expr.with(selector!(location = "**/*.png")?)?
.with(selector!(location = "**/*.jpg")?)
expr.with(selector!(location = "**/*.jpg")?)?
.with(selector!(location = "**/*.png")?)
}),
)
}))
Expand Down
Loading