119 references to GetTrailingTrivia
Microsoft.CodeAnalysis (4)
Syntax\CommonSyntaxNodeRemover.cs (1)
46!ContainsEndOfLine(node.GetTrailingTrivia(), endOfLineKind) &&
Syntax\SyntaxNode.cs (1)
576return this.GetTrailingTrivia().Count > 0;
Syntax\SyntaxNodeExtensions.cs (1)
325return syntax.WithLeadingTrivia(node.GetLeadingTrivia()).WithTrailingTrivia(node.GetTrailingTrivia());
Syntax\SyntaxNodeOrToken.cs (1)
391return _nodeOrParent.GetTrailingTrivia();
Microsoft.CodeAnalysis.CodeStyle (5)
src\Analyzers\Core\Analyzers\RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (1)
182foreach (var trivia in node.GetTrailingTrivia())
src\Analyzers\Core\Analyzers\UseConditionalExpression\UseConditionalExpressionHelpers.cs (1)
66HasRegularCommentTrivia(syntaxFacts, syntax.GetTrailingTrivia());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (1)
743return node.WithTrailingTrivia(node.GetTrailingTrivia().Concat(trivia));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (2)
343var trailingTrivia = operand.GetTrailingTrivia() 366if (resultNode.GetTrailingTrivia().Count == 0)
Microsoft.CodeAnalysis.CodeStyle.Fixes (13)
src\Analyzers\Core\CodeFixes\RemoveRedundantEquality\RemoveRedundantEqualityCodeFixProvider.cs (1)
79return node.WithTrailingTrivia(node.GetTrailingTrivia().Select(SyntaxTriviaExtensions.AsElastic));
src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\SimplifyLinqExpressionCodeFixProvider.cs (1)
66return innerInvocationExpression.ReplaceNode(innerName, outerName.WithTriviaFrom(innerName)).WithTrailingTrivia(current.GetTrailingTrivia());
src\Analyzers\Core\CodeFixes\UseCoalesceExpression\UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs (1)
79.WithTrailingTrivia(conditionalExpression.GetTrailingTrivia());
src\Analyzers\Core\CodeFixes\UseConditionalExpression\UseConditionalExpressionHelpers.cs (1)
24if (HasRegularCommentTrivia(syntaxFacts, syntax.GetTrailingTrivia()))
src\Analyzers\Core\CodeFixes\UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs (2)
208if (!newWhenTrueStatement.GetTrailingTrivia().Any(syntaxFacts.IsRegularComment) && !isElseIf) 209newWhenTrueStatement = newWhenTrueStatement.WithTrailingTrivia(ifStatement.GetTrailingTrivia());
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (2)
508var trailing = attributeList.GetTrailingTrivia(); 531var trailing = isComma(nextToken) ? nextToken.TrailingTrivia : attributeToRemove.GetTrailingTrivia();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AddImportHelpers.cs (4)
51var trailingTrivia = newImports[i].GetTrailingTrivia(); 65var originalFirstUsingTrailingTrivia = originalFirstUsing.GetTrailingTrivia(); 82newImports[^1] = newImports[^1].WithTrailingTrivia(originalLastUsing.GetTrailingTrivia()); 88var trailingTrivia = newImports[i].GetTrailingTrivia();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs (1)
248.WithTrailingTrivia(state.VariableDeclarator.GetTrailingTrivia()));
Microsoft.CodeAnalysis.CSharp (9)
Syntax\SyntaxFactory.cs (1)
2355if (lastNode.HasTrailingTrivia && lastNode.ContainsDiagnostics && HasUnterminatedMultiLineComment(lastNode.GetTrailingTrivia()))
Syntax\SyntaxNodeRemover.cs (7)
42result = result.WithTrailingTrivia(result.GetTrailingTrivia().Concat(residualTrivia)); 311this.AddResidualTrivia(node.GetTrailingTrivia()); 315this.AddEndOfLine(GetEndOfLine(node.GetTrailingTrivia())); 351this.AddResidualTrivia(node.GetTrailingTrivia()); 355this.AddEndOfLine(GetEndOfLine(node.GetTrailingTrivia())); 385this.AddResidualTrivia(node.GetTrailingTrivia()); 393var eol = GetEndOfLine(node.GetTrailingTrivia()) ??
Syntax\SyntaxNormalizer.cs (1)
1243var trailing = node.GetTrailingTrivia();
Microsoft.CodeAnalysis.CSharp.CodeStyle (7)
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (1)
237.Concat(declaration.GetTrailingTrivia());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (4)
884node.GetTrailingTrivia().Concat(SyntaxNodeOrTokenExtensions.GetTrivia(trailingNodesOrTokens).Concat(trailingTrivia)).FilterComments(addElasticMarker: false)); 888.WithTrailingTrivia(node.GetTrailingTrivia().FilterComments(addElasticMarker: true)) 901var hasTrailingComments = from.GetTrailingTrivia().Any(t => t.IsRegularComment()); 903finalTrivia.AddRange(from.GetTrailingTrivia());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.cs (1)
188structuredTrivia.GetTrailingTrivia().Any(SyntaxKind.EndOfLineTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesOrganizer.cs (1)
157var trailingTrivia = node.GetTrailingTrivia();
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (8)
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (1)
160var expressionTrivia = newStatement.GetTrailingTrivia();
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (3)
96var triviaToAppend = newNameNode.GetLeadingTrivia().AddRange(newNameNode.GetTrailingTrivia()); 152.WithTrailingTrivia(proposedReplacementNode.GetTrailingTrivia()); 163.WithTrailingTrivia(proposedReplacementNode.GetTrailingTrivia());
src\Analyzers\CSharp\CodeFixes\UseObjectInitializer\CSharpUseObjectInitializerCodeFixProvider.cs (1)
83expressionStatement.GetTrailingTrivia());
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs (1)
102.WithoutTrivia().WithTrailingTrivia(rightSideOfComparison.GetTrailingTrivia());
src\Analyzers\CSharp\CodeFixes\UseThrowExpression\UseThrowExpressionCodeFixProvider.cs (1)
66if (assignmentExpressionStatement.GetTrailingTrivia().Any(t => t.IsSingleOrMultiLineComment()))
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
185return CreateUtf8String(nodeToTakeTriviaFrom.GetLeadingTrivia(), stringValue, nodeToTakeTriviaFrom.GetTrailingTrivia(), isConvertedToReadOnlySpan);
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (1)
399SemicolonToken.WithTrailingTrivia(objectCreationNodeWithCorrectInitializer.GetTrailingTrivia()),
Microsoft.CodeAnalysis.CSharp.Features (10)
Copilot\CSharpCopilotCodeFixProvider.cs (1)
130.WithTrailingTrivia(memberDeclaration.HasTrailingTrivia ? memberDeclaration.GetTrailingTrivia() : method.GetTrailingTrivia())
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (1)
237.Concat(declaration.GetTrailingTrivia());
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (1)
160var expressionTrivia = newStatement.GetTrailingTrivia();
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (3)
96var triviaToAppend = newNameNode.GetLeadingTrivia().AddRange(newNameNode.GetTrailingTrivia()); 152.WithTrailingTrivia(proposedReplacementNode.GetTrailingTrivia()); 163.WithTrailingTrivia(proposedReplacementNode.GetTrailingTrivia());
src\Analyzers\CSharp\CodeFixes\UseObjectInitializer\CSharpUseObjectInitializerCodeFixProvider.cs (1)
83expressionStatement.GetTrailingTrivia());
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs (1)
102.WithoutTrivia().WithTrailingTrivia(rightSideOfComparison.GetTrailingTrivia());
src\Analyzers\CSharp\CodeFixes\UseThrowExpression\UseThrowExpressionCodeFixProvider.cs (1)
66if (assignmentExpressionStatement.GetTrailingTrivia().Any(t => t.IsSingleOrMultiLineComment()))
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (1)
185return CreateUtf8String(nodeToTakeTriviaFrom.GetLeadingTrivia(), stringValue, nodeToTakeTriviaFrom.GetTrailingTrivia(), isConvertedToReadOnlySpan);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (5)
Syntax\SyntaxNodeTests.cs (5)
3743Assert.Equal(1, namedNode.GetTrailingTrivia().Count); 3744Assert.Equal(0, namedNode.GetTrailingTrivia().Span.Length); // zero-width elastic trivia 3751Assert.Equal(0, namedNode.GetTrailingTrivia().Count); 3759Assert.Equal(1, namedNode.GetTrailingTrivia().Count); 3760Assert.Equal(2, namedNode.GetTrailingTrivia().Span.Length);
Microsoft.CodeAnalysis.CSharp.Workspaces (7)
CodeGeneration\CSharpSyntaxGenerator.cs (1)
3077var newNode = node.WithTrailingTrivia(node.GetTrailingTrivia().AddRange(previousToken.TrailingTrivia));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (4)
884node.GetTrailingTrivia().Concat(SyntaxNodeOrTokenExtensions.GetTrivia(trailingNodesOrTokens).Concat(trailingTrivia)).FilterComments(addElasticMarker: false)); 888.WithTrailingTrivia(node.GetTrailingTrivia().FilterComments(addElasticMarker: true)) 901var hasTrailingComments = from.GetTrailingTrivia().Any(t => t.IsRegularComment()); 903finalTrivia.AddRange(from.GetTrailingTrivia());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.cs (1)
188structuredTrivia.GetTrailingTrivia().Any(SyntaxKind.EndOfLineTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesOrganizer.cs (1)
157var trailingTrivia = node.GetTrailingTrivia();
Microsoft.CodeAnalysis.Features (16)
ChangeSignature\AbstractChangeSignatureService.cs (3)
1007updatedNodeList.Add(permutedParamNodes[index].WithLeadingTrivia(content.GetLeadingTrivia()).WithTrailingTrivia(content.GetTrailingTrivia())); 1017newDocComments = newDocComments.WithLeadingTrivia(structuredTrivia.GetLeadingTrivia()).WithTrailingTrivia(structuredTrivia.GetTrailingTrivia()); 1033node.GetTrailingTrivia(),
CodeRefactorings\MoveType\AbstractMoveTypeService.MoveTypeNamespaceScopeEditor.cs (1)
103syntaxNode = syntaxNode.WithTrailingTrivia(syntaxNode.GetTrailingTrivia().Select(SyntaxTriviaExtensions.AsElastic));
ConvertToInterpolatedString\AbstractConvertConcatenationToInterpolatedStringRefactoringProvider.cs (1)
132.WithTrailingTrivia(pieces.Last().GetTrailingTrivia());
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (2)
495var trailingTrivia = GetTriviaUntilSpace(newTrailing[^1].GetTrailingTrivia()).Concat(GetTrailingSpace(statementsAfterIf[^1].GetTrailingTrivia()));
ReplaceMethodWithProperty\AbstractReplaceMethodWithPropertyService.cs (1)
80var trailingTrivia = paramList.GetTrailingTrivia();
ReplacePropertyWithMethods\AbstractReplacePropertyWithMethodsService.cs (1)
408invocation = invocation.WithTrailingTrivia(_identifierName.GetTrailingTrivia());
src\Analyzers\Core\Analyzers\RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (1)
182foreach (var trivia in node.GetTrailingTrivia())
src\Analyzers\Core\Analyzers\UseConditionalExpression\UseConditionalExpressionHelpers.cs (1)
66HasRegularCommentTrivia(syntaxFacts, syntax.GetTrailingTrivia());
src\Analyzers\Core\CodeFixes\RemoveRedundantEquality\RemoveRedundantEqualityCodeFixProvider.cs (1)
79return node.WithTrailingTrivia(node.GetTrailingTrivia().Select(SyntaxTriviaExtensions.AsElastic));
src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\SimplifyLinqExpressionCodeFixProvider.cs (1)
66return innerInvocationExpression.ReplaceNode(innerName, outerName.WithTriviaFrom(innerName)).WithTrailingTrivia(current.GetTrailingTrivia());
src\Analyzers\Core\CodeFixes\UseCoalesceExpression\UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs (1)
79.WithTrailingTrivia(conditionalExpression.GetTrailingTrivia());
src\Analyzers\Core\CodeFixes\UseConditionalExpression\UseConditionalExpressionHelpers.cs (1)
24if (HasRegularCommentTrivia(syntaxFacts, syntax.GetTrailingTrivia()))
src\Analyzers\Core\CodeFixes\UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs (1)
209newWhenTrueStatement = newWhenTrueStatement.WithTrailingTrivia(ifStatement.GetTrailingTrivia());
Microsoft.CodeAnalysis.VisualBasic (9)
Scanner\Blender.vb (1)
138Return node.GetTrailingTrivia().Any(SyntaxKind.EndOfLineTrivia)
Syntax\SyntaxFacts.vb (1)
207Dim trailingTrivia As SyntaxTriviaList = node.GetTrailingTrivia()
Syntax\SyntaxNodeRemover.vb (7)
29result = result.WithTrailingTrivia(result.GetTrailingTrivia().Concat(residualTrivia)) 223Me.AddResidualTrivia(node.GetTrailingTrivia()) 224ElseIf (Me._options And SyntaxRemoveOptions.KeepEndOfLine) <> 0 AndAlso HasEndOfLine(node.GetTrailingTrivia()) Then 250Me.AddResidualTrivia(node.GetTrailingTrivia()) 251ElseIf (Me._options And SyntaxRemoveOptions.KeepEndOfLine) <> 0 AndAlso HasEndOfLine(node.GetTrailingTrivia()) Then 274Me.AddResidualTrivia(node.GetTrailingTrivia()) 278(HasEndOfLine(node.GetTrailingTrivia()) OrElse HasEndOfLine(token.LeadingTrivia) OrElse HasEndOfLine(token.TrailingTrivia)) Then
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (3)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\TypeBlockSyntaxExtensions.vb (3)
45Return node.WithTrailingTrivia(node.GetTrailingTrivia().Select(Function(t) If(t.Kind = SyntaxKind.ColonTrivia, SyntaxFactory.ElasticCarriageReturnLineFeed, t))) 50If Not allElements.Last().GetTrailingTrivia().Any(Function(t) t.Kind = SyntaxKind.EndOfLineTrivia OrElse t.Kind = SyntaxKind.ColonTrivia) Then 53ElseIf allElements.Last().GetTrailingTrivia().Any(Function(t) t.Kind = SyntaxKind.ColonTrivia) Then
Microsoft.CodeAnalysis.VisualBasic.Features (1)
Completion\KeywordRecommenders\PreprocessorDirectives\PreprocessorHelpers.vb (1)
54For Each followingTrivia In node.GetTrailingTrivia()
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (1)
TestSyntaxNodes.vb (1)
331Dim precedingTrivia = tree.GetLeadingTrivia(), followingTrivia = tree.GetTrailingTrivia()
Microsoft.CodeAnalysis.VisualBasic.Workspaces (3)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\TypeBlockSyntaxExtensions.vb (3)
45Return node.WithTrailingTrivia(node.GetTrailingTrivia().Select(Function(t) If(t.Kind = SyntaxKind.ColonTrivia, SyntaxFactory.ElasticCarriageReturnLineFeed, t))) 50If Not allElements.Last().GetTrailingTrivia().Any(Function(t) t.Kind = SyntaxKind.EndOfLineTrivia OrElse t.Kind = SyntaxKind.ColonTrivia) Then 53ElseIf allElements.Last().GetTrailingTrivia().Any(Function(t) t.Kind = SyntaxKind.ColonTrivia) Then
Microsoft.CodeAnalysis.Workspaces (15)
Editing\SyntaxGenerator.cs (5)
1068.WithTrailingTrivia(RemoveCommentLines(node.GetTrailingTrivia())); 1481.WithTrailingTrivia(changedNode.GetTrailingTrivia().Concat(node.GetTrailingTrivia())); 1488.WithTrailingTrivia(replacement.GetTrailingTrivia().AddRange(original.GetTrailingTrivia()));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (1)
743return node.WithTrailingTrivia(node.GetTrailingTrivia().Concat(trivia));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (2)
343var trailingTrivia = operand.GetTrailingTrivia() 366if (resultNode.GetTrailingTrivia().Count == 0)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (2)
508var trailing = attributeList.GetTrailingTrivia(); 531var trailing = isComma(nextToken) ? nextToken.TrailingTrivia : attributeToRemove.GetTrailingTrivia();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AddImportHelpers.cs (4)
51var trailingTrivia = newImports[i].GetTrailingTrivia(); 65var originalFirstUsingTrailingTrivia = originalFirstUsing.GetTrailingTrivia(); 82newImports[^1] = newImports[^1].WithTrailingTrivia(originalLastUsing.GetTrailingTrivia()); 88var trailingTrivia = newImports[i].GetTrailingTrivia();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs (1)
248.WithTrailingTrivia(state.VariableDeclarator.GetTrailingTrivia()));
Microsoft.VisualStudio.LanguageServices.VisualBasic (1)
CodeModel\VisualBasicCodeModelService.vb (1)
3826(Not list.HasTrailingTrivia OrElse Not list.GetTrailingTrivia().Any(SyntaxKind.EndOfLineTrivia)) Then
System.Text.RegularExpressions.Generator (1)
UpgradeToGeneratedRegexCodeFixer.cs (1)
329=> method.WithLeadingTrivia(nodeToFix.GetLeadingTrivia()).WithTrailingTrivia(nodeToFix.GetTrailingTrivia());