File tree Expand file tree Collapse file tree 1 file changed +32
-6
lines changed
Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Original file line number Diff line number Diff line change 1+ use itertools:: Itertools ;
2+
13use crate :: prelude:: * ;
24
35use crate :: prelude:: KeywordKind :: * ;
@@ -24,12 +26,18 @@ impl TokenIgnorer for IgnoreNonUnitImportClauses {
2426 lines
2527 . iter ( )
2628 . filter ( |line| line. get_line_type ( ) == LogicalLineType :: ImportClause )
27- . for_each ( |line| {
28- line. get_tokens ( ) . iter ( ) . for_each ( |token| {
29- token_marker. mark ( * token) ;
30- } )
31- } ) ;
29+ . for_each ( |line| self . ignore_clause_line ( line, token_marker) ) ;
30+ } ;
31+ }
32+ }
33+ impl IgnoreNonUnitImportClauses {
34+ fn ignore_clause_line ( & self , line : & LogicalLine , token_marker : & mut TokenMarker ) {
35+ let Some ( ( & start, & end) ) = line. get_tokens ( ) . iter ( ) . minmax ( ) . into_option ( ) else {
36+ return ;
3237 } ;
38+ for token in start..=end {
39+ token_marker. mark ( token) ;
40+ }
3341 }
3442}
3543
@@ -138,7 +146,25 @@ mod tests {
138146 uses a,b,c;
139147 "
140148 )
141- }
149+ } ,
150+ containing_conditional_directives = {
151+ indoc:: concatdoc!(
152+ stringify!( $typ) ,
153+ "
154+ foo;
155+ uses a, {$ifdef A}, b {$endif};
156+ (a,b,c);
157+ "
158+ ) ,
159+ indoc:: concatdoc!(
160+ stringify!( $typ) ,
161+ "
162+ foo;
163+ uses a, {$ifdef A}, b {$endif};
164+ (a, b, c);
165+ "
166+ )
167+ } ,
142168 ) ;
143169 }
144170 } ;
You can’t perform that action at this time.
0 commit comments