Skip to content

Commit edabc7f

Browse files
committed
Fix handling of semicolon followed by empty statement
Fixes #1777
1 parent 74ffc57 commit edabc7f

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1002SemicolonsMustBeSpacedCorrectly.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,26 @@ private static void HandleSemicolonToken(SyntaxTreeAnalysisContext context, Synt
9292
else
9393
{
9494
SyntaxToken nextToken = token.GetNextToken();
95-
if (nextToken.IsKind(SyntaxKind.CloseParenToken))
95+
switch (nextToken.Kind())
9696
{
97+
case SyntaxKind.CloseParenToken:
9798
// Special handling for the following case:
9899
// for (; ;)
99100
missingFollowingSpace = false;
101+
break;
102+
103+
case SyntaxKind.SemicolonToken:
104+
// Special handling for the following case:
105+
// Statement();;
106+
if (nextToken.Parent.IsKind(SyntaxKind.EmptyStatement))
107+
{
108+
missingFollowingSpace = false;
109+
}
110+
111+
break;
112+
113+
default:
114+
break;
100115
}
101116
}
102117

0 commit comments

Comments
 (0)