@@ -59,32 +59,37 @@ private static async Task<Document> GetTransformedDocumentAsync(Document documen
5959 var syntaxRoot = await document . GetSyntaxRootAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
6060 var replacements = new Dictionary < SyntaxToken , SyntaxToken > ( ) ;
6161
62- var token = syntaxRoot . FindToken ( diagnostic . Location . SourceSpan . Start ) ;
62+ var token = syntaxRoot . FindToken ( diagnostic . Location . SourceSpan . Start , findInsideTrivia : true ) ;
6363 SyntaxToken followingToken ;
6464
6565 switch ( diagnostic . Properties [ SA1003SymbolsMustBeSpacedCorrectly . CodeFixAction ] )
6666 {
6767 case SA1003SymbolsMustBeSpacedCorrectly . InsertBeforeTag :
6868 replacements [ token ] = token . WithLeadingTrivia ( token . LeadingTrivia . Add ( SyntaxFactory . Space ) ) ;
6969 break ;
70+
7071 case SA1003SymbolsMustBeSpacedCorrectly . InsertAfterTag :
7172 replacements [ token ] = token . WithTrailingTrivia ( token . TrailingTrivia . Insert ( 0 , SyntaxFactory . Space ) ) ;
7273 break ;
74+
7375 case SA1003SymbolsMustBeSpacedCorrectly . RemoveBeforeTag :
7476 var precedingToken = token . GetPreviousToken ( ) ;
7577 replacements [ precedingToken ] = precedingToken . WithTrailingTrivia ( precedingToken . TrailingTrivia . WithoutTrailingWhitespace ( ) ) ;
7678 replacements [ token ] = token . WithLeadingTrivia ( token . LeadingTrivia . WithoutLeadingWhitespace ( ) ) ;
7779 break ;
80+
7881 case SA1003SymbolsMustBeSpacedCorrectly . RemoveAfterTag :
7982 followingToken = token . GetNextToken ( ) ;
8083 replacements [ token ] = token . WithTrailingTrivia ( token . TrailingTrivia . WithoutLeadingWhitespace ( ) ) ;
8184 replacements [ followingToken ] = followingToken . WithLeadingTrivia ( followingToken . LeadingTrivia . WithoutLeadingWhitespace ( ) ) ;
8285 break ;
86+
8387 case SA1003SymbolsMustBeSpacedCorrectly . RemoveEndOfLineTag :
8488 followingToken = token . GetNextToken ( ) ;
8589 replacements [ token ] = token . WithTrailingTrivia ( token . TrailingTrivia . WithoutTrailingWhitespace ( ) ) ;
8690 replacements [ followingToken ] = followingToken . WithLeadingTrivia ( followingToken . LeadingTrivia . WithoutLeadingWhitespace ( ) ) ;
8791 break ;
92+
8893 case SA1003SymbolsMustBeSpacedCorrectly . RemoveEndOfLineWithTrailingSpaceTag :
8994 followingToken = token . GetNextToken ( ) ;
9095 replacements [ token ] = token . WithTrailingTrivia ( token . TrailingTrivia . WithoutTrailingWhitespace ( ) . Add ( SyntaxFactory . Space ) ) ;
0 commit comments