@@ -30,7 +30,7 @@ pub enum Transpilers {
3030 ValidationTranspiler ,
3131}
3232
33- #[ derive( Deserialize , Clone , Debug ) ]
33+ #[ derive( Deserialize , Clone , Debug , Default ) ]
3434#[ serde( rename_all = "camelCase" ) ]
3535pub struct TransformConfig {
3636 pub file_name : String ,
@@ -40,18 +40,6 @@ pub struct TransformConfig {
4040 pub context_symbols : HashMap < String , String > ,
4141}
4242
43- impl Default for TransformConfig {
44- fn default ( ) -> Self {
45- Self {
46- file_name : String :: new ( ) ,
47- transpilers : Vec :: new ( ) ,
48- cube_names : HashSet :: new ( ) ,
49- cube_symbols : HashMap :: new ( ) ,
50- context_symbols : HashMap :: new ( ) ,
51- }
52- }
53- }
54-
5543#[ derive( Serialize , Clone , Debug ) ]
5644#[ serde( rename_all = "camelCase" ) ]
5745pub struct TransformResult {
@@ -84,7 +72,9 @@ pub fn run_transpilers(
8472 } ;
8573
8674 let sm_cell = OnceCell :: new ( ) ;
87- sm_cell. set ( sf. clone ( ) ) . map_err ( |_err| anyhow ! ( "Failed to init OnceCell with source file" ) ) ?;
75+ sm_cell
76+ . set ( sf. clone ( ) )
77+ . map_err ( |_err| anyhow ! ( "Failed to init OnceCell with source file" ) ) ?;
8878
8979 let plugin_source_map = PluginSourceMapProxy {
9080 source_file : sm_cell,
@@ -95,30 +85,26 @@ pub fn run_transpilers(
9585 . into_iter ( )
9686 . for_each ( |transpiler| match transpiler {
9787 Transpilers :: CubeCheckDuplicatePropTranspiler => {
98- let mut visitor = CheckDupPropTransformVisitor {
99- source_map : Some ( plugin_source_map. clone ( ) ) ,
100- } ;
88+ let mut visitor =
89+ CheckDupPropTransformVisitor :: new ( Some ( plugin_source_map. clone ( ) ) ) ;
10190 program. visit_mut_with ( & mut visitor) ;
10291 }
10392 Transpilers :: CubePropContextTranspiler => {
104- let mut visitor = CubePropTransformVisitor {
105- cube_names : transform_config. cube_names . clone ( ) ,
106- cube_symbols : transform_config. cube_symbols . clone ( ) ,
107- context_symbols : transform_config. context_symbols . clone ( ) ,
108- source_map : Some ( plugin_source_map. clone ( ) ) ,
109- } ;
93+ let mut visitor = CubePropTransformVisitor :: new (
94+ transform_config. cube_names . clone ( ) ,
95+ transform_config. cube_symbols . clone ( ) ,
96+ transform_config. context_symbols . clone ( ) ,
97+ Some ( plugin_source_map. clone ( ) ) ,
98+ ) ;
11099 program. visit_mut_with ( & mut visitor) ;
111100 }
112101 Transpilers :: ImportExportTranspiler => {
113- let mut visitor = ImportExportTransformVisitor {
114- source_map : Some ( plugin_source_map. clone ( ) ) ,
115- } ;
102+ let mut visitor =
103+ ImportExportTransformVisitor :: new ( Some ( plugin_source_map. clone ( ) ) ) ;
116104 program. visit_mut_with ( & mut visitor) ;
117105 }
118106 Transpilers :: ValidationTranspiler => {
119- let mut visitor = ValidationTransformVisitor {
120- source_map : Some ( plugin_source_map. clone ( ) ) ,
121- } ;
107+ let mut visitor = ValidationTransformVisitor :: new ( Some ( plugin_source_map. clone ( ) ) ) ;
122108 program. visit_mut_with ( & mut visitor) ;
123109 }
124110 } ) ;
0 commit comments