private bool TryGetStringLiteralToken(SyntaxTree tree, int position, out SyntaxToken stringLiteral, CancellationToken cancellationToken) { if (tree.IsEntirelyWithinStringLiteral(position, cancellationToken)) { var token = tree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia: true); if (token.Kind() == SyntaxKind.EndOfDirectiveToken || token.Kind() == SyntaxKind.EndOfFileToken) { token = token.GetPreviousToken(includeSkipped: true, includeDirectives: true); } if (token.Kind() == SyntaxKind.StringLiteralToken && token.Parent.Kind() == SyntaxKind.ReferenceDirectiveTrivia) { stringLiteral = token; return true; } } stringLiteral = default(SyntaxToken); return false; }