713 references to LeadingTrivia
Microsoft.AspNetCore.App.Analyzers (1)
RouteEmbeddedLanguage\Infrastructure\SyntaxNodeExtensions.cs (1)
91var skippedToken = findSkippedToken(token.LeadingTrivia, position);
Microsoft.CodeAnalysis (16)
Syntax\SyntaxNavigator.cs (5)
252var firstToken = GetFirstToken(token.LeadingTrivia, predicate, stepInto); 301var lastToken = GetLastToken(token.LeadingTrivia, predicate, stepInto); 319var token = GetNextToken(current, current.Token.LeadingTrivia, predicate, stepInto, ref returnNext); 364token = GetPreviousToken(current, current.Token.LeadingTrivia, predicate, stepInto, ref returnPrevious); 592var lastToken = GetLastToken(current.LeadingTrivia, predicate, stepInto!);
Syntax\SyntaxNode.cs (3)
1066return GetFirstToken(includeZeroWidth: true).LeadingTrivia; 1131foreach (var trivia in token.LeadingTrivia) 1537trivia = GetTriviaThatContainsPosition(token.LeadingTrivia, position);
Syntax\SyntaxNode.Iterators.cs (1)
549foreach (var trivia in token.LeadingTrivia)
Syntax\SyntaxNodeOrToken.cs (2)
362return this.AsToken().LeadingTrivia; 856foreach (var trivia in node.AsToken().LeadingTrivia)
Syntax\SyntaxToken.cs (4)
194public bool HasLeadingTrivia => this.LeadingTrivia.Count > 0; 454return this.WithLeadingTrivia(token.LeadingTrivia).WithTrailingTrivia(token.TrailingTrivia); 518return this.LeadingTrivia.Concat(this.TrailingTrivia); 521return this.LeadingTrivia;
Syntax\SyntaxWalker.cs (1)
74foreach (var trivia in token.LeadingTrivia)
Microsoft.CodeAnalysis.CodeStyle (31)
src\Analyzers\Core\Analyzers\FileHeaders\AbstractFileHeaderHelper.cs (3)
36var firstNonWhitespaceTrivia = IndexOfFirstNonWhitespaceTrivia(firstToken.LeadingTrivia); 49for (var i = firstNonWhitespaceTrivia; i < firstToken.LeadingTrivia.Count; i++) 51var trivia = firstToken.LeadingTrivia[i];
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
94foreach (var trivia in nextToken.LeadingTrivia)
src\Analyzers\Core\Analyzers\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesDiagnosticAnalyzer.cs (1)
88var leadingTrivia = token.LeadingTrivia;
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
702foreach (var trivia in firstToken.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (5)
626var skippedToken = findSkippedToken(token.LeadingTrivia, position); 667var skippedToken = findSkippedToken(token.LeadingTrivia, position); 874foreach (var trivia in token.LeadingTrivia) 948triviaList = triviaList.AddRange(token.LeadingTrivia); 971triviaList = triviaList.InsertRange(0, current.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (2)
102if (!token.LeadingTrivia.Any() && !token.TrailingTrivia.Any()) 134return token.WithLeadingTrivia(trivia.Concat(token.LeadingTrivia));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
147var triviaList = compilationUnit.EndOfFileToken.LeadingTrivia; 183trivia = endOfFileToken.LeadingTrivia.Last();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractTriviaDataFactory.AbstractComplexTrivia.cs (1)
132var list = new TriviaList(Token1.TrailingTrivia, Token2.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TokenStream.cs (2)
392Debug.Assert((token1.IndexInStream >= 0 && token2.IndexInStream >= 0) || token1.Token.Equals(token2.Token.GetPreviousToken(includeZeroWidth: true)) || token2.Token.LeadingTrivia.Span.Contains(token1.Token.Span)); 417Debug.Assert((token1.IndexInStream >= 0 && token2.IndexInStream >= 0) || token1.Token.Equals(token2.Token.GetPreviousToken(includeZeroWidth: true)) || token2.Token.LeadingTrivia.Span.Contains(token1.Token.Span));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
255AddRange(triviaList, this.Token2.LeadingTrivia); 293var list = new TriviaList(this.Token1.TrailingTrivia, this.Token2.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Helpers\RemoveUnnecessaryImports\RemoveUnnecessaryImportsHelpers.cs (1)
17var trimmedLeadingTrivia = token.LeadingTrivia.SkipWhile(syntaxFacts.IsEndOfLineTrivia).ToList();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\FileBannerFacts\AbstractFileBannerFacts.cs (1)
176var leadingTrivia = firstToken.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\AbstractDocumentationCommentService.cs (1)
169if (token.LeadingTrivia.Count > 0 || HasLeadingWhitespace(tokenText))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (5)
97if (!IsOnSingleLine(syntaxFacts, token.LeadingTrivia, leading) || 233if (SpansPreprocessorDirective(syntaxFacts, token.LeadingTrivia) || 338var leadingTrivia = openParenToken.LeadingTrivia 344.Concat(closeParenToken.LeadingTrivia) 369if (nextToken.LeadingTrivia.Count == 0 &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (3)
214foreach (var trivia in token.LeadingTrivia) 231foreach (var trivia in token.LeadingTrivia) 355return previousToken.TrailingTrivia.HasAnyWhitespaceElasticTrivia() || currentToken.LeadingTrivia.HasAnyWhitespaceElasticTrivia();
Microsoft.CodeAnalysis.CodeStyle.Fixes (10)
src\Analyzers\Core\CodeFixes\NewLines\ConsecutiveStatementPlacement\ConsecutiveStatementPlacementCodeFixProvider.cs (1)
55(original, current) => current.WithLeadingTrivia(current.LeadingTrivia.Insert(0, endOfLineTrivia)));
src\Analyzers\Core\CodeFixes\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesCodeFixProvider.cs (1)
54var leadingTrivia = UpdateLeadingTrivia(syntaxKinds, token.LeadingTrivia);
src\Analyzers\Core\CodeFixes\UseObjectInitializer\AbstractUseObjectInitializerCodeFixProvider.cs (2)
103if (currentToken.LeadingTrivia is [.., var whitespace1] && 107var leadingTrivia = currentToken.LeadingTrivia.Replace(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (3)
529var leading = isComma(previousToken) ? previousToken.LeadingTrivia : attributeToRemove.GetLeadingTrivia(); 541var tokenWithInsertedTrivia = tokenToInsertTrivia.WithLeadingTrivia(trivia.Concat(tokenToInsertTrivia.LeadingTrivia)); 563.WithLeadingTrivia(modifier.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\IIndentationService.cs (1)
51newToken = newToken.WithLeadingTrivia(newToken.LeadingTrivia.Add(syntaxGenerator.EndOfLine(options.FormattingOptions.NewLine)));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AddImportHelpers.cs (2)
40firstToken.LeadingTrivia.Where(t => IsDocCommentOrElastic(syntaxFacts, t))); 46firstToken.LeadingTrivia.Where(t => !IsDocCommentOrElastic(syntaxFacts, t)));
Microsoft.CodeAnalysis.CSharp (17)
Syntax\CompilationUnitSyntax.cs (1)
59foreach (var trivia in firstToken.LeadingTrivia)
Syntax\CSharpSyntaxNode.cs (3)
169return firstToken.LeadingTrivia; 249foreach (var tr in token.LeadingTrivia) 289foreach (var tr in token.LeadingTrivia.Reverse())
Syntax\CSharpSyntaxWalker.cs (1)
77foreach (var tr in token.LeadingTrivia)
Syntax\DirectiveTriviaSyntax.cs (2)
73foreach (var tr in token.LeadingTrivia) 104foreach (var tr in token.LeadingTrivia.Reverse())
Syntax\SyntaxFactory.cs (2)
1207return Token(rewrittenToken.LeadingTrivia, SyntaxKind.LessThanToken, "{", rewrittenToken.ValueText, rewrittenToken.TrailingTrivia); 1210return Token(rewrittenToken.LeadingTrivia, SyntaxKind.GreaterThanToken, "}", rewrittenToken.ValueText, rewrittenToken.TrailingTrivia);
Syntax\SyntaxNodeRemover.cs (6)
198_residualTrivia.Add(result.LeadingTrivia); 329this.AddResidualTrivia(token.LeadingTrivia); 337var eol = GetEndOfLine(token.LeadingTrivia) ?? 386this.AddResidualTrivia(token.LeadingTrivia); 489var index = parentToken.LeadingTrivia.IndexOf(trivia); 491? (parentToken.LeadingTrivia, index)
Syntax\SyntaxNormalizer.cs (1)
98token.LeadingTrivia,
Syntax\SyntaxTokenParser.cs (1)
63/// parsed trivia will be set as the <see cref="SyntaxToken.LeadingTrivia"/> of the token.
Microsoft.CodeAnalysis.CSharp.CodeStyle (28)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_ProgramMain.cs (1)
67var lastPragma = root.GetFirstToken().LeadingTrivia.LastOrDefault(t => t.Kind() is SyntaxKind.PragmaWarningDirectiveTrivia);
src\Analyzers\CSharp\Analyzers\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
105if (nextToken.LeadingTrivia.Any(static t => t.Kind() is
src\Analyzers\CSharp\Analyzers\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementDiagnosticAnalyzer.cs (1)
86if (nextToken.LeadingTrivia.Any(static t => t.Kind() is
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (1)
128endOfLineTrivia = secondBrace.LeadingTrivia.Last(t => t.IsKind(SyntaxKind.EndOfLineTrivia));
src\Analyzers\CSharp\Analyzers\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
88if (thisOrBaseKeyword.LeadingTrivia.Any(t => !t.IsWhitespaceOrEndOfLine() && !t.IsSingleOrMultiLineComment()))
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (1)
122=> ContainsEndOfLine(previous.TrailingTrivia) || ContainsEndOfLine(next.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ArrowExpressionClauseSyntaxExtensions.cs (2)
46if (arrowExpression.ArrowToken.LeadingTrivia.Any(t => t.IsSingleOrMultiLineComment())) 47statement = statement.WithPrependedLeadingTrivia(arrowExpression.ArrowToken.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (5)
38block.CloseBraceToken.LeadingTrivia.Where(t => !t.IsWhitespaceOrEndOfLine())); 54var closeBraceLeadingDirectives = block.CloseBraceToken.LeadingTrivia.Where(IsAnyCodeDirective).ToImmutableArray(); 87var triviaIndex = parentToken.LeadingTrivia.IndexOf(parentTrivia); 88if (triviaIndex + 1 < parentToken.LeadingTrivia.Count) 90var nextTrivia = parentToken.LeadingTrivia[triviaIndex + 1];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberAccessExpressionSyntaxExtensions.cs (1)
30.AddRange(memberAccess.OperatorToken.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (4)
75return token.LeadingTrivia; 82return token.LeadingTrivia; 85return prevToken.TrailingTrivia.Concat(token.LeadingTrivia); 523ContainsInterleavedDirective(textSpan, token.LeadingTrivia, cancellationToken) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.SingleLineRewriter.cs (2)
30else if (token.LeadingTrivia.Count > 0) 66token.LeadingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (1)
230.WithLeadingTrivia(token.LeadingTrivia.FilterComments(addElasticMarker: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
193trivia = eof.LeadingTrivia.Last();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.cs (2)
19Analyze(token.LeadingTrivia, ref result); 87Analyze(token2.LeadingTrivia, ref result);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.cs (1)
332foreach (var xmlTrivia in token.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaRewriter.cs (1)
196leadingTrivia = token.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
254var triviaList = currentToken.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
290ProcessTriviaList(list, child.AsToken().LeadingTrivia);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (41)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (4)
305var leadingTrivia = token.LeadingTrivia; 329.WithAppendedTrailingTrivia(namespaceDeclaration.OpenBraceToken.LeadingTrivia); 347.WithAppendedTrailingTrivia(namespaceDeclaration.CloseBraceToken.LeadingTrivia) 384var nameSyntax = fileScopedNamespace.Name.WithAppendedTrailingTrivia(fileScopedNamespace.SemicolonToken.LeadingTrivia)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
61switchExpression, switchStatement.SwitchKeyword.LeadingTrivia, declaratorToRemoveType, nodeToGenerate, generateDeclaration);
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (3)
270: recordKeyword.WithLeadingTrivia(typeDeclaration.Keyword.LeadingTrivia); 599: p.Modifiers.First().LeadingTrivia); 737return token.LeadingTrivia;
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (1)
432var newLeadingTrivia = firstToken.LeadingTrivia.InsertRange(0, fileHeader);
src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
90secondBrace.LeadingTrivia.SkipWhile(t => t != lastEndOfLineTrivia).Skip(1));
src\Analyzers\CSharp\CodeFixes\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementCodeFixProvider.cs (4)
77replacementMap[colonToken] = colonToken.WithLeadingTrivia(colonToken.LeadingTrivia.AddRange(colonToken.TrailingTrivia).AddRange(thisBaseKeyword.LeadingTrivia)) 97replacementMap[colonToken] = colonToken.WithLeadingTrivia(thisBaseKeyword.LeadingTrivia).WithTrailingTrivia(SyntaxFactory.Space); 104var allColonTrivia = colonToken.LeadingTrivia.AddRange(colonToken.TrailingTrivia);
src\Analyzers\CSharp\CodeFixes\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementCodeFixProvider.cs (1)
132=> token.WithLeadingTrivia(token.LeadingTrivia.Insert(0, trivia));
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\RemoveAsyncModifierHelpers.cs (4)
25=> lambda.WithAsyncKeyword(default).WithPrependedLeadingTrivia(lambda.AsyncKeyword.LeadingTrivia); 28=> lambda.WithAsyncKeyword(default).WithPrependedLeadingTrivia(lambda.AsyncKeyword.LeadingTrivia); 31=> method.WithAsyncKeyword(default).WithPrependedLeadingTrivia(method.AsyncKeyword.LeadingTrivia); 40var asyncLeadingTrivia = modifiers[0].LeadingTrivia;
src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
44var leadingTrivia = recordKeyword.LeadingTrivia;
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (6)
186.Concat(initializer.OpenBraceToken.LeadingTrivia); 609if (token.LeadingTrivia is not [.., (kind: SyntaxKind.WhitespaceTrivia)]) 616for (int i = 0, n = token.LeadingTrivia.Count - 1; i < n; i++) 618var currentTrivia = token.LeadingTrivia[i]; 619var nextTrivia = token.LeadingTrivia[i + 1]; 621var afterNewLine = i == 0 || token.LeadingTrivia[i - 1].IsEndOfLine();
src\Analyzers\CSharp\CodeFixes\UseInterpolatedVerbatimString\CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (1)
57var newStartToken = SyntaxFactory.Token(oldStartToken.LeadingTrivia, SyntaxKind.InterpolatedVerbatimStringStartToken,
src\Analyzers\CSharp\CodeFixes\UseSimpleUsingStatement\UseSimpleUsingStatementCodeFixProvider.cs (3)
146return blockSyntax.CloseBraceToken.LeadingTrivia; 149var openBraceLeadingTrivia = blockSyntax.OpenBraceToken.LeadingTrivia; 185return blockSyntax.CloseBraceToken.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (2)
135return Literal(token.LeadingTrivia, tokenText, token.ValueText, token.TrailingTrivia); 144return Literal(token.LeadingTrivia, tokenText, token.ValueText, token.TrailingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (1)
595var closeBraceTrivia = block.CloseBraceToken.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CastExpressionSyntaxExtensions.cs (2)
17var leadingTrivia = node.OpenParenToken.LeadingTrivia 21.Concat(node.CloseParenToken.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\TypeDeclarationSyntaxExtensions.cs (5)
102var leadingTrivia = prependNewLineIfMissing ? token.LeadingTrivia.Insert(0, SyntaxFactory.ElasticCarriageReturnLineFeed) : token.LeadingTrivia; 126var leadingTrivia = closeBrace.LeadingTrivia; 139openBrace.TrailingTrivia.Concat(closeBrace.LeadingTrivia.Take(index + 1))); 141closeBrace.LeadingTrivia.Skip(index + 1));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (1)
50syntaxToken.LeadingTrivia,
Microsoft.CodeAnalysis.CSharp.Features (81)
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (1)
242var toggledToken = Token(currentKeyword.LeadingTrivia, toggledKeywordKind, currentKeyword.TrailingTrivia);
CodeRefactorings\EnableNullable\EnableNullableCodeRefactoringProvider.cs (1)
171var existingTriviaList = firstToken.LeadingTrivia;
CodeRefactorings\SyncNamespace\CSharpChangeNamespaceService.cs (2)
462openingBuilder.AddRange(namespaceDeclaration.OpenBraceToken.LeadingTrivia); 465closingBuilder.AddRange(namespaceDeclaration.CloseBraceToken.LeadingTrivia);
ConvertAnonymousType\CSharpConvertAnonymousTypeToTupleCodeRefactoringProvider.cs (1)
34OpenParenToken.WithLeadingTrivia(anonCreation.NewKeyword.LeadingTrivia).WithTrailingTrivia(anonCreation.OpenBraceToken.TrailingTrivia),
ConvertBetweenRegularAndVerbatimString\ConvertBetweenRegularAndVerbatimInterpolatedStringCodeRefactoringProvider.cs (2)
69leading: startToken.LeadingTrivia, 81leading: textToken.LeadingTrivia,
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.cs (2)
40elseClause.ElseKeyword.LeadingTrivia.Any(t => t.IsSingleOrMultiLineComment())) 48return elseClause.ElseKeyword.LeadingTrivia;
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.Rewriting.cs (1)
131statements.Add(BreakStatement().WithLeadingTrivia(block.CloseBraceToken.LeadingTrivia));
ConvertLinq\ConvertForEachToLinqQuery\AbstractConverter.cs (2)
89.WithCommentsFrom(ifStatement.IfKeyword.LeadingTrivia, ifStatement.IfKeyword.TrailingTrivia), 104forEachStatement.ForEachKeyword.LeadingTrivia,
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (1)
198: separators[i].LeadingTrivia));
ConvertToRawString\ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs (1)
692token.LeadingTrivia,
ConvertToRawString\ConvertRegularStringToRawStringCodeRefactoringProvider.cs (3)
168newToken = newToken.WithLeadingTrivia(newToken.LeadingTrivia.Add(Whitespace(indentation))); 196token.LeadingTrivia, 243token.LeadingTrivia,
DocumentationComments\CSharpDocumentationCommentSnippetService.cs (7)
79=> member.GetFirstToken().LeadingTrivia.Any(t => t is (kind: SyntaxKind.SingleLineDocumentationCommentTrivia or SyntaxKind.MultiLineDocumentationCommentTrivia)); 85var count = firstToken.LeadingTrivia.Count(t => t.IsDocComment()); 298&& firstTextToken.LeadingTrivia is [(kind: SyntaxKind.DocumentationCommentExteriorTrivia) firstTrivia] 311if (token.LeadingTrivia.Any(SyntaxKind.DocumentationCommentExteriorTrivia)) 350&& firstTextToken.LeadingTrivia.Count == 1 351&& firstTextToken.LeadingTrivia.ElementAt(0).Kind() == SyntaxKind.DocumentationCommentExteriorTrivia 352&& firstTextToken.LeadingTrivia.ElementAt(0).ToString() == ExteriorTriviaText
EmbeddedLanguages\EmbeddedLanguageUtilities.cs (1)
18stringLiteral.LeadingTrivia.AddRange(triviaList));
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (1)
509identifierLeadingTrivia = identifierLeadingTrivia.AddRange(identifier.LeadingTrivia);
ExtractMethod\CSharpMethodExtractor.PostProcessor.cs (1)
212foreach (var trivia in token.LeadingTrivia.Concat(token.TrailingTrivia))
ExtractMethod\Extensions.cs (2)
221foreach (var trivia in token.LeadingTrivia) 243if (token2.LeadingTrivia.Any(t => !t.IsElastic()))
Highlighting\KeywordHighlighters\IfStatementHighlighter.cs (1)
81second.LeadingTrivia.AsString().All(c => c == ' ');
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (1)
213return block.CloseBraceToken.LeadingTrivia.Any(HasCommentTrivia)
MetadataAsSource\FormattingRule.cs (1)
56var triviaList = token1.TrailingTrivia.Concat(token2.LeadingTrivia);
Organizing\Organizers\ModifiersOrganizer.cs (1)
22var leadingTrivia = initialList.First().LeadingTrivia;
QuickInfo\CSharpSyntacticQuickInfoProvider.cs (2)
102var searchListAbove = openBrace.LeadingTrivia.Reverse(); 110var searchListBelow = nextToken.LeadingTrivia;
Snippets\AbstractCSharpTypeSnippetProvider.cs (1)
84var triviaSpan = typeDeclaration.CloseBraceToken.LeadingTrivia.Span;
Snippets\CSharpSnippetHelpers.cs (1)
23var triviaSpan = block.CloseBraceToken.LeadingTrivia.Span;
SplitStringLiteral\SimpleStringSplitter.cs (1)
51_token.LeadingTrivia,
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_ProgramMain.cs (1)
67var lastPragma = root.GetFirstToken().LeadingTrivia.LastOrDefault(t => t.Kind() is SyntaxKind.PragmaWarningDirectiveTrivia);
src\Analyzers\CSharp\Analyzers\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
105if (nextToken.LeadingTrivia.Any(static t => t.Kind() is
src\Analyzers\CSharp\Analyzers\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementDiagnosticAnalyzer.cs (1)
86if (nextToken.LeadingTrivia.Any(static t => t.Kind() is
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (1)
128endOfLineTrivia = secondBrace.LeadingTrivia.Last(t => t.IsKind(SyntaxKind.EndOfLineTrivia));
src\Analyzers\CSharp\Analyzers\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementDiagnosticAnalyzer.cs (1)
88if (thisOrBaseKeyword.LeadingTrivia.Any(t => !t.IsWhitespaceOrEndOfLine() && !t.IsSingleOrMultiLineComment()))
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (1)
122=> ContainsEndOfLine(previous.TrailingTrivia) || ContainsEndOfLine(next.LeadingTrivia);
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (4)
305var leadingTrivia = token.LeadingTrivia; 329.WithAppendedTrailingTrivia(namespaceDeclaration.OpenBraceToken.LeadingTrivia); 347.WithAppendedTrailingTrivia(namespaceDeclaration.CloseBraceToken.LeadingTrivia) 384var nameSyntax = fileScopedNamespace.Name.WithAppendedTrailingTrivia(fileScopedNamespace.SemicolonToken.LeadingTrivia)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
61switchExpression, switchStatement.SwitchKeyword.LeadingTrivia, declaratorToRemoveType, nodeToGenerate, generateDeclaration);
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (3)
270: recordKeyword.WithLeadingTrivia(typeDeclaration.Keyword.LeadingTrivia); 599: p.Modifiers.First().LeadingTrivia); 737return token.LeadingTrivia;
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (1)
432var newLeadingTrivia = firstToken.LeadingTrivia.InsertRange(0, fileHeader);
src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
90secondBrace.LeadingTrivia.SkipWhile(t => t != lastEndOfLineTrivia).Skip(1));
src\Analyzers\CSharp\CodeFixes\NewLines\ConstructorInitializerPlacement\ConstructorInitializerPlacementCodeFixProvider.cs (4)
77replacementMap[colonToken] = colonToken.WithLeadingTrivia(colonToken.LeadingTrivia.AddRange(colonToken.TrailingTrivia).AddRange(thisBaseKeyword.LeadingTrivia)) 97replacementMap[colonToken] = colonToken.WithLeadingTrivia(thisBaseKeyword.LeadingTrivia).WithTrailingTrivia(SyntaxFactory.Space); 104var allColonTrivia = colonToken.LeadingTrivia.AddRange(colonToken.TrailingTrivia);
src\Analyzers\CSharp\CodeFixes\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementCodeFixProvider.cs (1)
132=> token.WithLeadingTrivia(token.LeadingTrivia.Insert(0, trivia));
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\RemoveAsyncModifierHelpers.cs (4)
25=> lambda.WithAsyncKeyword(default).WithPrependedLeadingTrivia(lambda.AsyncKeyword.LeadingTrivia); 28=> lambda.WithAsyncKeyword(default).WithPrependedLeadingTrivia(lambda.AsyncKeyword.LeadingTrivia); 31=> method.WithAsyncKeyword(default).WithPrependedLeadingTrivia(method.AsyncKeyword.LeadingTrivia); 40var asyncLeadingTrivia = modifiers[0].LeadingTrivia;
src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
44var leadingTrivia = recordKeyword.LeadingTrivia;
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (6)
186.Concat(initializer.OpenBraceToken.LeadingTrivia); 609if (token.LeadingTrivia is not [.., (kind: SyntaxKind.WhitespaceTrivia)]) 616for (int i = 0, n = token.LeadingTrivia.Count - 1; i < n; i++) 618var currentTrivia = token.LeadingTrivia[i]; 619var nextTrivia = token.LeadingTrivia[i + 1]; 621var afterNewLine = i == 0 || token.LeadingTrivia[i - 1].IsEndOfLine();
src\Analyzers\CSharp\CodeFixes\UseInterpolatedVerbatimString\CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (1)
57var newStartToken = SyntaxFactory.Token(oldStartToken.LeadingTrivia, SyntaxKind.InterpolatedVerbatimStringStartToken,
src\Analyzers\CSharp\CodeFixes\UseSimpleUsingStatement\UseSimpleUsingStatementCodeFixProvider.cs (3)
146return blockSyntax.CloseBraceToken.LeadingTrivia; 149var openBraceLeadingTrivia = blockSyntax.OpenBraceToken.LeadingTrivia; 185return blockSyntax.CloseBraceToken.LeadingTrivia;
Structure\CSharpStructureHelpers.cs (2)
45var nextLeadingTrivia = compressEmptyLines ? lastToken.GetNextToken(includeZeroWidth: true, includeSkipped: true).LeadingTrivia : default; 244var firstComment = startToken.LeadingTrivia.FirstOrNull(t => t.Kind() is SyntaxKind.SingleLineCommentTrivia or SyntaxKind.SingleLineDocumentationCommentTrivia);
Structure\Providers\CompilationUnitStructureProvider.cs (1)
45CSharpStructureHelpers.CollectCommentBlockSpans(compilationUnit.EndOfFileToken.LeadingTrivia, spans);
Structure\Providers\DisabledTextTriviaStructureProvider.cs (1)
32var parentTriviaList = trivia.Token.LeadingTrivia;
Structure\Providers\EnumDeclarationStructureProvider.cs (1)
47var leadingTrivia = enumDeclaration.CloseBraceToken.LeadingTrivia;
Structure\Providers\NamespaceDeclarationStructureProvider.cs (1)
56namespaceDeclaration.CloseBraceToken.LeadingTrivia, spans);
Structure\Providers\TypeDeclarationStructureProvider.cs (1)
55var leadingTrivia = typeDeclaration.CloseBraceToken.LeadingTrivia;
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (2)
DocumentationComments\DocumentationCommentCompilerTests.cs (2)
3226var existingLeadingTrivia = token.LeadingTrivia; 3227var newLeadingTrivia = SyntaxFactory.ParseToken("/** " + (_count++) + " */1)").LeadingTrivia;
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (151)
LexicalAndXml\LexicalTests.cs (111)
113var trivia = token.LeadingTrivia.ToArray(); 132var trivia = token.LeadingTrivia.ToArray(); 151var trivia = token.LeadingTrivia.ToArray(); 171var trivia = token.LeadingTrivia.Single(); 457Assert.Empty(token.LeadingTrivia); 484Assert.Empty(token.LeadingTrivia); 518Assert.Empty(token.LeadingTrivia); 601var trivia = token.LeadingTrivia.ToArray(); 3825t => t.LeadingTrivia.Any(SyntaxKind.ConflictMarkerTrivia) || 3840Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.WhitespaceTrivia); 3850var trivia = token.LeadingTrivia.Single(); 3868Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.WhitespaceTrivia); 3876var trivia = token.LeadingTrivia.Single(); 3899Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.WhitespaceTrivia); 3922Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.WhitespaceTrivia); 3940Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.WhitespaceTrivia); 3950Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.ConflictMarkerTrivia); 3956var trivia = token.LeadingTrivia.Single(); 3968Assert.Equal(3, token.LeadingTrivia.Count); 3969trivia = token.LeadingTrivia[0]; 3978trivia = token.LeadingTrivia[1]; 3983trivia = token.LeadingTrivia[2]; 3991Assert.Equal(3, token.LeadingTrivia.Count); 3993trivia = token.LeadingTrivia[0]; 4002trivia = token.LeadingTrivia[1]; 4006trivia = token.LeadingTrivia[2]; 4013Assert.Equal(4, token.LeadingTrivia.Count); 4014var trivia1 = token.LeadingTrivia[0]; 4023var trivia2 = token.LeadingTrivia[1]; 4028var trivia3 = token.LeadingTrivia[2]; 4033var trivia4 = token.LeadingTrivia[3]; 4046Assert.Equal(3, token.LeadingTrivia.Count); 4047trivia1 = token.LeadingTrivia[0]; 4056trivia2 = token.LeadingTrivia[1]; 4061trivia3 = token.LeadingTrivia[2]; 4079Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.WhitespaceTrivia); 4089Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.ConflictMarkerTrivia); 4095var trivia = token.LeadingTrivia.Single(); 4102Assert.Equal(3, token.LeadingTrivia.Count); 4103trivia = token.LeadingTrivia[0]; 4107trivia = token.LeadingTrivia[1]; 4112trivia = token.LeadingTrivia[2]; 4120Assert.Equal(3, token.LeadingTrivia.Count); 4122trivia = token.LeadingTrivia[0]; 4126trivia = token.LeadingTrivia[1]; 4130trivia = token.LeadingTrivia[2]; 4137Assert.Equal(4, token.LeadingTrivia.Count); 4138var trivia1 = token.LeadingTrivia[0]; 4142var trivia2 = token.LeadingTrivia[1]; 4147var trivia3 = token.LeadingTrivia[2]; 4152var trivia4 = token.LeadingTrivia[3]; 4171Assert.Equal(4, token.LeadingTrivia.Count); 4173var trivia = token.LeadingTrivia[0]; 4179trivia = token.LeadingTrivia[1]; 4182trivia = token.LeadingTrivia[2]; 4191trivia = token.LeadingTrivia[3]; 4211Assert.Equal(4, token.LeadingTrivia.Count); 4213var trivia = token.LeadingTrivia[0]; 4219trivia = token.LeadingTrivia[1]; 4222trivia = token.LeadingTrivia[2]; 4231trivia = token.LeadingTrivia[3]; 4245Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.WhitespaceTrivia); 4255Assert.True(token.LeadingTrivia.Single().Kind() == SyntaxKind.ConflictMarkerTrivia); 4261var trivia = token.LeadingTrivia.Single(); 4275Assert.Equal(3, token.LeadingTrivia.Count); 4276trivia = token.LeadingTrivia[0]; 4284trivia = token.LeadingTrivia[1]; 4287trivia = token.LeadingTrivia[2]; 4297Assert.Equal(3, token.LeadingTrivia.Count); 4299trivia = token.LeadingTrivia[0]; 4307trivia = token.LeadingTrivia[1]; 4310trivia = token.LeadingTrivia[2]; 4320Assert.Equal(4, token.LeadingTrivia.Count); 4321var trivia1 = token.LeadingTrivia[0]; 4329var trivia2 = token.LeadingTrivia[1]; 4332var trivia3 = token.LeadingTrivia[2]; 4335var trivia4 = token.LeadingTrivia[3]; 4349Assert.Equal(3, token.LeadingTrivia.Count); 4350trivia1 = token.LeadingTrivia[0]; 4358trivia2 = token.LeadingTrivia[1]; 4361trivia3 = token.LeadingTrivia[2]; 4380Assert.Equal(5, token.LeadingTrivia.Count); 4382var trivia = token.LeadingTrivia[0]; 4388trivia = token.LeadingTrivia[1]; 4391trivia = token.LeadingTrivia[2]; 4397trivia = token.LeadingTrivia[3]; 4400trivia = token.LeadingTrivia[4]; 4419Assert.Equal(7, token.LeadingTrivia.Count); 4421var trivia = token.LeadingTrivia[0]; 4427trivia = token.LeadingTrivia[1]; 4430trivia = token.LeadingTrivia[2]; 4437trivia = token.LeadingTrivia[3]; 4443trivia = token.LeadingTrivia[4]; 4446trivia = token.LeadingTrivia[5]; 4453trivia = token.LeadingTrivia[6]; 4475Assert.Equal(7, token.LeadingTrivia.Count); 4477var trivia = token.LeadingTrivia[0]; 4483trivia = token.LeadingTrivia[1]; 4486trivia = token.LeadingTrivia[2]; 4493trivia = token.LeadingTrivia[3]; 4499trivia = token.LeadingTrivia[4]; 4502trivia = token.LeadingTrivia[5]; 4511trivia = token.LeadingTrivia[6]; 4533Assert.Equal(7, token.LeadingTrivia.Count); 4535var trivia = token.LeadingTrivia[0]; 4541trivia = token.LeadingTrivia[1]; 4544trivia = token.LeadingTrivia[2]; 4553trivia = token.LeadingTrivia[3]; 4559trivia = token.LeadingTrivia[4]; 4562trivia = token.LeadingTrivia[5]; 4569trivia = token.LeadingTrivia[6];
LexicalAndXml\PreprocessorTests.cs (10)
2105var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2127var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2215var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2236var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2257var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2278var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2299var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2320var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2341var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single(); 2362var regionText = regionDirective.EndOfDirectiveToken.LeadingTrivia.Single();
LexicalAndXml\SyntaxTokenParserTests.cs (11)
277Assert.Empty(result.Token.LeadingTrivia); 282Assert.Empty(result.Token.LeadingTrivia); 296AssertTrivia(result.Token.LeadingTrivia, 303Assert.Empty(intermediateResult.Token.LeadingTrivia); 308Assert.Empty(intermediateResult.Token.LeadingTrivia); 329AssertTrivia(result.Token.LeadingTrivia, 337Assert.Empty(intermediateResult.Token.LeadingTrivia); 342Assert.Empty(intermediateResult.Token.LeadingTrivia); 359Assert.Empty(result.Token.LeadingTrivia); 373Assert.Empty(result.Token.LeadingTrivia); 396Assert.Empty(result.Token.LeadingTrivia);
LexicalAndXml\XmlDocCommentTests.cs (6)
80var leading = tree.GetCompilationUnitRoot().EndOfFileToken.LeadingTrivia; 100var leading = tree.GetCompilationUnitRoot().EndOfFileToken.LeadingTrivia; 117var leading = tree.GetCompilationUnitRoot().EndOfFileToken.LeadingTrivia; 132var leading = tree.GetCompilationUnitRoot().EndOfFileToken.LeadingTrivia; 170var leading = tree.GetCompilationUnitRoot().EndOfFileToken.LeadingTrivia; 2543var trivias = classKeyword.LeadingTrivia;
ParentChecker.cs (1)
25foreach (var trivia in token.LeadingTrivia)
Parsing\ParsingErrorRecoveryTests.cs (1)
7921Assert.Equal(numTokens, eofToken.LeadingTrivia.Count); // Confirm that we built a list.
Parsing\ScriptParsingTests.cs (1)
9740var skippedText = endOfDirective.LeadingTrivia.Single();
Parsing\SyntaxExtensions.cs (2)
19return node.GetFirstToken(includeSkipped: true).LeadingTrivia; 46return token.LeadingTrivia;
Syntax\StructuredTriviaTests.cs (1)
71Assert.Equal(" <goo> </goo> ", ident.LeadingTrivia[0].ToFullString());
Syntax\SyntaxNodeTests.cs (7)
3614Assert.NotEqual(emptyToken.LeadingTrivia[0], emptyToken.TrailingTrivia[0]); 3617Assert.NotEqual(emptyToken.LeadingTrivia, emptyToken.TrailingTrivia); 3753Assert.Equal(1, idToken.LeadingTrivia.Count); 3754Assert.Equal(0, idToken.LeadingTrivia.Span.Length); // zero-width elastic trivia 3762Assert.Equal(0, idToken.LeadingTrivia.Count); 3769Assert.Equal(1, idToken.LeadingTrivia.Count); 3770Assert.Equal(1, idToken.LeadingTrivia.Span.Length);
Microsoft.CodeAnalysis.CSharp.Workspaces (54)
Classification\Worker.cs (1)
152ClassifyTriviaList(token.LeadingTrivia);
Classification\Worker_DocumentationComments.cs (3)
38ClassifyXmlTrivia(documentationComment.EndOfComment.LeadingTrivia); 131ClassifyXmlTrivia(token.LeadingTrivia); 144ClassifyXmlTrivia(token.LeadingTrivia);
Classification\Worker_Preprocesser.cs (1)
93foreach (var trivia in node.EndOfDirectiveToken.LeadingTrivia)
Rename\CSharpRenameRewriterLanguageService.cs (7)
615? newToken.CopyAnnotationsTo(SyntaxFactory.VerbatimIdentifier(newToken.LeadingTrivia, currentNewIdentifier, valueText, newToken.TrailingTrivia)) 616: newToken.CopyAnnotationsTo(SyntaxFactory.Identifier(newToken.LeadingTrivia, SyntaxKind.IdentifierToken, currentNewIdentifier, valueText, newToken.TrailingTrivia)); 642newToken = createNewStringLiteral(newToken.LeadingTrivia, replacedString, replacedString, newToken.TrailingTrivia); 697SyntaxFactory.Token(newToken.LeadingTrivia, SyntaxKind.InterpolatedStringTextToken, text, value, newToken.TrailingTrivia)); 709var newIdentifierToken = SyntaxFactory.Identifier(newToken.LeadingTrivia, _replacementText, newToken.TrailingTrivia); 716var updatedToken = RenameInTrivia(oldToken, oldToken.LeadingTrivia); 719newToken = newToken.WithLeadingTrivia(updatedToken.LeadingTrivia);
Simplification\CSharpSimplificationService.cs (1)
131syntaxToken.LeadingTrivia,
Simplification\CSharpSimplificationService.Expander.cs (4)
602identifier = identifier.CopyAnnotationsTo(VerbatimIdentifier(identifier.LeadingTrivia, name, name, identifier.TrailingTrivia)); 1009return Token(oldToken.LeadingTrivia, SyntaxKind.LessThanToken, "{", "{", oldToken.TrailingTrivia); 1014return Token(oldToken.LeadingTrivia, SyntaxKind.GreaterThanToken, "}", "}", oldToken.TrailingTrivia); 1109.WithLeadingTrivia(thisExpression.GetFirstToken().LeadingTrivia);
Simplification\Reducers\CSharpEscapingReducer.cs (2)
140? originalToken.CopyAnnotationsTo(SyntaxFactory.VerbatimIdentifier(originalToken.LeadingTrivia, unescapedText, originalToken.ValueText, originalToken.TrailingTrivia)) 141: originalToken.CopyAnnotationsTo(SyntaxFactory.Identifier(originalToken.LeadingTrivia, SyntaxKind.IdentifierToken, unescapedText, originalToken.ValueText, originalToken.TrailingTrivia));
Simplification\Simplifiers\NameSimplifier.cs (2)
318((AliasQualifiedNameSyntax)name).Alias.Identifier.LeadingTrivia))); 519identifierToken.LeadingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ArrowExpressionClauseSyntaxExtensions.cs (2)
46if (arrowExpression.ArrowToken.LeadingTrivia.Any(t => t.IsSingleOrMultiLineComment())) 47statement = statement.WithPrependedLeadingTrivia(arrowExpression.ArrowToken.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (5)
38block.CloseBraceToken.LeadingTrivia.Where(t => !t.IsWhitespaceOrEndOfLine())); 54var closeBraceLeadingDirectives = block.CloseBraceToken.LeadingTrivia.Where(IsAnyCodeDirective).ToImmutableArray(); 87var triviaIndex = parentToken.LeadingTrivia.IndexOf(parentTrivia); 88if (triviaIndex + 1 < parentToken.LeadingTrivia.Count) 90var nextTrivia = parentToken.LeadingTrivia[triviaIndex + 1];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberAccessExpressionSyntaxExtensions.cs (1)
30.AddRange(memberAccess.OperatorToken.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (4)
75return token.LeadingTrivia; 82return token.LeadingTrivia; 85return prevToken.TrailingTrivia.Concat(token.LeadingTrivia); 523ContainsInterleavedDirective(textSpan, token.LeadingTrivia, cancellationToken) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.SingleLineRewriter.cs (2)
30else if (token.LeadingTrivia.Count > 0) 66token.LeadingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (1)
230.WithLeadingTrivia(token.LeadingTrivia.FilterComments(addElasticMarker: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (1)
193trivia = eof.LeadingTrivia.Last();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.cs (2)
19Analyze(token.LeadingTrivia, ref result); 87Analyze(token2.LeadingTrivia, ref result);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.cs (1)
332foreach (var xmlTrivia in token.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaRewriter.cs (1)
196leadingTrivia = token.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
254var triviaList = currentToken.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
290ProcessTriviaList(list, child.AsToken().LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (2)
135return Literal(token.LeadingTrivia, tokenText, token.ValueText, token.TrailingTrivia); 144return Literal(token.LeadingTrivia, tokenText, token.ValueText, token.TrailingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (1)
595var closeBraceTrivia = block.CloseBraceToken.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CastExpressionSyntaxExtensions.cs (2)
17var leadingTrivia = node.OpenParenToken.LeadingTrivia 21.Concat(node.CloseParenToken.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\TypeDeclarationSyntaxExtensions.cs (5)
102var leadingTrivia = prependNewLineIfMissing ? token.LeadingTrivia.Insert(0, SyntaxFactory.ElasticCarriageReturnLineFeed) : token.LeadingTrivia; 126var leadingTrivia = closeBrace.LeadingTrivia; 139openBrace.TrailingTrivia.Concat(closeBrace.LeadingTrivia.Take(index + 1))); 141closeBrace.LeadingTrivia.Skip(index + 1));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (1)
50syntaxToken.LeadingTrivia,
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (1)
Formatting\FormattingTriviaTests.cs (1)
1787.Where(tr => tr.IsKind(SyntaxKind.EndOfDirectiveToken)), (o, r) => o.WithTrailingTrivia(o.LeadingTrivia.Add(SyntaxFactory.ElasticEndOfLine(newLine)))
Microsoft.CodeAnalysis.Features (24)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaHelpers.cs (6)
45var spanChange = newStartToken.LeadingTrivia.FullSpan.Length - startToken.LeadingTrivia.FullSpan.Length; 111var trivia = startToken.LeadingTrivia.ToImmutableArray(); 167trivia = [.. endToken.LeadingTrivia]; 228var newStartToken = startToken.WithLeadingTrivia(previousOfStart.TrailingTrivia.Concat(startToken.LeadingTrivia)); 236newEndToken = newEndToken.WithTrailingTrivia(endToken.TrailingTrivia.Concat(nextOfEnd.LeadingTrivia));
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (2)
107? token.LeadingTrivia 207var trivia = _suppressionTargetInfo.StartToken.LeadingTrivia.ElementAt(indexOfPragma);
CodeRefactorings\MoveType\AbstractMoveTypeService.MoveTypeEditor.cs (1)
213if (endOfFileToken.LeadingTrivia.IsEmpty() &&
EmbeddedLanguages\Classification\AbstractEmbeddedLanguageClassificationService.cs (1)
115ProcessTriviaList(token.LeadingTrivia);
ExtractMethod\AbstractSyntaxTriviaService.cs (1)
129foreach (var trivia in token1.TrailingTrivia.Concat(token2.LeadingTrivia))
ExtractMethod\AbstractSyntaxTriviaService.Result.cs (1)
278return tokenPair.PreviousToken.TrailingTrivia.Concat(trailingTrivia).Concat(leadingTrivia).Concat(tokenPair.NextToken.LeadingTrivia);
ExtractMethod\MethodExtractor.VariableSymbol.cs (2)
271if (ContainsNoisyTrivia(identifier.LeadingTrivia)) 289if (ContainsNoisyTrivia(token.LeadingTrivia))
SpellCheck\AbstractSpellCheckSpanService.cs (1)
89ProcessTriviaList(token.LeadingTrivia, cancellationToken);
src\Analyzers\Core\Analyzers\FileHeaders\AbstractFileHeaderHelper.cs (3)
36var firstNonWhitespaceTrivia = IndexOfFirstNonWhitespaceTrivia(firstToken.LeadingTrivia); 49for (var i = firstNonWhitespaceTrivia; i < firstToken.LeadingTrivia.Count; i++) 51var trivia = firstToken.LeadingTrivia[i];
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
94foreach (var trivia in nextToken.LeadingTrivia)
src\Analyzers\Core\Analyzers\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesDiagnosticAnalyzer.cs (1)
88var leadingTrivia = token.LeadingTrivia;
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
702foreach (var trivia in firstToken.LeadingTrivia)
src\Analyzers\Core\CodeFixes\UseObjectInitializer\AbstractUseObjectInitializerCodeFixProvider.cs (2)
103if (currentToken.LeadingTrivia is [.., var whitespace1] && 107var leadingTrivia = currentToken.LeadingTrivia.Replace(
Structure\Syntax\BlockSpanCollector.cs (1)
78GetOutliningSpans(token.LeadingTrivia, spans);
Microsoft.CodeAnalysis.Test.Utilities (1)
Syntax\XmlHelpers.cs (1)
196if (token.LeadingTrivia.Any())
Microsoft.CodeAnalysis.VisualBasic (20)
Syntax\SyntaxFactory.vb (3)
924Return Token(rewrittenToken.LeadingTrivia, SyntaxKind.LessThanToken, rewrittenToken.TrailingTrivia, rewrittenToken.ValueText) 928Return Token(rewrittenToken.LeadingTrivia, SyntaxKind.GreaterThanToken, rewrittenToken.TrailingTrivia, rewrittenToken.ValueText) 1033For Each leadingTrivia In endOfFileToken.LeadingTrivia
Syntax\SyntaxNodePartials.vb (2)
33For Each tr In token.LeadingTrivia 57For Each tr In token.LeadingTrivia.Reverse()
Syntax\SyntaxNodeRemover.vb (7)
126Me._residualTrivia.Add(result.LeadingTrivia) 230Me.AddResidualTrivia(token.LeadingTrivia) 234(HasEndOfLine(token.LeadingTrivia) OrElse HasEndOfLine(token.TrailingTrivia) OrElse HasEndOfLine(node.GetLeadingTrivia())) Then 270Me.AddResidualTrivia(token.LeadingTrivia) 273(HasEndOfLine(node.GetTrailingTrivia()) OrElse HasEndOfLine(token.LeadingTrivia) OrElse HasEndOfLine(token.TrailingTrivia)) Then 343Dim index = parentToken.LeadingTrivia.IndexOf(trivia) 345(parentToken.LeadingTrivia, index),
Syntax\SyntaxNormalizer.vb (1)
136token.LeadingTrivia,
Syntax\VisualBasicSyntaxNode.vb (3)
166Return GetFirstToken(includeZeroWidth:=True).LeadingTrivia 345For Each tr In child.AsToken.LeadingTrivia 371For Each tr In token.LeadingTrivia.Reverse()
Syntax\VisualBasicSyntaxRewriter.vb (3)
46Dim leading = Me.VisitList(token.LeadingTrivia) 48If leading <> token.LeadingTrivia OrElse trailing <> token.TrailingTrivia Then 49If leading <> token.LeadingTrivia Then
Syntax\VisualBasicSyntaxWalker.vb (1)
64For Each tr In token.LeadingTrivia
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (16)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SingleLineRewriter.vb (3)
23ElseIf token.LeadingTrivia.Count > 0 Then 51token.LeadingTrivia, 56token.LeadingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxNodeExtensions.vb (1)
383Return ContainsInterleavedDirective(textSpan, token.LeadingTrivia, cancellationToken) OrElse
src\Workspaces\VisualBasic\Portable\Formatting\DefaultOperationProvider.vb (2)
61Dim combinedTrivia = (previousToken.TrailingTrivia, currentToken.LeadingTrivia) 178Return previousToken.TrailingTrivia.Any(SyntaxKind.EndOfLineTrivia) OrElse nextToken.LeadingTrivia.Any(SyntaxKind.EndOfLineTrivia)
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.vb (2)
11Analyze(token.LeadingTrivia, result) 30Analyze(token2.LeadingTrivia, result)
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.vb (1)
289For Each xmlTrivia In token.LeadingTrivia
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.ComplexTrivia.vb (1)
63Dim list As TriviaList = New TriviaList(commonToken1.TrailingTrivia, commonToken2.LeadingTrivia)
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.ModifiedComplexTrivia.vb (1)
75Dim list = New TriviaList(commonToken1.TrailingTrivia, commonToken2.LeadingTrivia)
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.TriviaRewriter.vb (1)
139Dim leadingTrivia = token.LeadingTrivia
src\Workspaces\VisualBasic\Portable\Formatting\Rules\AdjustSpaceFormattingRule.vb (1)
363Return ContainsLineBreak(previousToken.LeadingTrivia) OrElse ContainsLineBreak(previousToken.GetPreviousToken(includeZeroWidth:=True).TrailingTrivia)
src\Workspaces\VisualBasic\Portable\Formatting\Rules\BaseFormattingRule.vb (1)
60For Each trivia In nextToken.LeadingTrivia.Reverse()
src\Workspaces\VisualBasic\Portable\Formatting\Rules\ElasticTriviaFormattingRule.vb (1)
341Dim list = token1.TrailingTrivia.Concat(token2.LeadingTrivia)
src\Workspaces\VisualBasic\Portable\Formatting\Rules\NodeBasedFormattingRule.vb (1)
297If xmlToken.LeadingTrivia.Any(Function(t) t.Kind = SyntaxKind.EndOfLineTrivia) Then
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (5)
src\Analyzers\VisualBasic\CodeFixes\RemoveAsyncModifier\RemoveAsyncModifierHelpers.vb (1)
17Dim asyncLeadingTrivia = modifiers(0).LeadingTrivia
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTokenExtensions.vb (2)
88If Not token.LeadingTrivia.Span.Contains(originalToken.Span) Then 89Return CheckTrivia(token.LeadingTrivia, position, checkForSecondEol, allowsImplicitLineContinuation)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\MemberAccessExpressionSyntaxExtensions.vb (1)
31AddRange(memberAccess.OperatorToken.LeadingTrivia).
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Utilities\VisualBasicSimplificationHelpers.vb (1)
29SyntaxFactory.BracketedIdentifier(identifierToken.LeadingTrivia, identifierToken.ValueText, identifierToken.TrailingTrivia) _
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (1)
AutomaticCompletion\AutomaticLineEnderCommandHandler.vb (1)
105If nonMissingToken.TrailingTrivia.Concat(nextToken.LeadingTrivia).Any(AddressOf HasSkippedText) Then
Microsoft.CodeAnalysis.VisualBasic.Features (23)
CodeFixes\IncorrectExitContinue\IncorrectExitContinueCodeFixProvider.vb (2)
200.WithLeadingTrivia(exitStatement.BlockKeyword.LeadingTrivia) _ 219.WithLeadingTrivia(continueStatement.BlockKeyword.LeadingTrivia) _
CodeFixes\Suppression\VisualBasicSuppressionCodeFixProvider.vb (2)
248Dim enabledKeyword = SyntaxFactory.Token(disabledKeyword.LeadingTrivia, SyntaxKind.EnableKeyword, disabledKeyword.TrailingTrivia) 257Dim disabledKeyword = SyntaxFactory.Token(enabledKeyword.LeadingTrivia, SyntaxKind.DisableKeyword, enabledKeyword.TrailingTrivia)
ConvertForEachToFor\VisualBasicConvertForEachToForCodeRefactoringProvider.vb (1)
85.WithLeadingTrivia(controlVariable.GetFirstToken().LeadingTrivia) _
DocumentationComments\VisualBasicDocumentationCommentSnippetService.vb (6)
75Return member.GetFirstToken().LeadingTrivia.Any(SyntaxKind.DocumentationCommentTrivia) 102Dim count = firstToken.LeadingTrivia.Sum(Function(t) If(t.Kind = SyntaxKind.DocumentationCommentTrivia, 1, 0)) 176firstTextToken.LeadingTrivia.Count = 1 AndAlso 177firstTextToken.LeadingTrivia.ElementAt(0).Kind = SyntaxKind.DocumentationCommentExteriorTrivia AndAlso 178firstTextToken.LeadingTrivia.ElementAt(0).ToString() = "'''" AndAlso 189If token.LeadingTrivia.Any(SyntaxKind.DocumentationCommentExteriorTrivia) Then
ExtractMethod\Extensions.vb (1)
416identifier = identifier.WithLeadingTrivia(declarationStatement.GetLeadingTrivia.AddRange(identifier.LeadingTrivia))
ExtractMethod\VisualBasicMethodExtractor.PostProcessor.vb (1)
166For Each trivia In token.LeadingTrivia.Concat(token.TrailingTrivia)
ExtractMethod\VisualBasicMethodExtractor.TriviaResult.vb (5)
122token1.TrailingTrivia.Concat(list).Concat(ReplaceElasticToEndOfLine(token2.LeadingTrivia))) 126Return RemoveElasticAfterColon(token1.TrailingTrivia.Concat(list).Concat(token2.LeadingTrivia)) 137Return list.Concat(token2.LeadingTrivia) 140Return RemoveElasticAfterColon(token1.TrailingTrivia.Concat(list).Concat(token2.LeadingTrivia)) 143Return list.Concat(token2.LeadingTrivia)
MetadataAsSource\VisualBasicMetadataAsSourceService.vb (1)
115Dim triviaList = token1.TrailingTrivia.Concat(token2.LeadingTrivia)
SignatureHelp\AbstractIntrinsicOperatorSignatureHelpProvider.vb (1)
90For Each leadingTrivia In nextToken.LeadingTrivia
src\Analyzers\VisualBasic\CodeFixes\RemoveAsyncModifier\RemoveAsyncModifierHelpers.vb (1)
17Dim asyncLeadingTrivia = modifiers(0).LeadingTrivia
Structure\Providers\CompilationUnitStructureProvider.vb (1)
34CollectCommentsRegions(compilationUnit.EndOfFileToken.LeadingTrivia, spans)
Structure\VisualBasicStructureHelpers.vb (1)
101Dim firstComment = startToken.LeadingTrivia.FirstOrNull(Function(t) t.Kind = SyntaxKind.CommentTrivia)
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (65)
Scanner\ScannerTests.vb (32)
713Assert.Equal(SyntaxKind.CommentTrivia, tk.LeadingTrivia(0).Kind) 718Assert.Equal(SyntaxKind.WhitespaceTrivia, tk.LeadingTrivia(0).Kind) 720Assert.Equal(" ", tk.LeadingTrivia(0).ToString()) 726Assert.Equal(SyntaxKind.WhitespaceTrivia, tk.LeadingTrivia(0).Kind) 727Assert.Equal(SyntaxKind.CommentTrivia, tk.LeadingTrivia(1).Kind) 728Assert.Equal(" ", tk.LeadingTrivia(0).ToString()) 729Assert.Equal("' ", tk.LeadingTrivia(1).ToString()) 816Assert.Equal(3, tk.LeadingTrivia.Count) 817Assert.Equal(SyntaxKind.WhitespaceTrivia, tk.LeadingTrivia(0).Kind) 818Assert.Equal(SyntaxKind.LineContinuationTrivia, tk.LeadingTrivia(1).Kind) 819Assert.Equal(SyntaxKind.CommentTrivia, tk.LeadingTrivia(2).Kind) 825Assert.Equal(3, tk.LeadingTrivia.Count) 826Assert.Equal(SyntaxKind.WhitespaceTrivia, tk.LeadingTrivia(0).Kind) 827Assert.Equal(SyntaxKind.LineContinuationTrivia, tk.LeadingTrivia(1).Kind) 828Assert.Equal(SyntaxKind.CommentTrivia, tk.LeadingTrivia(2).Kind) 834Assert.Equal(3, tk.LeadingTrivia.Count) 835Assert.Equal(SyntaxKind.WhitespaceTrivia, tk.LeadingTrivia(0).Kind) 836Assert.False(tk.LeadingTrivia(0).ContainsDiagnostics) 837Assert.Equal(SyntaxKind.LineContinuationTrivia, tk.LeadingTrivia(1).Kind) 838Assert.False(tk.LeadingTrivia(1).ContainsDiagnostics) 839Assert.Equal(SyntaxKind.CommentTrivia, tk.LeadingTrivia(2).Kind) 840Assert.True(tk.LeadingTrivia(2).ContainsDiagnostics) 847Assert.Equal(3, tk.LeadingTrivia.Count) 848Assert.Equal(SyntaxKind.WhitespaceTrivia, tk.LeadingTrivia(0).Kind) 849Assert.Equal(SyntaxKind.LineContinuationTrivia, tk.LeadingTrivia(1).Kind) 850Assert.Equal(SyntaxKind.CommentTrivia, tk.LeadingTrivia(2).Kind) 856Assert.Equal(5, tk.LeadingTrivia.Count) 857Assert.Equal(SyntaxKind.WhitespaceTrivia, tk.LeadingTrivia(0).Kind) 858Assert.Equal(SyntaxKind.LineContinuationTrivia, tk.LeadingTrivia(1).Kind) 859Assert.Equal(SyntaxKind.WhitespaceTrivia, tk.LeadingTrivia(2).Kind) 860Assert.Equal(SyntaxKind.CommentTrivia, tk.LeadingTrivia(3).Kind) 861Assert.Equal(SyntaxKind.EndOfLineTrivia, tk.LeadingTrivia(4).Kind)
Syntax\SyntaxFactsTest.vb (1)
1046For Each trivia In currentToken.LeadingTrivia
Syntax\SyntaxTokenFactoryTests.vb (16)
21Assert.Equal(keywordToken.LeadingTrivia.Count, 1) 26Assert.Equal(keywordToken.LeadingTrivia.Count, 1) 31Assert.Equal(keywordToken.LeadingTrivia.Count, 1) 35Assert.Equal(keywordToken.LeadingTrivia.Count, 1) 39Assert.Equal(keywordToken.LeadingTrivia.Count, 1) 45Assert.Equal(keywordToken.LeadingTrivia.Count, 1) 50Assert.Equal(keywordToken.LeadingTrivia.Count, 1) 55Assert.Equal(keywordToken.LeadingTrivia.Count, 1) 65Assert.Equal(punctuationToken.LeadingTrivia.Count, 1) 70Assert.Equal(punctuationToken.LeadingTrivia.Count, 1) 75Assert.Equal(punctuationToken.LeadingTrivia.Count, 1) 79Assert.Equal(punctuationToken.LeadingTrivia.Count, 1) 83Assert.Equal(punctuationToken.LeadingTrivia.Count, 1) 89Assert.Equal(punctuationToken.LeadingTrivia.Count, 1) 94Assert.Equal(punctuationToken.LeadingTrivia.Count, 1) 99Assert.Equal(punctuationToken.LeadingTrivia.Count, 1)
TestSyntaxNodes.vb (16)
356Dim precedingTrivia = tree.LeadingTrivia(), followingTrivia = tree.TrailingTrivia() 679Dim precTrivia = tok.LeadingTrivia() 695precTrivia = tok.LeadingTrivia() 726precTrivia = tok.LeadingTrivia() 773Assert.Equal(1, keyword.LeadingTrivia().Count) 785Assert.Equal(2, keyword.LeadingTrivia().Count) 786Assert.Equal(" ", keyword.LeadingTrivia()(0).ToString) 794Assert.Equal(0, keyword.LeadingTrivia().Count) 805Assert.Equal(2, keyword.LeadingTrivia().Count) 808Assert.Equal("'goo", keyword.LeadingTrivia()(1).ToString) 1131Return SyntaxFactory.IntegerLiteralToken(token.LeadingTrivia, value.ToString(), LiteralBase.Decimal, node.TypeSuffix, value, token.TrailingTrivia()) 1137Return SyntaxFactory.Identifier(token.LeadingTrivia(), node.Text.ToUpperInvariant(), node.IsBracketed, node.IdentifierText.ToUpperInvariant(), 1145Return SyntaxFactory.Token(token.LeadingTrivia(), node.Kind, token.TrailingTrivia(), node.Text.ToUpperInvariant()) 1737Assert.Equal(1, tree.GetRoot().FindToken(0).LeadingTrivia.Count) 1803Assert.Equal(" <goo> </ > ", ident.LeadingTrivia()(0).ToFullString) 1804Assert.Equal("<goo> </ >", ident.LeadingTrivia()(0).ToString())
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (6)
ParserTestUtilities.vb (6)
415For Each tr In node.AsToken.LeadingTrivia 785For Each tr In node.AsToken.LeadingTrivia 790For Each tr In node.AsToken.LeadingTrivia 806For Each tr In node.AsToken.LeadingTrivia 812For Each tr In node.AsToken.LeadingTrivia 827InternalVerifyNoAdjacentTriviaHaveSameKind(node, node.AsToken.LeadingTrivia)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (62)
CaseCorrection\VisualBasicCaseCorrectionService.Rewriter.vb (6)
157Return SyntaxFactory.Identifier(newToken.LeadingTrivia, "New", newToken.TrailingTrivia) 227Return SyntaxFactory.BracketedIdentifier(token.LeadingTrivia, correctedName, token.TrailingTrivia) 229Return SyntaxFactory.Identifier(token.LeadingTrivia, correctedName, token.TrailingTrivia) 258Return SyntaxFactory.Token(token.LeadingTrivia, token.Kind, token.TrailingTrivia, expectedText) 279Return SyntaxFactory.ParseToken(expectedText).WithLeadingTrivia(token.LeadingTrivia).WithTrailingTrivia(token.TrailingTrivia) 294Return SyntaxFactory.ParseToken(expectedText).WithLeadingTrivia(token.LeadingTrivia).WithTrailingTrivia(token.TrailingTrivia)
Classification\Worker.DocumentationCommentClassifier.vb (2)
105ClassifyXmlTrivia(token.LeadingTrivia, classificationType) 118ClassifyXmlTrivia(token.LeadingTrivia, whitespaceClassificationType:=ClassificationTypeNames.XmlDocCommentText)
Classification\Worker.vb (1)
105ClassifyTrivia(token.LeadingTrivia)
CodeCleanup\Providers\AbstractTokensCodeCleanupProvider.vb (4)
81Dim leading = If(token.LeadingTrivia.Count > 0, token.LeadingTrivia, SyntaxTriviaList.Create(SyntaxFactory.ElasticMarker)) 92Dim leading = If(token.LeadingTrivia.Count > 0, token.LeadingTrivia, SyntaxTriviaList.Create(SyntaxFactory.ElasticMarker))
CodeCleanup\Providers\AddMissingTokensCodeCleanupProvider.vb (1)
560Not nextToken.LeadingTrivia.Any(SyntaxKind.EndOfLineTrivia)
CodeCleanup\Providers\NormalizeModifiersOrOperatorsCodeCleanupProvider.vb (1)
287Return SyntaxFactory.Token(newToken.LeadingTrivia, newToken.Kind, newToken.TrailingTrivia, expectedText)
CodeCleanup\Providers\ReduceTokensCodeCleanupProvider.vb (2)
296Dim leading = If(token.LeadingTrivia.Count > 0, token.LeadingTrivia, SyntaxTriviaList.Create(SyntaxFactory.ElasticMarker))
CodeCleanup\Providers\RemoveUnnecessaryLineContinuationCodeCleanupProvider.vb (1)
342Return GetTriviaList(token, _leading, token.LeadingTrivia)
CodeGeneration\VisualBasicSyntaxGenerator.vb (12)
2249SyntaxFactory.Token(sb.EndBlockStatement.BlockKeyword.LeadingTrivia, SyntaxKind.FunctionKeyword, sb.EndBlockStatement.BlockKeyword.TrailingTrivia) 2257SyntaxFactory.Token(ss.DeclarationKeyword.LeadingTrivia, SyntaxKind.FunctionKeyword, ss.DeclarationKeyword.TrailingTrivia), 2270SyntaxFactory.Token(ds.DeclarationKeyword.LeadingTrivia, SyntaxKind.FunctionKeyword, ds.DeclarationKeyword.TrailingTrivia), 2284SyntaxFactory.Token(ml.EndSubOrFunctionStatement.BlockKeyword.LeadingTrivia, SyntaxKind.FunctionKeyword, ml.EndSubOrFunctionStatement.BlockKeyword.TrailingTrivia) 2298SyntaxFactory.Token(lh.DeclarationKeyword.LeadingTrivia, SyntaxKind.FunctionKeyword, lh.DeclarationKeyword.TrailingTrivia), 2308SyntaxFactory.Token(ds.DeclarationKeyword.LeadingTrivia, SyntaxKind.FunctionKeyword, ds.DeclarationKeyword.TrailingTrivia), 2334SyntaxFactory.Token(mb.EndBlockStatement.BlockKeyword.LeadingTrivia, SyntaxKind.SubKeyword, mb.EndBlockStatement.BlockKeyword.TrailingTrivia) 2342SyntaxFactory.Token(ms.DeclarationKeyword.LeadingTrivia, SyntaxKind.SubKeyword, ms.DeclarationKeyword.TrailingTrivia), 2355SyntaxFactory.Token(ds.DeclarationKeyword.LeadingTrivia, SyntaxKind.SubKeyword, ds.DeclarationKeyword.TrailingTrivia), 2369SyntaxFactory.Token(ml.EndSubOrFunctionStatement.BlockKeyword.LeadingTrivia, SyntaxKind.SubKeyword, ml.EndSubOrFunctionStatement.BlockKeyword.TrailingTrivia) 2383SyntaxFactory.Token(lh.DeclarationKeyword.LeadingTrivia, SyntaxKind.SubKeyword, lh.DeclarationKeyword.TrailingTrivia), 2393SyntaxFactory.Token(ds.DeclarationKeyword.LeadingTrivia, SyntaxKind.SubKeyword, ds.DeclarationKeyword.TrailingTrivia),
Formatting\DefaultOperationProvider.vb (2)
61Dim combinedTrivia = (previousToken.TrailingTrivia, currentToken.LeadingTrivia) 178Return previousToken.TrailingTrivia.Any(SyntaxKind.EndOfLineTrivia) OrElse nextToken.LeadingTrivia.Any(SyntaxKind.EndOfLineTrivia)
Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.vb (2)
11Analyze(token.LeadingTrivia, result) 30Analyze(token2.LeadingTrivia, result)
Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.vb (1)
289For Each xmlTrivia In token.LeadingTrivia
Formatting\Engine\Trivia\TriviaDataFactory.ComplexTrivia.vb (1)
63Dim list As TriviaList = New TriviaList(commonToken1.TrailingTrivia, commonToken2.LeadingTrivia)
Formatting\Engine\Trivia\TriviaDataFactory.ModifiedComplexTrivia.vb (1)
75Dim list = New TriviaList(commonToken1.TrailingTrivia, commonToken2.LeadingTrivia)
Formatting\Engine\Trivia\TriviaDataFactory.TriviaRewriter.vb (1)
139Dim leadingTrivia = token.LeadingTrivia
Formatting\Rules\AdjustSpaceFormattingRule.vb (1)
363Return ContainsLineBreak(previousToken.LeadingTrivia) OrElse ContainsLineBreak(previousToken.GetPreviousToken(includeZeroWidth:=True).TrailingTrivia)
Formatting\Rules\BaseFormattingRule.vb (1)
60For Each trivia In nextToken.LeadingTrivia.Reverse()
Formatting\Rules\ElasticTriviaFormattingRule.vb (1)
341Dim list = token1.TrailingTrivia.Concat(token2.LeadingTrivia)
Formatting\Rules\NodeBasedFormattingRule.vb (1)
297If xmlToken.LeadingTrivia.Any(Function(t) t.Kind = SyntaxKind.EndOfLineTrivia) Then
Rename\VisualBasicRenameRewriterLanguageService.vb (6)
558newToken = newToken.CopyAnnotationsTo(SyntaxFactory.BracketedIdentifier(newToken.LeadingTrivia, valueText, newToken.TrailingTrivia)) 561newToken.LeadingTrivia, 594newToken = createNewStringLiteral(newToken.LeadingTrivia, replacedString, replacedString, newToken.TrailingTrivia) 644Dim newIdentifierToken = SyntaxFactory.XmlNameToken(newToken.LeadingTrivia, _replacementText, SyntaxFacts.GetKeywordKind(_replacementText), newToken.TrailingTrivia) 650Dim updatedToken = RenameInTrivia(oldToken, oldToken.LeadingTrivia) 652newToken = newToken.WithLeadingTrivia(updatedToken.LeadingTrivia)
Simplification\Reducers\VisualBasicEscapingReducer.vb (2)
213originalToken.CopyAnnotationsTo(SyntaxFactory.BracketedIdentifier(originalToken.LeadingTrivia, originalToken.ValueText, originalToken.TrailingTrivia)), 214originalToken.CopyAnnotationsTo(SyntaxFactory.Identifier(originalToken.LeadingTrivia, originalToken.ValueText, originalToken.TrailingTrivia)))
Simplification\Simplifiers\NameSimplifier.vb (1)
384identifierToken.LeadingTrivia,
Simplification\VisualBasicSimplificationService.Expander.vb (3)
255Dim newMemberAccess = SyntaxFactory.SimpleMemberAccessExpression(SyntaxFactory.ParseExpression(containingType), oldMemberAccess.OperatorToken, oldMemberAccess.Name).WithLeadingTrivia(thisExpression.GetFirstToken().LeadingTrivia) 585identifier.CopyAnnotationsTo(SyntaxFactory.BracketedIdentifier(identifier.LeadingTrivia, newName, identifier.TrailingTrivia)), 586identifier.CopyAnnotationsTo(SyntaxFactory.Identifier(identifier.LeadingTrivia, newName, identifier.TrailingTrivia)))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SingleLineRewriter.vb (3)
23ElseIf token.LeadingTrivia.Count > 0 Then 51token.LeadingTrivia, 56token.LeadingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxNodeExtensions.vb (1)
383Return ContainsInterleavedDirective(textSpan, token.LeadingTrivia, cancellationToken) OrElse
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\ContextQuery\SyntaxTokenExtensions.vb (2)
88If Not token.LeadingTrivia.Span.Contains(originalToken.Span) Then 89Return CheckTrivia(token.LeadingTrivia, position, checkForSecondEol, allowsImplicitLineContinuation)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\MemberAccessExpressionSyntaxExtensions.vb (1)
31AddRange(memberAccess.OperatorToken.LeadingTrivia).
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Utilities\VisualBasicSimplificationHelpers.vb (1)
29SyntaxFactory.BracketedIdentifier(identifierToken.LeadingTrivia, identifierToken.ValueText, identifierToken.TrailingTrivia) _
Microsoft.CodeAnalysis.Workspaces (40)
Classification\SyntaxClassification\AbstractSyntaxClassificationService.Worker.cs (1)
152ClassifyStructuredTrivia(syntax.LeadingTrivia);
Editing\SyntaxGenerator.cs (3)
1072return token.WithLeadingTrivia(RemoveCommentLines(token.LeadingTrivia)) 1501replacement.WithLeadingTrivia(original.LeadingTrivia.AddRange(replacement.LeadingTrivia))
FindSymbols\FindReferences\FindReferenceCache.cs (1)
178foreach (var trivia in token.LeadingTrivia)
FindSymbols\Shared\AbstractSyntaxIndex.cs (1)
170foreach (var trivia in token.LeadingTrivia)
ObsoleteSymbol\AbstractObsoleteSymbolService.cs (1)
85ExtractStructureFromTrivia(stack, token.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (5)
626var skippedToken = findSkippedToken(token.LeadingTrivia, position); 667var skippedToken = findSkippedToken(token.LeadingTrivia, position); 874foreach (var trivia in token.LeadingTrivia) 948triviaList = triviaList.AddRange(token.LeadingTrivia); 971triviaList = triviaList.InsertRange(0, current.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (2)
102if (!token.LeadingTrivia.Any() && !token.TrailingTrivia.Any()) 134return token.WithLeadingTrivia(trivia.Concat(token.LeadingTrivia));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (2)
147var triviaList = compilationUnit.EndOfFileToken.LeadingTrivia; 183trivia = endOfFileToken.LeadingTrivia.Last();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractTriviaDataFactory.AbstractComplexTrivia.cs (1)
132var list = new TriviaList(Token1.TrailingTrivia, Token2.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TokenStream.cs (2)
392Debug.Assert((token1.IndexInStream >= 0 && token2.IndexInStream >= 0) || token1.Token.Equals(token2.Token.GetPreviousToken(includeZeroWidth: true)) || token2.Token.LeadingTrivia.Span.Contains(token1.Token.Span)); 417Debug.Assert((token1.IndexInStream >= 0 && token2.IndexInStream >= 0) || token1.Token.Equals(token2.Token.GetPreviousToken(includeZeroWidth: true)) || token2.Token.LeadingTrivia.Span.Contains(token1.Token.Span));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
255AddRange(triviaList, this.Token2.LeadingTrivia); 293var list = new TriviaList(this.Token1.TrailingTrivia, this.Token2.LeadingTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Helpers\RemoveUnnecessaryImports\RemoveUnnecessaryImportsHelpers.cs (1)
17var trimmedLeadingTrivia = token.LeadingTrivia.SkipWhile(syntaxFacts.IsEndOfLineTrivia).ToList();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\FileBannerFacts\AbstractFileBannerFacts.cs (1)
176var leadingTrivia = firstToken.LeadingTrivia;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\AbstractDocumentationCommentService.cs (1)
169if (token.LeadingTrivia.Count > 0 || HasLeadingWhitespace(tokenText))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (5)
97if (!IsOnSingleLine(syntaxFacts, token.LeadingTrivia, leading) || 233if (SpansPreprocessorDirective(syntaxFacts, token.LeadingTrivia) || 338var leadingTrivia = openParenToken.LeadingTrivia 344.Concat(closeParenToken.LeadingTrivia) 369if (nextToken.LeadingTrivia.Count == 0 &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (3)
214foreach (var trivia in token.LeadingTrivia) 231foreach (var trivia in token.LeadingTrivia) 355return previousToken.TrailingTrivia.HasAnyWhitespaceElasticTrivia() || currentToken.LeadingTrivia.HasAnyWhitespaceElasticTrivia();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (3)
529var leading = isComma(previousToken) ? previousToken.LeadingTrivia : attributeToRemove.GetLeadingTrivia(); 541var tokenWithInsertedTrivia = tokenToInsertTrivia.WithLeadingTrivia(trivia.Concat(tokenToInsertTrivia.LeadingTrivia)); 563.WithLeadingTrivia(modifier.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (2)
527return operand.WithPrependedLeadingTrivia(operatorToken.LeadingTrivia) 571return subPattern.WithPrependedLeadingTrivia(opToken.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Indentation\IIndentationService.cs (1)
51newToken = newToken.WithLeadingTrivia(newToken.LeadingTrivia.Add(syntaxGenerator.EndOfLine(options.FormattingOptions.NewLine)));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AddImportHelpers.cs (2)
40firstToken.LeadingTrivia.Where(t => IsDocCommentOrElastic(syntaxFacts, t))); 46firstToken.LeadingTrivia.Where(t => !IsDocCommentOrElastic(syntaxFacts, t)));
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (1)
VisualStudioMSBuildWorkspaceTests.cs (1)
341var newDecl = decl.WithIdentifier(CS.SyntaxFactory.Identifier("Pogrom").WithLeadingTrivia(decl.Identifier.LeadingTrivia).WithTrailingTrivia(decl.Identifier.TrailingTrivia));
Microsoft.CodeAnalysis.Workspaces.UnitTests (5)
BatchFixAllProviderTests.cs (1)
127var newToken = SyntaxFactory.Literal(token.LeadingTrivia, replacement.ToString(), replacement, token.TrailingTrivia);
CodeCleanup\CodeCleanupTests.cs (2)
353root = root.ReplaceToken(previousToken, CSharp.SyntaxFactory.Identifier(previousToken.LeadingTrivia, previousToken.ValueText, previousToken.TrailingTrivia)); 354root = root.ReplaceToken(nextToken, CSharp.SyntaxFactory.Token(nextToken.LeadingTrivia, CSharp.CSharpExtensions.Kind(nextToken), nextToken.TrailingTrivia));
SyntaxNodeTests.cs (2)
61return Task.FromResult<SyntaxNode>(classDecl.WithIdentifier(SyntaxFactory.Identifier(id.LeadingTrivia, id.ToString() + "1", id.TrailingTrivia))); 67return Task.FromResult<SyntaxNode>(varDecl.WithIdentifier(SyntaxFactory.Identifier(id.LeadingTrivia, id.ToString() + "1", id.TrailingTrivia)));
Microsoft.VisualStudio.LanguageServices.CSharp (4)
CodeModel\CSharpCodeModelService.cs (3)
1246var commentList = CollectComments(firstToken.LeadingTrivia.ToArray()); 3292var triviaList = nextToken.LeadingTrivia; 3352var trivia = firstToken.LeadingTrivia;
CodeModel\MethodXml\MethodXmlBuilder.cs (1)
33GenerateComments(block.CloseBraceToken.LeadingTrivia);
Microsoft.VisualStudio.LanguageServices.VisualBasic (7)
CodeModel\VisualBasicCodeModelService.vb (7)
2229Dim triviaList = firstToken.LeadingTrivia 2230Dim commentList = CollectComments(firstToken.LeadingTrivia.ToArray()) 2423classKeyword:=SyntaxFactory.Token(moduleBlock.ModuleStatement.ModuleKeyword.LeadingTrivia, SyntaxKind.ClassKeyword, moduleBlock.ModuleStatement.ModuleKeyword.TrailingTrivia), 2431blockKeyword:=SyntaxFactory.Token(moduleBlock.EndModuleStatement.BlockKeyword.LeadingTrivia, SyntaxKind.ClassKeyword, moduleBlock.EndModuleStatement.BlockKeyword.TrailingTrivia))) 2443moduleKeyword:=SyntaxFactory.Token(classBlock.ClassStatement.ClassKeyword.LeadingTrivia, SyntaxKind.ModuleKeyword, classBlock.ClassStatement.ClassKeyword.TrailingTrivia), 2451blockKeyword:=SyntaxFactory.Token(classBlock.EndClassStatement.BlockKeyword.LeadingTrivia, SyntaxKind.ModuleKeyword, classBlock.EndClassStatement.BlockKeyword.TrailingTrivia))) 3817Dim trivia = firstToken.LeadingTrivia