-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unnecessary check of trailing trivia for directives. #71185
Conversation
{ | ||
foreach (var trivia in node.AsToken().LeadingTrivia) | ||
GetDirectivesInTrivia(trivia, filter, ref directives); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplified check and inlined.
@@ -865,40 +868,21 @@ private static void GetDirectives<TDirective>(SyntaxNode node, Func<TDirective, | |||
{ | |||
foreach (var trivia in node.DescendantTrivia(node => node.ContainsDirectives, descendIntoTrivia: true)) | |||
{ | |||
_ = GetDirectivesInTrivia(trivia, filter, ref directives); | |||
GetDirectivesInTrivia(trivia, filter, ref directives); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for return value.
{ | ||
foreach (var tr in trivia) | ||
{ | ||
if (!GetDirectivesInTrivia(tr, filter, ref directives) && tr.GetStructure() is SyntaxNode node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directives can't be inside other structured trivia. THey are teh structured trivia. So just removed this.
@333fred @RikkiGibson ptal. |
directives = new List<TDirective>(); | ||
} | ||
|
||
directives ??= []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
Directives can only be in leading trivia. So this walk is unnecessary.