Skip to content

Commit ebce43d

Browse files
committed
rust: rename compiler filter module
1 parent cfe0ef6 commit ebce43d

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

rust/bear/src/semantic/transformation.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub enum Error {
2727

2828
/// FilterAndFormat is a transformation that filters and formats the compiler calls.
2929
pub struct FilterAndFormat {
30-
filter: filter::SemanticFilter,
30+
filter: filter_by_compiler::FilterByCompiler,
3131
formatter: formatter::PathFormatter,
3232
}
3333

@@ -42,7 +42,7 @@ impl Transformation for FilterAndFormat {
4242
#[derive(Debug, Error)]
4343
pub enum FilterAndFormatError {
4444
#[error("Semantic filter configuration error: {0}")]
45-
SemanticFilter(#[from] filter::SemanticFilterError),
45+
FilterByCompiler(#[from] filter_by_compiler::ConfigurationError),
4646
#[error("Path formatter configuration error: {0}")]
4747
PathFormatter(#[from] formatter::PathFormatterError),
4848
}
@@ -73,7 +73,7 @@ impl TryFrom<&config::Output> for FilterAndFormat {
7373
}
7474
config::Output::Semantic { .. } => {
7575
// This will do no filtering and no formatting.
76-
let filter = filter::SemanticFilter::default();
76+
let filter = filter_by_compiler::FilterByCompiler::default();
7777
let formatter = formatter::PathFormatter::default();
7878
Ok(FilterAndFormat { filter, formatter })
7979
}
@@ -508,7 +508,7 @@ mod formatter {
508508
}
509509
}
510510

511-
mod filter {
511+
mod filter_by_compiler {
512512
use super::*;
513513
use std::collections::HashMap;
514514
use std::path::PathBuf;
@@ -519,11 +519,11 @@ mod filter {
519519
/// The transformation groups the instructions by the compiler path, so it can be
520520
/// applied to the compiler call when it matches the path.
521521
#[derive(Default)]
522-
pub struct SemanticFilter {
522+
pub struct FilterByCompiler {
523523
compilers: HashMap<PathBuf, Vec<config::Compiler>>,
524524
}
525525

526-
impl Transformation for SemanticFilter {
526+
impl Transformation for FilterByCompiler {
527527
fn apply(&self, input: semantic::CompilerCall) -> Result<semantic::CompilerCall, Error> {
528528
if let Some(configs) = self.compilers.get(&input.compiler) {
529529
Self::apply_when_match_compiler(configs.as_slice(), input)
@@ -533,7 +533,7 @@ mod filter {
533533
}
534534
}
535535

536-
impl SemanticFilter {
536+
impl FilterByCompiler {
537537
/// Apply the transformation to the compiler call.
538538
///
539539
/// Multiple configurations can be applied to the same compiler call.
@@ -631,7 +631,7 @@ mod filter {
631631
}
632632

633633
#[derive(Debug, Error)]
634-
pub enum SemanticFilterError {
634+
pub enum ConfigurationError {
635635
#[error("'Never' or 'Conditional' can't be used after 'Always' for path {0:?}")]
636636
AfterAlways(path::PathBuf),
637637
#[error("'Never' can't be used after 'Conditional' for path {0:?}")]
@@ -652,8 +652,8 @@ mod filter {
652652
NeverWithArguments(path::PathBuf),
653653
}
654654

655-
impl TryFrom<&[config::Compiler]> for SemanticFilter {
656-
type Error = SemanticFilterError;
655+
impl TryFrom<&[config::Compiler]> for FilterByCompiler {
656+
type Error = ConfigurationError;
657657

658658
/// Validate the configuration of the compiler list.
659659
///
@@ -681,32 +681,32 @@ mod filter {
681681
match compiler.ignore {
682682
// problems with the order of the configuration
683683
IgnoreOrConsider::Conditional if has_conditional => {
684-
return Err(SemanticFilterError::MultipleConditional(path.clone()));
684+
return Err(ConfigurationError::MultipleConditional(path.clone()));
685685
}
686686
IgnoreOrConsider::Always if has_always => {
687-
return Err(SemanticFilterError::MultipleAlways(path.clone()));
687+
return Err(ConfigurationError::MultipleAlways(path.clone()));
688688
}
689689
IgnoreOrConsider::Never if has_never => {
690-
return Err(SemanticFilterError::MultipleNever(path.clone()));
690+
return Err(ConfigurationError::MultipleNever(path.clone()));
691691
}
692692
IgnoreOrConsider::Always | IgnoreOrConsider::Never if has_conditional => {
693-
return Err(SemanticFilterError::AfterConditional(path.clone()));
693+
return Err(ConfigurationError::AfterConditional(path.clone()));
694694
}
695695
IgnoreOrConsider::Always | IgnoreOrConsider::Conditional if has_never => {
696-
return Err(SemanticFilterError::AfterNever(path.clone()));
696+
return Err(ConfigurationError::AfterNever(path.clone()));
697697
}
698698
IgnoreOrConsider::Never | IgnoreOrConsider::Conditional if has_always => {
699-
return Err(SemanticFilterError::AfterAlways(path.clone()));
699+
return Err(ConfigurationError::AfterAlways(path.clone()));
700700
}
701701
// problems with the arguments
702702
IgnoreOrConsider::Always if compiler.arguments != Arguments::default() => {
703-
return Err(SemanticFilterError::AlwaysWithArguments(path.clone()));
703+
return Err(ConfigurationError::AlwaysWithArguments(path.clone()));
704704
}
705705
IgnoreOrConsider::Conditional if compiler.arguments.match_.is_empty() => {
706-
return Err(SemanticFilterError::ConditionalWithoutMatch(path.clone()));
706+
return Err(ConfigurationError::ConditionalWithoutMatch(path.clone()));
707707
}
708708
IgnoreOrConsider::Never if !compiler.arguments.match_.is_empty() => {
709-
return Err(SemanticFilterError::NeverWithArguments(path.clone()));
709+
return Err(ConfigurationError::NeverWithArguments(path.clone()));
710710
}
711711
// update the flags, no problems found
712712
IgnoreOrConsider::Conditional => {
@@ -747,7 +747,7 @@ mod filter {
747747
let expected = input.clone();
748748

749749
let compilers: Vec<Compiler> = vec![];
750-
let sut = SemanticFilter::try_from(compilers.as_slice());
750+
let sut = FilterByCompiler::try_from(compilers.as_slice());
751751
assert!(sut.is_ok());
752752

753753
let result = sut.unwrap().apply(input);
@@ -773,7 +773,7 @@ mod filter {
773773
arguments: Arguments::default(),
774774
}];
775775

776-
let sut = SemanticFilter::try_from(compilers.as_slice());
776+
let sut = FilterByCompiler::try_from(compilers.as_slice());
777777
assert!(sut.is_ok());
778778

779779
let result = sut.unwrap().apply(input);
@@ -801,7 +801,7 @@ mod filter {
801801
},
802802
}];
803803

804-
let sut = SemanticFilter::try_from(compilers.as_slice());
804+
let sut = FilterByCompiler::try_from(compilers.as_slice());
805805
assert!(sut.is_ok());
806806

807807
let result = sut.unwrap().apply(input);
@@ -840,7 +840,7 @@ mod filter {
840840
},
841841
}];
842842

843-
let sut = SemanticFilter::try_from(compilers.as_slice());
843+
let sut = FilterByCompiler::try_from(compilers.as_slice());
844844
assert!(sut.is_ok());
845845

846846
let result = sut.unwrap().apply(input);
@@ -890,7 +890,7 @@ mod filter {
890890
];
891891

892892
for config in valid_configs {
893-
let result = SemanticFilter::try_from(config.as_slice());
893+
let result = FilterByCompiler::try_from(config.as_slice());
894894
assert!(
895895
result.is_ok(),
896896
"Expected valid configuration to pass: {:?}, {}",
@@ -972,7 +972,7 @@ mod filter {
972972
];
973973

974974
for config in invalid_configs {
975-
let result = SemanticFilter::try_from(config.as_slice());
975+
let result = FilterByCompiler::try_from(config.as_slice());
976976
assert!(
977977
result.is_err(),
978978
"Expected invalid configuration to fail: {:?}",

0 commit comments

Comments
 (0)