@@ -152,7 +152,7 @@ fn update_categories_file(rules: BTreeMap<String, RuleInfo>) -> Result<()> {
152152 let categories_path =
153153 project_root ( ) . join ( "crates/pgls_diagnostics_categories/src/categories.rs" ) ;
154154
155- let content = fs2:: read_to_string ( & categories_path) ?;
155+ let mut content = fs2:: read_to_string ( & categories_path) ?;
156156
157157 // Generate splinter rule entries grouped by category
158158 let mut splinter_rules: Vec < ( String , String ) > = rules
@@ -187,14 +187,39 @@ fn update_categories_file(rules: BTreeMap<String, RuleInfo>) -> Result<()> {
187187 let rules_start = "// splinter rules start" ;
188188 let rules_end = "// splinter rules end" ;
189189
190- let new_content = replace_between_markers (
190+ content = replace_between_markers (
191191 & content,
192192 rules_start,
193193 rules_end,
194194 & format ! ( "\n {splinter_entries}\n " ) ,
195195 ) ?;
196196
197- fs2:: write ( categories_path, new_content) ?;
197+ // Generate splinter group entries
198+ let mut groups: Vec < String > = splinter_rules
199+ . iter ( )
200+ . map ( |( group, _) | group. clone ( ) )
201+ . collect ( ) ;
202+ groups. sort ( ) ;
203+ groups. dedup ( ) ;
204+
205+ let mut group_entries = vec ! [ " \" splinter\" ," . to_string( ) ] ;
206+ for group in groups {
207+ group_entries. push ( format ! ( " \" splinter/{}\" ," , group) ) ;
208+ }
209+ let groups_content = group_entries. join ( "\n " ) ;
210+
211+ // Replace content between splinter groups markers
212+ let groups_start = "// Splinter groups start" ;
213+ let groups_end = "// Splinter groups end" ;
214+
215+ content = replace_between_markers (
216+ & content,
217+ groups_start,
218+ groups_end,
219+ & format ! ( "\n {groups_content}\n " ) ,
220+ ) ?;
221+
222+ fs2:: write ( categories_path, content) ?;
198223
199224 Ok ( ( ) )
200225}
0 commit comments