public static SyntaxToken FindLastTokenWithinLine(this TextLine line, SyntaxNode node) { var syntaxToken = node.FindToken(line.End); var previousToken = syntaxToken.GetPreviousToken(); var nextToken = syntaxToken.GetNextToken(); return(new[] { nextToken, syntaxToken, previousToken } .FirstOrDefault(t => line.ContainsPosition(t.Span.End) && t.Width() > 0)); }
public static SyntaxToken FindFirstTokenWithinLine(this TextLine line, SyntaxNode node) { var syntaxToken = node.FindToken(line.Start); var previousToken = syntaxToken.GetPreviousToken(); var nextToken = syntaxToken.GetNextToken(); return(new[] { previousToken, syntaxToken, nextToken } .FirstOrDefault(t => line.ContainsPosition(t.Span.Start))); }