@@ -670,8 +670,8 @@ public static bool SpanContainsDirectives(this SyntaxNode node)
670
670
throw new ArgumentNullException ( nameof ( node ) ) ;
671
671
672
672
return node . ContainsDirectives
673
- && ! node . GetLeadingTrivia ( ) . Any ( f => f . IsDirective )
674
- && ! node . GetTrailingTrivia ( ) . Any ( f => f . IsDirective ) ;
673
+ && ! node . GetLeadingTrivia ( ) . ContainsDirective ( )
674
+ && ! node . GetTrailingTrivia ( ) . ContainsDirective ( ) ;
675
675
}
676
676
677
677
internal static bool SpanOrLeadingTriviaContainsDirectives ( this SyntaxNode node )
@@ -680,7 +680,7 @@ internal static bool SpanOrLeadingTriviaContainsDirectives(this SyntaxNode node)
680
680
throw new ArgumentNullException ( nameof ( node ) ) ;
681
681
682
682
return node . ContainsDirectives
683
- && ! node . GetTrailingTrivia ( ) . Any ( f => f . IsDirective ) ;
683
+ && ! node . GetTrailingTrivia ( ) . ContainsDirective ( ) ;
684
684
}
685
685
686
686
internal static bool SpanOrTrailingTriviaContainsDirectives ( this SyntaxNode node )
@@ -689,7 +689,7 @@ internal static bool SpanOrTrailingTriviaContainsDirectives(this SyntaxNode node
689
689
throw new ArgumentNullException ( nameof ( node ) ) ;
690
690
691
691
return node . ContainsDirectives
692
- && ! node . GetLeadingTrivia ( ) . Any ( f => f . IsDirective ) ;
692
+ && ! node . GetLeadingTrivia ( ) . ContainsDirective ( ) ;
693
693
}
694
694
695
695
/// <summary>
@@ -702,8 +702,16 @@ public static bool ContainsDirectives(this SyntaxNode node, TextSpan span)
702
702
if ( node is null )
703
703
throw new ArgumentNullException ( nameof ( node ) ) ;
704
704
705
- return node . ContainsDirectives
706
- && node . DescendantTrivia ( span ) . Any ( f => f . IsDirective ) ;
705
+ if ( node . ContainsDirectives )
706
+ {
707
+ foreach ( SyntaxTrivia trivia in node . DescendantTrivia ( span ) )
708
+ {
709
+ if ( trivia . IsDirective )
710
+ return true ;
711
+ }
712
+ }
713
+
714
+ return false ;
707
715
}
708
716
709
717
/// <summary>
@@ -1434,5 +1442,16 @@ public static int IndexOf(this SyntaxTriviaList triviaList, Func<SyntaxTrivia, b
1434
1442
1435
1443
return - 1 ;
1436
1444
}
1445
+
1446
+ internal static bool ContainsDirective ( this SyntaxTriviaList triviaList )
1447
+ {
1448
+ foreach ( SyntaxTrivia trivia in triviaList )
1449
+ {
1450
+ if ( trivia . IsDirective )
1451
+ return true ;
1452
+ }
1453
+
1454
+ return false ;
1455
+ }
1437
1456
#endregion SyntaxTriviaList
1438
1457
}
0 commit comments