/// <summary>
        /// Gets a value indicating whether the <paramref name="token"/> is last in line.
        /// </summary>
        /// <param name="token">The token to process.</param>
        /// <returns>true if token is last in line, otherwise false.</returns>
        internal static bool IsLastInLine(this SyntaxToken token)
        {
            var fullLineSpan = token.SyntaxTree.GetLineSpan(token.FullSpan);

            if (token.SyntaxTree == null || fullLineSpan.EndLinePosition.Character == 0)
            {
                return(true);
            }

            var tokenLineSpan = token.SyntaxTree.GetLineSpan(token.Span);

            if (tokenLineSpan.EndLinePosition.Line != fullLineSpan.EndLinePosition.Line ||
                token.SyntaxTree.Length == token.FullSpan.End)
            {
                return(true);
            }

            // Use the slow path because we cant be sure if a multi line trivia is following this
            // token.
            var nextToken = token.GetNextToken();

            return(nextToken.IsKind(SyntaxKind.None) || token.GetEndLine() < nextToken.GetLine());
        }
Пример #2
0
        /// <summary>
        /// Gets a value indicating whether the <paramref name="token"/> is last in line.
        /// </summary>
        /// <param name="token">The token to process.</param>
        /// <returns>true if token is last in line, otherwise false.</returns>
        internal static bool IsLastInLine(this SyntaxToken token)
        {
            SyntaxToken nextToken = token.GetNextToken();

            return(nextToken.IsKind(SyntaxKind.None) || token.GetEndLine() < nextToken.GetLine());
        }
Пример #3
0
        /// <summary>
        /// Gets a value indicating whether the <paramref name="token"/> is first in line.
        /// </summary>
        /// <param name="token">The token to process.</param>
        /// <returns>true if token is first in line, otherwise false.</returns>
        internal static bool IsFirstInLine(this SyntaxToken token)
        {
            SyntaxToken previousToken = token.GetPreviousToken();

            return(previousToken.IsKind(SyntaxKind.None) || previousToken.GetEndLine() < token.GetLine());
        }