153 references to GetLastToken
Microsoft.CodeAnalysis.CSharp (2)
Binder\BinderFactory.BinderFactoryVisitor.cs (1)
1072token = containingNode.GetLastToken();
Syntax\CSharpSyntaxNode.cs (1)
177var lastToken = this.GetLastToken(includeZeroWidth: true);
Microsoft.CodeAnalysis.CSharp.CodeStyle (39)
src\Analyzers\CSharp\Analyzers\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessAnalyzer.cs (1)
181var nextToken = expressionStatement.GetLastToken().GetNextToken();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\StatementSyntaxExtensions.cs (1)
31var nextToken = statement.GetLastToken().GetNextToken();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (4)
163statement.GetLastToken() != token) 494return (node.GetFirstToken(includeZeroWidth: true), node.GetLastToken(includeZeroWidth: true)); 497var lastToken = node.GetLastToken(includeZeroWidth: true); 498var lastAttributeToken = attributes.Last().GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
44block.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (2)
92return objectCreationNode.Type.GetLastToken(); 97return arrayCreationNode.Type.GetLastToken();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (3)
115var lastTokenOfLabel = section.Labels.Last().GetLastToken(includeZeroWidth: true); 125var endToken = section.Statements.Last().GetLastToken(includeZeroWidth: true); 359var lastToken = statement.GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\QueryExpressionFormattingRule.cs (6)
48AddSuppressWrappingIfOnSingleLineOperation(list, queryExpression.GetFirstToken(includeZeroWidth: true), queryExpression.GetLastToken(includeZeroWidth: true)); 77var endToken = fromClause.Expression.GetLastToken(includeZeroWidth: true); 101var endToken = queryExpression.GetLastToken(includeZeroWidth: true); 118AddAnchorIndentationOperation(list, firstToken, queryClause.GetLastToken(includeZeroWidth: true)); 125AddAnchorIndentationOperation(list, firstToken, selectOrGroupClause.GetLastToken(includeZeroWidth: true)); 130AddAnchorIndentationOperation(list, continuation.IntoKeyword, continuation.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (15)
40AddSuppressWrappingIfOnSingleLineOperation(list, ifStatementNode.IfKeyword, ifStatementNode.Statement.GetLastToken(includeZeroWidth: true)); 44AddSuppressWrappingIfOnSingleLineOperation(list, ifStatementNode.Else.ElseKeyword, ifStatementNode.Else.Statement.GetLastToken(includeZeroWidth: true)); 63AddSuppressWrappingIfOnSingleLineOperation(list, openParenToken, property.GetLastToken()); 99AddSuppressWrappingIfOnSingleLineOperation(list, casePattern.GetFirstToken(), casePattern.GetLastToken()); 107AddSuppressWrappingIfOnSingleLineOperation(list, isPattern.GetFirstToken(), isPattern.GetLastToken()); 124AddSuppressWrappingIfOnSingleLineOperation(list, isPattern.IsKeyword, propertyPatternClause.GetLastToken()); 144AddSuppressWrappingIfOnSingleLineOperation(list, whileStatementNode.GetFirstToken(includeZeroWidth: true), whileStatementNode.Statement.GetLastToken(includeZeroWidth: true)); 172AddSuppressWrappingIfOnSingleLineOperation(list, firstToken, propertyDeclNode.AccessorList.GetLastToken()); 180AddSuppressWrappingIfOnSingleLineOperation(list, accessorDeclNode.Keyword, accessorDeclNode.GetLastToken(includeZeroWidth: true)); 188AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)); 198AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[i].GetFirstToken(includeZeroWidth: true), switchSection.Labels[i].GetLastToken(includeZeroWidth: true)); 205AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[switchSection.Labels.Count - 1].GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)); 226AddSuppressAllOperationIfOnMultipleLine(list, anchorToken, parameterNode.GetLastToken()); 271var lastToken = statementNode.GetLastToken(includeZeroWidth: true); 327var startToken = pragmaWarningDirectiveTrivia.GetLastToken(includeZeroWidth: true, includeDirectives: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (5)
76return (firstToken, embeddedStatement.GetLastToken(includeZeroWidth: true)); 86SwitchSectionSyntax switchSection => (switchSection.GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)), 87AnonymousMethodExpressionSyntax anonymousMethod => (anonymousMethod.DelegateKeyword, anonymousMethod.GetLastToken(includeZeroWidth: true)), 109var lastToken = statementNode.GetLastToken(includeZeroWidth: true); 119var lastToken = statementNode.GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
31var lastToken = (node as TypeDeclarationSyntax)?.TypeParameterList?.GetLastToken() ?? node.Identifier;
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (12)
src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
111? conditional.WhenFalse.GetLastToken()
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (2)
266var tokenAfterNamespace = namespaceDeclaration.GetLastToken(includeZeroWidth: true, includeSkipped: true).GetNextTokenOrEndOfFile(includeZeroWidth: true, includeSkipped: true); 400if (!fileScopedNamespace.GetLastToken().GetNextTokenOrEndOfFile().IsKind(SyntaxKind.EndOfFileToken)
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\MultiLineConditionalExpressionFormattingRule.cs (2)
61baseToken, conditional.QuestionToken, conditional.WhenTrue.GetLastToken(), 64baseToken, conditional.ColonToken, conditional.WhenFalse.GetLastToken(),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
91var lastToken = destination.GetLastToken();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (1)
297isRightAfterUsingOrImportDirective: targetToken.Parent is UsingDirectiveSyntax usingDirective && usingDirective?.GetLastToken() == targetToken,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
181var endToken = section.Statements.Last().GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.Rewriter.cs (4)
163var nextToken = compilationUnit.Usings.Last().GetLastToken().GetNextTokenOrEndOfFile(); 176var nextToken = compilationUnit.Usings.Last().GetLastToken().GetNextTokenOrEndOfFile(); 215var nextToken = namespaceDeclaration.Usings.Last().GetLastToken().GetNextTokenOrEndOfFile(); 228var nextToken = namespaceDeclaration.Usings.Last().GetLastToken().GetNextToken();
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (1)
382var nextToken = baseObjectCreationExpressionNode.GetLastToken(includeZeroWidth: true).GetNextToken(includeZeroWidth: true);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Diagnostics\GetDiagnosticsTests.cs (1)
1081span = localDecl.GetLastToken().GetNextToken().Span;
Microsoft.CodeAnalysis.CSharp.Features (30)
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (1)
336var nextToken = localDeclaration.GetLastToken().GetNextTokenOrEndOfFile();
DecompiledSource\CSharpDecompiledSourceFormattingRule.cs (1)
45if (previousStatement.GetLastToken() != previousToken || nextStatement.GetFirstToken() != currentToken)
EditAndContinue\BreakpointSpans.cs (1)
737return CreateSpan(switchStatement, (switchStatement.CloseParenToken != default) ? switchStatement.CloseParenToken : switchStatement.Expression.GetLastToken());
ExtractMethod\CSharpMethodExtractor.PostProcessor.cs (1)
70var lastToken = lastStatement.GetLastToken(includeZeroWidth: true);
ExtractMethod\CSharpSelectionValidator.cs (2)
124if (assign.Right.GetLastToken().Kind() == SyntaxKind.None) 129.With(s => s.LastTokenInFinalSpan = assign.Right.GetLastToken(includeZeroWidth: true)), text);
GenerateType\CSharpGenerateTypeService.cs (3)
202var token = simpleName.GetLastToken().GetNextToken(); 222var token = simpleName.GetLastToken().GetNextToken(); 241var nextToken = simpleName.GetLastToken().GetNextToken();
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (1)
474!nextStatement.GetLastToken().TrailingTrivia.Any(SyntaxKind.EndOfLineTrivia))
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (1)
139var isSingleLine = sourceText.AreOnSameLine(ifNode.GetFirstToken(), ifNode.GetLastToken());
src\Analyzers\CSharp\Analyzers\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessAnalyzer.cs (1)
181var nextToken = expressionStatement.GetLastToken().GetNextToken();
src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
111? conditional.WhenFalse.GetLastToken()
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (2)
266var tokenAfterNamespace = namespaceDeclaration.GetLastToken(includeZeroWidth: true, includeSkipped: true).GetNextTokenOrEndOfFile(includeZeroWidth: true, includeSkipped: true); 400if (!fileScopedNamespace.GetLastToken().GetNextTokenOrEndOfFile().IsKind(SyntaxKind.EndOfFileToken)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (2)
226(tokensForLeadingTrivia: new[] { s.Labels[0].GetFirstToken(), s.Labels[0].GetLastToken() }, 227tokensForTrailingTrivia: new[] { s.Statements[0].GetFirstToken(), s.Statements[0].GetLastToken() },
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\MultiLineConditionalExpressionFormattingRule.cs (2)
61baseToken, conditional.QuestionToken, conditional.WhenTrue.GetLastToken(), 64baseToken, conditional.ColonToken, conditional.WhenFalse.GetLastToken(),
Structure\Providers\AnonymousMethodExpressionStructureProvider.cs (1)
36? anonymousMethod.ParameterList.GetLastToken(includeZeroWidth: true)
Structure\Providers\ConstructorDeclarationStructureProvider.cs (1)
42constructorDeclaration.ParameterList.GetLastToken(includeZeroWidth: true),
Structure\Providers\ConversionOperatorDeclarationStructureProvider.cs (1)
44operatorDeclaration.ParameterList.GetLastToken(includeZeroWidth: true),
Structure\Providers\DestructorDeclarationStructureProvider.cs (1)
33destructorDeclaration.ParameterList.GetLastToken(includeZeroWidth: true),
Structure\Providers\IndexerDeclarationStructureProvider.cs (1)
43indexerDeclaration.ParameterList.GetLastToken(includeZeroWidth: true),
Structure\Providers\MethodDeclarationStructureProvider.cs (1)
42methodDeclaration.ParameterList.GetLastToken(includeZeroWidth: true),
Structure\Providers\NamespaceDeclarationStructureProvider.cs (1)
30namespaceDeclaration.Name.GetLastToken(includeZeroWidth: true),
Structure\Providers\OperatorDeclarationStructureProvider.cs (1)
42operatorDeclaration.ParameterList.GetLastToken(includeZeroWidth: true),
Structure\Providers\TypeDeclarationStructureProvider.cs (1)
30: typeDeclaration.TypeParameterList.GetLastToken(includeZeroWidth: true);
Wrapping\SeparatedSyntaxList\CSharpArgumentWrapper.cs (1)
90var endToken = listSyntax.GetLastToken();
Wrapping\SeparatedSyntaxList\CSharpParameterWrapper.cs (1)
67var lastToken = listSyntax.GetLastToken();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (11)
Parsing\ParsingErrorRecoveryTests.cs (2)
7377Assert.Equal("foreach", srcTree.GetLastToken().ToString()); 7380var foreachNode = srcTree.GetLastToken().Parent;
Syntax\SyntaxNodeTests.cs (9)
961var last = tree.GetCompilationUnitRoot().GetLastToken(); 969var last = tree.GetCompilationUnitRoot().GetLastToken(includeZeroWidth: true); 972last = tree.GetCompilationUnitRoot().Members[0].GetLastToken(includeZeroWidth: true); 1107var token = tree.GetCompilationUnitRoot().GetLastToken(); // skip EOF 1138var token = tree.GetCompilationUnitRoot().GetLastToken(includeSkipped: true); 1167var token = tree.GetCompilationUnitRoot().GetLastToken(includeSkipped: false); 1346var closeBraceChild = member.GetLastToken(); 2087var triviaLocation = method.ReturnType.GetLastToken().TrailingTrivia[0].GetLocation(); 2090Assert.Equal(method.ReturnType.GetLastToken().TrailingTrivia[0].Span, triviaLocation.SourceSpan);
Microsoft.CodeAnalysis.CSharp.Workspaces (49)
Formatting\TypingFormattingRule.cs (1)
86endToken = firstStatement.GetLastToken();
Simplification\CSharpSimplificationService.Expander.cs (2)
792if (invocationExpression != null && invocationExpression.Expression.GetLastToken() == originalSimpleName.GetLastToken())
Simplification\Reducers\CSharpMiscellaneousReducer.cs (1)
154if (!FormattingRangeHelper.AreTwoTokensOnSameLine(node.Statements[0].GetFirstToken(), node.Statements[0].GetLastToken()))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\StatementSyntaxExtensions.cs (1)
31var nextToken = statement.GetLastToken().GetNextToken();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (4)
163statement.GetLastToken() != token) 494return (node.GetFirstToken(includeZeroWidth: true), node.GetLastToken(includeZeroWidth: true)); 497var lastToken = node.GetLastToken(includeZeroWidth: true); 498var lastAttributeToken = attributes.Last().GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
44block.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (2)
92return objectCreationNode.Type.GetLastToken(); 97return arrayCreationNode.Type.GetLastToken();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (3)
115var lastTokenOfLabel = section.Labels.Last().GetLastToken(includeZeroWidth: true); 125var endToken = section.Statements.Last().GetLastToken(includeZeroWidth: true); 359var lastToken = statement.GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\QueryExpressionFormattingRule.cs (6)
48AddSuppressWrappingIfOnSingleLineOperation(list, queryExpression.GetFirstToken(includeZeroWidth: true), queryExpression.GetLastToken(includeZeroWidth: true)); 77var endToken = fromClause.Expression.GetLastToken(includeZeroWidth: true); 101var endToken = queryExpression.GetLastToken(includeZeroWidth: true); 118AddAnchorIndentationOperation(list, firstToken, queryClause.GetLastToken(includeZeroWidth: true)); 125AddAnchorIndentationOperation(list, firstToken, selectOrGroupClause.GetLastToken(includeZeroWidth: true)); 130AddAnchorIndentationOperation(list, continuation.IntoKeyword, continuation.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (15)
40AddSuppressWrappingIfOnSingleLineOperation(list, ifStatementNode.IfKeyword, ifStatementNode.Statement.GetLastToken(includeZeroWidth: true)); 44AddSuppressWrappingIfOnSingleLineOperation(list, ifStatementNode.Else.ElseKeyword, ifStatementNode.Else.Statement.GetLastToken(includeZeroWidth: true)); 63AddSuppressWrappingIfOnSingleLineOperation(list, openParenToken, property.GetLastToken()); 99AddSuppressWrappingIfOnSingleLineOperation(list, casePattern.GetFirstToken(), casePattern.GetLastToken()); 107AddSuppressWrappingIfOnSingleLineOperation(list, isPattern.GetFirstToken(), isPattern.GetLastToken()); 124AddSuppressWrappingIfOnSingleLineOperation(list, isPattern.IsKeyword, propertyPatternClause.GetLastToken()); 144AddSuppressWrappingIfOnSingleLineOperation(list, whileStatementNode.GetFirstToken(includeZeroWidth: true), whileStatementNode.Statement.GetLastToken(includeZeroWidth: true)); 172AddSuppressWrappingIfOnSingleLineOperation(list, firstToken, propertyDeclNode.AccessorList.GetLastToken()); 180AddSuppressWrappingIfOnSingleLineOperation(list, accessorDeclNode.Keyword, accessorDeclNode.GetLastToken(includeZeroWidth: true)); 188AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)); 198AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[i].GetFirstToken(includeZeroWidth: true), switchSection.Labels[i].GetLastToken(includeZeroWidth: true)); 205AddSuppressWrappingIfOnSingleLineOperation(list, switchSection.Labels[switchSection.Labels.Count - 1].GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)); 226AddSuppressAllOperationIfOnMultipleLine(list, anchorToken, parameterNode.GetLastToken()); 271var lastToken = statementNode.GetLastToken(includeZeroWidth: true); 327var startToken = pragmaWarningDirectiveTrivia.GetLastToken(includeZeroWidth: true, includeDirectives: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (5)
76return (firstToken, embeddedStatement.GetLastToken(includeZeroWidth: true)); 86SwitchSectionSyntax switchSection => (switchSection.GetFirstToken(includeZeroWidth: true), switchSection.GetLastToken(includeZeroWidth: true)), 87AnonymousMethodExpressionSyntax anonymousMethod => (anonymousMethod.DelegateKeyword, anonymousMethod.GetLastToken(includeZeroWidth: true)), 109var lastToken = statementNode.GetLastToken(includeZeroWidth: true); 119var lastToken = statementNode.GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
31var lastToken = (node as TypeDeclarationSyntax)?.TypeParameterList?.GetLastToken() ?? node.Identifier;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
91var lastToken = destination.GetLastToken();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (1)
297isRightAfterUsingOrImportDirective: targetToken.Parent is UsingDirectiveSyntax usingDirective && usingDirective?.GetLastToken() == targetToken,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (1)
181var endToken = section.Statements.Last().GetLastToken(includeZeroWidth: true);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.Rewriter.cs (4)
163var nextToken = compilationUnit.Usings.Last().GetLastToken().GetNextTokenOrEndOfFile(); 176var nextToken = compilationUnit.Usings.Last().GetLastToken().GetNextTokenOrEndOfFile(); 215var nextToken = namespaceDeclaration.Usings.Last().GetLastToken().GetNextTokenOrEndOfFile(); 228var nextToken = namespaceDeclaration.Usings.Last().GetLastToken().GetNextToken();
Microsoft.CodeAnalysis.UnitTests (1)
CommonSyntaxTests.cs (1)
112var csharpToken = CSharp.SyntaxFactory.ParseExpression("1 + 123 /*hello*/").GetLastToken();
Microsoft.VisualStudio.LanguageServices.CSharp (7)
CodeModel\CSharpCodeModelService.cs (1)
3289var lastToken = newMember.GetLastToken();
CodeModel\CSharpCodeModelService.NodeLocator.cs (5)
900endPosition = node.AttributeLists.Last().GetLastToken().Span.End; 941endPosition = node.AttributeLists.Last().GetLastToken().Span.End; 1237endPosition = node.AttributeLists.Last().GetLastToken().Span.End; 1279endPosition = field.AttributeLists.Last().GetLastToken().Span.End; 1320endPosition = node.AttributeLists.Last().GetLastToken().Span.End;
CodeModel\SyntaxNodeExtensions.cs (1)
65return attributeLists.Last().GetLastToken().GetNextToken();