Skip to content

Commit

Permalink
fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jun 17, 2024
1 parent 53bd739 commit 37475b6
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions crates/biome_analyze/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub(crate) enum Categories {
#[derive(Debug, Copy, Clone)]
/// The categories supported by the analyzer.
///
/// The default implementation of this type returns an instance with no categories.
/// The default implementation of this type returns an instance with all the categories.
///
/// Use [RuleCategoriesBuilder] to generate the categories you want to query.
pub struct RuleCategories(BitFlags<Categories>);
Expand All @@ -195,6 +195,11 @@ impl RuleCategories {
Self(empty)
}

pub fn all() -> Self {
let empty: BitFlags<Categories> = BitFlags::all();
Self(empty)
}

/// Checks whether the current categories contain a specific [RuleCategories]
pub fn contains(&self, other: impl Into<RuleCategories>) -> bool {
self.0.contains(other.into().0)
Expand All @@ -203,7 +208,7 @@ impl RuleCategories {

impl Default for RuleCategories {
fn default() -> Self {
Self::empty()
Self::all()
}
}

Expand Down Expand Up @@ -302,7 +307,17 @@ impl schemars::JsonSchema for RuleCategories {
}

#[derive(Debug, Default)]
/// A convenient type to build
/// A convenient type create a [RuleCategories] type
///
/// ```
/// use biome_analyze::{RuleCategoriesBuilder, RuleCategory};
/// let mut categories = RuleCategoriesBuilder::default().with_syntax().with_lint().build();
///
/// assert!(categories.contains(RuleCategory::Lint));
/// assert!(categories.contains(RuleCategory::Syntax));
/// assert!(!categories.contains(RuleCategory::Action));
/// assert!(!categories.contains(RuleCategory::Transformation));
/// ```
pub struct RuleCategoriesBuilder {
flags: BitFlags<Categories>,
}
Expand Down

0 comments on commit 37475b6

Please sign in to comment.