Skip to content

Commit

Permalink
Simplify syntax checks by using Parent instead of GetPreviousToken
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed May 19, 2021
1 parent 3163cdf commit 036d8e9
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,8 @@ private static void CheckBraceToken(SyntaxNodeAnalysisContext context, SyntaxTok
// may want to allow that and not have SA1500 report it as a style error.
if (context.GetStyleCopSettings(context.CancellationToken).LayoutRules.AllowDoWhileOnClosingBrace)
{
var openBracePreviousToken = openBraceToken.GetPreviousToken(includeZeroWidth: true);

if (openBracePreviousToken.IsKind(SyntaxKind.DoKeyword))
if (openBraceToken.Parent.IsKind(SyntaxKind.Block)
&& openBraceToken.Parent.Parent.IsKind(SyntaxKind.DoStatement))
{
return;
}
Expand Down

0 comments on commit 036d8e9

Please sign in to comment.