src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiers.cs (1)
27out SyntaxToken name,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (32)
20public static void Deconstruct(this SyntaxToken token, out SyntaxKind kind)
23public static bool IsLastTokenOfNode<T>(this SyntaxToken token) where T : SyntaxNode
26public static bool IsLastTokenOfNode<T>(this SyntaxToken token, [NotNullWhen(true)] out T? node) where T : SyntaxNode
39public static bool IsKindOrHasMatchingText(this SyntaxToken token, SyntaxKind kind)
42public static bool HasMatchingText(this SyntaxToken token, SyntaxKind kind)
45public static bool IsOpenBraceOrCommaOfObjectInitializer(this SyntaxToken token)
49public static bool IsOpenBraceOfAccessorList(this SyntaxToken token)
58public static bool CouldBeKeyword(this SyntaxToken token)
76public static bool IsPotentialModifier(this SyntaxToken token, out SyntaxKind modifierKind)
125public static bool IsLiteral(this SyntaxToken token)
141public static bool IntersectsWith(this SyntaxToken token, int position)
144public static SyntaxToken GetPreviousTokenIfTouchingWord(this SyntaxToken token, int position)
151private static bool IsWord(SyntaxToken token)
154public static SyntaxToken GetNextNonZeroWidthTokenOrEndOfFile(this SyntaxToken token)
160public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
162var previousToken = token.GetPreviousToken(includeSkipped: true, includeDirectives: true, includeDocumentationComments: true);
173public static bool SpansPreprocessorDirective(this IEnumerable<SyntaxToken> tokens)
180public static IEnumerable<SyntaxTrivia> GetAllTrailingTrivia(this SyntaxToken token)
195public static bool IsRegularStringLiteral(this SyntaxToken token)
198public static bool IsValidAttributeTarget(this SyntaxToken token)
218public static SyntaxToken WithCommentsFrom(
219this SyntaxToken token,
228public static SyntaxToken KeepCommentsAndAddElasticMarkers(this SyntaxToken token)
232public static bool TryParseGenericName(this SyntaxToken genericIdentifier, CancellationToken cancellationToken, [NotNullWhen(true)] out GenericNameSyntax? genericName)
236var lastToken = genericIdentifier.FindLastTokenOfPartialGenericName();
256public static SyntaxToken FindLastTokenOfPartialGenericName(this SyntaxToken genericIdentifier)
261var token = genericIdentifier.GetNextToken(includeSkipped: true);
270var next = token.GetNextToken(includeSkipped: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (9)
28var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
92public static bool IsRightOfDotOrArrowOrColonColon(this SyntaxTree syntaxTree, int position, SyntaxToken targetToken, CancellationToken cancellationToken)
190var eof = root.EndOfFileToken;
322private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int position, char lastChar, CancellationToken cancellationToken)
393this SyntaxTree syntaxTree, int position, out SyntaxToken stringLiteral, CancellationToken cancellationToken)
395var token = syntaxTree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia: true);
445var token = root.FindToken(position, findInsideTrivia: true);
540public static bool IsPreProcessorKeywordContext(this SyntaxTree syntaxTree, int position, SyntaxToken preProcessorTokenOnLeftOfPosition)
550var token = preProcessorTokenOnLeftOfPosition;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaRewriter.cs (16)
25private readonly Dictionary<SyntaxToken, SyntaxTriviaList> _trailingTriviaMap = [];
26private readonly Dictionary<SyntaxToken, SyntaxTriviaList> _leadingTriviaMap = [];
31Dictionary<ValueTuple<SyntaxToken, SyntaxToken>, TriviaData> map,
48Dictionary<ValueTuple<SyntaxToken, SyntaxToken>, TriviaData> map,
70KeyValuePair<ValueTuple<SyntaxToken, SyntaxToken>,
99private TextSpan GetTextSpan(ValueTuple<SyntaxToken, SyntaxToken> pair)
135ValueTuple<SyntaxToken, SyntaxToken> pair,
163public override SyntaxToken VisitToken(SyntaxToken token)
208private static SyntaxToken CreateNewToken(SyntaxTriviaList leadingTrivia, SyntaxToken token, SyntaxTriviaList trailingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\BaseFormattingRule.cs (27)
19SyntaxToken startToken,
20SyntaxToken endToken,
34SyntaxToken startToken,
35SyntaxToken endToken,
59SyntaxToken startToken,
60SyntaxToken endToken,
73SyntaxToken startToken,
74SyntaxToken endToken,
87SyntaxToken startToken,
88SyntaxToken endToken,
102SyntaxToken baseToken,
103SyntaxToken startToken,
104SyntaxToken endToken,
112SyntaxToken baseToken,
113SyntaxToken startToken,
114SyntaxToken endToken,
120protected static void AddSuppressWrappingIfOnSingleLineOperation(ArrayBuilder<SuppressOperation> list, SyntaxToken startToken, SyntaxToken endToken, SuppressOption extraOption = SuppressOption.None)
123protected static void AddSuppressAllOperationIfOnMultipleLine(ArrayBuilder<SuppressOperation> list, SyntaxToken startToken, SyntaxToken endToken, SuppressOption extraOption = SuppressOption.None)
126protected static void AddSuppressOperation(ArrayBuilder<SuppressOperation> list, SyntaxToken startToken, SyntaxToken endToken, SuppressOption option)
136protected static void AddAnchorIndentationOperation(List<AnchorIndentationOperation> list, SyntaxToken anchorToken, SyntaxToken endToken)
146protected static void AddAlignIndentationOfTokensToBaseTokenOperation(List<AlignTokensOperation> list, SyntaxNode containingNode, SyntaxToken baseNode, IEnumerable<SyntaxToken> tokens, AlignTokensOption option = AlignTokensOption.AlignIndentationOfTokensToBaseToken)
170var firstTokenOfNode = node.GetFirstToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (66)
79public SyntaxToken ParseToken(string text)
97public bool IsVerbatimIdentifier(SyntaxToken token)
100public bool IsOperator(SyntaxToken token)
111public bool IsReservedKeyword(SyntaxToken token)
114public bool IsContextualKeyword(SyntaxToken token)
117public bool IsPreprocessorKeyword(SyntaxToken token)
202public void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name)
278public bool IsThisConstructorInitializer(SyntaxToken token)
282public bool IsBaseConstructorInitializer(SyntaxToken token)
286public bool IsQueryKeyword(SyntaxToken token)
313public bool IsPredefinedType(SyntaxToken token)
316public bool IsPredefinedType(SyntaxToken token, PredefinedType type)
325public bool TryGetPredefinedType(SyntaxToken token, out PredefinedType type)
331private static PredefinedType GetPredefinedType(SyntaxToken token)
359public bool IsPredefinedOperator(SyntaxToken token)
362public bool IsPredefinedOperator(SyntaxToken token, PredefinedOperator op)
365public bool TryGetPredefinedOperator(SyntaxToken token, out PredefinedOperator op)
371private static PredefinedOperator GetPredefinedOperator(SyntaxToken token)
467var token = SyntaxFactory.ParseToken(identifier);
473var token = SyntaxFactory.ParseToken(identifier);
482public bool IsLiteral(SyntaxToken token)
510public bool IsStringLiteralOrInterpolatedStringLiteral(SyntaxToken token)
513public bool IsBindableToken(SemanticModel? semanticModel, SyntaxToken token)
829var identifier = ((IdentifierNameSyntax)node).Identifier;
850var nameToken = memberDeclaration.GetNameToken();
879var nameToken = fieldDeclarator.Identifier;
1004public SyntaxNode? TryGetBindableParent(SyntaxToken token)
1193public bool IsVerbatimStringLiteral(SyntaxToken token)
1196public bool IsRawStringLiteral(SyntaxToken token)
1203public bool IsNumericLiteral(SyntaxToken token)
1306SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1313SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1331public SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node)
1334public SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node)
1337public SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node)
1349public bool AreEquivalent(SyntaxToken token1, SyntaxToken token2)
1365out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode
1382public bool ContainsInterleavedDirective(TextSpan span, SyntaxToken token, CancellationToken cancellationToken)
1423public SyntaxToken? GetDeclarationIdentifierIfOverride(SyntaxToken token)
1457public void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right)
1500public void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen)
1508public void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1516public void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern)
1523public void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression)
1591public void GetPartsOfAliasQualifiedName(SyntaxNode node, out SyntaxNode alias, out SyntaxToken colonColonToken, out SyntaxNode name)
1599public void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken)
1621public void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1638SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull)
1660public void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments)
1668out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken)
1683public void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name)
1706public void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1715public void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer)
1723public void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default)
1731SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen)
1739public void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand)
1746public void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1779public SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (38)
20public static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRange(SyntaxToken endToken, bool useDefaultRange = true)
27private static ValueTuple<SyntaxToken, SyntaxToken>? FixupOpenBrace(ValueTuple<SyntaxToken, SyntaxToken>? tokenRange)
37var currentToken = tokenRange.Value.Item1;
38var previousToken = currentToken.GetPreviousToken();
55private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeWorker(SyntaxToken endToken, bool useDefaultRange)
112private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForSemicolon(SyntaxToken endToken)
168private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForCloseBrace(SyntaxToken endToken)
215var firstTokenOfInnerBlock = parent.GetFirstToken();
216var lastTokenOfInnerBlock = parent.GetLastToken();
250var firstTokenOfInnerBlock = parent.GetFirstToken();
251var lastTokenOfInnerBlock = parent.GetLastToken();
268private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForColon(SyntaxToken endToken)
285private static SyntaxToken GetPreviousTokenIfNotFirstTokenInTree(SyntaxToken token)
287var previousToken = token.GetPreviousToken();
291public static bool AreTwoTokensOnSameLine(SyntaxToken token1, SyntaxToken token2)
307private static SyntaxToken GetAppropriatePreviousToken(SyntaxToken startToken, bool canTokenBeFirstInABlock = false)
309var previousToken = startToken.GetPreviousToken();
345private static bool IsOpenBraceTokenOfABlockOrTypeOrNamespace(SyntaxToken previousToken)
406public static bool IsColonInSwitchLabel(SyntaxToken token)
413public static bool InBetweenTwoMembers(SyntaxToken previousToken, SyntaxToken currentToken)
433public static MemberDeclarationSyntax? GetEnclosingMember(SyntaxToken token)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (1)
138SyntaxToken identifier,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
254SyntaxToken identifier,
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
67SyntaxToken token,
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
68SyntaxToken token,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (75)
137this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
156var originalToken = tokenOnLeftOfPosition;
157var token = originalToken;
368this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
409var originalToken = tokenOnLeftOfPosition;
410var token = originalToken;
417var nextToken = originalToken.GetNextToken(includeSkipped: true);
842this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
847var token = tokenOnLeftOfPosition;
860public static bool IsTypeParameterConstraintContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
867var token = tokenOnLeftOfPosition;
891public static bool IsTypeOfExpressionContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
903public static bool IsDefaultExpressionContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
916this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
931SyntaxToken tokenOnLeftOfPosition,
934var token = tokenOnLeftOfPosition;
954public static bool IsGenericConstraintContext(this SyntaxTree syntaxTree, SyntaxToken targetToken)
961SyntaxToken tokenOnLeftOfPosition,
969var token = tokenOnLeftOfPosition;
983if (!syntaxTree.IsInPartiallyWrittenGeneric(position, cancellationToken, out var nameToken))
1049SyntaxToken tokenOnLeftOfPosition,
1139SyntaxToken tokenOnLeftOfPosition,
1153var token = tokenOnLeftOfPosition;
1165this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1167var token = tokenOnLeftOfPosition;
1180this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1182var token = tokenOnLeftOfPosition;
1194public static bool IsParameterTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1211public static bool IsPossibleExtensionMethodContext(this SyntaxTree syntaxTree, SyntaxToken tokenOnLeftOfPosition)
1223this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1225var token = tokenOnLeftOfPosition;
1255this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1257var token = tokenOnLeftOfPosition;
1282this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1284var token = tokenOnLeftOfPosition;
1307public static bool IsPossibleTupleContext(this SyntaxTree syntaxTree, SyntaxToken leftToken, int position)
1327var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.Parent);
1339var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.Parent!);
1352var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.Parent.Parent);
1362public static bool IsAtStartOfPattern(this SyntaxTree syntaxTree, SyntaxToken leftToken, int position)
1456public static bool IsAtEndOfPattern(this SyntaxTree syntaxTree, SyntaxToken leftToken, int position)
1458var originalLeftToken = leftToken;
1541static bool IsAtEndOfSwitchStatementPattern(SyntaxToken leftToken)
1563private static SyntaxToken FindTokenOnLeftOfNode(SyntaxNode node)
1566public static bool IsPossibleTupleOpenParenOrComma(this SyntaxToken possibleCommaOrParen)
1689private static bool IsPossibleVarDeconstructionOpenParenOrComma(SyntaxToken leftToken)
1711SyntaxToken tokenOnLeftOfPosition,
1734var token = tokenOnLeftOfPosition;
1749this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1751var token = tokenOnLeftOfPosition;
1766this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1880this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1885var token = tokenOnLeftOfPosition;
1914public static bool IsIsOrAsTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1916var token = tokenOnLeftOfPosition;
1926this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1944private static bool IsNonConstantExpressionContext(SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1958public static bool IsStatementContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1970var token = tokenOnLeftOfPosition;
1999public static bool IsInstanceContext(this SyntaxTree syntaxTree, SyntaxToken targetToken, SemanticModel semanticModel, CancellationToken cancellationToken)
2030this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
2043public static bool IsDefiniteCastTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
2045var token = tokenOnLeftOfPosition;
2058SyntaxToken tokenOnLeftOfPosition)
2165SyntaxToken tokenOnLeftOfPosition,
2342var previousToken = tokenOnLeftOfPosition.GetPreviousToken(includeSkipped: true);
2737public static bool IsInvocationOfVarExpression(this SyntaxToken token)
2811SyntaxToken tokenOnLeftOfPosition,
2817var token = tokenOnLeftOfPosition;
2928this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
2945var token = tokenOnLeftOfPosition;
2963public static bool IsCatchFilterContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
2971var token = tokenOnLeftOfPosition;
2988public static bool IsEnumBaseListContext(this SyntaxTree syntaxTree, SyntaxToken targetToken)
3055public static bool IsFunctionPointerCallingConventionContext(this SyntaxTree syntaxTree, SyntaxToken targetToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (14)
24protected override bool ShouldUseTokenIndenter(Indenter indenter, out SyntaxToken syntaxToken)
36protected override IndentationResult? GetDesiredIndentationWorker(Indenter indenter, SyntaxToken? tokenOpt, SyntaxTrivia? triviaOpt)
66private static IndentationResult? TryGetDesiredIndentation(Indenter indenter, SyntaxToken? tokenOpt)
74private static IndentationResult GetIndentationBasedOnToken(Indenter indenter, SyntaxToken token)
322private static IndentationResult GetIndentationFromCommaSeparatedList(Indenter indenter, SyntaxToken token)
335Indenter indenter, SeparatedSyntaxList<T> list, SyntaxToken token) where T : SyntaxNode
349var firstToken = node.GetFirstToken(includeZeroWidth: true);
362private static IndentationResult GetDefaultIndentationFromToken(Indenter indenter, SyntaxToken token)
372private static IndentationResult GetIndentationForQueryExpression(Indenter indenter, SyntaxToken token)
384var firstToken = queryExpressionClause.GetFirstToken(includeZeroWidth: true);
419var clauseToken = clause.GetFirstToken(includeZeroWidth: true);
431private static SyntaxNode? GetQueryExpressionClause(SyntaxToken token)
457private static bool IsPartOfQueryExpression(SyntaxToken token)
464Indenter indenter, SyntaxToken token, int? additionalSpace = null)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (1)
78var discardToken = Identifier(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSyntaxGeneratorInternal.cs (11)
51public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken name, SyntaxNode? initializer, bool isConst)
61public override SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
64internal static VariableDeclarationSyntax VariableDeclaration(SyntaxNode? type, SyntaxToken name, SyntaxNode? expression)
73public override SyntaxToken Identifier(string identifier)
105public override SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
108public override SyntaxNode InterpolatedStringText(SyntaxToken textToken)
111public override SyntaxToken InterpolatedStringTextToken(string content, string value)
139using var _ = ArrayBuilder<SyntaxToken>.GetInstance(out var result);
197public override SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isKeyword, SyntaxNode pattern)
238public override SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (52)
52private static bool DecomposeBinaryOrAssignmentExpression(SyntaxNode node, out SyntaxToken operatorToken, out ExpressionSyntax left, out ExpressionSyntax right)
78out var operatorToken, out var left, out var right))
257private IEnumerable<TypeInferenceInfo> InferTypeInAnonymousObjectCreation(AnonymousObjectCreationExpressionSyntax expression, SyntaxToken previousToken)
268ArgumentSyntax argument, SyntaxToken? previousToken = null)
341TupleExpressionSyntax tupleExpression, SyntaxToken previousToken)
368private IEnumerable<TypeInferenceInfo> InferTypeInAttributeArgument(AttributeArgumentSyntax argument, SyntaxToken? previousToken = null)
396private IEnumerable<TypeInferenceInfo> InferTypeInObjectCreationExpression(BaseObjectCreationExpressionSyntax expression, SyntaxToken previousToken)
511private IEnumerable<TypeInferenceInfo> InferTypeInArgumentList(ArgumentListSyntax argumentList, SyntaxToken previousToken)
541private IEnumerable<TypeInferenceInfo> InferTypeInAttributeArgumentList(AttributeArgumentListSyntax attributeArgumentList, SyntaxToken previousToken)
810ArrayCreationExpressionSyntax arrayCreationExpression, SyntaxToken? previousToken = null)
837private IEnumerable<TypeInferenceInfo> InferTypeInArrayRankSpecifier(ArrayRankSpecifierSyntax arrayRankSpecifier, SyntaxToken? previousToken = null)
847private IEnumerable<TypeInferenceInfo> InferTypeInArrayType(ArrayTypeSyntax arrayType, SyntaxToken? previousToken = null)
870private IEnumerable<TypeInferenceInfo> InferTypeInAttributeDeclaration(AttributeListSyntax attributeDeclaration, SyntaxToken? previousToken)
881SyntaxToken? previousToken)
890private IEnumerable<TypeInferenceInfo> InferTypeInBracketedArgumentList(BracketedArgumentListSyntax bracketedArgumentList, SyntaxToken previousToken)
906private static int GetArgumentListIndex(BaseArgumentListSyntax argumentList, SyntaxToken previousToken)
925private static int GetArgumentListIndex(AttributeArgumentListSyntax attributeArgumentList, SyntaxToken previousToken)
944private IEnumerable<TypeInferenceInfo> InferTypeInBinaryOrAssignmentExpression(ExpressionSyntax binop, SyntaxToken operatorToken, ExpressionSyntax left, ExpressionSyntax right, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1079private IEnumerable<TypeInferenceInfo> InferTypeInCastExpression(CastExpressionSyntax castExpression, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1091private IEnumerable<TypeInferenceInfo> InferTypeInCatchDeclaration(CatchDeclarationSyntax catchDeclaration, SyntaxToken? previousToken = null)
1100private IEnumerable<TypeInferenceInfo> InferTypeInCatchFilterClause(CatchFilterClauseSyntax catchFilterClause, SyntaxToken? previousToken = null)
1112SyntaxToken? previousToken = null)
1166private IEnumerable<TypeInferenceInfo> InferTypeInConditionalExpression(ConditionalExpressionSyntax conditional, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1199private IEnumerable<TypeInferenceInfo> InferTypeInDoStatement(DoStatementSyntax doStatement, SyntaxToken? previousToken = null)
1208private IEnumerable<TypeInferenceInfo> InferTypeInEqualsValueClause(EqualsValueClauseSyntax equalsValue, SyntaxToken? previousToken = null)
1237private IEnumerable<TypeInferenceInfo> InferTypeInExpressionStatement(SyntaxToken? previousToken = null)
1247private IEnumerable<TypeInferenceInfo> InferTypeInForEachStatement(ForEachStatementSyntax forEachStatementSyntax, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1274private IEnumerable<TypeInferenceInfo> InferTypeInForStatement(ForStatementSyntax forStatement, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1286private IEnumerable<TypeInferenceInfo> InferTypeInIfStatement(IfStatementSyntax ifStatement, SyntaxToken? previousToken = null)
1301SyntaxToken? previousToken = null)
1503var identifier = singleVariableDesignation.Identifier;
1595private IEnumerable<TypeInferenceInfo> InferTypeInLockStatement(LockStatementSyntax lockStatement, SyntaxToken? previousToken = null)
1604private IEnumerable<TypeInferenceInfo> InferTypeInLambdaExpression(LambdaExpressionSyntax lambdaExpression, SyntaxToken? previousToken = null)
1633private IEnumerable<TypeInferenceInfo> InferTypeInMemberDeclarator(AnonymousObjectMemberDeclaratorSyntax memberDeclarator, SyntaxToken? previousTokenOpt = null)
1652private IEnumerable<TypeInferenceInfo> InferTypeInNameColon(NameColonSyntax nameColon, SyntaxToken previousToken)
1668private IEnumerable<TypeInferenceInfo> InferTypeInExpressionColon(ExpressionColonSyntax expressionColon, SyntaxToken previousToken)
1686SyntaxToken? previousToken = null)
1869private IEnumerable<TypeInferenceInfo> InferTypeInNameEquals(NameEqualsSyntax nameEquals, SyntaxToken? previousToken = null)
1887private IEnumerable<TypeInferenceInfo> InferTypeInPostfixUnaryExpression(PostfixUnaryExpressionSyntax postfixUnaryExpressionSyntax, SyntaxToken? previousToken = null)
1903private IEnumerable<TypeInferenceInfo> InferTypeInPrefixUnaryExpression(PrefixUnaryExpressionSyntax prefixUnaryExpression, SyntaxToken? previousToken = null)
1959private IEnumerable<TypeInferenceInfo> InferTypeInAwaitExpression(AwaitExpressionSyntax awaitExpression, SyntaxToken? previousToken = null)
1981private IEnumerable<TypeInferenceInfo> InferTypeInYieldStatement(YieldStatementSyntax yieldStatement, SyntaxToken? previousToken = null)
2022ReturnStatementSyntax returnStatement, SyntaxToken? previousToken = null)
2100private IEnumerable<TypeInferenceInfo> InferTypeInSwitchExpression(SwitchExpressionSyntax switchExpression, SyntaxToken token)
2109SwitchLabelSyntax switchLabel, SyntaxToken? previousToken = null)
2125SwitchStatementSyntax switchStatement, SyntaxToken? previousToken = null)
2145private IEnumerable<TypeInferenceInfo> InferTypeInThrowExpression(ThrowExpressionSyntax throwExpression, SyntaxToken? previousToken = null)
2154private IEnumerable<TypeInferenceInfo> InferTypeInThrowStatement(ThrowStatementSyntax throwStatement, SyntaxToken? previousToken = null)
2163private IEnumerable<TypeInferenceInfo> InferTypeInUsingStatement(UsingStatementSyntax usingStatement, SyntaxToken? previousToken = null)
2368private IEnumerable<TypeInferenceInfo> InferTypeInWhenClause(WhenClauseSyntax whenClause, SyntaxToken? previousToken = null)
2377private IEnumerable<TypeInferenceInfo> InferTypeInWhileStatement(WhileStatementSyntax whileStatement, SyntaxToken? previousToken = null)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (9)
15public static SyntaxToken TryEscapeIdentifierToken(SyntaxToken syntaxToken, SyntaxNode parentOfToken)
59var firstRewrittenToken = rewrittenNode.GetFirstToken(true, false, true, true);
60var firstOriginalToken = originalNode.GetFirstToken(true, false, true, true);
61if (TryAddLeadingElasticTriviaIfNecessary(firstRewrittenToken, firstOriginalToken, out var rewrittenTokenWithLeadingElasticTrivia))
69public static bool TryAddLeadingElasticTriviaIfNecessary(SyntaxToken token, SyntaxToken originalToken, out SyntaxToken tokenWithLeadingWhitespace)
78var previousToken = originalToken.GetPreviousToken();
Completion\CompletionProviders\CrefCompletionProvider.cs (10)
89protected override async Task<(SyntaxToken, SemanticModel?, ImmutableArray<ISymbol>)> GetSymbolsAsync(
115private static bool IsCrefStartContext(SyntaxToken token)
125private static bool IsCrefParameterListContext(SyntaxToken token)
155private static bool IsCrefQualifiedNameContext(SyntaxToken token)
165SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken)
180SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken)
211QualifiedCrefSyntax parent, SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken)
237SemanticModel semanticModel, ImmutableArray<ISymbol> symbols, SyntaxToken token, int position, ImmutableArray<KeyValuePair<string, string>> options)
259SemanticModel semanticModel, ISymbol symbol, SyntaxToken token, int position, StringBuilder builder,
279SyntaxToken token,
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (23)
97SyntaxToken token, SemanticModel semanticModel,
111SyntaxToken token, SemanticModel semanticModel,
135private static bool IsPossibleOutVariableDeclaration(SyntaxToken token, SemanticModel semanticModel,
145if (argument is { RefOrOutKeyword: SyntaxToken(SyntaxKind.OutKeyword) })
168SyntaxToken token, SemanticModel semanticModel,
190private static bool IsPropertyDeclaration(SyntaxToken token, SemanticModel semanticModel,
204private static bool IsMethodDeclaration(SyntaxToken token, SemanticModel semanticModel,
219SyntaxToken token,
268SyntaxToken token,
279SyntaxToken token,
309private static bool IsFieldDeclaration(SyntaxToken token, SemanticModel semanticModel,
320private static bool IsIncompleteMemberDeclaration(SyntaxToken token, SemanticModel semanticModel,
331private static bool IsLocalFunctionDeclaration(SyntaxToken token, SemanticModel semanticModel,
342private static bool IsLocalVariableDeclaration(SyntaxToken token, SemanticModel semanticModel,
387private static bool IsEmbeddedVariableDeclaration(SyntaxToken token, SemanticModel semanticModel,
400private static bool IsForEachVariableDeclaration(SyntaxToken token, SemanticModel semanticModel,
416private static bool IsTypeParameterDeclaration(SyntaxToken token, out NameDeclarationInfo result)
432private static bool IsPrimaryConstructorParameter(SyntaxToken token, SemanticModel semanticModel,
452private static bool IsParameterDeclaration(SyntaxToken token, SemanticModel semanticModel,
465SyntaxToken token,
510private static bool IsPossibleTypeToken(SyntaxToken token)
558foreach (var modifer in modifiers)
605var modifier = modifiers[i];
Completion\CompletionProviders\OperatorsAndIndexer\UnnamedSymbolCompletionProvider_Conversions.cs (1)
86: (SyntaxToken?)null;
EditAndContinue\SyntaxComparer.cs (31)
966out IEnumerable<SyntaxToken> parameters,
967out SyntaxToken asyncKeyword,
971out SyntaxToken identifier,
1156List<SyntaxToken>? leftLocals = null;
1157List<SyntaxToken>? rightLocals = null;
1236List<SyntaxToken>? leftLocals = null;
1237List<SyntaxToken>? rightLocals = null;
1261List<SyntaxToken>? leftLocals = null;
1262List<SyntaxToken>? rightLocals = null;
1279private static void GetLocalNames(BlockSyntax block, ref List<SyntaxToken>? result)
1292private static void GetLocalNames(VariableDeclarationSyntax localDeclaration, ref List<SyntaxToken>? result)
1300internal static void GetLocalNames(CommonForEachStatementSyntax commonForEach, ref List<SyntaxToken>? result)
1318private static void GetLocalNames(ExpressionSyntax expression, ref List<SyntaxToken>? result)
1343private static void GetLocalNames(VariableDesignationSyntax designation, ref List<SyntaxToken>? result)
1368private static void GetLocalNames(SyntaxToken syntaxToken, [NotNull] ref List<SyntaxToken>? result)
1549var leftToken = oldNodeOrToken.AsToken();
1550var rightToken = newNodeOrToken.AsToken();
1570internal static IEnumerable<SyntaxToken> GetDescendantTokensIgnoringSeparators<TSyntaxNode>(SeparatedSyntaxList<TSyntaxNode> list)
1575foreach (var token in node.DescendantTokens())
1604public static double ComputeDistance(SyntaxToken oldToken, SyntaxToken newToken)
1618public static double ComputeDistance(IEnumerable<SyntaxToken>? oldTokens, IEnumerable<SyntaxToken>? newTokens)
1645public static IEnumerable<SequenceEdit> GetSequenceEdits(IEnumerable<SyntaxToken>? oldTokens, IEnumerable<SyntaxToken>? newTokens)
1651public static IEnumerable<SequenceEdit> GetSequenceEdits(ImmutableArray<SyntaxToken> oldTokens, ImmutableArray<SyntaxToken> newTokens)
1654private sealed class LcsTokens : LongestCommonImmutableArraySubsequence<SyntaxToken>
1658protected override bool Equals(SyntaxToken oldElement, SyntaxToken newElement)
ReplaceMethodWithProperty\CSharpReplaceMethodWithPropertyService.cs (6)
125var nameToken = GetPropertyName(getMethodDeclaration.Identifier, propertyName, nameChanged);
158private static SyntaxToken GetPropertyName(SyntaxToken identifier, string propertyName, bool nameChanged)
350public void ReplaceGetReference(SyntaxEditor editor, SyntaxToken nameToken, string propertyName, bool nameChanged)
353public void ReplaceSetReference(SyntaxEditor editor, SyntaxToken nameToken, string propertyName, bool nameChanged)
356public static void ReplaceInvocation(SyntaxEditor editor, SyntaxToken nameToken, string propertyName, bool nameChanged,
SignatureHelp\ElementAccessExpressionSignatureHelpProvider.cs (16)
46private static bool TryGetElementAccessExpression(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax? identifier, out SyntaxToken openBrace)
56if (!TryGetElementAccessExpression(root, position, document.GetRequiredLanguageService<ISyntaxFactsService>(), triggerInfo.TriggerReason, cancellationToken, out var expression, out var openBrace))
115private static TextSpan GetTextSpan(ExpressionSyntax expression, SyntaxToken openBracket)
145out var openBracket) ||
227SyntaxToken openToken,
284internal static bool IsTriggerToken(SyntaxToken token)
293internal static bool IsArgumentListToken(ElementAccessExpressionSyntax expression, SyntaxToken token)
299internal static TextSpan GetTextSpan(SyntaxToken openBracket)
306internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax? identifier, out SyntaxToken openBrace)
327internal static bool IsArgumentListToken(ArrayTypeSyntax node, SyntaxToken token)
333internal static bool IsTriggerToken(SyntaxToken token)
341internal static TextSpan GetTextSpan(SyntaxNode expression, SyntaxToken openBracket)
347internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax? identifier, out SyntaxToken openBrace)
368internal static bool IsTriggerToken(SyntaxToken token)
378internal static bool IsArgumentListToken(ElementBindingExpressionSyntax expression, SyntaxToken token)
384internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax? identifier, out SyntaxToken openBrace)
SignatureHelp\SignatureHelpUtilities.cs (9)
18private static readonly Func<BaseArgumentListSyntax, SyntaxToken> s_getBaseArgumentListOpenToken = list => list.GetOpenToken();
19private static readonly Func<TypeArgumentListSyntax, SyntaxToken> s_getTypeArgumentListOpenToken = list => list.LessThanToken;
20private static readonly Func<InitializerExpressionSyntax, SyntaxToken> s_getInitializerExpressionOpenToken = e => e.OpenBraceToken;
21private static readonly Func<AttributeArgumentListSyntax, SyntaxToken> s_getAttributeArgumentListOpenToken = list => list.OpenParenToken;
23private static readonly Func<BaseArgumentListSyntax, SyntaxToken> s_getBaseArgumentListCloseToken = list => list.GetCloseToken();
24private static readonly Func<TypeArgumentListSyntax, SyntaxToken> s_getTypeArgumentListCloseToken = list => list.GreaterThanToken;
25private static readonly Func<InitializerExpressionSyntax, SyntaxToken> s_getInitializerExpressionCloseToken = e => e.CloseBraceToken;
26private static readonly Func<AttributeArgumentListSyntax, SyntaxToken> s_getAttributeArgumentListCloseToken = list => list.CloseParenToken;
99internal static bool IsTriggerParenOrComma<TSyntaxNode>(SyntaxToken token, Func<char, bool> isTriggerCharacter) where TSyntaxNode : SyntaxNode
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiers.cs (1)
27out SyntaxToken name,
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
67SyntaxToken token,
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
68SyntaxToken token,
Structure\CSharpStructureHelpers.cs (17)
26private static int GetCollapsibleStart(SyntaxToken firstToken)
35private static (int spanEnd, int hintEnd) GetCollapsibleEnd(SyntaxToken lastToken, bool compressEmptyLines)
84public static SyntaxToken GetLastInlineMethodBlockToken(SyntaxNode node)
86var lastToken = node.GetLastToken(includeZeroWidth: true);
94var nextToken = lastToken.GetNextToken(includeSkipped: true);
235var startToken = node.GetFirstToken();
236var endToken = GetEndToken(node);
252var hintTextEndToken = GetHintTextEndToken(node);
267static SyntaxToken GetEndToken(SyntaxNode node)
287static SyntaxToken GetHintTextEndToken(SyntaxNode node)
332SyntaxNode node, SyntaxToken syntaxToken, bool compressEmptyLines,
342SyntaxNode node, SyntaxToken startToken,
387SyntaxNode node, SyntaxToken startToken,
388SyntaxToken endToken, bool compressEmptyLines, string bannerText, bool autoCollapse,
411SyntaxNode node, SyntaxToken syntaxToken, bool compressEmptyLines,
425SyntaxNode node, SyntaxToken startToken, SyntaxToken endToken, bool compressEmptyLines,
Rename\CSharpRenameRewriterLanguageService.cs (35)
70private readonly HashSet<SyntaxToken> _annotatedIdentifierTokens = [];
210public override SyntaxToken VisitToken(SyntaxToken token)
214var newToken = base.VisitToken(token);
254private bool IsPropertyAccessorNameConflict(SyntaxToken token)
259private bool IsGetPropertyAccessorNameConflict(SyntaxToken token)
263private bool IsSetPropertyAccessorNameConflict(SyntaxToken token)
267private bool IsInitPropertyAccessorNameConflict(SyntaxToken token)
276private bool IsPossiblyDestructorConflict(SyntaxToken token)
324private SyntaxToken RenameAndAnnotate(SyntaxToken token, SyntaxToken newToken, bool isRenameLocation, bool isOldText)
435var identifierToken = default(SyntaxToken);
517private bool IsRenameLocation(SyntaxToken token)
554private SyntaxToken UpdateAliasAnnotation(SyntaxToken newToken)
564private SyntaxToken RenameToken(SyntaxToken oldToken, SyntaxToken newToken, string? prefix, string? suffix)
635private SyntaxToken RenameInStringLiteral(SyntaxToken oldToken, SyntaxToken newToken, ImmutableSortedSet<TextSpan>? subSpansToReplace, Func<SyntaxTriviaList, string, string, SyntaxTriviaList, SyntaxToken> createNewStringLiteral)
650private SyntaxToken RenameInTrivia(SyntaxToken token, IEnumerable<SyntaxTrivia> leadingOrTrailingTriviaList)
678private SyntaxToken RenameWithinToken(SyntaxToken oldToken, SyntaxToken newToken)
709var newIdentifierToken = SyntaxFactory.Identifier(newToken.LeadingTrivia, _replacementText, newToken.TrailingTrivia);
716var updatedToken = RenameInTrivia(oldToken, oldToken.LeadingTrivia);
725var updatedToken = RenameInTrivia(oldToken, oldToken.TrailingTrivia);
742SyntaxToken token,
1146public override SyntaxNode? GetExpansionTargetForLocation(SyntaxToken token)
1149private static SyntaxNode? GetExpansionTarget(SyntaxToken token)
Simplification\CSharpSimplificationService.cs (10)
78public override SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, Func<SyntaxNode, bool>? expandInsideNode, CancellationToken cancellationToken)
96public static SyntaxToken TryEscapeIdentifierToken(SyntaxToken syntaxToken, SyntaxNode parentOfToken)
140var firstRewrittenToken = rewrittenNode.GetFirstToken(true, false, true, true);
141var firstOriginalToken = originalNode.GetFirstToken(true, false, true, true);
150private static bool TryAddLeadingElasticTriviaIfNecessary(SyntaxToken token, SyntaxToken originalToken, out SyntaxToken tokenWithLeadingWhitespace)
159var previousToken = originalToken.GetPreviousToken();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (32)
20public static void Deconstruct(this SyntaxToken token, out SyntaxKind kind)
23public static bool IsLastTokenOfNode<T>(this SyntaxToken token) where T : SyntaxNode
26public static bool IsLastTokenOfNode<T>(this SyntaxToken token, [NotNullWhen(true)] out T? node) where T : SyntaxNode
39public static bool IsKindOrHasMatchingText(this SyntaxToken token, SyntaxKind kind)
42public static bool HasMatchingText(this SyntaxToken token, SyntaxKind kind)
45public static bool IsOpenBraceOrCommaOfObjectInitializer(this SyntaxToken token)
49public static bool IsOpenBraceOfAccessorList(this SyntaxToken token)
58public static bool CouldBeKeyword(this SyntaxToken token)
76public static bool IsPotentialModifier(this SyntaxToken token, out SyntaxKind modifierKind)
125public static bool IsLiteral(this SyntaxToken token)
141public static bool IntersectsWith(this SyntaxToken token, int position)
144public static SyntaxToken GetPreviousTokenIfTouchingWord(this SyntaxToken token, int position)
151private static bool IsWord(SyntaxToken token)
154public static SyntaxToken GetNextNonZeroWidthTokenOrEndOfFile(this SyntaxToken token)
160public static bool IsFirstTokenOnLine(this SyntaxToken token, SourceText text)
162var previousToken = token.GetPreviousToken(includeSkipped: true, includeDirectives: true, includeDocumentationComments: true);
173public static bool SpansPreprocessorDirective(this IEnumerable<SyntaxToken> tokens)
180public static IEnumerable<SyntaxTrivia> GetAllTrailingTrivia(this SyntaxToken token)
195public static bool IsRegularStringLiteral(this SyntaxToken token)
198public static bool IsValidAttributeTarget(this SyntaxToken token)
218public static SyntaxToken WithCommentsFrom(
219this SyntaxToken token,
228public static SyntaxToken KeepCommentsAndAddElasticMarkers(this SyntaxToken token)
232public static bool TryParseGenericName(this SyntaxToken genericIdentifier, CancellationToken cancellationToken, [NotNullWhen(true)] out GenericNameSyntax? genericName)
236var lastToken = genericIdentifier.FindLastTokenOfPartialGenericName();
256public static SyntaxToken FindLastTokenOfPartialGenericName(this SyntaxToken genericIdentifier)
261var token = genericIdentifier.GetNextToken(includeSkipped: true);
270var next = token.GetNextToken(includeSkipped: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (9)
28var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
92public static bool IsRightOfDotOrArrowOrColonColon(this SyntaxTree syntaxTree, int position, SyntaxToken targetToken, CancellationToken cancellationToken)
190var eof = root.EndOfFileToken;
322private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int position, char lastChar, CancellationToken cancellationToken)
393this SyntaxTree syntaxTree, int position, out SyntaxToken stringLiteral, CancellationToken cancellationToken)
395var token = syntaxTree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia: true);
445var token = root.FindToken(position, findInsideTrivia: true);
540public static bool IsPreProcessorKeywordContext(this SyntaxTree syntaxTree, int position, SyntaxToken preProcessorTokenOnLeftOfPosition)
550var token = preProcessorTokenOnLeftOfPosition;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaRewriter.cs (16)
25private readonly Dictionary<SyntaxToken, SyntaxTriviaList> _trailingTriviaMap = [];
26private readonly Dictionary<SyntaxToken, SyntaxTriviaList> _leadingTriviaMap = [];
31Dictionary<ValueTuple<SyntaxToken, SyntaxToken>, TriviaData> map,
48Dictionary<ValueTuple<SyntaxToken, SyntaxToken>, TriviaData> map,
70KeyValuePair<ValueTuple<SyntaxToken, SyntaxToken>,
99private TextSpan GetTextSpan(ValueTuple<SyntaxToken, SyntaxToken> pair)
135ValueTuple<SyntaxToken, SyntaxToken> pair,
163public override SyntaxToken VisitToken(SyntaxToken token)
208private static SyntaxToken CreateNewToken(SyntaxTriviaList leadingTrivia, SyntaxToken token, SyntaxTriviaList trailingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\BaseFormattingRule.cs (27)
19SyntaxToken startToken,
20SyntaxToken endToken,
34SyntaxToken startToken,
35SyntaxToken endToken,
59SyntaxToken startToken,
60SyntaxToken endToken,
73SyntaxToken startToken,
74SyntaxToken endToken,
87SyntaxToken startToken,
88SyntaxToken endToken,
102SyntaxToken baseToken,
103SyntaxToken startToken,
104SyntaxToken endToken,
112SyntaxToken baseToken,
113SyntaxToken startToken,
114SyntaxToken endToken,
120protected static void AddSuppressWrappingIfOnSingleLineOperation(ArrayBuilder<SuppressOperation> list, SyntaxToken startToken, SyntaxToken endToken, SuppressOption extraOption = SuppressOption.None)
123protected static void AddSuppressAllOperationIfOnMultipleLine(ArrayBuilder<SuppressOperation> list, SyntaxToken startToken, SyntaxToken endToken, SuppressOption extraOption = SuppressOption.None)
126protected static void AddSuppressOperation(ArrayBuilder<SuppressOperation> list, SyntaxToken startToken, SyntaxToken endToken, SuppressOption option)
136protected static void AddAnchorIndentationOperation(List<AnchorIndentationOperation> list, SyntaxToken anchorToken, SyntaxToken endToken)
146protected static void AddAlignIndentationOfTokensToBaseTokenOperation(List<AlignTokensOperation> list, SyntaxNode containingNode, SyntaxToken baseNode, IEnumerable<SyntaxToken> tokens, AlignTokensOption option = AlignTokensOption.AlignIndentationOfTokensToBaseToken)
170var firstTokenOfNode = node.GetFirstToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (66)
79public SyntaxToken ParseToken(string text)
97public bool IsVerbatimIdentifier(SyntaxToken token)
100public bool IsOperator(SyntaxToken token)
111public bool IsReservedKeyword(SyntaxToken token)
114public bool IsContextualKeyword(SyntaxToken token)
117public bool IsPreprocessorKeyword(SyntaxToken token)
202public void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name)
278public bool IsThisConstructorInitializer(SyntaxToken token)
282public bool IsBaseConstructorInitializer(SyntaxToken token)
286public bool IsQueryKeyword(SyntaxToken token)
313public bool IsPredefinedType(SyntaxToken token)
316public bool IsPredefinedType(SyntaxToken token, PredefinedType type)
325public bool TryGetPredefinedType(SyntaxToken token, out PredefinedType type)
331private static PredefinedType GetPredefinedType(SyntaxToken token)
359public bool IsPredefinedOperator(SyntaxToken token)
362public bool IsPredefinedOperator(SyntaxToken token, PredefinedOperator op)
365public bool TryGetPredefinedOperator(SyntaxToken token, out PredefinedOperator op)
371private static PredefinedOperator GetPredefinedOperator(SyntaxToken token)
467var token = SyntaxFactory.ParseToken(identifier);
473var token = SyntaxFactory.ParseToken(identifier);
482public bool IsLiteral(SyntaxToken token)
510public bool IsStringLiteralOrInterpolatedStringLiteral(SyntaxToken token)
513public bool IsBindableToken(SemanticModel? semanticModel, SyntaxToken token)
829var identifier = ((IdentifierNameSyntax)node).Identifier;
850var nameToken = memberDeclaration.GetNameToken();
879var nameToken = fieldDeclarator.Identifier;
1004public SyntaxNode? TryGetBindableParent(SyntaxToken token)
1193public bool IsVerbatimStringLiteral(SyntaxToken token)
1196public bool IsRawStringLiteral(SyntaxToken token)
1203public bool IsNumericLiteral(SyntaxToken token)
1306SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1313SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1331public SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node)
1334public SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node)
1337public SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node)
1349public bool AreEquivalent(SyntaxToken token1, SyntaxToken token2)
1365out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode
1382public bool ContainsInterleavedDirective(TextSpan span, SyntaxToken token, CancellationToken cancellationToken)
1423public SyntaxToken? GetDeclarationIdentifierIfOverride(SyntaxToken token)
1457public void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right)
1500public void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen)
1508public void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1516public void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern)
1523public void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression)
1591public void GetPartsOfAliasQualifiedName(SyntaxNode node, out SyntaxNode alias, out SyntaxToken colonColonToken, out SyntaxNode name)
1599public void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken)
1621public void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1638SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull)
1660public void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments)
1668out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken)
1683public void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name)
1706public void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1715public void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer)
1723public void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default)
1731SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen)
1739public void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand)
1746public void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1779public SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (38)
20public static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRange(SyntaxToken endToken, bool useDefaultRange = true)
27private static ValueTuple<SyntaxToken, SyntaxToken>? FixupOpenBrace(ValueTuple<SyntaxToken, SyntaxToken>? tokenRange)
37var currentToken = tokenRange.Value.Item1;
38var previousToken = currentToken.GetPreviousToken();
55private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeWorker(SyntaxToken endToken, bool useDefaultRange)
112private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForSemicolon(SyntaxToken endToken)
168private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForCloseBrace(SyntaxToken endToken)
215var firstTokenOfInnerBlock = parent.GetFirstToken();
216var lastTokenOfInnerBlock = parent.GetLastToken();
250var firstTokenOfInnerBlock = parent.GetFirstToken();
251var lastTokenOfInnerBlock = parent.GetLastToken();
268private static ValueTuple<SyntaxToken, SyntaxToken>? FindAppropriateRangeForColon(SyntaxToken endToken)
285private static SyntaxToken GetPreviousTokenIfNotFirstTokenInTree(SyntaxToken token)
287var previousToken = token.GetPreviousToken();
291public static bool AreTwoTokensOnSameLine(SyntaxToken token1, SyntaxToken token2)
307private static SyntaxToken GetAppropriatePreviousToken(SyntaxToken startToken, bool canTokenBeFirstInABlock = false)
309var previousToken = startToken.GetPreviousToken();
345private static bool IsOpenBraceTokenOfABlockOrTypeOrNamespace(SyntaxToken previousToken)
406public static bool IsColonInSwitchLabel(SyntaxToken token)
413public static bool InBetweenTwoMembers(SyntaxToken previousToken, SyntaxToken currentToken)
433public static MemberDeclarationSyntax? GetEnclosingMember(SyntaxToken token)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (1)
138SyntaxToken identifier,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (1)
254SyntaxToken identifier,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\TypeParameterGenerator.cs (1)
29var varianceKeyword =
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (93)
88var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
137this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
156var originalToken = tokenOnLeftOfPosition;
157var token = originalToken;
355var token = leftToken.GetPreviousTokenIfTouchingWord(position);
368this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
409var originalToken = tokenOnLeftOfPosition;
410var token = originalToken;
417var nextToken = originalToken.GetNextToken(includeSkipped: true);
626var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken)
673var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken)
689var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken)
842this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
847var token = tokenOnLeftOfPosition;
860public static bool IsTypeParameterConstraintContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
867var token = tokenOnLeftOfPosition;
891public static bool IsTypeOfExpressionContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
893var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
903public static bool IsDefaultExpressionContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
905var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
916this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
918var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
931SyntaxToken tokenOnLeftOfPosition,
934var token = tokenOnLeftOfPosition;
954public static bool IsGenericConstraintContext(this SyntaxTree syntaxTree, SyntaxToken targetToken)
961SyntaxToken tokenOnLeftOfPosition,
969var token = tokenOnLeftOfPosition;
983if (!syntaxTree.IsInPartiallyWrittenGeneric(position, cancellationToken, out var nameToken))
1049SyntaxToken tokenOnLeftOfPosition,
1058var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
1139SyntaxToken tokenOnLeftOfPosition,
1153var token = tokenOnLeftOfPosition;
1165this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1167var token = tokenOnLeftOfPosition;
1180this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1182var token = tokenOnLeftOfPosition;
1194public static bool IsParameterTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1196var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
1211public static bool IsPossibleExtensionMethodContext(this SyntaxTree syntaxTree, SyntaxToken tokenOnLeftOfPosition)
1223this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1225var token = tokenOnLeftOfPosition;
1255this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1257var token = tokenOnLeftOfPosition;
1282this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1284var token = tokenOnLeftOfPosition;
1307public static bool IsPossibleTupleContext(this SyntaxTree syntaxTree, SyntaxToken leftToken, int position)
1327var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.Parent);
1339var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.Parent!);
1352var possibleCommaOrParen = FindTokenOnLeftOfNode(leftToken.Parent.Parent);
1362public static bool IsAtStartOfPattern(this SyntaxTree syntaxTree, SyntaxToken leftToken, int position)
1456public static bool IsAtEndOfPattern(this SyntaxTree syntaxTree, SyntaxToken leftToken, int position)
1458var originalLeftToken = leftToken;
1541static bool IsAtEndOfSwitchStatementPattern(SyntaxToken leftToken)
1563private static SyntaxToken FindTokenOnLeftOfNode(SyntaxNode node)
1566public static bool IsPossibleTupleOpenParenOrComma(this SyntaxToken possibleCommaOrParen)
1689private static bool IsPossibleVarDeconstructionOpenParenOrComma(SyntaxToken leftToken)
1711SyntaxToken tokenOnLeftOfPosition,
1734var token = tokenOnLeftOfPosition;
1749this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1751var token = tokenOnLeftOfPosition;
1766this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1782var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
1831var previous = token.GetPreviousToken(includeSkipped: true);
1880this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1885var token = tokenOnLeftOfPosition;
1914public static bool IsIsOrAsTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
1916var token = tokenOnLeftOfPosition;
1926this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1928var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
1944private static bool IsNonConstantExpressionContext(SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1958public static bool IsStatementContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
1970var token = tokenOnLeftOfPosition;
1981var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken)
1999public static bool IsInstanceContext(this SyntaxTree syntaxTree, SyntaxToken targetToken, SemanticModel semanticModel, CancellationToken cancellationToken)
2030this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition, CancellationToken cancellationToken)
2032var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
2043public static bool IsDefiniteCastTypeContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
2045var token = tokenOnLeftOfPosition;
2058SyntaxToken tokenOnLeftOfPosition)
2065var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
2165SyntaxToken tokenOnLeftOfPosition,
2175var token = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
2342var previousToken = tokenOnLeftOfPosition.GetPreviousToken(includeSkipped: true);
2737public static bool IsInvocationOfVarExpression(this SyntaxToken token)
2811SyntaxToken tokenOnLeftOfPosition,
2817var token = tokenOnLeftOfPosition;
2928this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
2945var token = tokenOnLeftOfPosition;
2963public static bool IsCatchFilterContext(this SyntaxTree syntaxTree, int position, SyntaxToken tokenOnLeftOfPosition)
2971var token = tokenOnLeftOfPosition;
2988public static bool IsEnumBaseListContext(this SyntaxTree syntaxTree, SyntaxToken targetToken)
3002var token = syntaxTree
3055public static bool IsFunctionPointerCallingConventionContext(this SyntaxTree syntaxTree, SyntaxToken targetToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (14)
24protected override bool ShouldUseTokenIndenter(Indenter indenter, out SyntaxToken syntaxToken)
36protected override IndentationResult? GetDesiredIndentationWorker(Indenter indenter, SyntaxToken? tokenOpt, SyntaxTrivia? triviaOpt)
66private static IndentationResult? TryGetDesiredIndentation(Indenter indenter, SyntaxToken? tokenOpt)
74private static IndentationResult GetIndentationBasedOnToken(Indenter indenter, SyntaxToken token)
322private static IndentationResult GetIndentationFromCommaSeparatedList(Indenter indenter, SyntaxToken token)
335Indenter indenter, SeparatedSyntaxList<T> list, SyntaxToken token) where T : SyntaxNode
349var firstToken = node.GetFirstToken(includeZeroWidth: true);
362private static IndentationResult GetDefaultIndentationFromToken(Indenter indenter, SyntaxToken token)
372private static IndentationResult GetIndentationForQueryExpression(Indenter indenter, SyntaxToken token)
384var firstToken = queryExpressionClause.GetFirstToken(includeZeroWidth: true);
419var clauseToken = clause.GetFirstToken(includeZeroWidth: true);
431private static SyntaxNode? GetQueryExpressionClause(SyntaxToken token)
457private static bool IsPartOfQueryExpression(SyntaxToken token)
464Indenter indenter, SyntaxToken token, int? additionalSpace = null)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (1)
78var discardToken = Identifier(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSyntaxGeneratorInternal.cs (11)
51public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken name, SyntaxNode? initializer, bool isConst)
61public override SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
64internal static VariableDeclarationSyntax VariableDeclaration(SyntaxNode? type, SyntaxToken name, SyntaxNode? expression)
73public override SyntaxToken Identifier(string identifier)
105public override SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
108public override SyntaxNode InterpolatedStringText(SyntaxToken textToken)
111public override SyntaxToken InterpolatedStringTextToken(string content, string value)
139using var _ = ArrayBuilder<SyntaxToken>.GetInstance(out var result);
197public override SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isKeyword, SyntaxNode pattern)
238public override SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (52)
52private static bool DecomposeBinaryOrAssignmentExpression(SyntaxNode node, out SyntaxToken operatorToken, out ExpressionSyntax left, out ExpressionSyntax right)
78out var operatorToken, out var left, out var right))
257private IEnumerable<TypeInferenceInfo> InferTypeInAnonymousObjectCreation(AnonymousObjectCreationExpressionSyntax expression, SyntaxToken previousToken)
268ArgumentSyntax argument, SyntaxToken? previousToken = null)
341TupleExpressionSyntax tupleExpression, SyntaxToken previousToken)
368private IEnumerable<TypeInferenceInfo> InferTypeInAttributeArgument(AttributeArgumentSyntax argument, SyntaxToken? previousToken = null)
396private IEnumerable<TypeInferenceInfo> InferTypeInObjectCreationExpression(BaseObjectCreationExpressionSyntax expression, SyntaxToken previousToken)
511private IEnumerable<TypeInferenceInfo> InferTypeInArgumentList(ArgumentListSyntax argumentList, SyntaxToken previousToken)
541private IEnumerable<TypeInferenceInfo> InferTypeInAttributeArgumentList(AttributeArgumentListSyntax attributeArgumentList, SyntaxToken previousToken)
810ArrayCreationExpressionSyntax arrayCreationExpression, SyntaxToken? previousToken = null)
837private IEnumerable<TypeInferenceInfo> InferTypeInArrayRankSpecifier(ArrayRankSpecifierSyntax arrayRankSpecifier, SyntaxToken? previousToken = null)
847private IEnumerable<TypeInferenceInfo> InferTypeInArrayType(ArrayTypeSyntax arrayType, SyntaxToken? previousToken = null)
870private IEnumerable<TypeInferenceInfo> InferTypeInAttributeDeclaration(AttributeListSyntax attributeDeclaration, SyntaxToken? previousToken)
881SyntaxToken? previousToken)
890private IEnumerable<TypeInferenceInfo> InferTypeInBracketedArgumentList(BracketedArgumentListSyntax bracketedArgumentList, SyntaxToken previousToken)
906private static int GetArgumentListIndex(BaseArgumentListSyntax argumentList, SyntaxToken previousToken)
925private static int GetArgumentListIndex(AttributeArgumentListSyntax attributeArgumentList, SyntaxToken previousToken)
944private IEnumerable<TypeInferenceInfo> InferTypeInBinaryOrAssignmentExpression(ExpressionSyntax binop, SyntaxToken operatorToken, ExpressionSyntax left, ExpressionSyntax right, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1079private IEnumerable<TypeInferenceInfo> InferTypeInCastExpression(CastExpressionSyntax castExpression, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1091private IEnumerable<TypeInferenceInfo> InferTypeInCatchDeclaration(CatchDeclarationSyntax catchDeclaration, SyntaxToken? previousToken = null)
1100private IEnumerable<TypeInferenceInfo> InferTypeInCatchFilterClause(CatchFilterClauseSyntax catchFilterClause, SyntaxToken? previousToken = null)
1112SyntaxToken? previousToken = null)
1166private IEnumerable<TypeInferenceInfo> InferTypeInConditionalExpression(ConditionalExpressionSyntax conditional, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1199private IEnumerable<TypeInferenceInfo> InferTypeInDoStatement(DoStatementSyntax doStatement, SyntaxToken? previousToken = null)
1208private IEnumerable<TypeInferenceInfo> InferTypeInEqualsValueClause(EqualsValueClauseSyntax equalsValue, SyntaxToken? previousToken = null)
1237private IEnumerable<TypeInferenceInfo> InferTypeInExpressionStatement(SyntaxToken? previousToken = null)
1247private IEnumerable<TypeInferenceInfo> InferTypeInForEachStatement(ForEachStatementSyntax forEachStatementSyntax, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1274private IEnumerable<TypeInferenceInfo> InferTypeInForStatement(ForStatementSyntax forStatement, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
1286private IEnumerable<TypeInferenceInfo> InferTypeInIfStatement(IfStatementSyntax ifStatement, SyntaxToken? previousToken = null)
1301SyntaxToken? previousToken = null)
1503var identifier = singleVariableDesignation.Identifier;
1595private IEnumerable<TypeInferenceInfo> InferTypeInLockStatement(LockStatementSyntax lockStatement, SyntaxToken? previousToken = null)
1604private IEnumerable<TypeInferenceInfo> InferTypeInLambdaExpression(LambdaExpressionSyntax lambdaExpression, SyntaxToken? previousToken = null)
1633private IEnumerable<TypeInferenceInfo> InferTypeInMemberDeclarator(AnonymousObjectMemberDeclaratorSyntax memberDeclarator, SyntaxToken? previousTokenOpt = null)
1652private IEnumerable<TypeInferenceInfo> InferTypeInNameColon(NameColonSyntax nameColon, SyntaxToken previousToken)
1668private IEnumerable<TypeInferenceInfo> InferTypeInExpressionColon(ExpressionColonSyntax expressionColon, SyntaxToken previousToken)
1686SyntaxToken? previousToken = null)
1869private IEnumerable<TypeInferenceInfo> InferTypeInNameEquals(NameEqualsSyntax nameEquals, SyntaxToken? previousToken = null)
1887private IEnumerable<TypeInferenceInfo> InferTypeInPostfixUnaryExpression(PostfixUnaryExpressionSyntax postfixUnaryExpressionSyntax, SyntaxToken? previousToken = null)
1903private IEnumerable<TypeInferenceInfo> InferTypeInPrefixUnaryExpression(PrefixUnaryExpressionSyntax prefixUnaryExpression, SyntaxToken? previousToken = null)
1959private IEnumerable<TypeInferenceInfo> InferTypeInAwaitExpression(AwaitExpressionSyntax awaitExpression, SyntaxToken? previousToken = null)
1981private IEnumerable<TypeInferenceInfo> InferTypeInYieldStatement(YieldStatementSyntax yieldStatement, SyntaxToken? previousToken = null)
2022ReturnStatementSyntax returnStatement, SyntaxToken? previousToken = null)
2100private IEnumerable<TypeInferenceInfo> InferTypeInSwitchExpression(SwitchExpressionSyntax switchExpression, SyntaxToken token)
2109SwitchLabelSyntax switchLabel, SyntaxToken? previousToken = null)
2125SwitchStatementSyntax switchStatement, SyntaxToken? previousToken = null)
2145private IEnumerable<TypeInferenceInfo> InferTypeInThrowExpression(ThrowExpressionSyntax throwExpression, SyntaxToken? previousToken = null)
2154private IEnumerable<TypeInferenceInfo> InferTypeInThrowStatement(ThrowStatementSyntax throwStatement, SyntaxToken? previousToken = null)
2163private IEnumerable<TypeInferenceInfo> InferTypeInUsingStatement(UsingStatementSyntax usingStatement, SyntaxToken? previousToken = null)
2368private IEnumerable<TypeInferenceInfo> InferTypeInWhenClause(WhenClauseSyntax whenClause, SyntaxToken? previousToken = null)
2377private IEnumerable<TypeInferenceInfo> InferTypeInWhileStatement(WhileStatementSyntax whileStatement, SyntaxToken? previousToken = null)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (9)
15public static SyntaxToken TryEscapeIdentifierToken(SyntaxToken syntaxToken, SyntaxNode parentOfToken)
59var firstRewrittenToken = rewrittenNode.GetFirstToken(true, false, true, true);
60var firstOriginalToken = originalNode.GetFirstToken(true, false, true, true);
61if (TryAddLeadingElasticTriviaIfNecessary(firstRewrittenToken, firstOriginalToken, out var rewrittenTokenWithLeadingElasticTrivia))
69public static bool TryAddLeadingElasticTriviaIfNecessary(SyntaxToken token, SyntaxToken originalToken, out SyntaxToken tokenWithLeadingWhitespace)
78var previousToken = originalToken.GetPreviousToken();
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (18)
87SyntaxToken getNewStartToken(SyntaxToken startToken, TextSpan currentDiagnosticSpan) => includeStartTokenChange
91SyntaxToken getNewEndToken(SyntaxToken endToken, TextSpan currentDiagnosticSpan) => includeEndTokenChange
104private static SyntaxTriviaList GetTriviaListForSuppression(SyntaxToken token, bool isStartToken, AbstractSuppressionCodeFixProvider fixer)
111private static SyntaxToken UpdateTriviaList(SyntaxToken token, bool isStartToken, SyntaxTriviaList triviaList, AbstractSuppressionCodeFixProvider fixer)
118private static bool CanRemovePragmaTrivia(SyntaxToken token, Diagnostic diagnostic, AbstractSuppressionCodeFixProvider fixer, bool isStartToken, out int indexOfTriviaToRemove)
158private SyntaxToken GetNewTokenWithModifiedPragma(SyntaxToken token, TextSpan currentDiagnosticSpan, bool add, bool toggle, int indexOfTriviaToRemoveOrToggle, bool isStartToken, CancellationToken cancellationToken)
165private SyntaxToken GetNewTokenWithAddedPragma(SyntaxToken token, TextSpan currentDiagnosticSpan, bool isStartToken, CancellationToken cancellationToken)
177private SyntaxToken GetNewTokenWithRemovedOrToggledPragma(SyntaxToken token, int indexOfTriviaToRemoveOrToggle, bool isStartToken, bool toggle)
180private static SyntaxToken GetNewTokenWithPragmaUnsuppress(SyntaxToken token, int indexOfTriviaToRemoveOrToggle, AbstractSuppressionCodeFixProvider fixer, bool isStartToken, bool toggle)
217public SyntaxToken StartToken_TestOnly => _suppressionTargetInfo.StartToken;
218public SyntaxToken EndToken_TestOnly => _suppressionTargetInfo.EndToken;
Completion\Providers\AbstractPartialMethodCompletionProvider.cs (4)
36protected abstract bool IsPartialMethodCompletionContext(SyntaxTree tree, int position, CancellationToken cancellationToken, out DeclarationModifiers modifiers, out SyntaxToken token);
47if (!IsPartialMethodCompletionContext(tree, position, cancellationToken, out var modifiers, out var token))
83Document document, int position, TextSpan span, DeclarationModifiers modifiers, SyntaxToken token, CancellationToken cancellationToken)
105private CompletionItem CreateItem(IMethodSymbol method, int line, TextSpan span, SemanticModel semanticModel, DeclarationModifiers modifiers, SyntaxToken token)
ConvertForToForEach\AbstractConvertForToForEachCodeRefactoringProvider.cs (7)
43out SyntaxToken iterationVariable,
50TForStatementSyntax currentFor, TTypeNode? typeNode, SyntaxToken foreachIdentifier,
61out var iterationVariable, out var initializer, out var memberAccess, out var stepValueExpressionOpt, cancellationToken))
312SyntaxToken iterationVariable,
363var foreachIdentifierReference = foreachIdentifier.WithoutAnnotations(RenameAnnotation.Kind).WithoutTrivia();
385(TTypeNode?, SyntaxToken, TStatementSyntax) TryDeconstructInitialDeclaration()
479var replacementToken = foreachIdentifierReference;
DocumentationComments\AbstractDocumentationCommentSnippetService.cs (11)
27protected abstract SyntaxToken GetTokenToRight(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken);
28protected abstract SyntaxToken GetTokenToLeft(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken);
29protected abstract bool IsDocCommentNewLine(SyntaxToken token);
35protected abstract bool HasSkippedTrailingTrivia(SyntaxToken token);
85var token = syntaxTree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia: true);
108private List<string>? GetDocumentationCommentLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out string? indentText, out int caretOffset, out int spanToReplaceLength)
139private List<string>? GetDocumentationCommentLinesNoIndentation(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out int caretOffset, out int spanToReplaceLength)
155private List<string>? GetDocumentationStubLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out int caretOffset, out int spanToReplaceLength, out string? existingCommentText)
288var token = GetTokenToLeft(syntaxTree, position, cancellationToken);
335var token = targetMember.GetFirstToken();
374var token = GetTokenToLeft(syntaxTree, position, cancellationToken);
EmbeddedLanguages\AbstractLanguageDetector.cs (4)
30protected abstract bool IsArgumentToWellKnownAPI(SyntaxToken token, SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken, out TOptions options);
40protected virtual bool IsEmbeddedLanguageInterpolatedStringTextToken(SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken)
51SyntaxToken token,
97private bool IsEmbeddedLanguageStringLiteralToken(SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken, out TOptions options)
EmbeddedLanguages\RegularExpressions\LanguageServices\AbstractRegexDiagnosticAnalyzer.cs (1)
80SyntaxToken token,
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexLanguageDetector.cs (1)
73SyntaxToken token,
ExtractMethod\AbstractSyntaxTriviaService.cs (16)
52IEnumerable<SyntaxToken> oldTokens,
53Func<SyntaxToken, SyntaxToken, SyntaxToken> computeReplacementToken)
70private static Dictionary<SyntaxToken, SyntaxToken> CreateOldToNewTokensMap(
71Dictionary<TriviaLocation, SyntaxToken> tokens,
74var token = default(SyntaxToken);
75var map = new Dictionary<SyntaxToken, SyntaxToken>();
93private static Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> GetTriviaAtEdges(Dictionary<TriviaLocation, SyntaxToken> tokens, TextSpan textSpan)
109private static Dictionary<TriviaLocation, SyntaxToken> GetTokensAtEdges(SyntaxNode root, TextSpan textSpan)
111var tokens = new Dictionary<TriviaLocation, SyntaxToken>
122SyntaxToken token1,
123SyntaxToken token2,
ExtractMethod\AbstractSyntaxTriviaService.Result.cs (14)
55private static Dictionary<SyntaxToken, SyntaxToken> CreateOldToNewTokensMap(
59var map = new Dictionary<SyntaxToken, SyntaxToken>();
100private Dictionary<TriviaLocation, SyntaxToken> RecoverTokensAtEdges(
122private Dictionary<SyntaxToken, SyntaxToken> CreateOldToNewTokensMap(
123Dictionary<TriviaLocation, SyntaxToken> tokens,
173private Dictionary<SyntaxToken, LeadingTrailingTriviaPair> CreateTokenLeadingTrailingTriviaMap(
174Dictionary<TriviaLocation, SyntaxToken> tokens)
177var map = new Dictionary<SyntaxToken, LeadingTrailingTriviaPair>();
211Dictionary<TriviaLocation, SyntaxToken> tokens)
259private static SyntaxToken ResolveAnnotation(
270Dictionary<SyntaxToken, LeadingTrailingTriviaPair> triviaMap)
ExtractMethod\MethodExtractor.Analyzer.cs (8)
317Dictionary<ISymbol, List<SyntaxToken>> symbolMap,
377private Dictionary<ISymbol, List<SyntaxToken>> GetSymbolMap(SemanticModel model)
510Dictionary<ISymbol, List<SyntaxToken>> symbolMap,
665Dictionary<ISymbol, List<SyntaxToken>> symbolMap,
722Dictionary<ISymbol, List<SyntaxToken>> symbolMap, SemanticModel model, ISymbol symbol, bool writtenInside)
883private static void AppendMethodTypeParameterUsedDirectly(IDictionary<ISymbol, List<SyntaxToken>> symbolMap, IDictionary<int, ITypeParameterSymbol> sortedMap)
901IDictionary<ISymbol, List<SyntaxToken>> symbolMap,
1002private OperationStatus CheckReadOnlyFields(SemanticModel semanticModel, Dictionary<ISymbol, List<SyntaxToken>> symbolMap)
QuickInfo\CommonSemanticQuickInfoProvider.cs (16)
23QuickInfoContext context, SyntaxToken token)
38CommonQuickInfoContext context, SyntaxToken token)
51SyntaxToken token)
68SyntaxToken token,
101var linkedToken = FindTokenInLinkedDocument(token, linkedModel, cancellationToken);
137private static SyntaxToken FindTokenInLinkedDocument(
138SyntaxToken token,
147var linkedToken = root.FindToken(token.SpanStart);
156SyntaxToken token,
181protected abstract bool GetBindableNodeForTokenIndicatingLambda(SyntaxToken token, [NotNullWhen(returnValue: true)] out SyntaxNode? found);
182protected abstract bool GetBindableNodeForTokenIndicatingPossibleIndexerAccess(SyntaxToken token, [NotNullWhen(returnValue: true)] out SyntaxNode? found);
183protected abstract bool GetBindableNodeForTokenIndicatingMemberAccess(SyntaxToken token, out SyntaxToken found);
191SolutionServices services, SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
237private ImmutableArray<ISymbol> GetSymbolsFromToken(SyntaxToken token, SolutionServices services, SemanticModel semanticModel, CancellationToken cancellationToken)
254if (GetBindableNodeForTokenIndicatingMemberAccess(token, out var accessedMember))
SignatureHelp\CommonSignatureHelpUtilities.cs (12)
26Func<TArgumentList, SyntaxToken> getOpenToken,
27Func<TArgumentList, SyntaxToken> getCloseToken,
50Func<TArgumentList, SyntaxToken> getOpenToken,
51Func<TArgumentList, SyntaxToken> getCloseToken,
59var closeToken = getCloseToken(argumentList);
74Func<TArgumentList, SyntaxToken> getCloseToken)
83Func<TArgumentList, SyntaxToken> getCloseToken)
86var closeToken = getCloseToken(argumentList);
93var lastToken = argumentList.GetLastToken();
94var nextToken = lastToken.GetNextToken();
108Func<SyntaxToken, bool> isTriggerToken,
109Func<TSyntax, SyntaxToken, bool> isArgumentListToken,
SpellCheck\AbstractSpellCheckCodeFixProvider.cs (10)
32protected abstract bool IsGeneric(SyntaxToken nameToken);
35protected abstract SyntaxToken CreateIdentifier(SyntaxToken nameToken, string newName);
55var token = syntaxRoot.FindToken(span.Start);
75var token = name.GetFirstToken();
89private async Task CheckTokenAsync(CodeFixContext context, Document document, SyntaxToken token, CancellationToken cancellationToken)
108CodeFixContext context, SyntaxToken nameToken, bool isGeneric, CancellationToken cancellationToken)
146CodeFixContext context, SyntaxToken nameToken, bool isGeneric,
211private CodeAction CreateCodeAction(SyntaxToken nameToken, string oldName, string newName, Document document)
220private async Task<Document> UpdateAsync(Document document, SyntaxToken nameToken, string newName, CancellationToken cancellationToken)
src\Analyzers\Core\Analyzers\AddAccessibilityModifiers\IAddAccessibilityModifiersService.cs (1)
21out SyntaxToken name,
src\Analyzers\Core\CodeFixes\GenerateConstructor\AbstractGenerateConstructorService.cs (5)
33protected abstract bool TryInitializeImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
34protected abstract bool TryInitializeSimpleNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
35protected abstract bool TryInitializeConstructorInitializerGeneration(SemanticDocument document, SyntaxNode constructorInitializer, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
36protected abstract bool TryInitializeSimpleAttributeNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
43protected abstract IMethodSymbol GetCurrentConstructor(SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken);
src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (2)
26protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
27protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateMethodService.cs (2)
26protected abstract bool TryInitializeExplicitInterfaceState(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
27protected abstract bool TryInitializeSimpleNameState(SemanticDocument document, TSimpleNameSyntax simpleName, CancellationToken cancellationToken, out SyntaxToken identifierToken, out TExpressionSyntax simpleNameOrMemberAccessExpression, out TInvocationExpressionSyntax invocationExpressionOpt, out bool isInConditionalExpression);
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.cs (3)
27protected abstract bool TryInitializeExplicitInterfaceState(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IPropertySymbol propertySymbol, out INamedTypeSymbol typeToGenerateIn);
28protected abstract bool TryInitializeIdentifierNameState(SemanticDocument document, TSimpleNameSyntax identifierName, CancellationToken cancellationToken, out SyntaxToken identifierToken, out TExpressionSyntax simpleNameOrMemberAccessExpression, out bool isInExecutableBlock, out bool isinConditionalAccessExpression);
30protected abstract bool TryConvertToLocalDeclaration(ITypeSymbol type, SyntaxToken identifierToken, SemanticModel semanticModel, CancellationToken cancellationToken, out SyntaxNode newRoot);
src\Analyzers\Core\CodeFixes\ImplementAbstractClass\ImplementAbstractClassData.cs (4)
33Document document, ImplementTypeOptions options, SyntaxNode classNode, SyntaxToken classIdentifier,
40private readonly SyntaxToken _classIdentifier = classIdentifier;
47Document document, SyntaxNode classNode, SyntaxToken classIdentifier, CancellationToken cancellationToken)
79Document document, SyntaxNode classNode, SyntaxToken classIdentifier, CancellationToken cancellationToken)
Completion\CompletionProviders\CrefCompletionProvider.vb (7)
100Protected Overrides Async Function GetSymbolsAsync(document As Document, position As Integer, options As CompletionOptions, cancellationToken As CancellationToken) As Task(Of (SyntaxToken, SemanticModel, ImmutableArray(Of ISymbol)))
122Private Shared Function IsCrefTypeParameterContext(token As SyntaxToken) As Boolean
128Private Shared Function IsCrefStartContext(token As SyntaxToken) As Boolean
152Private Shared Function IsCrefParameterListContext(token As SyntaxToken) As Boolean
160Private Shared Function IsFirstCrefParameterContext(ByRef token As SyntaxToken) As Boolean
164Private Overloads Shared Function GetSymbols(token As SyntaxToken, semanticModel As SemanticModel, cancellationToken As CancellationToken) As IEnumerable(Of ISymbol)
176Private Shared Iterator Function GetQualifiedSymbols(qualifiedName As QualifiedNameSyntax, token As SyntaxToken, semanticModel As SemanticModel, cancellationToken As CancellationToken) As IEnumerable(Of ISymbol)
src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (5)
28Protected Overrides Function TryInitializeImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken, ByRef token As SyntaxToken, ByRef arguments As ImmutableArray(Of Argument(Of ExpressionSyntax)), ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
60ByRef token As SyntaxToken,
95ByRef token As SyntaxToken,
130ByRef token As SyntaxToken,
168Protected Overrides Function GetCurrentConstructor(semanticModel As SemanticModel, token As SyntaxToken, cancellationToken As CancellationToken) As IMethodSymbol
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\VisualBasicGenerateConversionService.vb (2)
55Protected Overrides Function TryInitializeExplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
69Protected Overrides Function TryInitializeImplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
CodeCleanup\AbstractCodeCleanerService.cs (26)
150IEnumerable<SyntaxToken> previousTokens,
151IEnumerable<SyntaxToken> nextTokens,
157var previousToken = previousTokens.FirstOrDefault();
158var nextToken = nextTokens.FirstOrDefault();
237private static int GetPreviousTokenStartPosition(SpanMarkerType spanMarkerType, SyntaxToken previousToken)
253private static int GetNextTokenEndPosition(SpanMarkerType spanMarkerType, SyntaxToken nextToken)
276var tokenAnnotationMap = new Dictionary<SyntaxToken, List<SyntaxAnnotation>>();
283out var previousToken, out var startToken, out var endToken, out var nextToken);
331_ = GetSpanAlignedToTokens(root, span, out var startToken, out var endToken);
333var previousToken = startToken.GetPreviousToken(includeZeroWidth: true, includeSkipped: true, includeDirectives: true, includeDocumentationComments: true);
334var nextToken = endToken.GetNextToken(includeZeroWidth: true, includeSkipped: true, includeDirectives: true, includeDocumentationComments: true);
360out SyntaxToken previousToken,
361out SyntaxToken startToken,
362out SyntaxToken endToken,
363out SyntaxToken nextToken)
383out SyntaxToken startToken, out SyntaxToken endToken)
404private static SyntaxToken FindTokenOnRightOfPosition(SyntaxNode root, int position)
406var token = root.FindTokenOnRightOfPosition(position, includeSkipped: true, includeDirectives: true, includeDocumentationComments: true);
418private static SyntaxToken FindTokenOnLeftOfPosition(SyntaxNode root, int position)
421var token = root.FindTokenOnLeftOfPosition(position, includeSkipped: true, includeDirectives: true, includeDocumentationComments: true);
593private static SyntaxNode InjectAnnotations(SyntaxNode node, Dictionary<SyntaxToken, List<SyntaxAnnotation>> map)
Editing\SyntaxGenerator.cs (22)
53internal abstract SyntaxToken CreateInterpolatedStringStartToken(bool isVerbatim);
54internal abstract SyntaxToken CreateInterpolatedStringEndToken();
1070internal SyntaxToken RemoveLeadingAndTrailingComments(SyntaxToken token)
1438internal abstract SeparatedSyntaxList<TElement> SeparatedList<TElement>(IEnumerable<TElement> nodes, IEnumerable<SyntaxToken> separators) where TElement : SyntaxNode;
1451foreach (var token in original)
1498protected static SyntaxNode ReplaceWithTrivia(SyntaxNode root, SyntaxToken original, SyntaxToken replacement)
1500var combinedTriviaReplacement =
1615internal SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken identifier, SyntaxNode? initializer = null, bool isConst = false)
1621internal SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
1639internal SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initializer)
1759internal abstract SyntaxToken NumericLiteralToken(string text, ulong value);
1761internal SyntaxToken InterpolatedStringTextToken(string content, string value)
1763internal SyntaxNode InterpolatedStringText(SyntaxToken textToken)
1767internal SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
1833internal abstract SyntaxNode IdentifierName(SyntaxToken identifier);
1834internal SyntaxToken Identifier(string identifier) => SyntaxGeneratorInternal.Identifier(identifier);
1842internal abstract SyntaxNode GenericName(SyntaxToken identifier, IEnumerable<SyntaxNode> typeArguments);
2199SyntaxNode namedType, SyntaxToken openParen, SeparatedSyntaxList<SyntaxNode> arguments, SyntaxToken closeParen);
FindSymbols\FindReferences\Finders\AbstractReferenceFinder.cs (7)
40ISymbol symbol, FindReferencesDocumentState state, SyntaxToken token, CancellationToken cancellationToken)
161protected static bool IdentifiersMatch(ISyntaxFactsService syntaxFacts, string name, SyntaxToken token)
176public static ImmutableArray<SyntaxToken> FindMatchingIdentifierTokens(FindReferencesDocumentState state, string identifier, CancellationToken cancellationToken)
182ImmutableArray<SyntaxToken> tokens,
190foreach (var token in tokens)
203protected static FinderLocation CreateFinderLocation(FindReferencesDocumentState state, SyntaxToken token, CandidateReason reason, CancellationToken cancellationToken)
206public static ReferenceLocation CreateReferenceLocation(FindReferencesDocumentState state, SyntaxToken token, CandidateReason reason, CancellationToken cancellationToken)
FindSymbols\FindReferences\Finders\ConstructorInitializerSymbolReferenceFinder.cs (1)
76SyntaxToken token,
FindSymbols\FindReferences\FindReferenceCache.cs (19)
67private readonly ConcurrentDictionary<string, ImmutableArray<SyntaxToken>> _identifierCache;
70private ImmutableArray<SyntaxToken> _constructorInitializerCache;
71private ImmutableArray<SyntaxToken> _newKeywordsCache;
96ISemanticFactsService semanticFacts, SyntaxToken token, CancellationToken cancellationToken)
110public ImmutableArray<SyntaxToken> FindMatchingIdentifierTokens(
149private bool IsMatch(string identifier, SyntaxToken token)
152private ImmutableArray<SyntaxToken> FindMatchingIdentifierTokensFromTree(
155using var _ = ArrayBuilder<SyntaxToken>.GetInstance(out var result);
171var token = current.AsToken();
190private ImmutableArray<SyntaxToken> FindMatchingTokensFromText<TArgs>(
191string text, Func<string, SyntaxToken, TArgs, bool> isMatch, TArgs args, CancellationToken cancellationToken)
193using var _ = ArrayBuilder<SyntaxToken>.GetInstance(out var result);
200var token = this.Root.FindToken(index, findInsideTrivia: true);
213public ImmutableArray<SyntaxToken> GetConstructorInitializerTokens(CancellationToken cancellationToken)
222ImmutableArray<SyntaxToken> GetConstructorInitializerTokensWorker()
225using var _ = ArrayBuilder<SyntaxToken>.GetInstance(out var initializers);
228foreach (var token in constructor.DescendantTokens(descendIntoTrivia: false))
239public ImmutableArray<SyntaxToken> GetNewKeywordTokens(CancellationToken cancellationToken)
246ImmutableArray<SyntaxToken> GetNewKeywordTokensWorker()
ObsoleteSymbol\AbstractObsoleteSymbolService.cs (10)
19/// The <see cref="SyntaxToken.RawKind"/> of the <see langword="Dim"/> keyword in Visual Basic, or
25protected virtual void ProcessDimKeyword(ref ArrayBuilder<TextSpan>? result, SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
74var tokenFromNode = ProcessNode(semanticModel, current);
81var token = child.AsToken();
109SyntaxToken ProcessNode(SemanticModel semanticModel, SyntaxNode node)
113syntaxFacts.GetPartsOfUsingAliasDirective(node, out _, out var aliasToken, out var name);
126syntaxFacts.GetPartsOfObjectCreationExpression(node, out var creationKeyword, out _, out _, out _);
142syntaxFacts.GetPartsOfImplicitObjectCreationExpression(node, out var creationKeyword, out _, out _);
159void ProcessToken(SemanticModel semanticModel, SyntaxToken token)
171void ProcessIdentifier(SemanticModel semanticModel, SyntaxToken token)
Simplification\Simplifier.cs (6)
112public static async Task<SyntaxToken> ExpandAsync(SyntaxToken token, Document document, Func<SyntaxNode, bool>? expandInsideNode = null, CancellationToken cancellationToken = default)
126public static SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, Workspace workspace, Func<SyntaxNode, bool>? expandInsideNode = null, CancellationToken cancellationToken = default)
137internal static SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, SolutionServices services, Func<SyntaxNode, bool>? expandInsideNode = null, CancellationToken cancellationToken = default)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (34)
363IEnumerable<SyntaxToken> tokens,
364Func<SyntaxToken, SyntaxToken, CancellationToken, Task<SyntaxToken>> computeReplacementAsync,
391IEnumerable<SyntaxToken>? tokens,
392Func<SyntaxToken, SyntaxToken, CancellationToken, Task<SyntaxToken>>? computeReplacementTokenAsync,
404var tokenReplacements = new Dictionary<SyntaxToken, SyntaxToken>();
447var original = (SyntaxToken?)retryAnnotations.GetAnnotations(currentToken).SingleOrDefault() ?? currentToken;
485if (rewritten != original || !tokenReplacements.TryGetValue(original, out var replaced))
540private static readonly Func<SyntaxTriviaList, int, SyntaxToken> s_findSkippedTokenForward = FindSkippedTokenForward;
545private static SyntaxToken FindSkippedTokenForward(SyntaxTriviaList triviaList, int position)
553foreach (var token in skippedTokensTrivia.Tokens)
570private static readonly Func<SyntaxTriviaList, int, SyntaxToken> s_findSkippedTokenBackward = FindSkippedTokenBackward;
575private static SyntaxToken FindSkippedTokenBackward(SyntaxTriviaList triviaList, int position)
583foreach (var token in skippedTokensTrivia.Tokens)
597private static SyntaxToken GetInitialToken(
613public static SyntaxToken FindTokenOnRightOfPosition(
622var token = GetInitialToken(root, position, includeSkipped, includeDirectives, includeDocumentationComments);
626var skippedToken = findSkippedToken(token.LeadingTrivia, position);
633var skippedToken = findSkippedToken(token.TrailingTrivia, position);
652public static SyntaxToken FindTokenOnLeftOfPosition(
661var token = GetInitialToken(root, position, includeSkipped, includeDirectives, includeDocumentationComments);
667var skippedToken = findSkippedToken(token.LeadingTrivia, position);
676var skippedToken = findSkippedToken(token.TrailingTrivia, position);
767public static SyntaxToken WithoutLeadingTrivia(this SyntaxToken token)
775public static SyntaxToken WithoutTrailingTrivia(this SyntaxToken token)
867foreach (var token in root.DescendantTokens(descendIntoChildren: static node => node.ContainsDirectives))
946foreach (var token in node.DescendantTokens())
963var current = node.GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (32)
15public static SyntaxNode? GetAncestor(this SyntaxToken token, Func<SyntaxNode, bool>? predicate)
18public static T? GetAncestor<T>(this SyntaxToken token, Func<T, bool>? predicate = null) where T : SyntaxNode
21public static T GetRequiredAncestor<T>(this SyntaxToken token, Func<T, bool>? predicate = null) where T : SyntaxNode
24public static IEnumerable<T> GetAncestors<T>(this SyntaxToken token)
32public static IEnumerable<SyntaxNode> GetAncestors(this SyntaxToken token, Func<SyntaxNode, bool> predicate)
39public static SyntaxNode? GetCommonRoot(this SyntaxToken token1, SyntaxToken token2)
53public static bool CheckParent<T>(this SyntaxToken token, Func<T, bool> valueChecker) where T : SyntaxNode
63public static int Width(this SyntaxToken token)
66public static int FullWidth(this SyntaxToken token)
69public static SyntaxToken FindTokenFromEnd(this SyntaxNode root, int position, bool includeZeroWidth = true, bool findInsideTrivia = false)
71var token = root.FindToken(position, findInsideTrivia);
72var previousToken = token.GetPreviousToken(
85public static SyntaxToken GetNextTokenOrEndOfFile(
86this SyntaxToken token,
92var nextToken = token.GetNextToken(includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments);
99public static SyntaxToken WithoutTrivia(
100this SyntaxToken token)
110public static SyntaxToken With(this SyntaxToken token, SyntaxTriviaList leading, SyntaxTriviaList trailing)
113public static SyntaxToken WithPrependedLeadingTrivia(
114this SyntaxToken token,
125public static SyntaxToken WithPrependedLeadingTrivia(
126this SyntaxToken token,
137public static SyntaxToken WithPrependedLeadingTrivia(
138this SyntaxToken token,
147public static SyntaxToken WithAppendedTrailingTrivia(
148this SyntaxToken token,
154public static SyntaxToken WithAppendedTrailingTrivia(
155this SyntaxToken token,
161public static SyntaxTrivia[] GetTrivia(this IEnumerable<SyntaxToken> tokens)
164public static SyntaxNode GetRequiredParent(this SyntaxToken token)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\BottomUpBaseIndentationFinder.cs (18)
44SyntaxTree tree, SyntaxToken token, int position, CancellationToken cancellationToken)
70public int? FromAlignTokensOperations(SyntaxTree tree, SyntaxToken token)
74var nextToken = token.GetNextToken(includeZeroWidth: true);
79var alignmentBaseToken = GetAlignmentBaseTokenFor(nextToken);
90SyntaxTree tree, SyntaxToken token, int position, CancellationToken cancellationToken)
96SyntaxTree tree, SyntaxToken token, int position, int extraSpaces, CancellationToken cancellationToken)
111Func<SyntaxToken, int> tokenColumnGetter,
114var token = startingOperation.StartToken;
140Func<SyntaxToken, int> tokenColumnGetter,
154var baseToken = operation.BaseToken;
213private List<IndentBlockOperation> GetParentIndentBlockOperations(SyntaxToken token)
229private static IEnumerable<SyntaxNode> GetParentNodes(SyntaxToken token)
247private SyntaxToken GetAlignmentBaseTokenFor(SyntaxToken token)
278private IndentBlockOperation? GetIndentationDataFor(SyntaxNode root, SyntaxToken token, int position)
313var lastVisibleToken = default(SyntaxToken);
343var nextToken = operation.EndToken.GetNextToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Context\FormattingContext.cs (21)
43private readonly SegmentedDictionary<SyntaxToken, AnchorData> _anchorBaseTokenMap = [];
75SyntaxToken startToken,
76SyntaxToken endToken,
193Func<FormattingContext, IndentBlockOperation, SyntaxToken> effectiveBaseTokenGetter = operation.Option.IsOn(IndentBlockOption.RelativeToFirstTokenOnBaseTokenLine)
197Func<FormattingContext, IndentBlockOperation, SyntaxToken, int> relativeIndentationDeltaGetter = static (self, operation, effectiveBaseToken) =>
204Func<FormattingContext, SyntaxToken, int> relativeIndentationBaseIndentationGetter =
399var anchorToken = TokenStream.FirstTokenOfBaseTokenLine(operation.AnchorToken);
417public int GetBaseIndentation(SyntaxToken token)
435public bool TryGetEndTokenForRelativeIndentationSpan(SyntaxToken token, int maxChainDepth, out SyntaxToken endToken, CancellationToken cancellationToken)
468private AnchorData? GetAnchorData(SyntaxToken token)
483public int GetAnchorDeltaFromOriginalColumn(SyntaxToken token)
495public SyntaxToken GetAnchorToken(SyntaxToken token)
506public int GetDeltaFromPreviousChangesMap(SyntaxToken token, Dictionary<SyntaxToken, int> previousChangesMap)
518public SyntaxToken GetEndTokenForAnchorSpan(TokenData tokenData)
641var token1 = TokenStream.GetToken(pairIndex);
642var token2 = TokenStream.GetToken(pairIndex + 1);
656var token1 = TokenStream.GetToken(pairIndex);
657var token2 = TokenStream.GetToken(pairIndex + 1);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormatEngine.OperationApplier.cs (21)
220SyntaxToken token,
221IEnumerable<SyntaxToken> operationTokens,
244SyntaxToken token,
245IEnumerable<SyntaxToken> tokens,
246Dictionary<SyntaxToken, int> previousChangesMap,
260AlignTokensOperation operation, Dictionary<SyntaxToken, int> previousChangesMap, CancellationToken cancellationToken)
294SyntaxToken token,
296Dictionary<SyntaxToken, int> previousChangesMap,
324Dictionary<SyntaxToken, int> previousChangesMap,
354private IList<TokenData> GetTokenWithIndices(IEnumerable<SyntaxToken> tokens)
357foreach (var token in tokens)
380IList<TokenData> tokenWithIndices, Dictionary<SyntaxToken, int> newChangesMap, CancellationToken cancellationToken)
412Dictionary<SyntaxToken, int> previousChangesMap,
445SyntaxToken currentToken,
448Dictionary<SyntaxToken, int> previousChangesMap,
472SyntaxToken baseToken,
473SyntaxToken startToken,
474SyntaxToken endToken,
475Dictionary<SyntaxToken, int> previousChangesMap,
492Dictionary<SyntaxToken, int> previousChangesMap,
544int pairIndex, Dictionary<SyntaxToken, int> previousChangesMap, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (8)
44protected abstract SyntaxNode Rewriter(Dictionary<ValueTuple<SyntaxToken, SyntaxToken>, TriviaData> map, CancellationToken cancellationToken);
76private void AddTextChanges(List<TextChange> list, SyntaxToken token1, SyntaxToken token2, TriviaData data)
95using var pooledObject = SharedPools.Default<Dictionary<ValueTuple<SyntaxToken, SyntaxToken>, TriviaData>>().GetPooledObject();
110internal IEnumerable<ValueTuple<ValueTuple<SyntaxToken, SyntaxToken>, TriviaData>> GetChanges(CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TokenStream.cs (30)
30private readonly SegmentedList<SyntaxToken> _tokens;
62_tokens = new SegmentedList<SyntaxToken>(sizeOfList);
83var previousToken = _tokens[0];
86var currentToken = _tokens[i];
136public SyntaxToken GetToken(int index)
142public TokenData GetTokenData(SyntaxToken token)
156var previousToken = tokenData.Token.GetPreviousToken(includeZeroWidth: true);
174var nextToken = tokenData.Token.GetNextToken(includeZeroWidth: true);
183internal SyntaxToken FirstTokenOfBaseTokenLine(SyntaxToken token)
196public bool TwoTokensOriginallyOnSameLine(SyntaxToken token1, SyntaxToken token2)
199public bool TwoTokensOnSameLine(SyntaxToken token1, SyntaxToken token2)
202private bool TwoTokensOnSameLineWorker(SyntaxToken token1, SyntaxToken token2, Func<TokenData, TokenData, TriviaData> triviaDataGetter)
264public int GetCurrentColumn(SyntaxToken token)
274public int GetOriginalColumn(SyntaxToken token)
318public void GetTokenLength(SyntaxToken token, out int length, out bool onMultipleLines)
346public IEnumerable<ValueTuple<ValueTuple<SyntaxToken, SyntaxToken>, TriviaData>> GetTriviaDataWithTokenPair(CancellationToken cancellationToken)
351var token = this.FirstTokenInStream.Token;
354yield return ValueTuple.Create(ValueTuple.Create(default(SyntaxToken), token), trivia);
369var token = this.LastTokenInStream.Token;
372yield return ValueTuple.Create(ValueTuple.Create(token, default(SyntaxToken)), trivia);
476public bool IsFirstTokenOnLine(SyntaxToken token)
501private int GetTokenIndexInStream(SyntaxToken token)
556private sealed class TokenOrderComparer : IComparer<SyntaxToken>
562public int Compare(SyntaxToken x, SyntaxToken y)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\Operations\FormattingOperations.cs (24)
30public static AnchorIndentationOperation CreateAnchorIndentationOperation(SyntaxToken anchorToken, SyntaxToken endToken)
36public static AnchorIndentationOperation CreateAnchorIndentationOperation(SyntaxToken anchorToken, SyntaxToken endToken, TextSpan textSpan)
42public static SuppressOperation CreateSuppressOperation(SyntaxToken startToken, SyntaxToken endToken, SuppressOption option)
48private static SuppressOperation CreateSuppressOperation(SyntaxToken startToken, SyntaxToken endToken, TextSpan textSpan, SuppressOption option)
54public static IndentBlockOperation CreateIndentBlockOperation(SyntaxToken startToken, SyntaxToken endToken, int indentationDelta, IndentBlockOption option)
63public static IndentBlockOperation CreateIndentBlockOperation(SyntaxToken startToken, SyntaxToken endToken, TextSpan textSpan, int indentationDelta, IndentBlockOption option)
69public static IndentBlockOperation CreateRelativeIndentBlockOperation(SyntaxToken baseToken, SyntaxToken startToken, SyntaxToken endToken, int indentationDelta, IndentBlockOption option)
79public static IndentBlockOperation CreateRelativeIndentBlockOperation(SyntaxToken baseToken, SyntaxToken startToken, SyntaxToken endToken, TextSpan textSpan, int indentationDelta, IndentBlockOption option)
85public static AlignTokensOperation CreateAlignTokensOperation(SyntaxToken baseToken, IEnumerable<SyntaxToken> tokens, AlignTokensOption option)
183internal static AdjustNewLinesOperation? GetAdjustNewLinesOperation(IEnumerable<AbstractFormattingRule> formattingRules, SyntaxToken previousToken, SyntaxToken currentToken, SyntaxFormattingOptions options)
192internal static AdjustSpacesOperation? GetAdjustSpacesOperation(IEnumerable<AbstractFormattingRule> formattingRules, SyntaxToken previousToken, SyntaxToken currentToken, SyntaxFormattingOptions options)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFacts.cs (59)
107SyntaxToken ParseToken(string text);
110bool IsVerbatimIdentifier(SyntaxToken token);
111bool IsOperator(SyntaxToken token);
112bool IsPredefinedOperator(SyntaxToken token);
113bool IsPredefinedOperator(SyntaxToken token, PredefinedOperator op);
115bool IsPredefinedType(SyntaxToken token);
116bool IsPredefinedType(SyntaxToken token, PredefinedType type);
134bool IsReservedKeyword(SyntaxToken token);
153bool IsContextualKeyword(SyntaxToken token);
159bool IsPreprocessorKeyword(SyntaxToken token);
162bool IsLiteral(SyntaxToken token);
163bool IsStringLiteralOrInterpolatedStringLiteral(SyntaxToken token);
165bool IsNumericLiteral(SyntaxToken token);
166bool IsVerbatimStringLiteral(SyntaxToken token);
167bool IsRawStringLiteral(SyntaxToken token);
191bool TryGetPredefinedType(SyntaxToken token, out PredefinedType type);
192bool TryGetPredefinedOperator(SyntaxToken token, out PredefinedOperator op);
204out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode;
213void GetPartsOfAssignmentStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
214void GetPartsOfAssignmentExpressionOrStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
299SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node);
300SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node);
301SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node);
364bool IsThisConstructorInitializer(SyntaxToken token);
365bool IsBaseConstructorInitializer(SyntaxToken token);
366bool IsQueryKeyword(SyntaxToken token);
383bool IsBindableToken(SemanticModel? semanticModel, SyntaxToken token);
397bool AreEquivalent(SyntaxToken token1, SyntaxToken token2);
438SyntaxNode? TryGetBindableParent(SyntaxToken token);
467void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen);
468void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
471void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression);
472void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern);
474bool ContainsInterleavedDirective(TextSpan span, SyntaxToken token, CancellationToken cancellationToken);
486SyntaxToken? GetDeclarationIdentifierIfOverride(SyntaxToken token);
516void GetPartsOfAliasQualifiedName(SyntaxNode node, out SyntaxNode alias, out SyntaxToken colonColonToken, out SyntaxNode name);
518void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken);
522void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
525void GetPartsOfConditionalAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull);
527void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments);
528void GetPartsOfInterpolationExpression(SyntaxNode node, out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken);
530void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right);
531void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name);
533void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer);
534void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer);
535void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default);
536void GetPartsOfParenthesizedExpression(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen);
537void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand);
538void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken dotToken, out SyntaxNode right);
539void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name);
564SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (32)
94private static bool IsOnSingleLine(ISyntaxFacts syntaxFacts, SyntaxToken token, bool leading, bool trailing)
184foreach (var token in node.DescendantTokens())
210public static bool SpansPreprocessorDirective(this ISyntaxFacts syntaxFacts, IEnumerable<SyntaxToken> tokens)
217var previousToken = default(SyntaxToken);
223foreach (var token in orderedTokens)
272public static bool IsReservedOrContextualKeyword(this ISyntaxFacts syntaxFacts, SyntaxToken token)
275public static bool IsWord(this ISyntaxFacts syntaxFacts, SyntaxToken token)
323SyntaxToken openParenToken;
325SyntaxToken closeParenToken;
357var previousToken = node.GetFirstToken().GetPreviousToken();
368var nextToken = node.GetLastToken().GetNextToken();
380private static bool IsWordOrNumber(this ISyntaxFacts syntaxFacts, SyntaxToken token)
401public static SyntaxToken GetOperatorTokenOfBinaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
403syntaxFacts.GetPartsOfBinaryExpression(node, out _, out var token, out _);
429public static SyntaxToken GetOperatorTokenOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
431syntaxFacts.GetPartsOfMemberAccessExpression(node, out _, out var operatorToken, out _);
456var afterAttributesToken = root.FindTokenOnRightOfPosition(endOfAttributeLists);
519public static SyntaxToken GetIdentifierOfGenericName(this ISyntaxFacts syntaxFacts, SyntaxNode node)
521syntaxFacts.GetPartsOfGenericName(node, out var identifier, out _);
525public static SyntaxToken GetIdentifierOfIdentifierName(this ISyntaxFacts syntaxFacts, SyntaxNode node)
528public static SyntaxToken GetIdentifierOfParameter(this ISyntaxFacts syntaxFacts, SyntaxNode node)
530syntaxFacts.GetPartsOfParameter(node, out var identifier, out _);
588public static SyntaxToken GetOperatorTokenOfPrefixUnaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
590syntaxFacts.GetPartsOfPrefixUnaryExpression(node, out var operatorToken, out _);
712public static bool IsAwaitKeyword(this ISyntaxFacts syntaxFacts, SyntaxToken token)
715public static bool IsGlobalNamespaceKeyword(this ISyntaxFacts syntaxFacts, SyntaxToken token)
722public static bool IsCharacterLiteral(this ISyntaxFacts syntaxFacts, SyntaxToken token)
725public static bool IsStringLiteral(this ISyntaxFacts syntaxFacts, SyntaxToken token)
732public static bool IsIdentifier(this ISyntaxFacts syntaxFacts, SyntaxToken token)
735public static bool IsHashToken(this ISyntaxFacts syntaxFacts, SyntaxToken token)
738public static bool IsInterpolatedStringTextToken(this ISyntaxFacts syntaxFacts, SyntaxToken token)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (31)
46public static IEnumerable<(SyntaxToken, SyntaxToken)> ConvertToTokenPairs(this SyntaxNode root, IReadOnlyList<TextSpan> spans)
82public static ValueTuple<SyntaxToken, SyntaxToken> ConvertToTokenPair(this SyntaxNode root, TextSpan textSpan)
87var startToken = root.FindToken(textSpan.Start);
104var endToken = (root.FullSpan.End <= textSpan.End) ?
128public static bool IsInvalidTokenRange(this SyntaxNode root, SyntaxToken startToken, SyntaxToken endToken)
146public static int GetTokenColumn(this SyntaxTree tree, SyntaxToken token, int tabSize)
157public static string GetText(this SourceText text, SyntaxToken token1, SyntaxToken token2)
160public static string GetTextBetween(SyntaxToken token1, SyntaxToken token2)
168public static void AppendTextBetween(SyntaxToken token1, SyntaxToken token2, StringBuilder builder)
193for (var token = token1.GetNextToken(includeZeroWidth: true); token.FullSpan.End <= token2.FullSpan.Start; token = token.GetNextToken(includeZeroWidth: true))
201private static void AppendTextBetweenTwoAdjacentTokens(SyntaxToken token1, SyntaxToken token2, StringBuilder builder)
207private static void AppendLeadingTriviaText(SyntaxToken token, StringBuilder builder)
224private static void AppendPartialLeadingTriviaText(SyntaxToken token, StringBuilder builder, int token1FullSpanEnd)
242private static void AppendTrailingTriviaText(SyntaxToken token, StringBuilder builder)
260public static TextSpan GetSpanIncludingTrailingAndLeadingTriviaOfAdjacentTokens(SyntaxToken startToken, SyntaxToken endToken)
270private static int GetEndPositionOfSpan(SyntaxToken token)
272var nextToken = token.GetNextToken();
295public static int GetStartPositionOfSpan(SyntaxToken token)
297var previousToken = token.GetPreviousToken();
347public static bool HasAnyWhitespaceElasticTrivia(SyntaxToken previousToken, SyntaxToken currentToken)
362var startToken = root.FindToken(span.Start).GetPreviousToken();
363var endToken = root.FindTokenFromEnd(span.End).GetNextToken();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (14)
98public TDeclarationNode AddAttributes<TDeclarationNode>(TDeclarationNode destination, IEnumerable<AttributeData> attributes, SyntaxToken? target, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
107public TDeclarationNode UpdateDeclarationModifiers<TDeclarationNode>(TDeclarationNode declaration, IEnumerable<SyntaxToken> newModifiers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
133public abstract TDeclarationNode AddAttributes<TDeclarationNode>(TDeclarationNode destination, IEnumerable<AttributeData> attributes, SyntaxToken? target, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
138public abstract TDeclarationNode UpdateDeclarationModifiers<TDeclarationNode>(TDeclarationNode declaration, IEnumerable<SyntaxToken> newModifiers, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
522Func<SyntaxToken, bool> isComma,
528var previousToken = root.FindToken(attributeToRemove.FullSpan.Start - 1);
530var nextToken = root.FindToken(attributeToRemove.FullSpan.End + 1);
540var tokenToInsertTrivia = node.FindToken(position);
541var tokenWithInsertedTrivia = tokenToInsertTrivia.WithLeadingTrivia(trivia.Concat(tokenToInsertTrivia.LeadingTrivia));
549ArrayBuilder<SyntaxToken> newModifierTokens, SyntaxTokenList modifiersList,
550Func<SyntaxToken, bool> isAccessibilityModifier)
552using var _ = ArrayBuilder<SyntaxToken>.GetInstance(out var updatedModifiersList);
554foreach (var modifier in modifiersList)
556SyntaxToken newModifier;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (9)
148syntaxFacts.GetPartsOfBinaryExpression(expressionNode, out var leftOperand, out var operatorToken, out var rightOperand);
181var newToken = syntaxFacts.GetOperatorTokenOfBinaryExpression(newBinaryExpressionSyntax);
245syntaxFacts.GetPartsOfBinaryPattern(pattern, out var left, out var operatorToken, out var right);
257syntaxFacts.GetPartsOfBinaryPattern(newPattern, out _, out var newToken, out _);
258var newTokenWithTrivia = newToken.WithTriviaFrom(operatorToken);
267syntaxFacts.GetPartsOfIsPatternExpression(isExpression, out var left, out var isToken, out var pattern);
316syntaxFacts.GetPartsOfRelationalPattern(expressionNode, out var operatorToken, out var expression);
524var operatorToken = syntaxFacts.GetOperatorTokenOfPrefixUnaryExpression(expression);
556syntaxFacts.GetPartsOfUnaryPattern(pattern, out var opToken, out var subPattern);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SyntaxGeneratorInternalExtensions\SyntaxGeneratorInternal.cs (11)
37SyntaxNode? type, SyntaxToken identifier, SyntaxNode? initializer = null, bool isConst = false);
42public SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initializer)
47public abstract SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value);
49public abstract SyntaxToken Identifier(string identifier);
71/// <see cref="LocalDeclarationStatement(SyntaxNode, SyntaxToken, SyntaxNode, bool)"/>.
76public abstract SyntaxToken InterpolatedStringTextToken(string content, string value);
77public abstract SyntaxNode InterpolatedStringText(SyntaxToken textToken);
79public abstract SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken);
112public abstract SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isToken, SyntaxNode pattern);
125public abstract SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern);