Skip to content

Commit 036d8e9

Browse files
committed
Simplify syntax checks by using Parent instead of GetPreviousToken
1 parent 3163cdf commit 036d8e9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,8 @@ private static void CheckBraceToken(SyntaxNodeAnalysisContext context, SyntaxTok
290290
// may want to allow that and not have SA1500 report it as a style error.
291291
if (context.GetStyleCopSettings(context.CancellationToken).LayoutRules.AllowDoWhileOnClosingBrace)
292292
{
293-
var openBracePreviousToken = openBraceToken.GetPreviousToken(includeZeroWidth: true);
294-
295-
if (openBracePreviousToken.IsKind(SyntaxKind.DoKeyword))
293+
if (openBraceToken.Parent.IsKind(SyntaxKind.Block)
294+
&& openBraceToken.Parent.Parent.IsKind(SyntaxKind.DoStatement))
296295
{
297296
return;
298297
}

0 commit comments

Comments
 (0)