File tree Expand file tree Collapse file tree
StyleCop.Analyzers/StyleCop.Analyzers/Helpers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Helpers
55{
66 using Microsoft . CodeAnalysis ;
77 using Microsoft . CodeAnalysis . CSharp ;
8+ using Microsoft . CodeAnalysis . Text ;
89
910 /// <summary>
1011 /// Provides helper methods to work with token.
@@ -18,8 +19,8 @@ internal static class TokenHelper
1819 /// <returns>true if token is first in line, otherwise false.</returns>
1920 internal static bool IsFirstInLine ( this SyntaxToken token )
2021 {
21- SyntaxToken previousToken = token . GetPreviousToken ( ) ;
22- return previousToken . IsKind ( SyntaxKind . None ) || previousToken . GetEndLine ( ) < token . GetLine ( ) ;
22+ return token . SyntaxTree == null
23+ || token . SyntaxTree . GetLineSpan ( token . FullSpan ) . StartLinePosition . Character == 0 ;
2324 }
2425
2526 /// <summary>
@@ -29,8 +30,9 @@ internal static bool IsFirstInLine(this SyntaxToken token)
2930 /// <returns>true if token is last in line, otherwise false.</returns>
3031 internal static bool IsLastInLine ( this SyntaxToken token )
3132 {
32- SyntaxToken nextToken = token . GetNextToken ( ) ;
33- return nextToken . IsKind ( SyntaxKind . None ) || token . GetEndLine ( ) < nextToken . GetLine ( ) ;
33+ return token . SyntaxTree == null
34+ || token . SyntaxTree . GetLineSpan ( token . FullSpan ) . EndLinePosition . Character == 0
35+ || token . SyntaxTree . Length == token . FullSpan . End ;
3436 }
3537
3638 /// <summary>
You can’t perform that action at this time.
0 commit comments