3 types derived from SyntaxToken
Microsoft.CodeAnalysis.CSharp (3)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifier.cs (1)
13internal class SyntaxIdentifier : SyntaxToken
Syntax\InternalSyntax\SyntaxToken.SyntaxLiteral.cs (1)
14internal class SyntaxTokenWithValue<T> : SyntaxToken
Syntax\InternalSyntax\SyntaxToken.SyntaxTokenWithTrivia.cs (1)
11internal class SyntaxTokenWithTrivia : SyntaxToken
2 instantiations of SyntaxToken
Microsoft.CodeAnalysis.CSharp (2)
Binder\Semantics\Conversions\ConversionsBase.cs (1)
1755var greenNode = new Syntax.InternalSyntax.LiteralExpressionSyntax(SyntaxKind.NumericLiteralExpression, new Syntax.InternalSyntax.SyntaxToken(SyntaxKind.NumericLiteralToken));
Syntax\InternalSyntax\SyntaxToken.cs (1)
156s_tokensWithNoTrivia[(int)kind].Value = new SyntaxToken(kind);
835 references to SyntaxToken
Microsoft.CodeAnalysis.CSharp (831)
Parser\BlendedNode.cs (2)
16internal readonly SyntaxToken Token; 19internal BlendedNode(CSharp.CSharpSyntaxNode node, SyntaxToken token, Blender blender)
Parser\Blender.Cursor.cs (1)
148var greenToken = Lexer.RescanInterpolatedString((InterpolatedStringExpressionSyntax)node.Green);
Parser\Blender.Reader.cs (5)
144var token = this.LexNewToken(mode); 163private SyntaxToken LexNewToken(LexerMode mode) 175var token = _lexer.Lex(ref mode); 211token: (InternalSyntax.SyntaxToken)currentNodeOrToken.AsToken().Node); 314private BlendedNode CreateBlendedNode(CSharp.CSharpSyntaxNode node, SyntaxToken token)
Parser\DirectiveParser.cs (92)
37var hash = this.EatToken(SyntaxKind.HashToken, false); 88var lineKeyword = this.EatContextualToken(contextualKind); 117var id = this.EatToken(SyntaxKind.IdentifierToken, false); 118var end = this.ParseEndOfDirective(ignoreErrors: true); 137private DirectiveTriviaSyntax ParseIfDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive) 140var eod = this.ParseEndOfDirective(ignoreErrors: false); 146private DirectiveTriviaSyntax ParseElifDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive, bool endIsActive) 149var eod = this.ParseEndOfDirective(ignoreErrors: false); 174private DirectiveTriviaSyntax ParseElseDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive, bool endIsActive) 176var eod = this.ParseEndOfDirective(ignoreErrors: false); 196private DirectiveTriviaSyntax ParseEndIfDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive, bool endIsActive) 198var eod = this.ParseEndOfDirective(ignoreErrors: false); 215private DirectiveTriviaSyntax ParseRegionDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive) 220private DirectiveTriviaSyntax ParseEndRegionDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive) 222var eod = this.ParseEndOfDirectiveWithOptionalPreprocessingMessage(); 237private DirectiveTriviaSyntax ParseDefineOrUndefDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive, bool isFollowingToken) 244var name = this.EatToken(SyntaxKind.IdentifierToken, ErrorCode.ERR_IdentifierExpected); 246var end = this.ParseEndOfDirective(ignoreErrors: name.IsMissing); 279private DirectiveTriviaSyntax ParseErrorOrWarningDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive) 281var eod = this.ParseEndOfDirectiveWithOptionalPreprocessingMessage(); 361private DirectiveTriviaSyntax ParseLineDirective(SyntaxToken hash, SyntaxToken id, bool isActive) 363SyntaxToken line; 364SyntaxToken file = null; 397var end = this.ParseEndOfDirective(ignoreErrors: line.IsMissing || !isActive, afterLineNumber: sawLineButNotFile); 401private LineSpanDirectiveTriviaSyntax ParseLineSpanDirective(SyntaxToken hash, SyntaxToken lineKeyword, bool isActive) 412var minus = EatToken(SyntaxKind.MinusToken, reportError: reportError); 422var characterOffset = (CurrentToken.Kind == SyntaxKind.NumericLiteralToken) ? 431var file = EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_MissingPPFile, reportError: reportError); 439var endOfDirective = this.ParseEndOfDirective(ignoreErrors: !reportError); 442static bool noTriviaBetween(SyntaxToken token1, SyntaxToken token2) 452var openParen = EatToken(SyntaxKind.OpenParenToken, reportError); 455var lineToken = ParseLineDirectiveNumericLiteral(ref reportError, minValue: 1, maxValue: MaxLineValue, out line); 457var comma = EatToken(SyntaxKind.CommaToken, reportError); 460var characterToken = ParseLineDirectiveNumericLiteral(ref reportError, minValue: 1, maxValue: MaxCharacterValue, out character); 462var closeParen = EatToken(SyntaxKind.CloseParenToken, reportError); 468private SyntaxToken ParseLineDirectiveNumericLiteral(ref bool reportError, int minValue, int maxValue, out int value) 470var token = this.EatToken(SyntaxKind.NumericLiteralToken, ErrorCode.ERR_LineSpanDirectiveInvalidValue, reportError: reportError); 488private DirectiveTriviaSyntax ParseReferenceDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive, bool isFollowingToken) 502SyntaxToken file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_ExpectedPPFile, reportError: isActive); 504var end = this.ParseEndOfDirective(ignoreErrors: file.IsMissing || !isActive); 508private DirectiveTriviaSyntax ParseLoadDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive, bool isFollowingToken) 522SyntaxToken file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_ExpectedPPFile, reportError: isActive); 524var end = this.ParseEndOfDirective(ignoreErrors: file.IsMissing || !isActive); 528private DirectiveTriviaSyntax ParseNullableDirective(SyntaxToken hash, SyntaxToken token, bool isActive) 535SyntaxToken setting = this.CurrentToken.Kind switch 543SyntaxToken target = this.CurrentToken.Kind switch 552var end = this.ParseEndOfDirective(ignoreErrors: setting.IsMissing || target?.IsMissing == true || !isActive); 556private DirectiveTriviaSyntax ParsePragmaDirective(SyntaxToken hash, SyntaxToken pragma, bool isActive) 566var warning = this.EatContextualToken(SyntaxKind.WarningKeyword); 567SyntaxToken style; 575SyntaxToken id; 619var end = this.ParseEndOfDirective(hasError || !isActive, afterPragma: true); 625var end = this.ParseEndOfDirective(ignoreErrors: true, afterPragma: true); 631var checksum = this.EatToken(); 632var file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive); 633var guid = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive && !file.IsMissing); 643var bytes = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive && !guid.IsMissing); 664var eod = this.ParseEndOfDirective(ignoreErrors: hasError, afterPragma: true); 669var warning = this.EatToken(SyntaxKind.WarningKeyword, ErrorCode.WRN_IllegalPragma, reportError: isActive); 670var style = this.EatToken(SyntaxKind.DisableKeyword, reportError: false); 671var eod = this.ParseEndOfDirective(ignoreErrors: true, afterPragma: true); 676private DirectiveTriviaSyntax ParseShebangDirective(SyntaxToken hash, SyntaxToken exclamation, bool isActive) 684private SyntaxToken ParseEndOfDirectiveWithOptionalPreprocessingMessage() 687private SyntaxToken ParseEndOfDirective(bool ignoreErrors, bool afterPragma = false, bool afterLineNumber = false) 689var skippedTokens = new SyntaxListBuilder<SyntaxToken>(); 695skippedTokens = new SyntaxListBuilder<SyntaxToken>(10); 720SyntaxToken endOfDirective = this.CurrentToken.Kind == SyntaxKind.EndOfDirectiveToken 743var op = this.EatToken(); 756var op = this.EatToken(); 769var op = this.EatToken(); 781var op = this.EatToken(); 794var open = this.EatToken(); 796var close = this.EatToken(SyntaxKind.CloseParenToken); 799var identifier = TruncateIdentifier(this.EatToken()); 811private static SyntaxToken TruncateIdentifier(SyntaxToken identifier)
Parser\DocumentationCommentParser.cs (83)
86var eoc = this.EatToken(SyntaxKind.EndOfDocumentationCommentToken); 110var token = this.EatToken(); 204var lessThan = this.EatToken(SyntaxKind.LessThanToken); // guaranteed 228SyntaxToken greaterThan; 231var lessThanSlash = this.EatToken(SyntaxKind.LessThanSlashToken, reportError: false); 281var slashGreater = this.EatToken(SyntaxKind.SlashGreaterThanToken, false); 379var badTokens = default(SyntaxListBuilder<SyntaxToken>); 396badTokens = _pool.Allocate<SyntaxToken>(); 399var token = this.EatToken(); 447var equals = this.EatToken(SyntaxKind.EqualsToken, false); 464default(SyntaxList<SyntaxToken>), 469SyntaxToken startQuote; 470SyntaxToken endQuote; 489var textTokens = _pool.Allocate<SyntaxToken>(); 525SyntaxToken openQuote = EatToken(this.CurrentToken.Kind == SyntaxKind.SingleQuoteToken 532SyntaxToken current = this.CurrentToken; 553private void ParseCrefAttribute(out SyntaxToken startQuote, out CrefSyntax cref, out SyntaxToken endQuote) 571private void ParseNameAttribute(out SyntaxToken startQuote, out IdentifierNameSyntax identifier, out SyntaxToken endQuote) 589private void ParseXmlAttributeText(out SyntaxToken startQuote, SyntaxListBuilder<SyntaxToken> textTokens, out SyntaxToken endQuote) 611var token = this.EatToken(); 629private SyntaxToken ParseXmlAttributeStartQuote() 640var startQuote = this.EatToken(quoteKind, reportError: false); 648private SyntaxToken ParseXmlAttributeEndQuote(SyntaxKind quoteKind) 655var endQuote = this.EatToken(quoteKind, reportError: false); 663private SyntaxToken SkipNonAsciiQuotationMark() 665var quote = SyntaxFactory.MissingToken(SyntaxKind.DoubleQuoteToken); 676private static bool IsNonAsciiQuotationMark(SyntaxToken token) 683var id = this.EatToken(SyntaxKind.IdentifierToken); 687var colon = this.EatToken(); 722var lessThanExclamationMinusMinusToken = this.EatToken(SyntaxKind.XmlCommentStartToken); 724var textTokens = _pool.Allocate<SyntaxToken>(); 729var token = this.EatToken(); 742var minusMinusGreaterThanToken = this.EatToken(SyntaxKind.XmlCommentEndToken); 749var startCDataToken = this.EatToken(SyntaxKind.XmlCDataStartToken); 751var textTokens = new SyntaxListBuilder<SyntaxToken>(10); 758var endCDataToken = this.EatToken(SyntaxKind.XmlCDataEndToken); 765var startProcessingInstructionToken = this.EatToken(SyntaxKind.XmlProcessingInstructionStartToken); 773var textTokens = new SyntaxListBuilder<SyntaxToken>(10); 777var textToken = this.EatToken(); 785var endProcessingInstructionToken = this.EatToken(SyntaxKind.XmlProcessingInstructionEndToken); 841private SyntaxToken WithXmlParseError(SyntaxToken node, XmlParseErrorCode code, params string[] args) 908SyntaxToken dot = EatToken(SyntaxKind.DotToken); 917var badTokens = _pool.Allocate<SyntaxToken>(); 972SyntaxToken thisKeyword = EatToken(); 984SyntaxToken operatorKeyword = EatToken(); 985SyntaxToken checkedKeyword = TryEatCheckedKeyword(isConversion: false, ref operatorKeyword); 987SyntaxToken operatorToken; 1019var operatorToken2 = this.EatToken(); 1024var operatorToken3 = this.EatToken(); 1039var nonOverloadableOperator = SyntaxFactory.Token( 1071var operatorToken2 = this.EatToken(); 1081var operatorToken2 = this.EatToken(); 1082var nonOverloadableOperator = SyntaxFactory.Token( 1110private SyntaxToken TryEatCheckedKeyword(bool isConversion, ref SyntaxToken operatorKeyword) 1112SyntaxToken checkedKeyword = tryEatCheckedOrHandleUnchecked(ref operatorKeyword); 1122SyntaxToken tryEatCheckedOrHandleUnchecked(ref SyntaxToken operatorKeyword) 1127var misplacedToken = AddErrorAsWarning(EatToken(), ErrorCode.ERR_MisplacedUnchecked); 1143SyntaxToken implicitOrExplicit = EatToken(); 1145SyntaxToken operatorKeyword = EatToken(SyntaxKind.OperatorKeyword); 1146SyntaxToken checkedKeyword = TryEatCheckedKeyword(isConversion: true, ref operatorKeyword); 1184SyntaxToken open = EatToken(openKind); 1195SyntaxToken comma = EatToken(SyntaxKind.CommaToken); 1212SyntaxToken close = EatToken(closeKind); 1250SyntaxToken refKindOpt = null; 1260SyntaxToken readOnlyOpt = null; 1266var misplacedToken = AddErrorAsWarning(EatToken(), ErrorCode.ERR_RefReadOnlyWrongOrdering); 1286SyntaxToken identifierToken = EatToken(SyntaxKind.IdentifierToken); 1293var open = EatToken(); 1324SyntaxToken close = EatToken(SyntaxKind.GreaterThanToken); 1384SyntaxToken alias = EatToken(); 1392SyntaxToken colonColon = EatToken(); 1418SyntaxToken dot = EatToken(); 1462SyntaxToken open = EatToken(); 1491var close = this.EatToken(SyntaxKind.CloseBracketToken); 1563SyntaxToken identifierToken = this.EatToken(SyntaxKind.IdentifierToken, reportError: false); 1567var badTokens = _pool.Allocate<SyntaxToken>();
Parser\DocumentationCommentXmlTokens.cs (24)
16private static readonly SyntaxToken s_seeToken = Identifier(DocumentationCommentXmlNames.SeeElementName); 17private static readonly SyntaxToken s_codeToken = Identifier(DocumentationCommentXmlNames.CodeElementName); 18private static readonly SyntaxToken s_listToken = Identifier(DocumentationCommentXmlNames.ListElementName); 19private static readonly SyntaxToken s_paramToken = Identifier(DocumentationCommentXmlNames.ParameterElementName); 20private static readonly SyntaxToken s_valueToken = Identifier(DocumentationCommentXmlNames.ValueElementName); 21private static readonly SyntaxToken s_exampleToken = Identifier(DocumentationCommentXmlNames.ExampleElementName); 22private static readonly SyntaxToken s_includeToken = Identifier(DocumentationCommentXmlNames.IncludeElementName); 23private static readonly SyntaxToken s_remarksToken = Identifier(DocumentationCommentXmlNames.RemarksElementName); 24private static readonly SyntaxToken s_seealsoToken = Identifier(DocumentationCommentXmlNames.SeeAlsoElementName); 25private static readonly SyntaxToken s_summaryToken = Identifier(DocumentationCommentXmlNames.SummaryElementName); 26private static readonly SyntaxToken s_exceptionToken = Identifier(DocumentationCommentXmlNames.ExceptionElementName); 27private static readonly SyntaxToken s_typeparamToken = Identifier(DocumentationCommentXmlNames.TypeParameterElementName); 28private static readonly SyntaxToken s_permissionToken = Identifier(DocumentationCommentXmlNames.PermissionElementName); 29private static readonly SyntaxToken s_typeparamrefToken = Identifier(DocumentationCommentXmlNames.TypeParameterReferenceElementName); 32private static readonly SyntaxToken s_crefToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.CrefAttributeName); 33private static readonly SyntaxToken s_fileToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.FileAttributeName); 34private static readonly SyntaxToken s_nameToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.NameAttributeName); 35private static readonly SyntaxToken s_pathToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.PathAttributeName); 36private static readonly SyntaxToken s_typeToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.TypeAttributeName); 38private static SyntaxToken Identifier(string text) 43private static SyntaxToken IdentifierWithLeadingSpace(string text) 60public static SyntaxToken? LookupToken(string text, SyntaxListBuilder? leading) 75private static SyntaxToken? LookupXmlElementTag(string text) 157private static SyntaxToken? LookupXmlAttribute(string text)
Parser\LanguageParser.cs (349)
183SyntaxToken? tmp = null; 190var eof = this.EatToken(SyntaxKind.EndOfFileToken); 231var fileAsTrivia = _syntaxFactory.SkippedTokensTrivia(builder.ToList<SyntaxToken>()); 253var namespaceToken = this.EatToken(SyntaxKind.NamespaceKeyword); 262SyntaxToken? openBrace = null; 263SyntaxToken? semicolon = null; 363ref SyntaxToken? openBraceOrSemicolon, 412[NotNullIfNotNull(nameof(openBraceOrSemicolon))] ref SyntaxToken? openBraceOrSemicolon, 564[NotNullIfNotNull(nameof(openBraceOrSemicolon))] ref SyntaxToken? openBraceOrSemicolon, 616var token = this.EatToken(); 731var skippedToken = EatToken(); 817ref SyntaxToken? openBrace, 851ref SyntaxToken? openBraceOrSemicolon, 957var globalToken = this.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword 963var usingToken = this.EatToken(SyntaxKind.UsingKeyword); 964var staticToken = this.TryEatToken(SyntaxKind.StaticKeyword); 965var unsafeToken = this.TryEatToken(SyntaxKind.UnsafeKeyword); 978SyntaxToken semicolon; 1027private static bool IsGlobalAttributeTarget(SyntaxToken token) 1123var openBracket = this.EatToken(SyntaxKind.OpenBracketToken); 1140var closeBracket = this.EatToken(SyntaxKind.CloseBracketToken); 1175LanguageParser @this, ref SyntaxToken openBracket, SeparatedSyntaxListBuilder<AttributeSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 1211var openParen = this.EatToken(SyntaxKind.OpenParenToken); 1230LanguageParser @this, ref SyntaxToken openParen, SeparatedSyntaxListBuilder<AttributeArgumentSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 1291private static DeclarationModifiers GetModifierExcludingScoped(SyntaxToken token) 1366SyntaxToken scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter: false); 1378SyntaxToken modTok; 1382var nextToken = PeekToken(1); 1413var next = PeekToken(1); 1474bool isStructOrRecordKeyword(SyntaxToken token) 1607private static bool IsNonContextualModifier(SyntaxToken nextToken) 1615var nextToken = this.PeekToken(1); 1727if (!tryScanRecordStart(out var keyword, out var recordModifier)) 1738var name = this.ParseIdentifierToken(); 1761SyntaxToken semicolon; 1762SyntaxToken? openBrace; 1763SyntaxToken? closeBrace; 1851bool tryScanRecordStart([NotNullWhen(true)] out SyntaxToken? keyword, out SyntaxToken? recordModifier) 1868var misplacedToken = this.EatToken(); 1885static TypeDeclarationSyntax constructTypeDeclaration(ContextAwareSyntax syntaxFactory, SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, SyntaxToken keyword, SyntaxToken? recordModifier, 1886SyntaxToken name, TypeParameterListSyntax typeParameters, ParameterListSyntax? paramList, BaseListSyntax baseList, SyntaxListBuilder<TypeParameterConstraintClauseSyntax> constraints, 1887SyntaxToken? openBrace, SyntaxListBuilder<MemberDeclarationSyntax> members, SyntaxToken? closeBrace, SyntaxToken semicolon) 1889var modifiersList = (SyntaxList<SyntaxToken>)modifiers.ToList(); 1968private void SkipBadMemberListTokens(ref SyntaxToken openBrace, SyntaxListBuilder members) 1980openBrace = (SyntaxToken)tmp; 1992var token = this.EatToken(); 2057var colon = this.TryEatToken(SyntaxKind.ColonToken); 2097PostSkipAction skipBadBaseListTokens(ref SyntaxToken colon, SeparatedSyntaxListBuilder<BaseTypeSyntax> list, SyntaxKind expected) 2124var where = this.EatContextualToken(SyntaxKind.WhereKeyword); 2129var colon = this.EatToken(SyntaxKind.ColonToken); 2157SyntaxToken separatorToken = this.EatToken(SyntaxKind.CommaToken); 2267var allows = this.EatContextualToken(SyntaxKind.AllowsKeyword); 2436new SyntaxList<SyntaxToken>(), 2573var identifier = this.EatToken(); 2720SyntaxToken identifierOrThisOpt; 2905var misplacedModifier = this.CurrentToken; 2922ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, SyntaxToken identifierOrThisOpt, TypeParameterListSyntax typeParameterListOpt, 2963ref ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, ref SyntaxToken identifierOrThisOpt, 2986ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, SyntaxToken identifierOrThisOpt, 3133SyntaxToken identifierOrThisOpt; 3185SyntaxToken identifierOrThisOpt) 3264if (child is not SyntaxToken token) 3288var name = this.ParseIdentifierToken(); 3298this.ParseBlockAndExpressionBodiesWithSemicolon(out var body, out var expressionBody, out var semicolon); 3310var colon = this.EatToken(SyntaxKind.ColonToken); 3317SyntaxToken token; 3343var tilde = this.EatToken(SyntaxKind.TildeToken); 3345var name = this.ParseIdentifierToken(); 3352out BlockSyntax body, out ArrowExpressionClauseSyntax expressionBody, out SyntaxToken semicolon); 3364out SyntaxToken semicolon, 3452SyntaxToken identifier, 3470var colonToken = this.CurrentToken; 3491this.ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon); 3617var style = this.CurrentToken.Kind is SyntaxKind.ImplicitKeyword or SyntaxKind.ExplicitKeyword 3624SyntaxToken opKeyword; 3654var checkedKeyword = TryEatCheckedOrHandleUnchecked(ref opKeyword); 3673this.ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon); 3701SyntaxToken separator = null; 3759private SyntaxToken TryEatCheckedOrHandleUnchecked(ref SyntaxToken operatorKeyword) 3780var firstToken = this.CurrentToken; 3807var opKeyword = this.EatToken(SyntaxKind.OperatorKeyword); 3808var checkedKeyword = TryEatCheckedOrHandleUnchecked(ref opKeyword); 3809SyntaxToken opToken; 3856var tk = this.CurrentToken; 3860var opToken2 = this.EatToken(); 3917this.ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon); 3947SyntaxToken thisKeyword, 3963SyntaxToken semicolon = null; 4007SyntaxToken identifier, 4044var equals = this.EatToken(SyntaxKind.EqualsToken); 4049SyntaxToken semicolon = null; 4098var openBrace = this.EatToken(SyntaxKind.OpenBraceToken); 4143var refKeyword = this.CurrentToken.Kind == SyntaxKind.RefKeyword && !this.IsPossibleLambdaExpression(Precedence.Expression) 4151private PostSkipAction SkipBadAccessorListTokens(ref SyntaxToken openBrace, SyntaxListBuilder<AccessorDeclarationSyntax> list, ErrorCode error) 4198var token = this.PeekToken(peekIndex); 4335var token = (first && !this.CurrentToken.ContainsDiagnostics) ? this.EatTokenWithPrejudice(expected) : this.EatToken(); 4361var token = (first && !this.CurrentToken.ContainsDiagnostics) ? this.EatTokenWithPrejudice(errorCode) : this.EatToken(); 4384var accessorName = this.EatToken(SyntaxKind.IdentifierToken, 4415SyntaxToken semicolon = null; 4469private SyntaxToken EatAccessorSemicolon() 4475private static SyntaxKind GetAccessorKind(SyntaxToken accessorName) 4495var parameters = this.ParseParameterList(out var open, out var close, SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken); 4506var parameters = this.ParseParameterList(out var open, out var close, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); 4567out SyntaxToken open, 4568out SyntaxToken close, 4593LanguageParser @this, ref SyntaxToken open, SeparatedSyntaxListBuilder<ParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 4682SyntaxToken identifier; 4701var equalsToken = TryEatToken(SyntaxKind.EqualsToken); 4711internal static bool NoTriviaBetween(SyntaxToken token1, SyntaxToken token2) 4716private static bool IsParameterModifierExcludingScoped(SyntaxToken token) 4748SyntaxToken scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter); 4788var eventToken = this.EatToken(); 4799SyntaxToken eventToken, 4803SyntaxToken identifierOrThisOpt; 4829SyntaxToken identifier; 4860SyntaxToken semicolon = null; 4891var semi = this.EatToken(); 4908if (modifiers is [.., SyntaxToken { Kind: SyntaxKind.ScopedKeyword } scopedKeyword]) 4924SyntaxToken eventToken, 5001SyntaxList<SyntaxToken> mods, 5188SyntaxList<SyntaxToken> mods, 5259var missingIdentifier = CreateMissingIdentifierToken(); 5277var name = this.ParseIdentifierToken(); 5304var equals = this.EatToken(); 5307var refKeyword = isLocalOrField && !isConst && this.CurrentToken.Kind == SyntaxKind.RefKeyword && !this.IsPossibleLambdaExpression(Precedence.Expression) 5375args.AddSeparator((SyntaxToken)item); 5479var delegateToken = this.EatToken(SyntaxKind.DelegateKeyword); 5483var name = this.ParseIdentifierToken(); 5512var enumToken = this.EatToken(SyntaxKind.EnumKeyword); 5513var name = this.ParseIdentifierToken(); 5527var colon = this.EatToken(SyntaxKind.ColonToken); 5537SyntaxToken semicolon; 5538SyntaxToken openBrace; 5539SyntaxToken closeBrace; 5583LanguageParser @this, ref SyntaxToken openBrace, SeparatedSyntaxListBuilder<EnumMemberDeclarationSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 5600var memberName = this.ParseIdentifierToken(); 5636private static SyntaxToken CreateMissingIdentifierToken() 5678private bool IsTrueIdentifier(SyntaxToken token) 5699private SyntaxToken ParseIdentifierToken(ErrorCode code = ErrorCode.ERR_IdentifierExpected) 5712var result = CreateMissingIdentifierToken(); 5717SyntaxToken identifierToken = this.EatToken(); 5767var open = this.EatToken(SyntaxKind.LessThanToken); 5786LanguageParser @this, ref SyntaxToken open, SeparatedSyntaxListBuilder<TypeParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 5862this.ParseTypeArgumentList(out var open, types, out var close); 5916out var greaterThanToken, out bool isDefinitelyTypeArgumentList); 6012out SyntaxToken greaterThanToken, 6025var start = this.EatToken(); 6200private void ParseTypeArgumentList(out SyntaxToken open, SeparatedSyntaxListBuilder<TypeSyntax> types, out SyntaxToken close) 6273static bool tokenBreaksTypeArgumentList(SyntaxToken token) 6418out SyntaxToken identifierOrThisOpt, 6434SyntaxToken separator = null; 6554private void AccumulateExplicitInterfaceName(ref NameSyntax explicitInterfaceName, ref SyntaxToken separator) 6616SyntaxToken separator = null; 6703var separator = this.EatToken(); 6713SyntaxToken separator) 6755private SyntaxToken ConvertToMissingWithTrailingTrivia(SyntaxToken token, SyntaxKind expectedKind) 6757var newToken = SyntaxFactory.MissingToken(expectedKind); 6825private ScanTypeFlags ScanType(out SyntaxToken lastTokenOfType, bool forPattern = false) 6835private ScanTypeFlags ScanNamedTypePart(out SyntaxToken lastTokenOfType) 6854private ScanTypeFlags ScanType(ParseTypeMode mode, out SyntaxToken lastTokenOfType) 7028private ScanTypeFlags ScanTupleType(out SyntaxToken lastTokenOfType) 7072private ScanTypeFlags ScanFunctionPointerType(out SyntaxToken lastTokenOfType) 7082var peek1 = PeekToken(1); 7142var ignoredModifiers = _pool.Allocate<SyntaxToken>(); 7280var question = TryEatNullableQualifierIfApplicable(type, mode); 7342private SyntaxToken TryEatNullableQualifierIfApplicable( 7356var questionToken = this.EatToken(); 7434var nextToken = PeekToken(1); 7524var open = this.EatToken(SyntaxKind.OpenBracketToken); 7586var open = this.EatToken(SyntaxKind.OpenParenToken); 7625private PostSkipAction SkipBadArrayRankSpecifierTokens(ref SyntaxToken openBracket, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expected) 7638var token = this.EatToken(); 7671var @delegate = EatToken(SyntaxKind.DelegateKeyword); 7672var asterisk = EatToken(SyntaxKind.AsteriskToken); 7678var lessThanTokenError = WithAdditionalDiagnostics(SyntaxFactory.MissingToken(SyntaxKind.LessThanToken), GetExpectedTokenError(SyntaxKind.LessThanToken, SyntaxKind.None)); 7696var lessThanToken = EatTokenAsKind(SyntaxKind.LessThanToken); 7705var modifiers = _pool.Allocate<SyntaxToken>(); 7755SyntaxToken managedSpecifier; 7756SyntaxToken peek1 = PeekToken(1); 7783var openBracket = EatToken(SyntaxKind.OpenBracketToken); 7803var closeBracket = EatToken(SyntaxKind.CloseBracketToken); 7831private static bool IsPossibleFunctionPointerParameterListStart(SyntaxToken token) 8233var token1 = PeekToken(1); 8353SyntaxToken identifierOrThisOpt; 8516SyntaxToken nextToken = PeekToken(1); 8597private bool? IsPossibleTypedIdentifierStart(SyntaxToken current, SyntaxToken next, bool allowThisKeyword) 8671(SyntaxToken)openBrace, 8702(SyntaxToken)openBrace, 8836var @fixed = this.EatToken(SyntaxKind.FixedKeyword); 8837var openParen = this.EatToken(SyntaxKind.OpenParenToken); 8921var @try = this.EatToken(SyntaxKind.TryKeyword); 8996var @catch = this.EatToken(); 9003var openParen = this.EatToken(); 9007SyntaxToken name = null; 9015var closeParen = this.EatToken(SyntaxKind.CloseParenToken); 9024var whenKeyword = this.EatContextualToken(SyntaxKind.WhenKeyword); 9036var openParen = this.EatToken(SyntaxKind.OpenParenToken); 9040var closeParen = this.EatToken(SyntaxKind.CloseParenToken); 9084var keyword = this.EatToken(); 9095var @do = this.EatToken(SyntaxKind.DoKeyword); 9097var @while = this.EatToken(SyntaxKind.WhileKeyword); 9098var openParen = this.EatToken(SyntaxKind.OpenParenToken); 9161var forToken = this.EatToken(SyntaxKind.ForKeyword); 9162var openParen = this.EatToken(SyntaxKind.OpenParenToken); 9166SyntaxToken secondSemicolonToken; 9242SyntaxToken eatCommaOrSemicolon() 9247SyntaxToken eatUnexpectedTokensAndCloseParenToken() 9254var result = this.EatToken(SyntaxKind.CloseParenToken); 9261SeparatedSyntaxList<ExpressionSyntax> parseForStatementExpressionList(ref SyntaxToken startToken, bool allowSemicolonAsSeparator) 9273LanguageParser @this, ref SyntaxToken startToken, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 9291SyntaxList<AttributeListSyntax> attributes, SyntaxToken awaitTokenOpt) 9301SyntaxToken @foreach; 9307var skippedForToken = this.EatToken(); 9316var openParen = this.EatToken(SyntaxKind.OpenParenToken); 9319var @in = this.EatToken(SyntaxKind.InKeyword, ErrorCode.ERR_InExpected); 9326var closeParen = this.EatToken(SyntaxKind.CloseParenToken); 9334SyntaxToken identifier; 9344identifier = SyntaxToken.WithValue(SyntaxKind.IdentifierToken, discard.LeadingTrivia.Node, discard.Text, discard.ValueText, discard.TrailingTrivia.Node); 9442SyntaxToken lastTokenOfType; 9513var @goto = this.EatToken(SyntaxKind.GotoKeyword); 9515SyntaxToken caseOrDefault = null; 9546var stack = ArrayBuilder<(SyntaxToken, SyntaxToken, ExpressionSyntax, SyntaxToken, StatementSyntax, SyntaxToken)>.GetInstance(); 9551var ifKeyword = this.EatToken(SyntaxKind.IfKeyword); 9552var openParen = this.EatToken(SyntaxKind.OpenParenToken); 9554var closeParen = this.EatToken(SyntaxKind.CloseParenToken); 9557var elseKeyword = this.CurrentToken.Kind != SyntaxKind.ElseKeyword ? 9656var yieldToken = ConvertToKeyword(this.EatToken()); 9657SyntaxToken returnOrBreak; 9693parseSwitchHeader(out var switchKeyword, out var openParen, out var expression, out var closeParen, out var openBrace); 9710out SyntaxToken switchKeyword, 9711out SyntaxToken openParen, 9713out SyntaxToken closeParen, 9714out SyntaxToken openBrace) 9778var caseKeyword = this.EatToken(); 9856private UsingStatementSyntax ParseUsingStatement(SyntaxList<AttributeListSyntax> attributes, SyntaxToken awaitTokenOpt = null) 9858var @using = this.EatToken(SyntaxKind.UsingKeyword); 9859var openParen = this.EatToken(SyntaxKind.OpenParenToken); 9897SyntaxToken scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter: false); 10013SyntaxToken awaitKeyword, usingKeyword; 10038SyntaxToken scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter: false); 10070if (attributes.Count == 0 && mods.Count > 0 && IsAccessibilityModifier(((SyntaxToken)mods[0]).ContextualKind)) 10088var mod = (SyntaxToken)mods[i]; 10111private SyntaxToken ParsePossibleScopedKeyword(bool isFunctionPointerParameter) 10117SyntaxToken scopedKeyword = this.EatContextualToken(SyntaxKind.ScopedKeyword); 10150var openParen = this.EatToken(SyntaxKind.OpenParenToken); 10223VariableFlags initialFlags, SyntaxToken? scopedKeyword) 10249SyntaxList<SyntaxToken> mods, 10250SyntaxToken? scopedKeyword, 10305SyntaxToken mod; 10424SyntaxList<SyntaxToken> modifiers, 10426SyntaxToken identifier) 10451var modifier = modifiers[i]; 10514SyntaxToken semicolon; 10547SyntaxToken semicolon; 10890var next = PeekToken(1); 11082var operatorToken = eatOperatorToken(operatorTokenKind); 11161var token1 = this.CurrentToken; 11215SyntaxToken eatOperatorToken(SyntaxKind operatorTokenKind) 11227var token1 = EatToken(); 11228var token2 = EatToken(); 11240var token1 = EatToken(); 11242var token3 = EatToken(); 11265var questionToken = this.EatToken(); 11354public static bool IsAtDotDotToken(SyntaxToken token1, SyntaxToken token2) 11362public SyntaxToken EatDotDotToken() 11365var token1 = this.EatToken(); 11366var token2 = this.EatToken(); 11368var dotDotToken = SyntaxFactory.Token(token1.GetLeadingTrivia(), SyntaxKind.DotDotToken, token2.GetTrailingTrivia()); 11400var scopedKeyword = isScoped 11417private ExpressionSyntax ParseIsExpression(ExpressionSyntax leftOperand, SyntaxToken opToken) 11558var refKeyword = this.EatToken(); 11771var nextToken = this.PeekToken(1); 11872openToken: out SyntaxToken openToken, 11874closeToken: out SyntaxToken closeToken, 11888openToken: out SyntaxToken openToken, 11890closeToken: out SyntaxToken closeToken, 11897out SyntaxToken openToken, 11899out SyntaxToken closeToken, 11967LanguageParser @this, ref SyntaxToken open, SeparatedSyntaxListBuilder<ArgumentSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 12010SyntaxToken refKindKeyword = null; 12056var keyword = this.EatToken(); 12100var checkedOrUnchecked = this.EatToken(); 12143var tk = this.PeekToken(curTk++); 12192var token1 = this.PeekToken(1); 12200var token2 = this.PeekToken(2); 12259var identifier = this.IsTrueIdentifier() ? this.EatToken() : CreateMissingIdentifierToken(); 12261var equalsToken = TryEatToken(SyntaxKind.EqualsToken); 12319var openParen = this.EatToken(SyntaxKind.OpenParenToken); 12347private TupleExpressionSyntax ParseTupleExpressionTail(SyntaxToken openParen, ArgumentSyntax firstArg) 12512var token1 = this.PeekToken(1); 12715var openBracket = this.EatToken(SyntaxKind.OpenBracketToken); 12732LanguageParser @this, ref SyntaxToken openBracket, SeparatedSyntaxListBuilder<CollectionElementSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 12761var @new = this.EatToken(SyntaxKind.NewKeyword); 12765var openBrace = this.EatToken(SyntaxKind.OpenBraceToken); 12815SyntaxToken @new = this.EatToken(SyntaxKind.NewKeyword); 12888private WithExpressionSyntax ParseWithExpression(ExpressionSyntax receiverExpression, SyntaxToken withKeyword) 12890var openBrace = this.EatToken(SyntaxKind.OpenBraceToken); 12915var openBrace = this.EatToken(SyntaxKind.OpenBraceToken); 12989LanguageParser @this, ref SyntaxToken startToken, SeparatedSyntaxListBuilder<T> list, SyntaxKind expectedKind, SyntaxKind closeKind) 13022var openBrace = this.EatToken(SyntaxKind.OpenBraceToken); 13049var @new = this.EatToken(SyntaxKind.NewKeyword); 13050var openBracket = this.EatToken(SyntaxKind.OpenBracketToken); 13089var openBrace = this.EatToken(SyntaxKind.OpenBraceToken); 13107LanguageParser @this, ref SyntaxToken openBrace, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 13125var @stackalloc = this.EatToken(SyntaxKind.StackAllocKeyword); 13126var openBracket = this.EatToken(SyntaxKind.OpenBracketToken); 13184var @delegate = this.EatToken(SyntaxKind.DelegateKeyword); 13203var openBrace = this.EatToken(SyntaxKind.OpenBraceToken); 13225private SyntaxList<SyntaxToken> ParseAnonymousFunctionModifiers() 13324var arrow = this.EatToken(SyntaxKind.EqualsGreaterThanToken); 13334var identifier = (this.CurrentToken.Kind != SyntaxKind.IdentifierToken && this.PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken) 13339var arrow = this.EatToken(SyntaxKind.EqualsGreaterThanToken); 13357var openParen = this.EatToken(SyntaxKind.OpenParenToken); 13379LanguageParser @this, ref SyntaxToken openParen, SeparatedSyntaxListBuilder<ParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 13429var identifier = this.ParseIdentifierToken(); 13432var equalsToken = TryEatToken(SyntaxKind.EqualsToken); 13474var peek1 = this.PeekToken(1); 13491private static bool IsTokenQueryContextualKeyword(SyntaxToken token) 13511private static bool IsTokenStartOfNewQueryClause(SyntaxToken token) 13653var @from = this.EatContextualToken(SyntaxKind.FromKeyword); 13659SyntaxToken name; 13724var @orderby = this.EatContextualToken(SyntaxKind.OrderByKeyword); 13769SyntaxToken direction = null; 13865LanguageParser parser, ref SyntaxToken openToken, SeparatedSyntaxListBuilder<TNode> builder, SyntaxKind expectedKind, SyntaxKind closeTokenKind) where TNode : GreenNode; 13897ref SyntaxToken openToken, 13919ref SyntaxToken openToken, 14095SyntaxListBuilder<SyntaxToken> b = _pool.Allocate<SyntaxToken>();
Parser\LanguageParser_InterpolatedString.cs (10)
41var originalToken = this.EatToken(); 78SyntaxToken getOpenQuote() 238SyntaxToken getCloseQuote() 319private static SyntaxToken TokenOrMissingToken(GreenNode? leading, SyntaxKind kind, string text, GreenNode? trailing) 395SyntaxToken openBraceToken) 421(InterpolationFormatClauseSyntax? format, SyntaxToken closeBraceToken) getFormatAndCloseBrace() 437SyntaxToken getInterpolationCloseToken(GreenNode? leading) 452private SyntaxToken MakeInterpolatedStringTextToken(Lexer.InterpolatedStringKind kind, string text) 467var token = tempLexer.Lex(ref mode); 469var result = SyntaxFactory.Literal(leading: null, text, SyntaxKind.InterpolatedStringTextToken, token.ValueText, trailing: null);
Parser\LanguageParser_Patterns.cs (9)
279var varToken = ConvertToKeyword(typeIdentifierToken); 289var openParenToken = this.EatToken(SyntaxKind.OpenParenToken); 299var closeParenToken = this.EatToken(SyntaxKind.CloseParenToken); 486var openBraceToken = this.EatToken(SyntaxKind.OpenBraceToken); 511var colon = EatToken(); 540LanguageParser @this, ref SyntaxToken open, SeparatedSyntaxListBuilder<T> list, SyntaxKind expectedKind, SyntaxKind closeKind) 568private SwitchExpressionSyntax ParseSwitchExpression(ExpressionSyntax governingExpression, SyntaxToken switchKeyword) 624var commaToken = this.CurrentToken.Kind == SyntaxKind.SemicolonToken 637var openBracket = this.EatToken(SyntaxKind.OpenBracketToken);
Parser\Lexer.cs (19)
229public SyntaxToken Lex(ref LexerMode mode) 231var result = Lex(mode); 240public SyntaxToken Lex(LexerMode mode) 303private SyntaxToken LexSyntaxToken() 338private SyntaxToken Create(in TokenInfo info, SyntaxListBuilder? leading, SyntaxListBuilder? trailing, SyntaxDiagnosticInfo[]? errors) 345SyntaxToken token; 2490private SyntaxToken LexDirectiveToken() 2503var token = Create(in info, null, directiveTriviaCache, errors); 2509public SyntaxToken LexEndOfDirectiveWithOptionalPreprocessingMessage() 2546var endOfDirective = SyntaxFactory.Token(leading, SyntaxKind.EndOfDirectiveToken, trailing); 2826private SyntaxToken LexXmlToken() 3182private SyntaxToken LexXmlElementTagToken() 3197SyntaxToken? token = DocumentationCommentXmlTokens.LookupToken(tagInfo.Text, leading); 3368private SyntaxToken LexXmlAttributeTextToken() 3521private SyntaxToken LexXmlCharacter() 3577private SyntaxToken LexXmlCrefOrNameToken() 3990private SyntaxToken LexXmlCDataSectionTextToken() 4112private SyntaxToken LexXmlCommentTextToken() 4242private SyntaxToken LexXmlProcessingInstructionTextToken()
Parser\Lexer_StringLiteral.cs (1)
300internal static SyntaxToken RescanInterpolatedString(InterpolatedStringExpressionSyntax interpolatedString)
Parser\LexerCache.cs (4)
34private readonly TextKeyedCache<SyntaxToken> _tokenMap; 41_tokenMap = TextKeyedCache<SyntaxToken>.GetInstance(); 104internal SyntaxToken LookupToken<TArg>( 109Func<TArg, SyntaxToken> createTokenFunction,
Parser\QuickScanner.cs (4)
192private SyntaxToken? QuickScanSyntaxToken() 237var token = _cache.LookupToken( 253private static SyntaxToken CreateQuickToken(Lexer lexer) 259var token = lexer.LexSyntaxToken();
Parser\SyntaxParser.cs (55)
29private SyntaxToken _currentToken; 30private ArrayElement<SyntaxToken>[] _lexedTokens; 39private static readonly ObjectPool<ArrayElement<SyntaxToken>[]> s_lexedTokensPool = new ObjectPool<ArrayElement<SyntaxToken>[]>(() => new ArrayElement<SyntaxToken>[CachedTokenArraySize], 2); 149var token = lexer.Lex(mode); 316protected SyntaxToken CurrentToken 324private SyntaxToken FetchCurrentToken() 380private void AddLexedToken(SyntaxToken token) 454private void ReturnLexedTokensToPool(ArrayElement<SyntaxToken>[] lexedTokens) 466protected SyntaxToken PeekToken(int n) 486protected SyntaxToken EatToken() 488var ct = this.CurrentToken; 497protected SyntaxToken TryEatToken(SyntaxKind kind) 521protected SyntaxToken EatToken(SyntaxKind kind) 525var ct = this.CurrentToken; 537protected SyntaxToken EatTokenAsKind(SyntaxKind expected) 541var ct = this.CurrentToken; 548var replacement = CreateMissingToken(expected, this.CurrentToken.Kind, reportError: true); 552private SyntaxToken CreateMissingToken(SyntaxKind expected, SyntaxKind actual, bool reportError) 555var token = SyntaxFactory.MissingToken(expected); 564private SyntaxToken CreateMissingToken(SyntaxKind expected, ErrorCode code, bool reportError) 567var token = SyntaxFactory.MissingToken(expected); 576protected SyntaxToken EatToken(SyntaxKind kind, bool reportError) 595protected SyntaxToken EatToken(SyntaxKind kind, ErrorCode code, bool reportError = true) 608protected SyntaxToken EatTokenWithPrejudice(SyntaxKind kind) 610var token = this.CurrentToken; 621protected SyntaxToken EatTokenWithPrejudice(ErrorCode errorCode, params object[] args) 623var token = this.EatToken(); 628protected SyntaxToken EatContextualToken(SyntaxKind kind, ErrorCode code, bool reportError = true) 642protected SyntaxToken EatContextualToken(SyntaxKind kind, bool reportError = true) 736SyntaxToken ct = this.CurrentToken; 778SyntaxToken token = node as SyntaxToken; 834var firstToken = node.GetFirstToken(); 840var firstToken = node.GetFirstToken(); 862var lastToken = node.GetLastNonmissingToken(); 900var oldToken = node as SyntaxToken ?? node.GetFirstToken(); 901var newToken = AddSkippedSyntax(oldToken, skippedSyntax, trailing: false); 919var token = node as SyntaxToken; 926var lastToken = node.GetLastToken(); 927var newToken = AddSkippedSyntax(lastToken, skippedSyntax, trailing: true); 936internal SyntaxToken AddSkippedSyntax(SyntaxToken target, GreenNode skippedSyntax, bool trailing) 949SyntaxToken token = node as SyntaxToken; 957SyntaxToken tk = token.TokenWithLeadingTrivia(null).TokenWithTrailingTrivia(null); 1096protected static SyntaxToken ConvertToKeyword(SyntaxToken token) 1115protected static SyntaxToken ConvertToIdentifier(SyntaxToken token) 1119var identifier = SyntaxToken.Identifier(token.Kind, token.LeadingTrivia.Node, token.Text, token.ValueText, token.TrailingTrivia.Node);
Symbols\Source\AttributeLocation.cs (1)
123internal static AttributeLocation ToAttributeLocation(this Syntax.InternalSyntax.SyntaxToken token)
Syntax\InternalSyntax\CSharpSyntaxNode.cs (8)
98public SyntaxToken GetFirstToken() 100return (SyntaxToken)this.GetFirstTerminal(); 103public SyntaxToken GetLastToken() 105return (SyntaxToken)this.GetLastTerminal(); 108public SyntaxToken GetLastNonmissingToken() 110return (SyntaxToken)this.GetLastNonmissingTerminal(); 199var t = node as SyntaxToken;
Syntax\InternalSyntax\CSharpSyntaxRewriter.cs (1)
21public override CSharpSyntaxNode VisitToken(SyntaxToken token)
Syntax\InternalSyntax\CSharpSyntaxVisitor.cs (2)
25public virtual TResult VisitToken(SyntaxToken token) 53public virtual void VisitToken(SyntaxToken token)
Syntax\InternalSyntax\SyntaxFactory.cs (55)
32private static SyntaxToken s_xmlCarriageReturnLineFeed; 33private static SyntaxToken XmlCarriageReturnLineFeed 116public static SyntaxToken Token(SyntaxKind kind) 118return SyntaxToken.Create(kind); 121internal static SyntaxToken Token(GreenNode leading, SyntaxKind kind, GreenNode trailing) 123return SyntaxToken.Create(kind, leading, trailing); 127/// Creates a token whose <see cref="SyntaxToken.Text"/> and <see cref="SyntaxToken.ValueText"/> are the same. 129internal static SyntaxToken Token(GreenNode leading, SyntaxKind kind, string text, GreenNode trailing) 134internal static SyntaxToken Token(GreenNode leading, SyntaxKind kind, string text, string valueText, GreenNode trailing) 142return kind >= SyntaxToken.FirstTokenWithWellKnownText && kind <= SyntaxToken.LastTokenWithWellKnownText && text == defaultText && valueText == defaultText 144: SyntaxToken.WithValue(kind, leading, text, valueText, trailing); 147internal static SyntaxToken MissingToken(SyntaxKind kind) 149return SyntaxToken.CreateMissing(kind); 152internal static SyntaxToken MissingToken(GreenNode leading, SyntaxKind kind, GreenNode trailing) 154return SyntaxToken.CreateMissing(kind, leading, trailing); 157internal static SyntaxToken Identifier(string text) 162internal static SyntaxToken Identifier(GreenNode leading, string text, GreenNode trailing) 167internal static SyntaxToken Identifier(SyntaxKind contextualKind, GreenNode leading, string text, string valueText, GreenNode trailing) 169return SyntaxToken.Identifier(contextualKind, leading, text, valueText, trailing); 172internal static SyntaxToken Literal(GreenNode leading, string text, int value, GreenNode trailing) 174return SyntaxToken.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing); 177internal static SyntaxToken Literal(GreenNode leading, string text, uint value, GreenNode trailing) 179return SyntaxToken.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing); 182internal static SyntaxToken Literal(GreenNode leading, string text, long value, GreenNode trailing) 184return SyntaxToken.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing); 187internal static SyntaxToken Literal(GreenNode leading, string text, ulong value, GreenNode trailing) 189return SyntaxToken.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing); 192internal static SyntaxToken Literal(GreenNode leading, string text, float value, GreenNode trailing) 194return SyntaxToken.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing); 197internal static SyntaxToken Literal(GreenNode leading, string text, double value, GreenNode trailing) 199return SyntaxToken.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing); 202internal static SyntaxToken Literal(GreenNode leading, string text, decimal value, GreenNode trailing) 204return SyntaxToken.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing); 207internal static SyntaxToken Literal(GreenNode leading, string text, string value, GreenNode trailing) 209return SyntaxToken.WithValue(SyntaxKind.StringLiteralToken, leading, text, value, trailing); 212internal static SyntaxToken Literal(GreenNode leading, string text, SyntaxKind kind, string value, GreenNode trailing) 214return SyntaxToken.WithValue(kind, leading, text, value, trailing); 217internal static SyntaxToken Literal(GreenNode leading, string text, char value, GreenNode trailing) 219return SyntaxToken.WithValue(SyntaxKind.CharacterLiteralToken, leading, text, value, trailing); 222internal static SyntaxToken BadToken(GreenNode leading, string text, GreenNode trailing) 224return SyntaxToken.WithValue(SyntaxKind.BadToken, leading, text, text, trailing); 227internal static SyntaxToken XmlTextLiteral(GreenNode leading, string text, string value, GreenNode trailing) 229return SyntaxToken.WithValue(SyntaxKind.XmlTextLiteralToken, leading, text, value, trailing); 232internal static SyntaxToken XmlTextNewLine(GreenNode leading, string text, string value, GreenNode trailing) 239return SyntaxToken.WithValue(SyntaxKind.XmlTextLiteralNewLineToken, leading, text, value, trailing); 242internal static SyntaxToken XmlTextNewLine(string text) 244return SyntaxToken.WithValue(SyntaxKind.XmlTextLiteralNewLineToken, null, text, text, null); 247internal static SyntaxToken XmlEntity(GreenNode leading, string text, string value, GreenNode trailing) 249return SyntaxToken.WithValue(SyntaxKind.XmlEntityLiteralToken, leading, text, value, trailing); 307public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(SyntaxToken token) where TNode : CSharpSyntaxNode 312public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(TNode node1, SyntaxToken token, TNode node2) where TNode : CSharpSyntaxNode 344internal static IEnumerable<SyntaxToken> GetWellKnownTokens() 346return SyntaxToken.GetWellKnownTokens();
Syntax\InternalSyntax\SyntaxFirstTokenReplacer.cs (8)
16private readonly SyntaxToken _oldToken; 17private readonly SyntaxToken _newToken; 21private SyntaxFirstTokenReplacer(SyntaxToken oldToken, SyntaxToken newToken, int diagnosticOffsetDelta) 29internal static TRoot Replace<TRoot>(TRoot root, SyntaxToken oldToken, SyntaxToken newToken, int diagnosticOffsetDelta) 44var token = node as SyntaxToken;
Syntax\InternalSyntax\SyntaxLastTokenReplacer.cs (8)
16private readonly SyntaxToken _oldToken; 17private readonly SyntaxToken _newToken; 21private SyntaxLastTokenReplacer(SyntaxToken oldToken, SyntaxToken newToken) 27internal static TRoot Replace<TRoot>(TRoot root, SyntaxToken newToken) 30var oldToken = root.GetLastToken(); 49var token = node as SyntaxToken;
Syntax\InternalSyntax\SyntaxListPoolExtensions.cs (2)
11public static SyntaxList<SyntaxToken> ToTokenListAndFree(this SyntaxListPool pool, SyntaxListBuilder builder) 15return new SyntaxList<SyntaxToken>(listNode);
Syntax\InternalSyntax\SyntaxToken.cs (29)
70internal static SyntaxToken Create(SyntaxKind kind) 85internal static SyntaxToken Create(SyntaxKind kind, GreenNode leading, GreenNode trailing) 121internal static SyntaxToken CreateMissing(SyntaxKind kind) 135internal static SyntaxToken CreateMissing(SyntaxKind kind, GreenNode leading, GreenNode trailing) 144private static readonly ArrayElement<SyntaxToken>[] s_tokensWithNoTrivia = new ArrayElement<SyntaxToken>[(int)LastTokenWithWellKnownText + 1]; 145private static readonly ArrayElement<SyntaxToken>[] s_tokensWithElasticTrivia = new ArrayElement<SyntaxToken>[(int)LastTokenWithWellKnownText + 1]; 146private static readonly ArrayElement<SyntaxToken>[] s_tokensWithSingleTrailingSpace = new ArrayElement<SyntaxToken>[(int)LastTokenWithWellKnownText + 1]; 147private static readonly ArrayElement<SyntaxToken>[] s_tokensWithSingleTrailingCRLF = new ArrayElement<SyntaxToken>[(int)LastTokenWithWellKnownText + 1]; 148private static readonly ArrayElement<SyntaxToken>[] s_missingTokensWithNoTrivia = new ArrayElement<SyntaxToken>[(int)LastTokenWithWellKnownText + 1]; 150private static readonly SyntaxToken s_missingIdentifierTokenWithNoTrivia = new MissingTokenWithTrivia(SyntaxKind.IdentifierToken, leading: null, trailing: null); 164internal static IEnumerable<SyntaxToken> GetWellKnownTokens() 199internal static SyntaxToken Identifier(string text) 204internal static SyntaxToken Identifier(GreenNode leading, string text, GreenNode trailing) 221internal static SyntaxToken Identifier(SyntaxKind contextualKind, GreenNode leading, string text, string valueText, GreenNode trailing) 231internal static SyntaxToken WithValue<T>(SyntaxKind kind, string text, T value) 236internal static SyntaxToken WithValue<T>(SyntaxKind kind, GreenNode leading, string text, T value, GreenNode trailing) 241internal static SyntaxToken StringLiteral(string text) 246internal static SyntaxToken StringLiteral(CSharpSyntaxNode leading, string text, CSharpSyntaxNode trailing) 347public virtual SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 357public virtual SyntaxToken TokenWithTrailingTrivia(GreenNode trivia) 364System.Diagnostics.Debug.Assert(this.GetType() == typeof(SyntaxToken)); 370System.Diagnostics.Debug.Assert(this.GetType() == typeof(SyntaxToken)); 435var otherToken = (SyntaxToken)other;
Syntax\InternalSyntax\SyntaxToken.MissingTokenWithTrivia.cs (2)
47public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 52public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifier.cs (2)
44public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 49public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifierExtended.cs (2)
47public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 52public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifierWithTrailingTrivia.cs (2)
40public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 45public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifierWithTrivia.cs (2)
68public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 73public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxLiteral.cs (2)
57public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 62public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxLiteralWithTrivia.cs (2)
63public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 68public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxTokenWithTrivia.cs (2)
56public override SyntaxToken TokenWithLeadingTrivia(GreenNode trivia) 61public override SyntaxToken TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\TypeDeclarationSyntax.cs (30)
15CoreSyntax.SyntaxList<SyntaxToken> modifiers, 16SyntaxToken keyword, 17SyntaxToken identifier, 22SyntaxToken openBraceToken, 24SyntaxToken closeBraceToken, 25SyntaxToken semicolonToken); 32CoreSyntax.SyntaxList<SyntaxToken> modifiers, 33SyntaxToken keyword, 34SyntaxToken identifier, 39SyntaxToken openBraceToken, 41SyntaxToken closeBraceToken, 42SyntaxToken semicolonToken) 64CoreSyntax.SyntaxList<SyntaxToken> modifiers, 65SyntaxToken keyword, 66SyntaxToken identifier, 71SyntaxToken openBraceToken, 73SyntaxToken closeBraceToken, 74SyntaxToken semicolonToken) 96CoreSyntax.SyntaxList<SyntaxToken> modifiers, 97SyntaxToken keyword, 98SyntaxToken identifier, 103SyntaxToken openBraceToken, 105SyntaxToken closeBraceToken, 106SyntaxToken semicolonToken) 129CoreSyntax.SyntaxList<SyntaxToken> modifiers, 130SyntaxToken keyword, 131SyntaxToken identifier, 136SyntaxToken openBraceToken, 138SyntaxToken closeBraceToken, 139SyntaxToken semicolonToken)
Syntax\SyntaxEquivalence.cs (4)
80if (((Green.SyntaxToken)before).ValueText != ((Green.SyntaxToken)after).ValueText) 95if (((Green.SyntaxToken)before).Text != ((Green.SyntaxToken)after).Text)
Syntax\SyntaxFactory.cs (1)
1663var token = lexer.Lex(InternalSyntax.LexerMode.Syntax);
Syntax\SyntaxFacts.cs (2)
443internal static bool IsIdentifierVar(this Syntax.InternalSyntax.SyntaxToken node) 448internal static bool IsIdentifierVarOrPredefinedType(this Syntax.InternalSyntax.SyntaxToken node)
Syntax\SyntaxTokenParser.cs (3)
55var token = _lexer.Lex(InternalSyntax.LexerMode.Syntax); 70var containingToken = InternalSyntax.SyntaxFactory.MissingToken(leading: leadingTrivia.Node, SyntaxKind.None, trailing: null); 85var containingToken = InternalSyntax.SyntaxFactory.MissingToken(leading: null, SyntaxKind.None, trailing: trailingTrivia.Node);
Syntax\SyntaxTreeDiagnosticEnumerator.cs (3)
142var token = node as Syntax.InternalSyntax.SyntaxToken; 153private void PushToken(Syntax.InternalSyntax.SyntaxToken token)
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (4)
IncrementalParsing\IncrementalParsingTests.cs (2)
3074var oldToken = ((Syntax.InternalSyntax.ClassDeclarationSyntax)oldClassC).Identifier; 3075var newToken = ((Syntax.InternalSyntax.ClassDeclarationSyntax)newClassC).Identifier;
LexicalAndXml\CrefLexerTests.cs (1)
448var token = lexer.Lex(InternalSyntax.LexerMode.XmlCrefQuote | InternalSyntax.LexerMode.XmlDocCommentStyleSingleLine | InternalSyntax.LexerMode.XmlDocCommentLocationInterior);
LexicalAndXml\NameAttributeValueLexerTests.cs (1)
412var token = lexer.Lex(InternalSyntax.LexerMode.XmlNameQuote | InternalSyntax.LexerMode.XmlDocCommentStyleSingleLine | InternalSyntax.LexerMode.XmlDocCommentLocationInterior);