@@ -91,17 +91,30 @@ impl Default for MergeMethod {
9191 }
9292}
9393
94+ #[ derive( Debug , Deserialize , Serialize , Clone , Copy , JsonSchema ) ]
95+ #[ serde( rename_all = "lowercase" ) ]
96+ pub enum DiagnosticFilterPathType {
97+ IN ,
98+ NOT_IN
99+ }
100+
101+ impl Default for DiagnosticFilterPathType {
102+ fn default ( ) -> Self {
103+ DiagnosticFilterPathType :: IN
104+ }
105+ }
106+
94107#[ derive( Debug , Clone , JsonSchema ) ]
95108#[ schemars( deny_unknown_fields) ]
96109pub struct DiagnosticFilter {
97- #[ schemars( with = "String " ) ]
98- pub paths : Pattern ,
110+ #[ schemars( default , schema_with = "regex_vec_schema " ) ]
111+ pub paths : Vec < Pattern > ,
99112 #[ schemars( default , schema_with = "regex_vec_schema" ) ]
100113 pub codes : Vec < Regex > ,
101114 #[ schemars( default ) ]
102115 pub types : Vec < DiagnosticSetting > ,
103- #[ schemars( skip_deserializing ) ]
104- pub negation : bool ,
116+ #[ schemars( default ) ]
117+ pub path_type : DiagnosticFilterPathType ,
105118}
106119
107120/// Serialize the schema as Vec<String> and adds the default
@@ -118,20 +131,21 @@ impl<'de> serde::Deserialize<'de> for DiagnosticFilter {
118131 {
119132 #[ derive( serde:: Deserialize ) ]
120133 struct Helper {
121- paths : String ,
134+ paths : Vec < String > ,
122135 #[ serde( default ) ]
123136 codes : Vec < String > ,
124137 #[ serde( default ) ]
125138 types : Vec < DiagnosticSetting > ,
139+ #[ serde( default ) ]
140+ path_type : DiagnosticFilterPathType ,
126141 }
127142 let helper = Helper :: deserialize ( deserializer) ?;
128- let ( path_str, negation) = if let Some ( stripped) = helper. paths . strip_prefix ( '!' ) {
129- ( stripped, true )
130- } else {
131- ( helper. paths . as_str ( ) , false )
132- } ;
133- let sanitized_path = PathBuf :: from ( path_str) . sanitize ( ) ;
134- let path_pattern = Pattern :: new ( & sanitized_path) . map_err ( serde:: de:: Error :: custom) ?;
143+ let mut paths = vec ! [ ] ;
144+ for path in helper. paths . iter ( ) {
145+ let sanitized_path = PathBuf :: from ( path) . sanitize ( ) ;
146+ let path_pattern = Pattern :: new ( & sanitized_path) . map_err ( serde:: de:: Error :: custom) ?;
147+ paths. push ( path_pattern) ;
148+ }
135149 let mut code_regexes = Vec :: with_capacity ( helper. codes . len ( ) ) ;
136150 for code in & helper. codes {
137151 let regex = Regex :: new ( code) . map_err ( serde:: de:: Error :: custom) ?;
@@ -143,10 +157,10 @@ impl<'de> serde::Deserialize<'de> for DiagnosticFilter {
143157 }
144158 }
145159 Ok ( DiagnosticFilter {
146- paths : path_pattern ,
160+ paths : paths ,
147161 codes : code_regexes,
148162 types : helper. types ,
149- negation ,
163+ path_type : helper . path_type ,
150164 } )
151165 }
152166}
@@ -158,14 +172,12 @@ impl Serialize for DiagnosticFilter {
158172 {
159173 use serde:: ser:: SerializeStruct ;
160174 let mut s = serializer. serialize_struct ( "DiagnosticFilter" , 3 ) ?;
161- let mut path_str = self . paths . as_str ( ) . to_string ( ) ;
162- if self . negation {
163- path_str = format ! ( "!{}" , path_str) ;
164- }
165- s. serialize_field ( "paths" , & path_str) ?;
175+ let paths: Vec < String > = self . paths . iter ( ) . map ( |p| p. as_str ( ) . to_string ( ) ) . collect ( ) ;
176+ s. serialize_field ( "paths" , & paths) ?;
166177 let codes: Vec < String > = self . codes . iter ( ) . map ( |r| r. as_str ( ) . to_string ( ) ) . collect ( ) ;
167178 s. serialize_field ( "codes" , & codes) ?;
168179 s. serialize_field ( "types" , & self . types ) ?;
180+ s. serialize_field ( "path_type" , & self . path_type ) ?;
169181 s. end ( )
170182 }
171183}
0 commit comments