88
99use crate :: { config, semantic} ;
1010
11+ /// Responsible to transform the semantic of an executed command.
12+ pub trait Transformation : Send {
13+ fn apply ( & self , _: semantic:: CompilerCall ) -> anyhow:: Result < semantic:: CompilerCall > ;
14+ }
15+
1116/// FilterAndFormat is a transformation that filters and formats the compiler calls.
1217pub struct FilterAndFormat {
1318 filter : filter:: SemanticFilter ,
1419 formatter : formatter:: PathFormatter ,
1520}
1621
17- impl semantic :: Transformation for FilterAndFormat {
22+ impl Transformation for FilterAndFormat {
1823 fn apply ( & self , input : semantic:: CompilerCall ) -> anyhow:: Result < semantic:: CompilerCall > {
1924 let candidate = self . filter . apply ( input) ?;
2025 let formatted = self . formatter . apply ( candidate) ?;
@@ -67,7 +72,7 @@ mod formatter {
6772 //! file paths. In the current implementation, the `arguments` attribute is not
6873 //! transformed.
6974
70- use crate :: { config , semantic } ;
75+ use super :: * ;
7176 use std:: env;
7277 use std:: path:: { Path , PathBuf } ;
7378
@@ -78,7 +83,7 @@ mod formatter {
7883 SkipFormat ,
7984 }
8085
81- impl semantic :: Transformation for PathFormatter {
86+ impl Transformation for PathFormatter {
8287 fn apply ( & self , call : semantic:: CompilerCall ) -> anyhow:: Result < semantic:: CompilerCall > {
8388 match self {
8489 PathFormatter :: SkipFormat => Ok ( call) ,
@@ -169,7 +174,7 @@ mod formatter {
169174}
170175
171176mod filter {
172- use crate :: { config , semantic } ;
177+ use super :: * ;
173178 use anyhow:: anyhow;
174179 use std:: collections:: HashMap ;
175180 use std:: path:: PathBuf ;
@@ -184,7 +189,7 @@ mod filter {
184189 compilers : HashMap < PathBuf , Vec < config:: Compiler > > ,
185190 }
186191
187- impl semantic :: Transformation for SemanticFilter {
192+ impl Transformation for SemanticFilter {
188193 fn apply ( & self , input : semantic:: CompilerCall ) -> anyhow:: Result < semantic:: CompilerCall > {
189194 if let Some ( configs) = self . compilers . get ( & input. compiler ) {
190195 Self :: apply_when_match_compiler ( configs. as_slice ( ) , input)
@@ -310,7 +315,8 @@ mod filter {
310315 mod tests {
311316 use super :: * ;
312317 use crate :: config:: { Arguments , Compiler , IgnoreOrConsider } ;
313- use crate :: semantic:: { CompilerCall , CompilerPass , Transformation } ;
318+ use crate :: semantic:: transformation:: Transformation ;
319+ use crate :: semantic:: { CompilerCall , CompilerPass } ;
314320 use std:: path:: PathBuf ;
315321
316322 #[ test]
0 commit comments