From 036d8e9760b18cd8a7db59f88b2e3bb5413081d8 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 19 May 2021 14:45:55 -0700 Subject: [PATCH] Simplify syntax checks by using Parent instead of GetPreviousToken --- .../SA1500BracesForMultiLineStatementsMustNotShareLine.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs index d1b641f95..101612fcd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs @@ -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; }