14 instantiations of SyntaxTrivia
Microsoft.CodeAnalysis (10)
Syntax\SyntaxNode.cs (1)
1534var trivia = new SyntaxTrivia();
Syntax\SyntaxTrivia.cs (3)
311return new SyntaxTrivia( 340return new SyntaxTrivia( 388return new SyntaxTrivia(
Syntax\SyntaxTriviaList.cs (3)
133return new SyntaxTrivia(Token, Node.GetSlot(index), Position + Node.GetSlotOffset(index), Index + index); 138return new SyntaxTrivia(Token, Node, Position, Index); 513current = new SyntaxTrivia(Token, GetGreenNodeAt(offset + i), position, Index + i);
Syntax\SyntaxTriviaList.Enumerator.cs (2)
118return new SyntaxTrivia(_token, _current, _position, _baseIndex + _index); 130current = new SyntaxTrivia(_token, _current, _position, _baseIndex + _index);
Syntax\SyntaxTriviaList.Reversed.cs (1)
126return new SyntaxTrivia(_token, _current, _position, _baseIndex + _index);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (1)
Syntax\SyntaxNodeTests.cs (1)
1841SyntaxTrivia trivia = new SyntaxTrivia();
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (1)
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.vb (1)
38Dim previousTrivia As New SyntaxTrivia
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (1)
TestSyntaxNodes.vb (1)
2205Dim trivia As New SyntaxTrivia()
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.vb (1)
38Dim previousTrivia As New SyntaxTrivia
2289 references to SyntaxTrivia
Microsoft.AspNetCore.App.Analyzers (6)
RouteEmbeddedLanguage\Infrastructure\RouteStringSyntaxDetector.cs (5)
187foreach (var trivia in list) 201SyntaxTrivia trivia, 224public static bool IsRegularComment(this SyntaxTrivia trivia) 227public static bool IsSingleOrMultiLineComment(this SyntaxTrivia trivia) 230public static bool IsShebangDirective(this SyntaxTrivia trivia)
RouteEmbeddedLanguage\Infrastructure\SyntaxNodeExtensions.cs (1)
130foreach (var trivia in Enumerable.Reverse(triviaList))
Microsoft.CodeAnalysis (236)
Diagnostic\SourceLocation.cs (1)
42public SourceLocation(in SyntaxTrivia trivia)
DiagnosticAnalyzer\AnalyzerDriver.cs (2)
371protected AnalyzerDriver(ImmutableArray<DiagnosticAnalyzer> analyzers, AnalyzerManager analyzerManager, SeverityFilter severityFilter, Func<SyntaxTrivia, bool> isComment) 2416internal AnalyzerDriver(ImmutableArray<DiagnosticAnalyzer> analyzers, Func<SyntaxNode, TLanguageKindEnum> getKind, AnalyzerManager analyzerManager, SeverityFilter severityFilter, Func<SyntaxTrivia, bool> isComment)
SourceGeneration\GeneratedCodeUtilities.cs (6)
49SyntaxTree tree, Func<SyntaxTrivia, bool> isComment, CancellationToken cancellationToken) 55internal static bool IsGeneratedCode(string? filePath, SyntaxNode root, Func<SyntaxTrivia, bool> isComment) 88private static bool BeginsWithAutoGeneratedComment(SyntaxNode root, Func<SyntaxTrivia, bool> isComment) 94foreach (var trivia in leadingTrivia) 118SyntaxTree tree, Func<SyntaxTrivia, bool> isComment, CancellationToken cancellationToken) 125foreach (var trivia in leadingTrivia)
Syntax\GreenNode.cs (1)
888public abstract SyntaxNode GetStructure(SyntaxTrivia parentTrivia);
Syntax\ICompilationUnitSyntax.cs (1)
23/// <see cref="SyntaxTrivia"/> (whitespace, comments, directives) attached to it.
Syntax\InternalSyntax\SyntaxList.cs (1)
160public sealed override SyntaxNode GetStructure(SyntaxTrivia parentTrivia)
Syntax\IStructuredTriviaSyntax.cs (1)
18SyntaxTrivia ParentTrivia { get; }
Syntax\SeparatedSyntaxList.cs (1)
453foreach (var tr in separator.TrailingTrivia)
Syntax\SyntaxDiffer.cs (4)
442foreach (var tr in node1.GetLeadingTrivia()) 448foreach (var tr in node1.GetTrailingTrivia()) 454foreach (var tr in node2.GetLeadingTrivia()) 463foreach (var tr in node2.GetTrailingTrivia())
Syntax\SyntaxList.cs (8)
29protected internal override SyntaxNode ReplaceCore<TNode>(IEnumerable<TNode>? nodes = null, Func<TNode, TNode, SyntaxNode>? computeReplacementNode = null, IEnumerable<SyntaxToken>? tokens = null, Func<SyntaxToken, SyntaxToken, SyntaxToken>? computeReplacementToken = null, IEnumerable<SyntaxTrivia>? trivia = null, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? computeReplacementTrivia = null) 54protected internal override SyntaxNode ReplaceTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia) 59protected internal override SyntaxNode InsertTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia, bool insertBefore)
Syntax\SyntaxNavigator.cs (29)
31private static readonly Func<SyntaxTrivia, bool>?[] s_stepIntoFunctions = new Func<SyntaxTrivia, bool>?[] 43private static Func<SyntaxTrivia, bool>? GetStepIntoFunction( 82internal SyntaxToken GetPreviousToken(in SyntaxToken current, Func<SyntaxToken, bool> predicate, Func<SyntaxTrivia, bool>? stepInto) 87internal SyntaxToken GetNextToken(in SyntaxToken current, Func<SyntaxToken, bool> predicate, Func<SyntaxTrivia, bool>? stepInto) 95internal SyntaxToken GetFirstToken(SyntaxNode current, Func<SyntaxToken, bool>? predicate, Func<SyntaxTrivia, bool>? stepInto) 141internal SyntaxToken GetLastToken(SyntaxNode current, Func<SyntaxToken, bool> predicate, Func<SyntaxTrivia, bool>? stepInto) 188Func<SyntaxTrivia, bool> stepInto) 191foreach (var trivia in triviaList) 209Func<SyntaxTrivia, bool> stepInto) 213foreach (var trivia in list.Reverse()) 226SyntaxTrivia trivia, 228Func<SyntaxTrivia, bool>? stepInto, 246Func<SyntaxTrivia, bool>? stepInto) 280Func<SyntaxTrivia, bool>? stepInto) 312SyntaxTrivia current, 314Func<SyntaxTrivia, bool>? stepInto) 344SyntaxTrivia current, 346Func<SyntaxTrivia, bool>? stepInto) 376SyntaxTrivia current, 379Func<SyntaxTrivia, bool>? stepInto, 382foreach (var trivia in list) 405SyntaxTrivia current, 408Func<SyntaxTrivia, bool>? stepInto, 411foreach (var trivia in list.Reverse()) 433Func<SyntaxTrivia, bool>? stepInto) 483Func<SyntaxTrivia, bool>? stepInto) 530internal SyntaxToken GetNextToken(in SyntaxToken current, Func<SyntaxToken, bool>? predicate, bool searchInsideCurrentTokenTrailingTrivia, Func<SyntaxTrivia, bool>? stepInto) 584Func<SyntaxTrivia, bool>? stepInto)
Syntax\SyntaxNode.cs (36)
730public virtual SyntaxTrivia ParentTrivia 734return default(SyntaxTrivia); 1086public SyntaxTrivia FindTrivia(int position, bool findInsideTrivia = false) 1088return FindTrivia(position, findInsideTrivia ? SyntaxTrivia.Any : null); 1100public SyntaxTrivia FindTrivia(int position, Func<SyntaxTrivia, bool>? stepInto) 1107return default(SyntaxTrivia); 1110internal static SyntaxTrivia FindTriviaByOffset(SyntaxNode node, int textOffset, Func<SyntaxTrivia, bool>? stepInto = null) 1131foreach (var trivia in token.LeadingTrivia) 1150foreach (var trivia in token.TrailingTrivia) 1167return default(SyntaxTrivia); 1175return default(SyntaxTrivia); 1181public IEnumerable<SyntaxTrivia> DescendantTrivia(Func<SyntaxNode, bool>? descendIntoChildren = null, bool descendIntoTrivia = false) 1189public IEnumerable<SyntaxTrivia> DescendantTrivia(TextSpan span, Func<SyntaxNode, bool>? descendIntoChildren = null, bool descendIntoTrivia = false) 1315public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(string annotationKind) 1324public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(params string[] annotationKinds) 1333public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(SyntaxAnnotation annotation) 1443return this.FindToken(position, SyntaxTrivia.Any); 1502private SyntaxToken FindToken(int position, Func<SyntaxTrivia, bool> findInsideTrivia) 1515protected virtual SyntaxToken FindTokenCore(int position, Func<SyntaxTrivia, bool> stepInto) 1520var trivia = GetTriviaFromSyntaxToken(position, token); 1531internal static SyntaxTrivia GetTriviaFromSyntaxToken(int position, in SyntaxToken token) 1534var trivia = new SyntaxTrivia(); 1547internal static SyntaxTrivia GetTriviaThatContainsPosition(in SyntaxTriviaList list, int position) 1549foreach (var trivia in list) 1562return default(SyntaxTrivia); 1570protected virtual SyntaxTrivia FindTriviaCore(int position, bool findInsideTrivia) 1583IEnumerable<SyntaxTrivia>? trivia = null, 1584Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? computeReplacementTrivia = null) 1591protected internal abstract SyntaxNode ReplaceTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia); 1592protected internal abstract SyntaxNode InsertTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia, bool insertBefore);
Syntax\SyntaxNode.Iterators.cs (10)
31private IEnumerable<SyntaxTrivia> DescendantTriviaImpl(TextSpan span, Func<SyntaxNode, bool>? descendIntoChildren = null, bool descendIntoTrivia = false) 138public bool TryGetNext(out SyntaxTrivia value) 234public bool TryGetNext(out SyntaxTrivia value) 329public bool TryGetNext(out SyntaxTrivia value) 507SyntaxTrivia trivia; 532private IEnumerable<SyntaxTrivia> DescendantTriviaOnly(TextSpan span, Func<SyntaxNode, bool>? descendIntoChildren) 549foreach (var trivia in token.LeadingTrivia) 557foreach (var trivia in token.TrailingTrivia) 570private IEnumerable<SyntaxTrivia> DescendantTriviaIntoTrivia(TextSpan span, Func<SyntaxNode, bool>? descendIntoChildren) 606SyntaxTrivia trivia;
Syntax\SyntaxNodeExtensions.cs (24)
36IEnumerable<SyntaxTrivia>? trivia, 37Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? computeReplacementTrivia) 166public static TRoot ReplaceTrivia<TRoot>(this TRoot root, SyntaxTrivia oldTrivia, IEnumerable<SyntaxTrivia> newTrivia) 179public static TRoot InsertTriviaBefore<TRoot>(this TRoot root, SyntaxTrivia trivia, IEnumerable<SyntaxTrivia> newTrivia) 192public static TRoot InsertTriviaAfter<TRoot>(this TRoot root, SyntaxTrivia trivia, IEnumerable<SyntaxTrivia> newTrivia) 236public static TRoot ReplaceTrivia<TRoot>(this TRoot root, IEnumerable<SyntaxTrivia> trivia, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia> computeReplacementTrivia) 249public static TRoot ReplaceTrivia<TRoot>(this TRoot root, SyntaxTrivia trivia, SyntaxTrivia newTrivia) 361IEnumerable<SyntaxTrivia>? trivia) where TSyntax : SyntaxNode 375return node.WithLeadingTrivia((IEnumerable<SyntaxTrivia>?)null); 383params SyntaxTrivia[]? trivia) where TSyntax : SyntaxNode 385return node.WithLeadingTrivia((IEnumerable<SyntaxTrivia>?)trivia); 405IEnumerable<SyntaxTrivia>? trivia) where TSyntax : SyntaxNode 417return node.WithTrailingTrivia((IEnumerable<SyntaxTrivia>?)null); 425params SyntaxTrivia[]? trivia) where TSyntax : SyntaxNode 427return node.WithTrailingTrivia((IEnumerable<SyntaxTrivia>?)trivia);
Syntax\SyntaxNodeOrToken.cs (9)
397public SyntaxNodeOrToken WithLeadingTrivia(IEnumerable<SyntaxTrivia> trivia) 412public SyntaxNodeOrToken WithLeadingTrivia(params SyntaxTrivia[] trivia) 414return WithLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia); 417public SyntaxNodeOrToken WithTrailingTrivia(IEnumerable<SyntaxTrivia> trivia) 432public SyntaxNodeOrToken WithTrailingTrivia(params SyntaxTrivia[] trivia) 434return WithTrailingTrivia((IEnumerable<SyntaxTrivia>)trivia); 856foreach (var trivia in node.AsToken().LeadingTrivia) 871foreach (var trivia in node.DescendantTrivia(node => node.ContainsDirectives, descendIntoTrivia: true)) 877private static void GetDirectivesInTrivia<TDirective>(in SyntaxTrivia trivia, Func<TDirective, bool>? filter, ref List<TDirective>? directives)
Syntax\SyntaxToken.cs (12)
462return this.WithLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia); 468public SyntaxToken WithLeadingTrivia(params SyntaxTrivia[]? trivia) 470return this.WithLeadingTrivia((IEnumerable<SyntaxTrivia>?)trivia); 476public SyntaxToken WithLeadingTrivia(IEnumerable<SyntaxTrivia>? trivia) 488return this.WithTrailingTrivia((IEnumerable<SyntaxTrivia>)trivia); 494public SyntaxToken WithTrailingTrivia(params SyntaxTrivia[]? trivia) 496return this.WithTrailingTrivia((IEnumerable<SyntaxTrivia>?)trivia); 502public SyntaxToken WithTrailingTrivia(IEnumerable<SyntaxTrivia>? trivia) 512public IEnumerable<SyntaxTrivia> GetAllTrivia() 529return SpecializedCollections.EmptyEnumerable<SyntaxTrivia>(); 598internal SyntaxToken GetNextToken(Func<SyntaxToken, bool> predicate, Func<SyntaxTrivia, bool>? stepInto = null) 629internal SyntaxToken GetPreviousToken(Func<SyntaxToken, bool> predicate, Func<SyntaxTrivia, bool>? stepInto = null)
Syntax\SyntaxTree.cs (1)
200public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxTrivia trivia);
Syntax\SyntaxTrivia.cs (27)
22public readonly struct SyntaxTrivia : IEquatable<SyntaxTrivia> 24internal static readonly Func<SyntaxTrivia, bool> Any = t => true; 33Debug.Assert(this.RawKind != 0 || this.Equals(default(SyntaxTrivia))); 249/// Determines whether two <see cref="SyntaxTrivia"/>s are equal. 251public static bool operator ==(SyntaxTrivia left, SyntaxTrivia right) 257/// Determines whether two <see cref="SyntaxTrivia"/>s are unequal. 259public static bool operator !=(SyntaxTrivia left, SyntaxTrivia right) 265/// Determines whether the supplied <see cref="SyntaxTrivia"/> is equal to this 266/// <see cref="SyntaxTrivia"/>. 268public bool Equals(SyntaxTrivia other) 274/// Determines whether the supplied <see cref="SyntaxTrivia"/> is equal to this 275/// <see cref="SyntaxTrivia"/>. 279return obj is SyntaxTrivia trivia && Equals(trivia); 283/// Serves as hash function for <see cref="SyntaxTrivia"/>. 294public SyntaxTrivia WithAdditionalAnnotations(params SyntaxAnnotation[] annotations) 302public SyntaxTrivia WithAdditionalAnnotations(IEnumerable<SyntaxAnnotation> annotations) 317return default(SyntaxTrivia); 323public SyntaxTrivia WithoutAnnotations(params SyntaxAnnotation[] annotations) 331public SyntaxTrivia WithoutAnnotations(IEnumerable<SyntaxAnnotation> annotations) 346return default(SyntaxTrivia); 352public SyntaxTrivia WithoutAnnotations(string annotationKind) 370public SyntaxTrivia CopyAnnotationsTo(SyntaxTrivia trivia) 374return default(SyntaxTrivia); 429public bool IsEquivalentTo(SyntaxTrivia trivia)
Syntax\SyntaxTriviaList.cs (34)
20/// Represents a read-only list of <see cref="SyntaxTrivia"/>. 24public readonly partial struct SyntaxTriviaList : IEquatable<SyntaxTriviaList>, IReadOnlyList<SyntaxTrivia> 44public SyntaxTriviaList(SyntaxTrivia trivia) 56public SyntaxTriviaList(params SyntaxTrivia[] trivias) 65public SyntaxTriviaList(IEnumerable<SyntaxTrivia>? trivias) 70public static SyntaxTriviaList Create(ReadOnlySpan<SyntaxTrivia> trivias) 78private static GreenNode? CreateNodeFromSpan(ReadOnlySpan<SyntaxTrivia> trivias) 111public SyntaxTrivia ElementAt(int index) 123public SyntaxTrivia this[int index] 184public SyntaxTrivia First() 199public SyntaxTrivia Last() 231public int IndexOf(SyntaxTrivia triviaInList) 235var trivia = this[i]; 262public SyntaxTriviaList Add(SyntaxTrivia trivia) 271public SyntaxTriviaList AddRange(IEnumerable<SyntaxTrivia> trivia) 281public SyntaxTriviaList Insert(int index, SyntaxTrivia trivia) 283if (trivia == default(SyntaxTrivia)) 316public SyntaxTriviaList InsertRange(int index, IEnumerable<SyntaxTrivia> trivia) 330var triviaCollection = trivia as ICollection<SyntaxTrivia>; 379public SyntaxTriviaList Remove(SyntaxTrivia triviaInList) 395public SyntaxTriviaList Replace(SyntaxTrivia triviaInList, SyntaxTrivia newTrivia) 397if (newTrivia == default(SyntaxTrivia)) 410public SyntaxTriviaList ReplaceRange(SyntaxTrivia triviaInList, IEnumerable<SyntaxTrivia> newTrivia) 425private SyntaxTrivia[] Nodes => this.ToArray(); 427IEnumerator<SyntaxTrivia> IEnumerable<SyntaxTrivia>.GetEnumerator() 431return SpecializedCollections.EmptyEnumerator<SyntaxTrivia>(); 441return SpecializedCollections.EmptyEnumerator<SyntaxTrivia>(); 490internal void CopyTo(int offset, SyntaxTrivia[] array, int arrayOffset, int count) 503var first = this[offset]; 508var current = first; 529public static SyntaxTriviaList Create(SyntaxTrivia trivia)
Syntax\SyntaxTriviaList.Enumerator.cs (4)
109public SyntaxTrivia Current 122internal bool TryMoveNextAndGetCurrent(out SyntaxTrivia current) 135private class EnumeratorImpl : IEnumerator<SyntaxTrivia> 145public SyntaxTrivia Current => _enumerator.Current;
Syntax\SyntaxTriviaList.Reversed.cs (9)
19public readonly struct Reversed : IEnumerable<SyntaxTrivia>, IEquatable<Reversed> 33IEnumerator<SyntaxTrivia> IEnumerable<SyntaxTrivia>.GetEnumerator() 37return SpecializedCollections.EmptyEnumerator<SyntaxTrivia>(); 48return SpecializedCollections.EmptyEnumerator<SyntaxTrivia>(); 94var last = list.Last(); 117public SyntaxTrivia Current 131private class ReversedEnumeratorImpl : IEnumerator<SyntaxTrivia> 141public SyntaxTrivia Current => _enumerator.Current;
Syntax\SyntaxTriviaListBuilder.cs (12)
13private SyntaxTrivia[] _nodes; 18_nodes = new SyntaxTrivia[size]; 26public static SyntaxTriviaList Create(IEnumerable<SyntaxTrivia>? trivia) 48public SyntaxTrivia this[int index] 61public void AddRange(IEnumerable<SyntaxTrivia>? items) 65foreach (var item in items) 72public SyntaxTriviaListBuilder Add(SyntaxTrivia item) 83public void Add(SyntaxTrivia[] items) 86public void Add(ReadOnlySpan<SyntaxTrivia> items) 91public void Add(SyntaxTrivia[] items, int offset, int length) 94public void Add(ReadOnlySpan<SyntaxTrivia> items, int offset, int length) 123var tmp = new SyntaxTrivia[size];
Syntax\SyntaxWalker.cs (3)
74foreach (var trivia in token.LeadingTrivia) 85foreach (var trivia in token.TrailingTrivia) 98protected virtual void VisitTrivia(SyntaxTrivia trivia)
Microsoft.CodeAnalysis.CodeStyle (205)
src\Analyzers\Core\Analyzers\FileHeaders\AbstractFileHeaderHelper.cs (4)
19protected abstract ReadOnlyMemory<char> GetTextContextOfComment(SyntaxTrivia commentTrivia); 51var trivia = firstToken.LeadingTrivia[i]; 136where T : IReadOnlyList<SyntaxTrivia> 140var currentTrivia = triviaList[index];
src\Analyzers\Core\Analyzers\FileHeaders\FileHeader.cs (1)
85/// start of the first line after any directive trivia (<see cref="SyntaxTrivia.IsDirective"/>) to account for
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
94foreach (var trivia in nextToken.LeadingTrivia)
src\Analyzers\Core\Analyzers\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesDiagnosticAnalyzer.cs (3)
74if (!ContainsMultipleBlankLines(token, out var badTrivia)) 86private bool ContainsMultipleBlankLines(SyntaxToken token, out SyntaxTrivia firstBadTrivia) 133var trivia = triviaList[index];
src\Analyzers\Core\Analyzers\RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (2)
71protected abstract bool IsRegularCommentOrDocComment(SyntaxTrivia trivia); 182foreach (var trivia in node.GetTrailingTrivia())
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (19)
157using var _1 = PooledDictionary<string, List<(SyntaxTrivia pragma, bool isDisable)>>.GetInstance(out var idToPragmasMap); 158using var _2 = ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)>.GetInstance(out var sortedPragmasWithIds); 159using var _3 = PooledDictionary<SyntaxTrivia, bool>.GetInstance(out var pragmasToIsUsedMap); 228PooledDictionary<string, List<(SyntaxTrivia pragma, bool isDisable)>> idToPragmasMap, 229PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap, 230ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)> sortedPragmasWithIds, 241foreach (var trivia in root.DescendantTrivia(node => node.ContainsDirectives)) 510PooledDictionary<string, List<(SyntaxTrivia pragma, bool isDisable)>> idToPragmasMap, 511PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap, 546PooledDictionary<string, List<(SyntaxTrivia pragma, bool isDisable)>> idToPragmasMap, 547PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap) 560SyntaxTrivia? lastEnablePragma = null; 609PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap, 610ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)> sortedPragmasWithIds, 631PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap, 632ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)> sortedPragmasWithIds, 678SyntaxTrivia pragma, 679ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)> sortedPragmasWithIds, 680out SyntaxTrivia togglePragma)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
702foreach (var trivia in firstToken.LeadingTrivia)
src\Analyzers\Core\Analyzers\UseConditionalExpression\UseConditionalExpressionHelpers.cs (1)
70foreach (var trivia in triviaList)
src\Compilers\Core\Portable\SourceGeneration\GeneratedCodeUtilities.cs (6)
49SyntaxTree tree, Func<SyntaxTrivia, bool> isComment, CancellationToken cancellationToken) 55internal static bool IsGeneratedCode(string? filePath, SyntaxNode root, Func<SyntaxTrivia, bool> isComment) 88private static bool BeginsWithAutoGeneratedComment(SyntaxNode root, Func<SyntaxTrivia, bool> isComment) 94foreach (var trivia in leadingTrivia) 118SyntaxTree tree, Func<SyntaxTrivia, bool> isComment, CancellationToken cancellationToken) 125foreach (var trivia in leadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (23)
376IEnumerable<SyntaxTrivia> trivia, 377Func<SyntaxTrivia, SyntaxTrivia, CancellationToken, Task<SyntaxTrivia>> computeReplacementAsync, 393IEnumerable<SyntaxTrivia>? trivia, 394Func<SyntaxTrivia, SyntaxTrivia, CancellationToken, Task<SyntaxTrivia>>? computeReplacementTriviaAsync, 405var triviaReplacements = new Dictionary<SyntaxTrivia, SyntaxTrivia>(); 453var original = (SyntaxTrivia?)retryAnnotations.GetAnnotations(currentTrivia).SingleOrDefault() ?? currentTrivia; 498if (!triviaReplacements.TryGetValue(original, out var replaced)) 547foreach (var trivia in triviaList) 577foreach (var trivia in triviaList.Reverse()) 690params SyntaxTrivia[] trivia) where T : SyntaxNode 697return node.WithPrependedLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia); 714IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode 724params SyntaxTrivia[] trivia) where T : SyntaxNode 731return node.WithAppendedTrailingTrivia((IEnumerable<SyntaxTrivia>)trivia); 748IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode 758IEnumerable<SyntaxTrivia> leadingTrivia, 759IEnumerable<SyntaxTrivia> trailingTrivia) where T : SyntaxNode 874foreach (var trivia in token.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeOrTokenExtensions.cs (4)
53public static SyntaxTrivia[] GetTrivia(params SyntaxNodeOrToken[] nodesOrTokens) 56public static SyntaxNodeOrToken WithAppendedTrailingTrivia(this SyntaxNodeOrToken nodeOrToken, params SyntaxTrivia[] trivia) 57=> WithAppendedTrailingTrivia(nodeOrToken, (IEnumerable<SyntaxTrivia>)trivia); 59public static SyntaxNodeOrToken WithAppendedTrailingTrivia(this SyntaxNodeOrToken nodeOrToken, IEnumerable<SyntaxTrivia> trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (7)
115params SyntaxTrivia[] trivia) 122return token.WithPrependedLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia); 139IEnumerable<SyntaxTrivia> trivia) 149params SyntaxTrivia[] trivia) 151return token.WithAppendedTrailingTrivia((IEnumerable<SyntaxTrivia>)trivia); 156IEnumerable<SyntaxTrivia> trivia) 161public static SyntaxTrivia[] GetTrivia(this IEnumerable<SyntaxToken> tokens)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (3)
148foreach (var trivia in triviaList.Reverse()) 168internal static SyntaxTrivia FindTriviaAndAdjustForEndOfFile( 172var trivia = root.FindTrivia(position, findInsideTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTriviaExtensions.cs (5)
9public static int Width(this SyntaxTrivia trivia) 12public static int FullWidth(this SyntaxTrivia trivia) 15public static bool IsElastic(this SyntaxTrivia trivia) 18public static SyntaxTrivia AsElastic(this SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTriviaListExtensions.cs (4)
11public static SyntaxTrivia? FirstOrNull(this SyntaxTriviaList triviaList, Func<SyntaxTrivia, bool> predicate) 13foreach (var trivia in triviaList) 24public static SyntaxTrivia LastOrDefault(this SyntaxTriviaList triviaList)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
33public static TreeData Create(SyntaxTrivia trivia, int initialColumn)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
16private readonly SyntaxTrivia _trivia; 19public StructuredTrivia(SyntaxTrivia trivia, int initialColumn)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
64foreach (var trivia in list)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (45)
41private delegate LineColumnDelta Formatter<T>(LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<T> changes, CancellationToken cancellationToken); 117protected abstract bool IsWhitespace(SyntaxTrivia trivia); 122protected abstract bool IsEndOfLine(SyntaxTrivia trivia); 127protected abstract bool LineContinuationFollowedByWhitespaceComment(SyntaxTrivia previousTrivia, SyntaxTrivia nextTrivia); 134protected abstract bool IsVisualBasicComment(SyntaxTrivia trivia); 170protected abstract SyntaxTrivia CreateWhitespace(string text); 175protected abstract SyntaxTrivia CreateEndOfLine(); 180protected abstract LineColumnRule GetLineColumnRuleBetween(SyntaxTrivia trivia1, LineColumnDelta existingWhitespaceBetween, bool implicitLineBreak, SyntaxTrivia trivia2, CancellationToken cancellationToken); 185protected abstract LineColumnDelta Format(LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<SyntaxTrivia> changes, CancellationToken cancellationToken); 190protected abstract LineColumnDelta Format(LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<TextChange> changes, CancellationToken cancellationToken); 195protected abstract bool ContainsImplicitLineBreak(SyntaxTrivia trivia); 240using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var triviaList); 260private static void AddRange(ArrayBuilder<SyntaxTrivia> result, SyntaxTriviaList triviaList) 262foreach (var trivia in triviaList) 289var previousWhitespaceTrivia = default(SyntaxTrivia); 290var previousTrivia = default(SyntaxTrivia); 297SyntaxTrivia trivia; 373SyntaxTrivia trivia1, 375SyntaxTrivia trivia2, 397private LineColumnRule GetOverallLineColumnRuleBetween(SyntaxTrivia trivia1, LineColumnDelta existingWhitespaceBetween, bool implicitLineBreak, SyntaxTrivia trivia2, CancellationToken cancellationToken) 464private void GetTokensAtEdgeOfStructureTrivia(SyntaxTrivia trivia1, SyntaxTrivia trivia2, out SyntaxToken token1, out SyntaxToken token2) 544LineColumn lineColumnBeforeTrivia1, SyntaxTrivia trivia1, LineColumn lineColumnAfterTrivia1, LineColumnDelta existingWhitespaceBetween, SyntaxTrivia trivia2, LineColumnRule rule) 566LineColumn lineColumnBeforeTrivia1, LineColumn lineColumnAfterTrivia1, LineColumnDelta existingWhitespaceBetween, SyntaxTrivia trivia2, LineColumnRule rule) 625private void AddExtraLines(int linesBetweenTokens, ArrayBuilder<SyntaxTrivia> changes) 629using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var lineBreaks); 642private int GetInsertionIndex(ArrayBuilder<SyntaxTrivia> changes) 758ArrayBuilder<SyntaxTrivia> changes) 767ArrayBuilder<SyntaxTrivia> changes) 832private TextSpan GetTextSpan(SyntaxTrivia trivia1, SyntaxTrivia trivia2) 847private bool IsWhitespaceOrEndOfLine(SyntaxTrivia trivia) 852SyntaxTrivia previousTrivia, 853SyntaxTrivia trivia1, 855SyntaxTrivia trivia2) 904protected LineColumn GetLineColumn(LineColumn lineColumn, SyntaxTrivia trivia) 911protected LineColumnDelta GetLineColumnDelta(LineColumn lineColumn, SyntaxTrivia trivia) 936protected int GetExistingIndentation(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\TriviaHelpers.cs (1)
19using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var builder);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\TriviaList.cs (2)
14public SyntaxTrivia this[int index] 48public SyntaxTrivia Current => _enumerator.Current;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
32Indenter indenter, SyntaxToken? token, SyntaxTrivia? trivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (2)
107private readonly SyntaxTrivia? TryGetImmediatelyPrecedingVisibleTrivia() 117var trivia = Root.FindTrivia(lastPos.Value);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\FileBannerFacts\AbstractFileBannerFacts.cs (24)
19private readonly Matcher<SyntaxTrivia> _oneOrMoreBlankLines; 24private readonly Matcher<SyntaxTrivia> _bannerMatcher; 29private readonly Matcher<SyntaxTrivia> _fileBannerMatcher; 34Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsWhitespaceTrivia, "\\b")); 35var endOfLine = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsEndOfLineTrivia, "\\n"); 38var shebangComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsShebangDirectiveTrivia, "#!"); 39var singleLineComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsSingleLineCommentTrivia, "//"); 40var multiLineComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsMultiLineCommentTrivia, "/**/"); 41var singleLineDocumentationComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsSingleLineDocCommentTrivia, "///"); 42var multiLineDocumentationComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsMultiLineDocCommentTrivia, "/** */"); 61public abstract SyntaxTrivia CreateTrivia(SyntaxTrivia trivia, string text); 66public ImmutableArray<SyntaxTrivia> GetLeadingBlankLines(SyntaxNode node) 69public ImmutableArray<SyntaxTrivia> GetLeadingBlankLines<TSyntaxNode>(TSyntaxNode node) 83TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) 86var leadingTriviaToKeep = new List<SyntaxTrivia>(node.GetLeadingTrivia()); 96public ImmutableArray<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(TSyntaxNode node) 111TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) 125List<SyntaxTrivia> leadingTriviaToStrip, leadingTriviaToKeep; 140leadingTriviaToStrip = new List<SyntaxTrivia>(leadingTrivia.Take(ppIndex + 1)); 141leadingTriviaToKeep = new List<SyntaxTrivia>(leadingTrivia.Skip(ppIndex + 1)); 145leadingTriviaToKeep = new List<SyntaxTrivia>(leadingTrivia); 166public ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxNode root) 172public ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxToken firstToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\FileBannerFacts\IFileBannerFacts.cs (8)
12SyntaxTrivia CreateTrivia(SyntaxTrivia trivia, string text); 14ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxNode root); 15ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxToken firstToken); 18ImmutableArray<SyntaxTrivia> GetLeadingBlankLines(SyntaxNode node); 22TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode; 24ImmutableArray<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(TSyntaxNode node) where TSyntaxNode : SyntaxNode; 27TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\FileBannerFacts\IFileBannerFactsExtensions.cs (1)
12public static ImmutableArray<SyntaxTrivia> GetTriviaAfterLeadingBlankLines(
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFacts.cs (9)
89SyntaxTrivia ElasticMarker { get; } 90SyntaxTrivia ElasticCarriageReturnLineFeed { get; } 177bool IsRegularComment(SyntaxTrivia trivia); 178bool IsDocumentationComment(SyntaxTrivia trivia); 179bool IsElastic(SyntaxTrivia trivia); 180bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes); 182bool IsPreprocessorDirective(SyntaxTrivia trivia); 287bool IsDocumentationCommentExteriorTrivia(SyntaxTrivia trivia); 490SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (10)
123foreach (var trivia in triviaList) 282public static bool IsRegularOrDocumentationComment(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 389public static bool IsWhitespaceOrEndOfLineTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 684public static bool IsEndOfLineTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 687public static bool IsMultiLineCommentTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 690public static bool IsMultiLineDocCommentTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 693public static bool IsShebangDirectiveTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 696public static bool IsSingleLineCommentTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 699public static bool IsSingleLineDocCommentTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 702public static bool IsWhitespaceTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AnnotationTable.cs (11)
81public SyntaxTrivia WithAdditionalAnnotations(SyntaxTrivia trivia, params TAnnotation[] annotations) 93public SyntaxTrivia WithoutAnnotations(SyntaxTrivia trivia, params TAnnotation[] annotations) 117public IEnumerable<TAnnotation> GetAnnotations(SyntaxTrivia trivia) 129public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxTrivia trivia) where TSpecificAnnotation : TAnnotation 141public bool HasAnnotations(SyntaxTrivia trivia) 153public bool HasAnnotations<TSpecificAnnotation>(SyntaxTrivia trivia) where TSpecificAnnotation : TAnnotation 165public bool HasAnnotation(SyntaxTrivia trivia, TAnnotation annotation) 180public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(SyntaxNode node) 192public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (3)
214foreach (var trivia in token.LeadingTrivia) 231foreach (var trivia in token.LeadingTrivia) 249foreach (var trivia in token.TrailingTrivia)
Microsoft.CodeAnalysis.CodeStyle.Fixes (31)
src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (3)
103var startTrivia = root.FindTrivia(startLine.Start); 104var firstMiddleTrivia = root.FindTrivia(firstMiddleLine.Start); 105var secondMiddleTrivia = root.FindTrivia(secondMiddleLine.Start);
src\Analyzers\Core\CodeFixes\FileHeaders\AbstractFileHeaderCodeFixProvider.cs (5)
53var newLineTrivia = generator.EndOfLine(options.NewLine); 58internal static async Task<SyntaxNode> GetTransformedSyntaxRootAsync(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, Document document, string? fileHeaderTemplate, CancellationToken cancellationToken) 94private static SyntaxNode ReplaceHeader(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, SyntaxNode root, string expectedFileHeader) 119var triviaLine = triviaList[i]; 176private static SyntaxNode AddHeader(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, SyntaxNode root, string expectedFileHeader)
src\Analyzers\Core\CodeFixes\ImplementInterface\AbstractImplementInterfaceService.cs (1)
75using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var trivia);
src\Analyzers\Core\CodeFixes\NewLines\ConsecutiveStatementPlacement\ConsecutiveStatementPlacementCodeFixProvider.cs (1)
50var endOfLineTrivia = generator.EndOfLine(options.NewLine);
src\Analyzers\Core\CodeFixes\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesCodeFixProvider.cs (3)
65using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var builder); 71var trivia = triviaList[currentStart]; 141var trivia = triviaList[index];
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (1)
712var lastDirective = leadingTrivia.LastOrDefault(t => t.IsDirective);
src\Analyzers\Core\CodeFixes\UseObjectInitializer\AbstractUseObjectInitializerCodeFixProvider.cs (3)
55protected abstract SyntaxTrivia Whitespace(string text); 130private SyntaxTrivia IncreaseIndent(SyntaxTrivia whitespaceTrivia, SyntaxFormattingOptions options)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (3)
502Func<SyntaxTrivia, bool> isEndOfLineTrivia, 504out IEnumerable<SyntaxTrivia> triviaOfRemovedNode) 524out IEnumerable<SyntaxTrivia> triviaOfRemovedNode)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (5)
121private static ImmutableArray<SyntaxTrivia> GetDesiredLeadingIndentation( 124using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var triviaList); 130var lastWhitespace = default(SyntaxTrivia); 131foreach (var trivia in node.GetLeadingTrivia().Reverse())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AddImportHelpers.cs (1)
99private static bool IsDocCommentOrElastic(ISyntaxFacts syntaxFacts, SyntaxTrivia t)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs (1)
176private static ImmutableArray<SyntaxTrivia> GetMergedTrivia(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SyntaxGeneratorInternalExtensions\SyntaxGeneratorInternal.cs (4)
23public abstract SyntaxTrivia CarriageReturnLineFeed { get; } 24public abstract SyntaxTrivia ElasticCarriageReturnLineFeed { get; } 26public abstract SyntaxTrivia EndOfLine(string text); 27public abstract SyntaxTrivia SingleLineComment(string text);
Microsoft.CodeAnalysis.CSharp (148)
Binder\BinderFactory.BinderFactoryVisitor.cs (1)
1419SyntaxTrivia containingTrivia = structuredTrivia.ParentTrivia;
Compilation\CSharpCompilation.cs (1)
4756Func<SyntaxTrivia, bool> isComment = trivia => trivia.Kind() == SyntaxKind.SingleLineCommentTrivia || trivia.Kind() == SyntaxKind.MultiLineCommentTrivia;
Compiler\DocumentationCommentCompiler.cs (1)
272foreach (var trivia in implementationPart.GetNonNullSyntaxNode().GetLeadingTrivia())
Compiler\DocumentationCommentCompiler.IncludeElementExpander.cs (1)
623SyntaxTrivia trivia = leadingTrivia.ElementAt(0);
Compiler\UnprocessedDocumentationCommentFinder.cs (1)
91public override void VisitTrivia(SyntaxTrivia trivia)
CSharpExtensions.cs (11)
31/// Determines if <see cref="SyntaxTrivia"/> is of a specified kind. 36public static bool IsKind(this SyntaxTrivia trivia, SyntaxKind kind) 196/// Returns <see cref="SyntaxKind"/> for <see cref="SyntaxTrivia"/> from <see cref="SyntaxTrivia.RawKind"/> property. 198public static SyntaxKind Kind(this SyntaxTrivia trivia) 304public static SyntaxToken ReplaceTrivia(this SyntaxToken token, IEnumerable<SyntaxTrivia> trivia, Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia> computeReplacementTrivia) 317public static SyntaxToken ReplaceTrivia(this SyntaxToken token, SyntaxTrivia oldTrivia, SyntaxTrivia newTrivia)
DocumentationComments\SourceDocumentationCommentUtils.cs (1)
64foreach (var trivia in syntaxNode.GetLeadingTrivia().Reverse())
Syntax\CompilationUnitSyntax.cs (1)
59foreach (var trivia in firstToken.LeadingTrivia)
Syntax\CSharpSyntaxNode.cs (15)
249foreach (var tr in token.LeadingTrivia) 289foreach (var tr in token.LeadingTrivia.Reverse()) 334internal SyntaxToken GetFirstToken(Func<SyntaxToken, bool>? predicate, Func<SyntaxTrivia, bool>? stepInto = null) 383SyntaxTrivia trivia = GetTriviaFromSyntaxToken(position, nonTriviaToken); 426public new SyntaxTrivia FindTrivia(int position, Func<SyntaxTrivia, bool> stepInto) 437public new SyntaxTrivia FindTrivia(int position, bool findInsideTrivia = false) 469IEnumerable<SyntaxTrivia>? trivia = null, 470Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? computeReplacementTrivia = null) 495protected internal override SyntaxNode ReplaceTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia) 500protected internal override SyntaxNode InsertTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia, bool insertBefore)
Syntax\CSharpSyntaxRewriter.cs (6)
117public virtual SyntaxTrivia VisitTrivia(SyntaxTrivia trivia) 289foreach (var item in list) 292var visited = this.VisitListElement(item); 316public virtual SyntaxTrivia VisitListElement(SyntaxTrivia element)
Syntax\CSharpSyntaxTree.cs (1)
831public override IEnumerable<Diagnostic> GetDiagnostics(SyntaxTrivia trivia)
Syntax\CSharpSyntaxWalker.cs (3)
77foreach (var tr in token.LeadingTrivia) 88foreach (var tr in token.TrailingTrivia) 95public virtual void VisitTrivia(SyntaxTrivia trivia)
Syntax\DirectiveTriviaSyntax.cs (2)
73foreach (var tr in token.LeadingTrivia) 104foreach (var tr in token.LeadingTrivia.Reverse())
Syntax\InternalSyntax\CSharpSyntaxNode.cs (3)
252private static readonly ConditionalWeakTable<SyntaxNode, Dictionary<CodeAnalysis.SyntaxTrivia, WeakReference<SyntaxNode>>> s_structuresTable 253= new ConditionalWeakTable<SyntaxNode, Dictionary<CodeAnalysis.SyntaxTrivia, WeakReference<SyntaxNode>>>(); 270public override SyntaxNode GetStructure(Microsoft.CodeAnalysis.SyntaxTrivia trivia)
Syntax\InternalSyntax\SyntaxTrivia.cs (1)
90public static implicit operator CodeAnalysis.SyntaxTrivia(SyntaxTrivia trivia)
Syntax\StructuredTriviaSyntax.cs (3)
14private SyntaxTrivia _parent; 22internal static StructuredTriviaSyntax Create(SyntaxTrivia trivia) 35public override SyntaxTrivia ParentTrivia => _parent;
Syntax\SyntaxExtensions.cs (1)
126public static SyntaxTriviaList ToSyntaxTriviaList(this IEnumerable<SyntaxTrivia> sequence)
Syntax\SyntaxFactory.cs (29)
31public static SyntaxTrivia CarriageReturnLineFeed { get; } = Syntax.InternalSyntax.SyntaxFactory.CarriageReturnLineFeed; 36public static SyntaxTrivia LineFeed { get; } = Syntax.InternalSyntax.SyntaxFactory.LineFeed; 41public static SyntaxTrivia CarriageReturn { get; } = Syntax.InternalSyntax.SyntaxFactory.CarriageReturn; 46public static SyntaxTrivia Space { get; } = Syntax.InternalSyntax.SyntaxFactory.Space; 51public static SyntaxTrivia Tab { get; } = Syntax.InternalSyntax.SyntaxFactory.Tab; 58public static SyntaxTrivia ElasticCarriageReturnLineFeed { get; } = Syntax.InternalSyntax.SyntaxFactory.ElasticCarriageReturnLineFeed; 65public static SyntaxTrivia ElasticLineFeed { get; } = Syntax.InternalSyntax.SyntaxFactory.ElasticLineFeed; 72public static SyntaxTrivia ElasticCarriageReturn { get; } = Syntax.InternalSyntax.SyntaxFactory.ElasticCarriageReturn; 78public static SyntaxTrivia ElasticSpace { get; } = Syntax.InternalSyntax.SyntaxFactory.ElasticSpace; 84public static SyntaxTrivia ElasticTab { get; } = Syntax.InternalSyntax.SyntaxFactory.ElasticTab; 91public static SyntaxTrivia ElasticMarker { get; } = Syntax.InternalSyntax.SyntaxFactory.ElasticZeroSpace; 98public static SyntaxTrivia EndOfLine(string text) 109public static SyntaxTrivia ElasticEndOfLine(string text) 116public static SyntaxTrivia EndOfLine(string text, bool elastic) 126public static SyntaxTrivia Whitespace(string text) 137public static SyntaxTrivia ElasticWhitespace(string text) 144public static SyntaxTrivia Whitespace(string text, bool elastic) 155public static SyntaxTrivia Comment(string text) 164public static SyntaxTrivia DisabledText(string text) 172public static SyntaxTrivia PreprocessingMessage(string text) 191public static SyntaxTrivia SyntaxTrivia(SyntaxKind kind, string text) 1219public static SyntaxTrivia DocumentationCommentExterior(string text) 1293public static SyntaxTrivia Trivia(StructuredTriviaSyntax node) 1310public static SyntaxTriviaList TriviaList(SyntaxTrivia trivia) 1319public static SyntaxTriviaList TriviaList(params SyntaxTrivia[] trivias) 1326public static SyntaxTriviaList TriviaList(IEnumerable<SyntaxTrivia> trivias) 1624SyntaxTrivia trivia = leadingTrivia.First(); 2386token = token.GetPreviousToken(predicate: SyntaxToken.Any, stepInto: CodeAnalysis.SyntaxTrivia.Any); 2415foreach (var trivia in triviaList)
Syntax\SyntaxNodeRemover.cs (6)
108private void AddEndOfLine(SyntaxTrivia? eolTrivia) 122/// Returns whether the specified <see cref="SyntaxTrivia"/> token is also the end of the line. This will 126private static bool IsEndOfLine(SyntaxTrivia trivia) 136private static SyntaxTrivia? GetEndOfLine(SyntaxTriviaList list) 138foreach (var trivia in list) 485static (SyntaxTriviaList triviaList, int index) getTriviaListAndIndex(SyntaxTrivia trivia)
Syntax\SyntaxNormalizer.cs (23)
20private readonly SyntaxTrivia _eolTrivia; 32private ArrayBuilder<SyntaxTrivia>? _indentations; 146private SyntaxTrivia GetIndentation(int count) 153_indentations = ArrayBuilder<SyntaxTrivia>.GetInstance(capacity); 1023ArrayBuilder<SyntaxTrivia> currentTriviaList = ArrayBuilder<SyntaxTrivia>.GetInstance(triviaList.Count); 1026foreach (var trivia in triviaList) 1066var tr = this.VisitStructuredTrivia(trivia); 1134private static readonly SyntaxTrivia s_trimmedDocCommentExterior = SyntaxFactory.DocumentationCommentExterior("///"); 1136private SyntaxTrivia GetSpace() 1141private SyntaxTrivia GetEndOfLine() 1146private SyntaxTrivia VisitStructuredTrivia(SyntaxTrivia trivia) 1154SyntaxTrivia result = VisitTrivia(trivia); 1162private static bool NeedsSeparatorBetween(SyntaxTrivia trivia) 1175private static bool NeedsLineBreakBetween(SyntaxTrivia trivia, SyntaxTrivia next, bool isTrailingTrivia) 1181private static bool NeedsLineBreakBefore(SyntaxTrivia trivia, bool isTrailingTrivia) 1193private static bool NeedsLineBreakAfter(SyntaxTrivia trivia, bool isTrailingTrivia) 1207private static bool NeedsIndentAfterLineBreak(SyntaxTrivia trivia) 1227private static bool EndsInLineBreak(SyntaxTrivia trivia) 1297private static int GetDeclarationDepth(SyntaxTrivia trivia) 1316var tr = ((StructuredTriviaSyntax)node).ParentTrivia;
Syntax\SyntaxReplacer.cs (37)
23IEnumerable<SyntaxTrivia>? trivia = null, 24Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? computeReplacementTrivia = null) 48IEnumerable<SyntaxTrivia>? trivia = null, 49Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? computeReplacementTrivia = null) 70private readonly Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? _computeReplacementTrivia; 74private readonly HashSet<SyntaxTrivia> _triviaSet; 86IEnumerable<SyntaxTrivia>? trivia, 87Func<SyntaxTrivia, SyntaxTrivia, SyntaxTrivia>? computeReplacementTrivia) 95_triviaSet = trivia != null ? new HashSet<SyntaxTrivia>(trivia) : s_noTrivia; 114private static readonly HashSet<SyntaxTrivia> s_noTrivia = new HashSet<SyntaxTrivia>(); 217public override SyntaxTrivia VisitListElement(SyntaxTrivia trivia) 219var rewritten = trivia; 255public static SyntaxNode ReplaceTriviaInList(SyntaxNode root, SyntaxTrivia triviaInList, IEnumerable<SyntaxTrivia> newTrivia) 260public static SyntaxNode InsertTriviaInList(SyntaxNode root, SyntaxTrivia triviaInList, IEnumerable<SyntaxTrivia> newTrivia, bool insertBefore) 265public static SyntaxToken ReplaceTriviaInList(SyntaxToken root, SyntaxTrivia triviaInList, IEnumerable<SyntaxTrivia> newTrivia) 270public static SyntaxToken InsertTriviaInList(SyntaxToken root, SyntaxTrivia triviaInList, IEnumerable<SyntaxTrivia> newTrivia, bool insertBefore) 355public override SyntaxTrivia VisitListElement(SyntaxTrivia trivia) 357var rewritten = trivia; 492private readonly SyntaxTrivia _originalTrivia; 493private readonly IEnumerable<SyntaxTrivia> _newTrivia; 496SyntaxTrivia originalTrivia, 497IEnumerable<SyntaxTrivia> newTrivia,
Microsoft.CodeAnalysis.CSharp.CodeStyle (143)
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\FileHeaders\CSharpFileHeaderHelper.cs (1)
21protected override ReadOnlyMemory<char> GetTextContextOfComment(SyntaxTrivia commentTrivia)
src\Analyzers\CSharp\Analyzers\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
96if (token.TrailingTrivia is not [.., SyntaxTrivia(SyntaxKind.EndOfLineTrivia)])
src\Analyzers\CSharp\Analyzers\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementDiagnosticAnalyzer.cs (1)
77if (token.TrailingTrivia is not [.., SyntaxTrivia(SyntaxKind.EndOfLineTrivia)])
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (1)
95out SyntaxTrivia endOfLineTrivia)
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (1)
126foreach (var trivia in triviaList)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (1)
43protected override bool IsRegularCommentOrDocComment(SyntaxTrivia trivia)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
90void ProcessTrivia(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (4)
46static bool IsAnyCodeDirective(SyntaxTrivia trivia) 85var parentTrivia = conditionalDirective.ParentTrivia; 90var nextTrivia = parentToken.LeadingTrivia[triviaIndex + 1]; 103foreach (var closeBraceDirective in closeBraceLeadingDirectives)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberAccessExpressionSyntaxExtensions.cs (2)
35private static IEnumerable<SyntaxTrivia> WithoutElasticTrivia(IEnumerable<SyntaxTrivia> list)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (10)
58public static IEnumerable<SyntaxTrivia> GetAllPrecedingTriviaToPreviousToken( 68public static IEnumerable<SyntaxTrivia> GetAllPrecedingTriviaToPreviousToken( 532foreach (var trivia in list) 548SyntaxTrivia trivia, 655public static ImmutableArray<SyntaxTrivia> GetLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode 661public static TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode 664public static ImmutableArray<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode 670public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode 877IEnumerable<SyntaxTrivia> leadingTrivia, 878IEnumerable<SyntaxTrivia> trailingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.SingleLineRewriter.cs (1)
28token = token.WithLeadingTrivia(Enumerable.Empty<SyntaxTrivia>());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (4)
180public static IEnumerable<SyntaxTrivia> GetAllTrailingTrivia(this SyntaxToken token) 182foreach (var trivia in token.TrailingTrivia) 220IEnumerable<SyntaxTrivia> leadingTrivia, 221IEnumerable<SyntaxTrivia> trailingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (3)
183var trivia = root.FindTrivia(position); 226var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position); 496var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position, findInsideTrivia: false);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTriviaExtensions.cs (24)
21public static void Deconstruct(this SyntaxTrivia trivia, out SyntaxKind kind) 24public static bool IsSingleOrMultiLineComment(this SyntaxTrivia trivia) 27public static bool IsRegularComment(this SyntaxTrivia trivia) 30public static bool IsWhitespaceOrSingleOrMultiLineComment(this SyntaxTrivia trivia) 33public static bool IsRegularOrDocComment(this SyntaxTrivia trivia) 36public static bool IsSingleLineComment(this SyntaxTrivia trivia) 39public static bool IsMultiLineComment(this SyntaxTrivia trivia) 42public static bool IsShebangDirective(this SyntaxTrivia trivia) 45public static bool IsCompleteMultiLineComment(this SyntaxTrivia trivia) 54public static bool IsDocComment(this SyntaxTrivia trivia) 57public static bool IsSingleLineDocComment(this SyntaxTrivia trivia) 60public static bool IsMultiLineDocComment(this SyntaxTrivia trivia) 63public static string GetCommentText(this SyntaxTrivia trivia) 119public static string AsString(this IEnumerable<SyntaxTrivia> trivia) 135public static int GetFullWidth(this IEnumerable<SyntaxTrivia> trivia) 144public static bool IsWhitespaceOrEndOfLine(this SyntaxTrivia trivia) 147public static bool IsEndOfLine(this SyntaxTrivia trivia) 150public static bool IsWhitespace(this SyntaxTrivia trivia) 153public static SyntaxTrivia GetPreviousTrivia( 154this SyntaxTrivia trivia, SyntaxTree syntaxTree, CancellationToken cancellationToken, bool findInsideTrivia = false) 165public static IEnumerable<SyntaxTrivia> FilterComments(this IEnumerable<SyntaxTrivia> trivia, bool addElasticMarker) 168foreach (var t in trivia) 201public static bool IsPragmaDirective(this SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTriviaListExtensions.cs (10)
18public static SyntaxTrivia? GetFirstNewLine(this SyntaxTriviaList triviaList) 25public static SyntaxTrivia? GetLastComment(this SyntaxTriviaList triviaList) 32public static SyntaxTrivia? GetLastCommentOrWhitespace(this SyntaxTriviaList triviaList) 42public static IEnumerable<SyntaxTrivia> SkipInitialWhitespace(this IEnumerable<SyntaxTrivia> triviaList) 45private static ImmutableArray<ImmutableArray<SyntaxTrivia>> GetLeadingBlankLines(SyntaxTriviaList triviaList) 47using var result = TemporaryArray<ImmutableArray<SyntaxTrivia>>.Empty; 48using var currentLine = TemporaryArray<SyntaxTrivia>.Empty; 49foreach (var trivia in triviaList) 78public static IEnumerable<SyntaxTrivia> TakeRange(this SyntaxTriviaList triviaList, int start, int end)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\CSharpStructuredTriviaFormatEngine.cs (2)
17SyntaxTrivia trivia, 29SyntaxTrivia trivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.cs (34)
20private SyntaxTrivia _newLine; 37protected override bool IsWhitespace(SyntaxTrivia trivia) 40protected override bool IsEndOfLine(SyntaxTrivia trivia) 49protected override SyntaxTrivia CreateWhitespace(string text) 52protected override SyntaxTrivia CreateEndOfLine() 62protected override LineColumnRule GetLineColumnRuleBetween(SyntaxTrivia trivia1, LineColumnDelta existingWhitespaceBetween, bool implicitLineBreak, SyntaxTrivia trivia2, CancellationToken cancellationToken) 108var previous = trivia2; 177protected override bool ContainsImplicitLineBreak(SyntaxTrivia trivia) 191private bool IsStartOrEndOfFile(SyntaxTrivia trivia1, SyntaxTrivia trivia2) 205private static bool IsMultilineComment(SyntaxTrivia trivia1) 208private bool TryFormatMultiLineCommentTrivia(LineColumn lineColumn, SyntaxTrivia trivia, out SyntaxTrivia result) 230var firstTrivia = multilineCommentTrivia.First(); 241LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<SyntaxTrivia> changes, 249if (TryFormatMultiLineCommentTrivia(lineColumn, trivia, out var newComment)) 260LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<TextChange> changes, CancellationToken cancellationToken) 267if (TryFormatMultiLineCommentTrivia(lineColumn, trivia, out var newComment)) 276private SyntaxTrivia FormatDocumentComment(LineColumn lineColumn, SyntaxTrivia trivia) 300var newTrivia = singleLineDocumentationCommentExteriorCommentRewriter.VisitTrivia(trivia); 316var newMultiLineTrivia = multiLineDocumentationCommentExteriorCommentRewriter.VisitTrivia(trivia); 322LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<SyntaxTrivia> changes, CancellationToken cancellationToken) 338var formattedTrivia = SyntaxFactory.Trivia((StructuredTriviaSyntax)result.GetFormattedRoot(cancellationToken)); 344var docComment = FormatDocumentComment(lineColumn, trivia); 351LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<TextChange> changes, CancellationToken cancellationToken) 372var formattedTrivia = SyntaxFactory.Trivia((StructuredTriviaSyntax)result.GetFormattedRoot(cancellationToken)); 376var docComment = FormatDocumentComment(lineColumn, trivia); 385protected override bool LineContinuationFollowedByWhitespaceComment(SyntaxTrivia trivia, SyntaxTrivia nextTrivia) 394protected override bool IsVisualBasicComment(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (4)
33public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia) 57var parsedNewTrivia = SyntaxFactory.DocumentationCommentExterior(newTriviaText); 66private static bool IsBeginningOrEndOfDocumentComment(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.cs (3)
99foreach (var trivia in list) 135private static void AnalyzeLineBreak(SyntaxTrivia trivia, ref AnalysisResult result) 152private static void AnalyzeWhitespacesInTrivia(SyntaxTrivia trivia, ref AnalysisResult result)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.cs (12)
107private static bool OnElastic(SyntaxTrivia trivia) 112foreach (var t in structure.DescendantTrivia()) 125private bool OnWhitespace(SyntaxTrivia trivia) 154private bool OnEndOfLine(SyntaxTrivia trivia, int currentIndex) 189private readonly bool OnComment(SyntaxTrivia trivia) 213private static bool OnSkippedTokensOrText(SyntaxTrivia trivia) 224private bool OnRegion(SyntaxTrivia trivia, int currentIndex) 246private bool OnPreprocessor(SyntaxTrivia trivia, int currentIndex) 268private bool OnTouchedNoisyCharacter(SyntaxTrivia trivia) 309private bool OnDisabledTextTrivia(SyntaxTrivia trivia, int index) 323private static bool ShouldFormatSingleLineDocumentationComment(int indentation, int tabSize, SyntaxTrivia trivia) 332foreach (var xmlTrivia in token.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaRewriter.cs (1)
118var trivia = triviaList[i];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (1)
36public static string ContentBeforeLastNewLine(this IEnumerable<SyntaxTrivia> trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (3)
255var firstNonWhitespaceTrivia = triviaList.FirstOrDefault(trivia => !IsWhitespace(trivia)); 480private static bool IsWhitespace(SyntaxTrivia trivia) 486private static int GetNumberOfLines(IEnumerable<SyntaxTrivia> triviaList)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (2)
299foreach (var trivia in triviaList) 305static void ProcessTrivia(ArrayBuilder<SuppressOperation> list, SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpFileBannerFacts.cs (2)
21public override SyntaxTrivia CreateTrivia(SyntaxTrivia trivia, string text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (10)
40public SyntaxTrivia ElasticMarker 43public SyntaxTrivia ElasticCarriageReturnLineFeed 1105var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position, findInsideTrivia: false); 1217public bool IsRegularComment(SyntaxTrivia trivia) 1220public bool IsDocumentationComment(SyntaxTrivia trivia) 1223public bool IsElastic(SyntaxTrivia trivia) 1226public bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes) 1229public bool IsDocumentationCommentExteriorTrivia(SyntaxTrivia trivia) 1373public bool IsPreprocessorDirective(SyntaxTrivia trivia) 1440public SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesOrganizer.cs (3)
21SyntaxTrivia fallbackTrivia, 108SyntaxTrivia newLineTrivia, 159private static void EnsureNewLines(IList<SyntaxNode> list, SyntaxTrivia newLineTrivia)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (58)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
388if (openBraceToken.TrailingTrivia is not [.., SyntaxTrivia(SyntaxKind.EndOfLineTrivia)])
src\Analyzers\CSharp\CodeFixes\DocumentationComments\CSharpAddDocCommentNodesCodeFixProvider.cs (1)
44foreach (var node in docCommentNodes)
src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
51var firstTrivia = trailingTrivia[0];
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (3)
317private static IEnumerable<SyntaxTrivia> MassageTrivia(IEnumerable<SyntaxTrivia> triviaList) 319foreach (var trivia in triviaList)
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (5)
271private static (IEnumerable<UsingDirectiveSyntax> deduplicatedUsings, IEnumerable<SyntaxTrivia> orphanedTrivia) RemoveDuplicateUsings( 278var orphanedTrivia = Enumerable.Empty<SyntaxTrivia>(); 335private static IEnumerable<IEnumerable<SyntaxTrivia>> SplitIntoLines(SyntaxTriviaList triviaList) 407private static (CompilationUnitSyntax compilationUnitWithoutHeader, ImmutableArray<SyntaxTrivia> header) RemoveFileHeader( 423private static CompilationUnitSyntax AddFileHeader(CompilationUnitSyntax compilationUnit, ImmutableArray<SyntaxTrivia> fileHeader)
src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
83text, firstBrace, out var secondBrace, out var lastEndOfLineTrivia))
src\Analyzers\CSharp\CodeFixes\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementCodeFixProvider.cs (4)
53var endOfLineTrivia = ElasticEndOfLine(options.NewLine); 64SyntaxTrivia endOfLineTrivia, 128private static SyntaxNode AddLeadingTrivia(SyntaxNode node, SyntaxTrivia trivia) 131private static SyntaxToken AddLeadingTrivia(SyntaxToken token, SyntaxTrivia trivia)
src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionCodeFixProvider.cs (2)
80private static IEnumerable<SyntaxTrivia> TakeComments(SyntaxTriviaList triviaList) 82var lastComment = triviaList.Last(t => t.IsSingleOrMultiLineComment());
src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
48var skippedTrivia = leadingTrivia[skippedTriviaIndex];
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (9)
612using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var result); 618var currentTrivia = token.LeadingTrivia[i]; 619var nextTrivia = token.LeadingTrivia[i + 1]; 643SyntaxTrivia GetIndentedWhitespaceTrivia(string preferredIndentation, string firstTokenOnLineIndentationString, int pos) 659using var _1 = ArrayBuilder<SyntaxTrivia>.GetInstance(out var newLeadingTrivia); 660using var _2 = ArrayBuilder<SyntaxTrivia>.GetInstance(out var newTrailingTrivia); 675var currentTrivia = leadingTrivia[i]; 701foreach (var trivia in parentStatement.GetTrailingTrivia()) 841private static SyntaxTrivia DetermineEndOfLine<TParentExpression>(
src\Analyzers\CSharp\CodeFixes\UseObjectInitializer\CSharpUseObjectInitializerCodeFixProvider.cs (1)
46protected override SyntaxTrivia Whitespace(string text)
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs (1)
86ImmutableArray<SyntaxTrivia> trivia,
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (6)
40private static readonly Matcher<SyntaxTrivia> s_commentFollowedByBlankLine = Matcher.Sequence( 41Matcher.Single<SyntaxTrivia>(t => t.IsSingleOrMultiLineComment(), "comment"), 42Matcher.Single<SyntaxTrivia>(t => t.Kind() == SyntaxKind.EndOfLineTrivia, "first end of line"), 43Matcher.Repeat(Matcher.Single<SyntaxTrivia>(t => t.Kind() == SyntaxKind.WhitespaceTrivia, "whitespace")), 44Matcher.Single<SyntaxTrivia>(t => t.IsKind(SyntaxKind.EndOfLineTrivia), "second end of line")); 202ImmutableArray<SyntaxTrivia> GetLeadingCommentTrivia(MemberDeclarationSyntax firstMember)
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider_DocComments.cs (10)
34private static SyntaxTrivia GetDocComment(SyntaxNode node) 37private static SyntaxTrivia GetDocComment(SyntaxTriviaList trivia) 46private static DocumentationCommentTriviaSyntax? GetDocCommentStructure(SyntaxTrivia trivia) 106var existingTypeDeclarationDocComment = GetDocComment(typeDeclarationLeadingTrivia); 107var existingConstructorDocComment = GetDocComment(constructorDeclaration); 121static SyntaxTriviaList InsertOrReplaceDocComments(SyntaxTriviaList leadingTrivia, SyntaxTrivia newDocComment) 125var existingDocComment = GetDocComment(leadingTrivia); 139static SyntaxTrivia MergeDocComments(SyntaxTrivia typeDeclarationDocComment, SyntaxTrivia constructorDocComment)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (2)
114private static SyntaxTrivia ReplaceUnterminatedConstructs(SyntaxTrivia skippedTokensTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (3)
452IEnumerable<SyntaxTrivia> trivia; 457ComputePositionAndTriviaForRemoveAttributeList(attributeList, (SyntaxTrivia t) => t.IsKind(SyntaxKind.EndOfLineTrivia), out positionOfRemovedNode, out trivia); 596var lastEndIf = closeBraceTrivia.LastOrDefault(t => t.GetStructure() is EndIfDirectiveTriviaSyntax);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (3)
36protected override IndentationResult? GetDesiredIndentationWorker(Indenter indenter, SyntaxToken? tokenOpt, SyntaxTrivia? triviaOpt) 40private static IndentationResult? TryGetDesiredIndentation(Indenter indenter, SyntaxTrivia? triviaOpt) 54var trivia = triviaOpt.Value;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSyntaxGeneratorInternal.cs (4)
33public override SyntaxTrivia CarriageReturnLineFeed 36public override SyntaxTrivia ElasticCarriageReturnLineFeed 45public override SyntaxTrivia EndOfLine(string text) 48public override SyntaxTrivia SingleLineComment(string text)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (5)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (1)
861private static SyntaxTrivia GetNewLineTrivia(SyntaxFormattingOptions formattingOptions)
BlockCommentEditing\BlockCommentEditingCommandHandler.cs (2)
118if (!IsCaretInsideBlockCommentSyntax(caretPosition, buffer, editorOptionsService, out var blockComment, out var newLine, cancellationToken)) 270out SyntaxTrivia trivia,
SplitComment\CSharpSplitCommentService.cs (1)
23public bool IsAllowed(SyntaxNode root, SyntaxTrivia trivia)
TextStructureNavigation\CSharpTextStructureNavigatorProvider.cs (1)
28protected override bool ShouldSelectEntireTriviaFromStart(SyntaxTrivia trivia)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
Formatting\FormattingEngineTests.cs (2)
2541var markerTrivia = root.FindTrivia(position, findInsideTrivia: true); 2542var annotatedMarkerTrivia = markerTrivia.WithAdditionalAnnotations(annotation);
Microsoft.CodeAnalysis.CSharp.Features (140)
BraceCompletion\AbstractCurlyBraceOrBracketCompletionService.cs (1)
119var annotatedNewline = SyntaxFactory.EndOfLine(options.FormattingOptions.NewLine).WithAdditionalAnnotations(s_closingBraceNewlineAnnotation);
BraceMatching\BlockCommentBraceMatcher.cs (1)
43foreach (var trivia in triviaList)
ChangeSignature\CSharpChangeSignatureService.cs (1)
768private ImmutableArray<SyntaxTrivia> UpdateParamTagsInLeadingTrivia(
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (7)
58var pragmaDirectiveTrivia = Trivia(pragmaDirective); 59var endOfLineTrivia = CarriageReturnLineFeed; 65var titleComment = Comment(string.Format(" // {0}", title)).WithAdditionalAnnotations(Formatter.Annotation); 93protected override bool IsEndOfLine(SyntaxTrivia trivia) 222protected override bool IsAnyPragmaDirectiveForId(SyntaxTrivia trivia, string id, out bool enableDirective, out bool hasMultipleIds) 237protected override SyntaxTrivia TogglePragmaDirective(SyntaxTrivia trivia)
CodeRefactorings\EnableNullable\EnableNullableCodeRefactoringProvider.cs (2)
164var newLine = SyntaxFactory.EndOfLine(options.NewLine); 169var nullableDisableTrivia = SyntaxFactory.Trivia(SyntaxFactory.NullableDirectiveTrivia(DisableKeyword.WithPrependedLeadingTrivia(SyntaxFactory.ElasticSpace), isActive: true));
CodeRefactorings\SyncNamespace\CSharpChangeNamespaceService.cs (4)
452private static (ImmutableArray<SyntaxTrivia> openingTrivia, ImmutableArray<SyntaxTrivia> closingTrivia) 455var openingBuilder = ArrayBuilder<SyntaxTrivia>.GetInstance(); 456var closingBuilder = ArrayBuilder<SyntaxTrivia>.GetInstance();
ConvertLinq\ConvertForEachToLinqQuery\AbstractConverter.cs (5)
99IEnumerable<SyntaxTrivia> extraLeadingTrivia, 100IEnumerable<SyntaxTrivia> extraTrailingTrivia) 147IEnumerable<SyntaxTrivia> leadingCommentsTrivia, 148IEnumerable<SyntaxTrivia> trailingCommentsTrivia, 198var droppedTrivia = new List<SyntaxTrivia>();
ConvertLinq\ConvertForEachToLinqQuery\AbstractToMethodConverter.cs (6)
28SyntaxTrivia[] trivia) : AbstractConverter(forEachInfo) 39private readonly SyntaxTrivia[] _trivia = trivia; 104SyntaxTrivia[] leadingTrivia; 142static SyntaxTrivia[] GetTriviaFromVariableDeclarator(VariableDeclaratorSyntax variableDeclarator) 144static SyntaxTrivia[] GetTriviaFromNode(SyntaxNode node) 156return new IEnumerable<SyntaxTrivia>[] {
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (1)
183var localDeclarationLeadingTrivia = new IEnumerable<SyntaxTrivia>[] {
ConvertLinq\ConvertForEachToLinqQuery\ToCountConverter.cs (1)
21SyntaxTrivia[] trivia) : AbstractToMethodConverter(forEachInfo, selectExpression, modifyingExpression, trivia)
ConvertLinq\ConvertForEachToLinqQuery\ToToListConverter.cs (1)
22SyntaxTrivia[] trivia) : AbstractToMethodConverter(forEachInfo, selectExpression, modifyingExpression, trivia)
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider_DocumentationComments.cs (4)
19private static SyntaxTrivia GetDocComment(SyntaxTriviaList trivia) 22private static DocumentationCommentTriviaSyntax? GetDocCommentStructure(SyntaxTrivia trivia) 36var trivia = GetDocComment(triviaList); 73var updatedTrivia = Trivia(docComment.WithContent([.. content]));
ConvertProgram\ConvertProgramTransform_ProgramMain.cs (2)
137while (triviaToMove is [.., SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia), SyntaxTrivia(SyntaxKind.EndOfLineTrivia)])
DocumentationComments\CSharpDocumentationCommentSnippetService.cs (1)
255protected override bool IsEndOfLineTrivia(SyntaxTrivia trivia)
DocumentationComments\DocCommentConverter.cs (3)
50var newLeadingTrivia = new List<SyntaxTrivia>(); 52foreach (var trivia in node.GetLeadingTrivia()) 79private IEnumerable<SyntaxTrivia> ConvertDocCommentToRegularComment(DocumentationCommentTriviaSyntax structuredTrivia)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
63var triviaList = new List<SyntaxTrivia>();
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (1)
341using var _4 = ArrayBuilder<SyntaxTrivia>.GetInstance(out var triviaList);
ExtractMethod\CSharpMethodExtractor.PostProcessor.cs (1)
212foreach (var trivia in token.LeadingTrivia.Concat(token.TrailingTrivia))
ExtractMethod\CSharpMethodExtractor.TriviaResult.cs (5)
87private IEnumerable<SyntaxTrivia> TriviaResolver( 145private IEnumerable<SyntaxTrivia> FilterBeforeBeginningOfSpan(PreviousNextTokenPair tokenPair, IEnumerable<SyntaxTrivia> list) 157private static IEnumerable<SyntaxTrivia> AppendLeadingTrivia(PreviousNextTokenPair tokenPair) 168private static IEnumerable<SyntaxTrivia> AppendTrailingTrivia(PreviousNextTokenPair tokenPair)
ExtractMethod\Extensions.cs (4)
172foreach (var trivia in tokens.GetAllTrivia()) 217public static IEnumerable<SyntaxTrivia> GetAllTrivia(this IEnumerable<SyntaxToken> tokens) 221foreach (var trivia in token.LeadingTrivia) 226foreach (var trivia in token.TrailingTrivia)
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (1)
488var precedingEndOfLine = nextStatementLeading.LastOrDefault(t => t.Kind() == SyntaxKind.EndOfLineTrivia);
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (1)
217static bool HasCommentTrivia(SyntaxTrivia trivia)
MetadataAsSource\CSharpMetadataAsSourceService.cs (1)
138private static SyntaxTrivia[] CreateNullableTrivia(bool enable)
QuickInfo\CSharpSyntacticQuickInfoProvider.cs (4)
103if (TryFindFurthestNearbyComment(ref searchListAbove, out var nearbyComment)) 118private static bool TryFindFurthestNearbyComment<T>(ref T triviaSearchList, out SyntaxTrivia nearbyTrivia) 119where T : IEnumerable<SyntaxTrivia> 123foreach (var trivia in triviaSearchList)
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.cs (4)
235private static SyntaxTrivia ConvertTrivia(SyntaxTrivia trivia, CSharpSyntaxRewriter rewriter) 242private static SyntaxTrivia ConvertDocumentationComment(SyntaxTrivia trivia, CSharpSyntaxRewriter rewriter)
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\FileHeaders\CSharpFileHeaderHelper.cs (1)
21protected override ReadOnlyMemory<char> GetTextContextOfComment(SyntaxTrivia commentTrivia)
src\Analyzers\CSharp\Analyzers\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
96if (token.TrailingTrivia is not [.., SyntaxTrivia(SyntaxKind.EndOfLineTrivia)])
src\Analyzers\CSharp\Analyzers\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementDiagnosticAnalyzer.cs (1)
77if (token.TrailingTrivia is not [.., SyntaxTrivia(SyntaxKind.EndOfLineTrivia)])
src\Analyzers\CSharp\Analyzers\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementDiagnosticAnalyzer.cs (1)
95out SyntaxTrivia endOfLineTrivia)
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (1)
126foreach (var trivia in triviaList)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (1)
43protected override bool IsRegularCommentOrDocComment(SyntaxTrivia trivia)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
90void ProcessTrivia(SyntaxTrivia trivia)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
388if (openBraceToken.TrailingTrivia is not [.., SyntaxTrivia(SyntaxKind.EndOfLineTrivia)])
src\Analyzers\CSharp\CodeFixes\DocumentationComments\CSharpAddDocCommentNodesCodeFixProvider.cs (1)
44foreach (var node in docCommentNodes)
src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
51var firstTrivia = trailingTrivia[0];
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (3)
317private static IEnumerable<SyntaxTrivia> MassageTrivia(IEnumerable<SyntaxTrivia> triviaList) 319foreach (var trivia in triviaList)
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (5)
271private static (IEnumerable<UsingDirectiveSyntax> deduplicatedUsings, IEnumerable<SyntaxTrivia> orphanedTrivia) RemoveDuplicateUsings( 278var orphanedTrivia = Enumerable.Empty<SyntaxTrivia>(); 335private static IEnumerable<IEnumerable<SyntaxTrivia>> SplitIntoLines(SyntaxTriviaList triviaList) 407private static (CompilationUnitSyntax compilationUnitWithoutHeader, ImmutableArray<SyntaxTrivia> header) RemoveFileHeader( 423private static CompilationUnitSyntax AddFileHeader(CompilationUnitSyntax compilationUnit, ImmutableArray<SyntaxTrivia> fileHeader)
src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
83text, firstBrace, out var secondBrace, out var lastEndOfLineTrivia))
src\Analyzers\CSharp\CodeFixes\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementCodeFixProvider.cs (4)
53var endOfLineTrivia = ElasticEndOfLine(options.NewLine); 64SyntaxTrivia endOfLineTrivia, 128private static SyntaxNode AddLeadingTrivia(SyntaxNode node, SyntaxTrivia trivia) 131private static SyntaxToken AddLeadingTrivia(SyntaxToken token, SyntaxTrivia trivia)
src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionCodeFixProvider.cs (2)
80private static IEnumerable<SyntaxTrivia> TakeComments(SyntaxTriviaList triviaList) 82var lastComment = triviaList.Last(t => t.IsSingleOrMultiLineComment());
src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
48var skippedTrivia = leadingTrivia[skippedTriviaIndex];
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (9)
612using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var result); 618var currentTrivia = token.LeadingTrivia[i]; 619var nextTrivia = token.LeadingTrivia[i + 1]; 643SyntaxTrivia GetIndentedWhitespaceTrivia(string preferredIndentation, string firstTokenOnLineIndentationString, int pos) 659using var _1 = ArrayBuilder<SyntaxTrivia>.GetInstance(out var newLeadingTrivia); 660using var _2 = ArrayBuilder<SyntaxTrivia>.GetInstance(out var newTrailingTrivia); 675var currentTrivia = leadingTrivia[i]; 701foreach (var trivia in parentStatement.GetTrailingTrivia()) 841private static SyntaxTrivia DetermineEndOfLine<TParentExpression>(
src\Analyzers\CSharp\CodeFixes\UseObjectInitializer\CSharpUseObjectInitializerCodeFixProvider.cs (1)
46protected override SyntaxTrivia Whitespace(string text)
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs (1)
86ImmutableArray<SyntaxTrivia> trivia,
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (6)
40private static readonly Matcher<SyntaxTrivia> s_commentFollowedByBlankLine = Matcher.Sequence( 41Matcher.Single<SyntaxTrivia>(t => t.IsSingleOrMultiLineComment(), "comment"), 42Matcher.Single<SyntaxTrivia>(t => t.Kind() == SyntaxKind.EndOfLineTrivia, "first end of line"), 43Matcher.Repeat(Matcher.Single<SyntaxTrivia>(t => t.Kind() == SyntaxKind.WhitespaceTrivia, "whitespace")), 44Matcher.Single<SyntaxTrivia>(t => t.IsKind(SyntaxKind.EndOfLineTrivia), "second end of line")); 202ImmutableArray<SyntaxTrivia> GetLeadingCommentTrivia(MemberDeclarationSyntax firstMember)
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider_DocComments.cs (10)
34private static SyntaxTrivia GetDocComment(SyntaxNode node) 37private static SyntaxTrivia GetDocComment(SyntaxTriviaList trivia) 46private static DocumentationCommentTriviaSyntax? GetDocCommentStructure(SyntaxTrivia trivia) 106var existingTypeDeclarationDocComment = GetDocComment(typeDeclarationLeadingTrivia); 107var existingConstructorDocComment = GetDocComment(constructorDeclaration); 121static SyntaxTriviaList InsertOrReplaceDocComments(SyntaxTriviaList leadingTrivia, SyntaxTrivia newDocComment) 125var existingDocComment = GetDocComment(leadingTrivia); 139static SyntaxTrivia MergeDocComments(SyntaxTrivia typeDeclarationDocComment, SyntaxTrivia constructorDocComment)
Structure\CSharpStructureHelpers.cs (10)
50foreach (var trivia in trailingTrivia) 56foreach (var trivia in nextLeadingTrivia) 65static bool ProcessTrivia(SyntaxTrivia trivia, bool compressEmptyLines, ref int end, ref int? hintEnd) 118public static string GetCommentBannerText(SyntaxTrivia comment) 151SyntaxTrivia startComment, SyntaxTrivia endComment) 169SyntaxTrivia? startComment = null; 170SyntaxTrivia? endComment = null; 175foreach (var trivia in triviaList) 187else if (trivia is not SyntaxTrivia(
Structure\Providers\DisabledTextTriviaStructureProvider.cs (7)
16SyntaxTrivia trivia, 26SyntaxTree syntaxTree, SyntaxTrivia trivia, 56var endTrivia = GetCorrespondingEndTrivia(trivia, parentTriviaList, indexInParent); 68private static int GetEndPositionExludingLastNewLine(SyntaxTree syntaxTree, SyntaxTrivia trivia, CancellationToken cancellationToken) 76private static SyntaxTrivia GetCorrespondingEndTrivia( 77SyntaxTrivia trivia, SyntaxTriviaList triviaList, int index) 91var currentTrivia = triviaList[i];
Structure\Providers\MultilineCommentBlockStructureProvider.cs (1)
14SyntaxTrivia trivia,
TaskList\CSharpTaskListService.cs (4)
33SyntaxTrivia trivia, 83protected override bool PreprocessorHasComment(SyntaxTrivia trivia) 89protected override bool IsSingleLineComment(SyntaxTrivia trivia) 92protected override bool IsMultilineComment(SyntaxTrivia trivia)
UseAutoProperty\CSharpUseAutoPropertyCodeFixProvider.cs (1)
153var indentation = leadingTrivia is [.., (kind: SyntaxKind.WhitespaceTrivia) whitespaceTrivia]
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (1)
Diagnostics\Suppression\SuppressionTests.cs (1)
1106foreach (var trivia in context.Node.DescendantTrivia().Where(t => t.Kind() is SyntaxKind.SingleLineCommentTrivia or SyntaxKind.MultiLineCommentTrivia))
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (1)
Semantics\SyntaxTreeRootTests.cs (1)
117Assert.Throws<InvalidOperationException>(() => { tree.GetDiagnostics(default(SyntaxTrivia)); });
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (237)
LexicalAndXml\LexicalTests.cs (24)
171var trivia = token.LeadingTrivia.Single(); 3850var trivia = token.LeadingTrivia.Single(); 3876var trivia = token.LeadingTrivia.Single(); 3956var trivia = token.LeadingTrivia.Single(); 4014var trivia1 = token.LeadingTrivia[0]; 4023var trivia2 = token.LeadingTrivia[1]; 4028var trivia3 = token.LeadingTrivia[2]; 4033var trivia4 = token.LeadingTrivia[3]; 4095var trivia = token.LeadingTrivia.Single(); 4138var trivia1 = token.LeadingTrivia[0]; 4142var trivia2 = token.LeadingTrivia[1]; 4147var trivia3 = token.LeadingTrivia[2]; 4152var trivia4 = token.LeadingTrivia[3]; 4173var trivia = token.LeadingTrivia[0]; 4213var trivia = token.LeadingTrivia[0]; 4261var trivia = token.LeadingTrivia.Single(); 4321var trivia1 = token.LeadingTrivia[0]; 4329var trivia2 = token.LeadingTrivia[1]; 4332var trivia3 = token.LeadingTrivia[2]; 4335var trivia4 = token.LeadingTrivia[3]; 4382var trivia = token.LeadingTrivia[0]; 4421var trivia = token.LeadingTrivia[0]; 4477var trivia = token.LeadingTrivia[0]; 4535var trivia = token.LeadingTrivia[0];
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 (1)
85var docCommentTrivia = result.Token.GetLeadingTrivia()[0];
LexicalAndXml\XmlDocCommentTests.cs (58)
82var node = leading[0]; 151var node = leading[0]; 172var node = leading[0]; 197var node = leading[0]; 219var node = leading[0]; 242var node = leading[0]; 265var node = leading[0]; 292var node = leading[0]; 320var node = leading[0]; 344var node = leading[0]; 369var node = leading[0]; 395var node = leading[0]; 422var node = leading[0]; 449var node = leading[0]; 477var node = leading[0]; 506var node = leading[0]; 536var node = leading[0]; 565var node = leading[0]; 595var node = leading[0]; 626var node = leading[0]; 649var node = leading[0]; 671var node = leading[0]; 693var node = leading[0]; 715var node = leading[0]; 737var node = leading[0]; 757var node = leading[0]; 791var node = leading[0]; 824var node = leading[0]; 855var node = leading[0]; 883var node = leading[0]; 908var node = leading[0]; 934var node = leading[0]; 959var node = leading[0]; 986var node = leading[0]; 1017var node = leading[0]; 1045var node = leading[0]; 1070var node = leading[0]; 1095var node = leading[0]; 1122var node = leading[0]; 1155var node = leading[0]; 1186var node = leading[0]; 1212var node = leading[0]; 1239var node = leading[0]; 1267var node = leading[0]; 1296var node = leading[0]; 1312var node = leading[0]; 1336var node = leading[0]; 1361var node = leading[0]; 1385var node = leading[0]; 1410var node = leading[0]; 1434var node = leading[0]; 1459var node = leading[0]; 1483var node = leading[0]; 1563var node = leading[0]; 1591var node = leading[0]; 1619var node = leading[0]; 1645var node = leading[0]; 3300private void VerifyDiagnostics(SyntaxTrivia trivia, List<TestError> errors)
ParentChecker.cs (2)
25foreach (var trivia in token.LeadingTrivia) 38foreach (var trivia in token.TrailingTrivia)
Parsing\CrefParsingTests.cs (1)
29var trivia = SyntaxFactory.ParseLeadingTrivia(commentText, options ?? CSharpParseOptions.Default).Single();
Parsing\NameAttributeValueParsingTests.cs (1)
30var trivia = SyntaxFactory.ParseLeadingTrivia(commentText).Single();
Parsing\ScriptParsingTests.cs (3)
9639var trivia = eof.GetLeadingTrivia().Single(); 9723private void TestShebang(SyntaxTrivia trivia, string expectedSkippedText) 9740var skippedText = endOfDirective.LeadingTrivia.Single();
Parsing\SyntaxExtensions.cs (3)
88internal static ImmutableArray<DiagnosticInfo> Errors(this SyntaxTrivia trivia) 93internal static ImmutableArray<DiagnosticInfo> Warnings(this SyntaxTrivia trivia) 98internal static ImmutableArray<DiagnosticInfo> ErrorsAndWarnings(this SyntaxTrivia trivia)
Parsing\VerbatimCrefParsingTests.cs (1)
29var trivia = SyntaxFactory.ParseLeadingTrivia(commentText).Single();
Syntax\StructuredTriviaTests.cs (14)
24var trivia1 = SyntaxFactory.Trivia(SyntaxFactory.IfDirectiveTrivia(SyntaxFactory.IdentifierName(conditionName), false, false, false)); 28var trivia2 = structuredTrivia.ParentTrivia; 65var sTrivia = SyntaxFactory.Trivia(docComment); 66Assert.NotEqual(default(SyntaxTrivia), sTrivia); 81var trResult = identExpr.FindTrivia(6, SyntaxTrivia.Any); 88var identTrivia = identExpr.GetLeadingTrivia()[0]; 89var foundTrivia = ((DocumentationCommentTriviaSyntax)foundDocComment).ParentTrivia; 167var trivia = tree.GetCompilationUnitRoot().DescendantTrivia().Single(t => t.Kind() == SyntaxKind.SingleLineDocumentationCommentTrivia); 183var trivia = tree.GetCompilationUnitRoot().DescendantTrivia().Single(t => t.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia); 193var t1 = trivia[0]; 199var t2 = trivia[1]; 204var t3 = trivia[-1]; 211var t2 = trl[0];
Syntax\SyntaxAnnotationTests.cs (43)
44var oldTrivia = default(SyntaxTrivia); 45var newTrivia = oldTrivia.WithAdditionalAnnotations(annotation); 98var fromTrivia = default(SyntaxTrivia); 100var toTrivia = GetAllTrivia(tree.GetCompilationUnitRoot()).FirstOrDefault(); 101var annotatedTrivia = fromTrivia.CopyAnnotationsTo(toTrivia); 108var toTrivia = default(SyntaxTrivia); 110var fromTrivia = GetAllTrivia(tree.GetCompilationUnitRoot()).FirstOrDefault(); 111var annotatedTrivia = fromTrivia.CopyAnnotationsTo(toTrivia); 112Assert.True(default(SyntaxTrivia).IsEquivalentTo(annotatedTrivia)); 119var fromTrivia = GetAllTrivia(tree.GetCompilationUnitRoot()).FirstOrDefault(); 120var toTrivia = GetAllTrivia(tree.GetCompilationUnitRoot()).FirstOrDefault(); 121var annotatedTrivia = fromTrivia.CopyAnnotationsTo(toTrivia); 225var trivia = GetAllTrivia(tree.GetCompilationUnitRoot()).First(); 228var annotatedTrivia = trivia.WithAdditionalAnnotations(annotation1); 235var trivia2 = newRoot.GetAnnotatedTrivia(annotation1).Single(); 238var twiceAnnotatedTrivia = trivia2.WithAdditionalAnnotations(annotation2); 373var oldTrivia = actualTrivia.ElementAt(i); 374var newTrivia = annotatedTrivia.ElementAt(i); 456var triviaMap = new Dictionary<SyntaxTrivia, SyntaxTrivia>(); 459var oldTrivia = destTreeTriviaEnumerator.Current; 460var newTrivia = sourceTreeTriviaEnumerator.Current.CopyAnnotationsTo(oldTrivia); 566foreach (var trivia in GetAllTrivia(syntaxTree.GetCompilationUnitRoot())) 569var newTrivia = trivia.WithAdditionalAnnotations(annotation); 642private void TestAnnotation(SyntaxAnnotation annotation, SyntaxNode root, SyntaxTrivia oldTrivia) 648var annotatedTrivia = results.Single(); 656private List<SyntaxTrivia> GetAllTrivia(SyntaxNode root) 672public List<SyntaxTrivia> Trivia { get; } 678this.Trivia = new List<SyntaxTrivia>(); 701public override void VisitTrivia(SyntaxTrivia trivia) 742public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia) 792public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia) 813private readonly Dictionary<SyntaxTrivia, SyntaxTrivia> _triviaMap; 815public CopyAnnotationRewriter(Dictionary<SyntaxNodeOrToken, SyntaxNodeOrToken> nodeOrTokenMap, Dictionary<SyntaxTrivia, SyntaxTrivia> triviaMap) : 842public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia)
Syntax\SyntaxNodeTests.cs (41)
790var trivia = tree.GetCompilationUnitRoot().FindTrivia(position); 794Assert.Equal(default(SyntaxTrivia), trivia); 932var trivia = tree.GetCompilationUnitRoot().Members[0].GetLeadingTrivia()[0]; 935var triviaAgain = tree.GetCompilationUnitRoot().Members[0].GetLeadingTrivia()[0]; 938Assert.True(SyntaxTrivia.Equals(trivia, triviaAgain)); 1354var trivia = tree.GetCompilationUnitRoot().EndOfFileToken.GetLeadingTrivia()[0]; 1365var trivia = tree.GetCompilationUnitRoot().EndOfFileToken.GetLeadingTrivia()[0]; 1369var parentTrivia = trivia.GetStructure().ParentTrivia; 1380Assert.Equal(default(SyntaxTrivia), def.ParentTrivia); 1382var trivia = SyntaxFactory.Trivia(def); 1390var tokenTrivia = token.TrailingTrivia[0]; 1392var tokenStructuredParentTrivia = tokenStructuredTrivia.ParentTrivia; 1841SyntaxTrivia trivia = new SyntaxTrivia(); 1959var tt0 = someNode.Identifier.TrailingTrivia[0]; 1960var tt1 = someNode.Identifier.TrailingTrivia[1]; 1969var tr0 = str0.ParentTrivia; 1972var tr1 = str1.ParentTrivia; 1996var tt0 = someNode.Identifier.TrailingTrivia[0]; 1997var tt1 = someNode.Identifier.TrailingTrivia[1]; 2006var tr0 = str0.ParentTrivia; 2009var tr1 = str1.ParentTrivia; 2385var twoSpace = SyntaxFactory.Whitespace(" "); 2395var trivia = expr.DescendantTokens().First(t => t.Text == "a").TrailingTrivia[0]; 2396var twoSpaces = SyntaxFactory.Whitespace(" "); 2405var twoSpaces = SyntaxFactory.Whitespace(" "); 2417var comment1 = leadingTrivia[0]; 2420var newComment1 = SyntaxFactory.ParseLeadingTrivia("/* a */")[0]; 2421var newComment2 = SyntaxFactory.ParseLeadingTrivia("/* b */")[0]; 2429var ex3 = ex.ReplaceTrivia(comment1, new SyntaxTrivia[] { }); 2439var comment1 = leadingTrivia[0]; 2442var newComment1 = SyntaxFactory.ParseLeadingTrivia("/* a */")[0]; 2443var newComment2 = SyntaxFactory.ParseLeadingTrivia("/* b */")[0]; 2456var trivia = id.TrailingTrivia[0]; 2457var twoSpace = SyntaxFactory.Whitespace(" "); 3460var trivia = tree.GetCompilationUnitRoot().FindTrivia(code.IndexOf("#r", StringComparison.Ordinal)); // ReferenceDirective. 3568var trivia = root.DescendantTrivia().First(); 3587var rootTrivia = root.FindTrivia(0); 3592var methodTrivia = method.FindTrivia(0); 3593Assert.Equal(default(SyntaxTrivia), methodTrivia); 3599var emptyWhitespace = SyntaxFactory.Whitespace(""); 3871var trivia = tree.GetCompilationUnitRoot().FindTrivia(position);
Syntax\SyntaxRewriterTests.cs (16)
200trivia.Kind() == SyntaxKind.WhitespaceTrivia ? default(SyntaxTrivia) : trivia); 213var rewriter = new RedRewriter(rewriteTrivia: trivia => default(SyntaxTrivia)); 469var comment1 = leadingTrivia[0]; 472var newComment1 = SyntaxFactory.ParseLeadingTrivia("/* a */")[0]; 473var newComment2 = SyntaxFactory.ParseLeadingTrivia("/* b */")[0]; 481var newRoot2 = root.ReplaceTrivia(comment1, new SyntaxTrivia[] { }); 496var comment1 = leadingTrivia[0]; 499var newComment1 = SyntaxFactory.ParseLeadingTrivia("/* a */")[0]; 500var newComment2 = SyntaxFactory.ParseLeadingTrivia("/* b */")[0]; 758private readonly Func<SyntaxTrivia, SyntaxTrivia> _rewriteTrivia; 763Func<SyntaxTrivia, SyntaxTrivia> rewriteTrivia = null) 782public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia) 784var visited = base.VisitTrivia(trivia);
Syntax\SyntaxTriviaListTests.cs (19)
61var elementA = list[0]; 62var elementB = list[1]; 63var elementC = list[2]; 69var triviaD = SyntaxFactory.ParseLeadingTrivia("/*D*/")[0]; 70var triviaE = SyntaxFactory.ParseLeadingTrivia("/*E*/")[0]; 156newList = list.ReplaceRange(elementA, new SyntaxTrivia[] { }); 160newList = list.ReplaceRange(elementB, new SyntaxTrivia[] { }); 164newList = list.ReplaceRange(elementC, new SyntaxTrivia[] { }); 175Assert.Throws<ArgumentOutOfRangeException>(() => list.Add(default(SyntaxTrivia))); 176Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(0, default(SyntaxTrivia))); 177Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxTrivia>)null)); 178Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxTrivia>)null)); 179Assert.Throws<ArgumentNullException>(() => list.ReplaceRange(elementA, (IEnumerable<SyntaxTrivia>)null)); 193var triviaD = SyntaxFactory.ParseLeadingTrivia("/*D*/")[0]; 194var triviaE = SyntaxFactory.ParseLeadingTrivia("/*E*/")[0]; 223Assert.Throws<ArgumentOutOfRangeException>(() => list.Add(default(SyntaxTrivia))); 224Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(0, default(SyntaxTrivia))); 225Assert.Throws<ArgumentNullException>(() => list.AddRange((IEnumerable<SyntaxTrivia>)null)); 226Assert.Throws<ArgumentNullException>(() => list.InsertRange(0, (IEnumerable<SyntaxTrivia>)null));
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CompilationTestUtils.cs (1)
490foreach (var trivia in token.TrailingTrivia)
Microsoft.CodeAnalysis.CSharp.Workspaces (171)
Classification\Worker.cs (5)
63private void AddClassification(SyntaxTrivia trivia, string type) 193var trivia = enumerator.Current; 205private void ClassifyTrivia(SyntaxTrivia trivia, SyntaxTriviaList triviaList) 273private void ClassifyConflictMarker(SyntaxTrivia trivia) 276private void ClassifyDisabledText(SyntaxTrivia trivia, SyntaxTriviaList triviaList)
Classification\Worker_DocumentationComments.cs (2)
68foreach (var t in triviaList) 83private void ClassifyExteriorTrivia(SyntaxTrivia trivia)
Classification\Worker_Preprocesser.cs (3)
82foreach (var trivia in lastToken.TrailingTrivia) 93foreach (var trivia in node.EndOfDirectiveToken.LeadingTrivia) 99private void ClassifyPreprocessorTrivia(SyntaxTrivia trivia, bool allowComments)
CodeGeneration\CSharpSyntaxGenerator.cs (6)
43internal override SyntaxTrivia ElasticMarker => SyntaxFactory.ElasticMarker; 48internal override SyntaxTrivia Whitespace(string text) 69internal override SyntaxTrivia Trivia(SyntaxNode node) 92internal override SyntaxNode? DocumentationCommentTriviaWithUpdatedContent(SyntaxTrivia trivia, IEnumerable<SyntaxNode> content) 3054internal override bool IsRegularOrDocComment(SyntaxTrivia trivia) 3627static IEnumerable<IEnumerable<SyntaxTrivia>> splitIntoLines(SyntaxTriviaList triviaList)
OrganizeImports\CSharpOrganizeImportsService.Rewriter.cs (1)
22private readonly SyntaxTrivia _fallbackTrivia = CSharpSyntaxGeneratorInternal.Instance.EndOfLine(options.NewLine);
Rename\CSharpRenameRewriterLanguageService.cs (4)
650private SyntaxToken RenameInTrivia(SyntaxToken token, IEnumerable<SyntaxTrivia> leadingOrTrailingTriviaList) 663private SyntaxTrivia RenameInCommentTrivia(SyntaxTrivia trivia) 670var newTrivia = SyntaxFactory.Comment(replacedString);
Simplification\CSharpSimplificationService.Expander.cs (1)
33private static readonly SyntaxTrivia s_oneWhitespaceSeparator = SyntaxTrivia(SyntaxKind.WhitespaceTrivia, " ");
Simplification\CSharpSimplificationService.NodesAndTokensToReduceComputer.cs (2)
120public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (4)
46static bool IsAnyCodeDirective(SyntaxTrivia trivia) 85var parentTrivia = conditionalDirective.ParentTrivia; 90var nextTrivia = parentToken.LeadingTrivia[triviaIndex + 1]; 103foreach (var closeBraceDirective in closeBraceLeadingDirectives)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberAccessExpressionSyntaxExtensions.cs (2)
35private static IEnumerable<SyntaxTrivia> WithoutElasticTrivia(IEnumerable<SyntaxTrivia> list)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (10)
58public static IEnumerable<SyntaxTrivia> GetAllPrecedingTriviaToPreviousToken( 68public static IEnumerable<SyntaxTrivia> GetAllPrecedingTriviaToPreviousToken( 532foreach (var trivia in list) 548SyntaxTrivia trivia, 655public static ImmutableArray<SyntaxTrivia> GetLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode 661public static TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode 664public static ImmutableArray<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode 670public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode 877IEnumerable<SyntaxTrivia> leadingTrivia, 878IEnumerable<SyntaxTrivia> trailingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.SingleLineRewriter.cs (1)
28token = token.WithLeadingTrivia(Enumerable.Empty<SyntaxTrivia>());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (4)
180public static IEnumerable<SyntaxTrivia> GetAllTrailingTrivia(this SyntaxToken token) 182foreach (var trivia in token.TrailingTrivia) 220IEnumerable<SyntaxTrivia> leadingTrivia, 221IEnumerable<SyntaxTrivia> trailingTrivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (3)
183var trivia = root.FindTrivia(position); 226var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position); 496var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position, findInsideTrivia: false);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTriviaExtensions.cs (24)
21public static void Deconstruct(this SyntaxTrivia trivia, out SyntaxKind kind) 24public static bool IsSingleOrMultiLineComment(this SyntaxTrivia trivia) 27public static bool IsRegularComment(this SyntaxTrivia trivia) 30public static bool IsWhitespaceOrSingleOrMultiLineComment(this SyntaxTrivia trivia) 33public static bool IsRegularOrDocComment(this SyntaxTrivia trivia) 36public static bool IsSingleLineComment(this SyntaxTrivia trivia) 39public static bool IsMultiLineComment(this SyntaxTrivia trivia) 42public static bool IsShebangDirective(this SyntaxTrivia trivia) 45public static bool IsCompleteMultiLineComment(this SyntaxTrivia trivia) 54public static bool IsDocComment(this SyntaxTrivia trivia) 57public static bool IsSingleLineDocComment(this SyntaxTrivia trivia) 60public static bool IsMultiLineDocComment(this SyntaxTrivia trivia) 63public static string GetCommentText(this SyntaxTrivia trivia) 119public static string AsString(this IEnumerable<SyntaxTrivia> trivia) 135public static int GetFullWidth(this IEnumerable<SyntaxTrivia> trivia) 144public static bool IsWhitespaceOrEndOfLine(this SyntaxTrivia trivia) 147public static bool IsEndOfLine(this SyntaxTrivia trivia) 150public static bool IsWhitespace(this SyntaxTrivia trivia) 153public static SyntaxTrivia GetPreviousTrivia( 154this SyntaxTrivia trivia, SyntaxTree syntaxTree, CancellationToken cancellationToken, bool findInsideTrivia = false) 165public static IEnumerable<SyntaxTrivia> FilterComments(this IEnumerable<SyntaxTrivia> trivia, bool addElasticMarker) 168foreach (var t in trivia) 201public static bool IsPragmaDirective(this SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTriviaListExtensions.cs (10)
18public static SyntaxTrivia? GetFirstNewLine(this SyntaxTriviaList triviaList) 25public static SyntaxTrivia? GetLastComment(this SyntaxTriviaList triviaList) 32public static SyntaxTrivia? GetLastCommentOrWhitespace(this SyntaxTriviaList triviaList) 42public static IEnumerable<SyntaxTrivia> SkipInitialWhitespace(this IEnumerable<SyntaxTrivia> triviaList) 45private static ImmutableArray<ImmutableArray<SyntaxTrivia>> GetLeadingBlankLines(SyntaxTriviaList triviaList) 47using var result = TemporaryArray<ImmutableArray<SyntaxTrivia>>.Empty; 48using var currentLine = TemporaryArray<SyntaxTrivia>.Empty; 49foreach (var trivia in triviaList) 78public static IEnumerable<SyntaxTrivia> TakeRange(this SyntaxTriviaList triviaList, int start, int end)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\CSharpStructuredTriviaFormatEngine.cs (2)
17SyntaxTrivia trivia, 29SyntaxTrivia trivia,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.cs (34)
20private SyntaxTrivia _newLine; 37protected override bool IsWhitespace(SyntaxTrivia trivia) 40protected override bool IsEndOfLine(SyntaxTrivia trivia) 49protected override SyntaxTrivia CreateWhitespace(string text) 52protected override SyntaxTrivia CreateEndOfLine() 62protected override LineColumnRule GetLineColumnRuleBetween(SyntaxTrivia trivia1, LineColumnDelta existingWhitespaceBetween, bool implicitLineBreak, SyntaxTrivia trivia2, CancellationToken cancellationToken) 108var previous = trivia2; 177protected override bool ContainsImplicitLineBreak(SyntaxTrivia trivia) 191private bool IsStartOrEndOfFile(SyntaxTrivia trivia1, SyntaxTrivia trivia2) 205private static bool IsMultilineComment(SyntaxTrivia trivia1) 208private bool TryFormatMultiLineCommentTrivia(LineColumn lineColumn, SyntaxTrivia trivia, out SyntaxTrivia result) 230var firstTrivia = multilineCommentTrivia.First(); 241LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<SyntaxTrivia> changes, 249if (TryFormatMultiLineCommentTrivia(lineColumn, trivia, out var newComment)) 260LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<TextChange> changes, CancellationToken cancellationToken) 267if (TryFormatMultiLineCommentTrivia(lineColumn, trivia, out var newComment)) 276private SyntaxTrivia FormatDocumentComment(LineColumn lineColumn, SyntaxTrivia trivia) 300var newTrivia = singleLineDocumentationCommentExteriorCommentRewriter.VisitTrivia(trivia); 316var newMultiLineTrivia = multiLineDocumentationCommentExteriorCommentRewriter.VisitTrivia(trivia); 322LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<SyntaxTrivia> changes, CancellationToken cancellationToken) 338var formattedTrivia = SyntaxFactory.Trivia((StructuredTriviaSyntax)result.GetFormattedRoot(cancellationToken)); 344var docComment = FormatDocumentComment(lineColumn, trivia); 351LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<TextChange> changes, CancellationToken cancellationToken) 372var formattedTrivia = SyntaxFactory.Trivia((StructuredTriviaSyntax)result.GetFormattedRoot(cancellationToken)); 376var docComment = FormatDocumentComment(lineColumn, trivia); 385protected override bool LineContinuationFollowedByWhitespaceComment(SyntaxTrivia trivia, SyntaxTrivia nextTrivia) 394protected override bool IsVisualBasicComment(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (4)
33public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia) 57var parsedNewTrivia = SyntaxFactory.DocumentationCommentExterior(newTriviaText); 66private static bool IsBeginningOrEndOfDocumentComment(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.cs (3)
99foreach (var trivia in list) 135private static void AnalyzeLineBreak(SyntaxTrivia trivia, ref AnalysisResult result) 152private static void AnalyzeWhitespacesInTrivia(SyntaxTrivia trivia, ref AnalysisResult result)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.cs (12)
107private static bool OnElastic(SyntaxTrivia trivia) 112foreach (var t in structure.DescendantTrivia()) 125private bool OnWhitespace(SyntaxTrivia trivia) 154private bool OnEndOfLine(SyntaxTrivia trivia, int currentIndex) 189private readonly bool OnComment(SyntaxTrivia trivia) 213private static bool OnSkippedTokensOrText(SyntaxTrivia trivia) 224private bool OnRegion(SyntaxTrivia trivia, int currentIndex) 246private bool OnPreprocessor(SyntaxTrivia trivia, int currentIndex) 268private bool OnTouchedNoisyCharacter(SyntaxTrivia trivia) 309private bool OnDisabledTextTrivia(SyntaxTrivia trivia, int index) 323private static bool ShouldFormatSingleLineDocumentationComment(int indentation, int tabSize, SyntaxTrivia trivia) 332foreach (var xmlTrivia in token.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaRewriter.cs (1)
118var trivia = triviaList[i];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (1)
36public static string ContentBeforeLastNewLine(this IEnumerable<SyntaxTrivia> trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (3)
255var firstNonWhitespaceTrivia = triviaList.FirstOrDefault(trivia => !IsWhitespace(trivia)); 480private static bool IsWhitespace(SyntaxTrivia trivia) 486private static int GetNumberOfLines(IEnumerable<SyntaxTrivia> triviaList)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (2)
299foreach (var trivia in triviaList) 305static void ProcessTrivia(ArrayBuilder<SuppressOperation> list, SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpFileBannerFacts.cs (2)
21public override SyntaxTrivia CreateTrivia(SyntaxTrivia trivia, string text)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (10)
40public SyntaxTrivia ElasticMarker 43public SyntaxTrivia ElasticCarriageReturnLineFeed 1105var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position, findInsideTrivia: false); 1217public bool IsRegularComment(SyntaxTrivia trivia) 1220public bool IsDocumentationComment(SyntaxTrivia trivia) 1223public bool IsElastic(SyntaxTrivia trivia) 1226public bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes) 1229public bool IsDocumentationCommentExteriorTrivia(SyntaxTrivia trivia) 1373public bool IsPreprocessorDirective(SyntaxTrivia trivia) 1440public SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesOrganizer.cs (3)
21SyntaxTrivia fallbackTrivia, 108SyntaxTrivia newLineTrivia, 159private static void EnsureNewLines(IList<SyntaxNode> list, SyntaxTrivia newLineTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (2)
114private static SyntaxTrivia ReplaceUnterminatedConstructs(SyntaxTrivia skippedTokensTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (3)
452IEnumerable<SyntaxTrivia> trivia; 457ComputePositionAndTriviaForRemoveAttributeList(attributeList, (SyntaxTrivia t) => t.IsKind(SyntaxKind.EndOfLineTrivia), out positionOfRemovedNode, out trivia); 596var lastEndIf = closeBraceTrivia.LastOrDefault(t => t.GetStructure() is EndIfDirectiveTriviaSyntax);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (3)
36protected override IndentationResult? GetDesiredIndentationWorker(Indenter indenter, SyntaxToken? tokenOpt, SyntaxTrivia? triviaOpt) 40private static IndentationResult? TryGetDesiredIndentation(Indenter indenter, SyntaxTrivia? triviaOpt) 54var trivia = triviaOpt.Value;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSyntaxGeneratorInternal.cs (4)
33public override SyntaxTrivia CarriageReturnLineFeed 36public override SyntaxTrivia ElasticCarriageReturnLineFeed 45public override SyntaxTrivia EndOfLine(string text) 48public override SyntaxTrivia SingleLineComment(string text)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (1)
EmbeddedLanguages\VirtualChars\CSharpVirtualCharServiceTests.cs (1)
124var skippedTrivia = namespaceDeclaration.OpenBraceToken.TrailingTrivia.Single(t => t.Kind() is SyntaxKind.SkippedTokensTrivia);
Microsoft.CodeAnalysis.EditorFeatures (5)
SplitComment\ISplitCommentService.cs (1)
13bool IsAllowed(SyntaxNode root, SyntaxTrivia trivia);
SplitComment\SplitCommentCommandHandler.cs (3)
184ITextView textView, LineFormattingOptions options, ITextSnapshotLine triviaLine, SyntaxTrivia trivia, int position) 205private static string GetCommentPrefix(ITextSnapshot snapshot, SyntaxTrivia trivia, int position) 220private static string GetWhitespaceAfterCommentPrefix(SyntaxTrivia trivia, ITextSnapshotLine triviaLine, string commentPrefix, int position)
TextStructureNavigation\AbstractTextStructureNavigatorProvider.cs (1)
21protected abstract bool ShouldSelectEntireTriviaFromStart(SyntaxTrivia trivia);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
Structure\AbstractSyntaxTriviaStructureProviderTests.cs (1)
23var trivia = root.FindTrivia(position, findInsideTrivia: true);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
CodeGeneration\CodeGenerationTests.CSharp.cs (1)
1404var eol = SyntaxFactory.EndOfLine(@"");
CodeGeneration\CodeGenerationTests.VisualBasic.cs (1)
1474var eol = VB.SyntaxFactory.EndOfLine(@"");
Microsoft.CodeAnalysis.Features (162)
AddFileBanner\AbstractAddFileBannerCodeRefactoringProvider.cs (3)
98private static string GetEquivalenceKey(Document document, ImmutableArray<SyntaxTrivia> banner) 109private static ImmutableArray<SyntaxTrivia> GetBannerFromEquivalenceKey(string equivalenceKey, Document document) 122private async Task<ImmutableArray<SyntaxTrivia>> TryGetBannerAsync(
AddFileBanner\AbstractAddFileBannerNewDocumentFormattingProvider.cs (1)
30var newLineTrivia = SyntaxGeneratorInternal.EndOfLine(options.FormattingOptions.NewLine);
AddFileBanner\AddFileBannerHelpers.cs (7)
48private static ImmutableArray<SyntaxTrivia> UpdateEmbeddedFileNames( 51ImmutableArray<SyntaxTrivia> banner, 52Func<SyntaxTrivia, string, SyntaxTrivia> createTrivia) 59var result = new FixedSizeArrayBuilder<SyntaxTrivia>(banner.Length); 60foreach (var trivia in banner) 62var updated = createTrivia(trivia, trivia.ToFullString().Replace(sourceName, destinationName));
ChangeSignature\AbstractChangeSignatureService.cs (5)
971protected ImmutableArray<SyntaxTrivia> GetPermutedDocCommentTrivia(SyntaxNode node, ImmutableArray<SyntaxNode> permutedParamNodes, LanguageServices services, LineFormattingOptions options) 973var updatedLeadingTrivia = ImmutableArray.CreateBuilder<SyntaxTrivia>(); 978foreach (var trivia in node.GetLeadingTrivia()) 1018var newTrivia = Generator.Trivia(newDocComments); 1035var newTrivia = Generator.Trivia(extraDocComments);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.cs (4)
66protected abstract bool IsEndOfLine(SyntaxTrivia trivia); 69protected abstract bool IsAnyPragmaDirectiveForId(SyntaxTrivia trivia, string id, out bool enableDirective, out bool hasMultipleIds); 70protected abstract SyntaxTrivia TogglePragmaDirective(SyntaxTrivia trivia);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaHelpers.cs (10)
65private static int GetPositionForPragmaInsertion(ImmutableArray<SyntaxTrivia> triviaList, TextSpan currentDiagnosticSpan, AbstractSuppressionCodeFixProvider fixer, bool isStartToken, out SyntaxTrivia triviaAtIndex) 71bool shouldConsiderTrivia(SyntaxTrivia trivia) 81var trivia = triviaList[index]; 112var index = GetPositionForPragmaInsertion(trivia, currentDiagnosticSpan, fixer, isStartToken: true, triviaAtIndex: out var insertAfterTrivia); 136private static bool IsEndOfLineOrHasLeadingEndOfLine(SyntaxTrivia trivia, AbstractSuppressionCodeFixProvider fixer) 142private static bool IsEndOfLineOrHasTrailingEndOfLine(SyntaxTrivia trivia, AbstractSuppressionCodeFixProvider fixer) 148private static bool IsEndOfLineOrContainsEndOfLine(SyntaxTrivia trivia, AbstractSuppressionCodeFixProvider fixer) 163ImmutableArray<SyntaxTrivia> trivia; 174var index = GetPositionForPragmaInsertion(trivia, currentDiagnosticSpan, fixer, isStartToken: false, triviaAtIndex: out var insertBeforeTrivia);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (5)
125bool shouldIncludeTrivia(SyntaxTrivia t) => isStartToken ? t.FullSpan.End <= diagnosticSpan.Start : t.FullSpan.Start >= diagnosticSpan.End; 133foreach (var trivia in filteredTriviaList) 188var triviaToToggle = triviaList.ElementAt(indexOfTriviaToRemoveOrToggle); 190var toggledTrivia = fixer.TogglePragmaDirective(triviaToToggle); 207var trivia = _suppressionTargetInfo.StartToken.LeadingTrivia.ElementAt(indexOfPragma);
CodeLens\CodeLensReferencesService.cs (1)
182var parentTrivia = structuredTriviaSyntax.ParentTrivia;
CodeRefactorings\MoveType\AbstractMoveTypeService.MoveTypeEditor.cs (1)
174foreach (var trivia in member.GetLeadingTrivia())
ConvertLinq\ConvertForEachToLinqQuery\ExtendedSyntaxNode.cs (4)
13IEnumerable<SyntaxTrivia> extraLeadingComments, 14IEnumerable<SyntaxTrivia> extraTrailingComments) 18public ImmutableArray<SyntaxTrivia> ExtraLeadingComments { get; } = extraLeadingComments.ToImmutableArray(); 20public ImmutableArray<SyntaxTrivia> ExtraTrailingComments { get; } = extraTrailingComments.ToImmutableArray();
DocumentationComments\AbstractDocumentationCommentSnippetService.cs (2)
30protected abstract bool IsEndOfLineTrivia(SyntaxTrivia trivia); 303var trivia = syntaxTree.GetRoot(cancellationToken).FindTrivia(position, findInsideTrivia: false);
EmbeddedLanguages\Classification\AbstractEmbeddedLanguageClassificationService.cs (2)
149foreach (var trivia in triviaList) 153private void ProcessTrivia(SyntaxTrivia trivia)
EmbeddedLanguages\EmbeddedLanguageDetector.cs (2)
123foreach (var trivia in list) 135SyntaxTrivia trivia,
ExtractMethod\AbstractSyntaxTriviaService.cs (10)
65Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> triviaList) 76var emptyList = SpecializedCollections.EmptyEnumerable<SyntaxTrivia>(); 93private static Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> GetTriviaAtEdges(Dictionary<TriviaLocation, SyntaxToken> tokens, TextSpan textSpan) 98var triviaList = new Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> 121private static (List<SyntaxTrivia>, List<SyntaxTrivia>) SplitTrivia( 124Func<SyntaxTrivia, bool> conditionToLeftAtCallSite) 126var triviaLeftAtCallSite = new List<SyntaxTrivia>(); 127var triviaMovedToDefinition = new List<SyntaxTrivia>(); 129foreach (var trivia in token1.TrailingTrivia.Concat(token2.LeadingTrivia))
ExtractMethod\AbstractSyntaxTriviaService.Result.cs (8)
23private readonly Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> _triviaList; 29Dictionary<TriviaLocation, IEnumerable<SyntaxTrivia>> triviaList) 73private LeadingTrailingTriviaPair GetTrailingAndLeadingTrivia(IEnumerable<SyntaxTrivia> trivia) 87private int GetFirstEndOfLineIndex(List<SyntaxTrivia> list) 144IEnumerable<SyntaxTrivia> trivia) 243private static IEnumerable<SyntaxTrivia> CreateTriviaListFromTo( 244List<SyntaxTrivia> list, 267private static IEnumerable<SyntaxTrivia> ResolveTrivia(
ExtractMethod\ISyntaxTriviaService.cs (3)
29public IEnumerable<SyntaxTrivia> LeadingTrivia { get; set; } 30public IEnumerable<SyntaxTrivia> TrailingTrivia { get; set; } 34internal delegate IEnumerable<SyntaxTrivia> TriviaResolver(TriviaLocation location, PreviousNextTokenPair tokenPair, Dictionary<SyntaxToken, LeadingTrailingTriviaPair> triviaMap);
ExtractMethod\MethodExtractor.TriviaResult.cs (15)
52protected IEnumerable<SyntaxTrivia> FilterTriviaList(IEnumerable<SyntaxTrivia> list) 64protected IEnumerable<SyntaxTrivia> RemoveBlankLines(IEnumerable<SyntaxTrivia> list) 67var currentLine = new List<SyntaxTrivia>(); 68var result = new List<SyntaxTrivia>(); 73foreach (var trivia in list) 109protected IEnumerable<SyntaxTrivia> RemoveLeadingElasticBeforeEndOfLine(IEnumerable<SyntaxTrivia> list) 111var trivia = list.FirstOrDefault(); 132protected IEnumerable<SyntaxTrivia> MergeLineBreaks(IEnumerable<SyntaxTrivia> list) 136var stack = new Stack<SyntaxTrivia>(); 139foreach (var trivia in list) 154var top = stack.Peek();
InvertIf\AbstractInvertIfCodeRefactoringProvider.cs (8)
618IEnumerable<SyntaxTrivia> GetTriviaAfterSpace(IEnumerable<SyntaxTrivia> syntaxTrivias) 623IEnumerable<SyntaxTrivia> GetTriviaUntilSpace(IEnumerable<SyntaxTrivia> syntaxTrivias) 628IEnumerable<SyntaxTrivia> GetTrailingSpace(IEnumerable<SyntaxTrivia> syntaxTrivias) 633IEnumerable<SyntaxTrivia> GetLeadingSpace(IEnumerable<SyntaxTrivia> syntaxTrivias)
MetadataAsSource\AbstractMetadataAsSourceService.AbstractMetadataFormattingRule.cs (2)
38protected int GetNumberOfLines(IEnumerable<SyntaxTrivia> triviaList) 44foreach (var trivia in triviaList)
ReplaceMethodWithProperty\AbstractReplaceMethodWithPropertyService.cs (1)
75private static void AddParamListTriviaIfNeeded(ISyntaxFacts syntaxFacts, SyntaxNode methodDeclaration, List<SyntaxTrivia> finalLeadingTrivia)
SpellCheck\AbstractSpellCheckSpanService.cs (2)
243foreach (var trivia in triviaList) 247private void ProcessTrivia(SyntaxTrivia trivia, CancellationToken cancellationToken)
src\Analyzers\Core\Analyzers\FileHeaders\AbstractFileHeaderHelper.cs (4)
19protected abstract ReadOnlyMemory<char> GetTextContextOfComment(SyntaxTrivia commentTrivia); 51var trivia = firstToken.LeadingTrivia[i]; 136where T : IReadOnlyList<SyntaxTrivia> 140var currentTrivia = triviaList[index];
src\Analyzers\Core\Analyzers\FileHeaders\FileHeader.cs (1)
85/// start of the first line after any directive trivia (<see cref="SyntaxTrivia.IsDirective"/>) to account for
src\Analyzers\Core\Analyzers\NewLines\ConsecutiveStatementPlacement\AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs (1)
94foreach (var trivia in nextToken.LeadingTrivia)
src\Analyzers\Core\Analyzers\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesDiagnosticAnalyzer.cs (3)
74if (!ContainsMultipleBlankLines(token, out var badTrivia)) 86private bool ContainsMultipleBlankLines(SyntaxToken token, out SyntaxTrivia firstBadTrivia) 133var trivia = triviaList[index];
src\Analyzers\Core\Analyzers\RemoveUnnecessaryImports\AbstractRemoveUnnecessaryImportsDiagnosticAnalyzer.cs (2)
71protected abstract bool IsRegularCommentOrDocComment(SyntaxTrivia trivia); 182foreach (var trivia in node.GetTrailingTrivia())
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (19)
157using var _1 = PooledDictionary<string, List<(SyntaxTrivia pragma, bool isDisable)>>.GetInstance(out var idToPragmasMap); 158using var _2 = ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)>.GetInstance(out var sortedPragmasWithIds); 159using var _3 = PooledDictionary<SyntaxTrivia, bool>.GetInstance(out var pragmasToIsUsedMap); 228PooledDictionary<string, List<(SyntaxTrivia pragma, bool isDisable)>> idToPragmasMap, 229PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap, 230ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)> sortedPragmasWithIds, 241foreach (var trivia in root.DescendantTrivia(node => node.ContainsDirectives)) 510PooledDictionary<string, List<(SyntaxTrivia pragma, bool isDisable)>> idToPragmasMap, 511PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap, 546PooledDictionary<string, List<(SyntaxTrivia pragma, bool isDisable)>> idToPragmasMap, 547PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap) 560SyntaxTrivia? lastEnablePragma = null; 609PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap, 610ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)> sortedPragmasWithIds, 631PooledDictionary<SyntaxTrivia, bool> pragmasToIsUsedMap, 632ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)> sortedPragmasWithIds, 678SyntaxTrivia pragma, 679ArrayBuilder<(SyntaxTrivia pragma, ImmutableArray<string> ids, bool isDisable)> sortedPragmasWithIds, 680out SyntaxTrivia togglePragma)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
702foreach (var trivia in firstToken.LeadingTrivia)
src\Analyzers\Core\Analyzers\UseConditionalExpression\UseConditionalExpressionHelpers.cs (1)
70foreach (var trivia in triviaList)
src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (3)
103var startTrivia = root.FindTrivia(startLine.Start); 104var firstMiddleTrivia = root.FindTrivia(firstMiddleLine.Start); 105var secondMiddleTrivia = root.FindTrivia(secondMiddleLine.Start);
src\Analyzers\Core\CodeFixes\FileHeaders\AbstractFileHeaderCodeFixProvider.cs (4)
58internal static async Task<SyntaxNode> GetTransformedSyntaxRootAsync(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, Document document, string? fileHeaderTemplate, CancellationToken cancellationToken) 94private static SyntaxNode ReplaceHeader(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, SyntaxNode root, string expectedFileHeader) 119var triviaLine = triviaList[i]; 176private static SyntaxNode AddHeader(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, SyntaxNode root, string expectedFileHeader)
src\Analyzers\Core\CodeFixes\ImplementInterface\AbstractImplementInterfaceService.cs (1)
75using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var trivia);
src\Analyzers\Core\CodeFixes\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesCodeFixProvider.cs (3)
65using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var builder); 71var trivia = triviaList[currentStart]; 141var trivia = triviaList[index];
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (1)
712var lastDirective = leadingTrivia.LastOrDefault(t => t.IsDirective);
src\Analyzers\Core\CodeFixes\UseObjectInitializer\AbstractUseObjectInitializerCodeFixProvider.cs (3)
55protected abstract SyntaxTrivia Whitespace(string text); 130private SyntaxTrivia IncreaseIndent(SyntaxTrivia whitespaceTrivia, SyntaxFormattingOptions options)
Structure\Syntax\AbstractSyntaxNodeStructureProvider.cs (1)
15SyntaxTrivia trivia,
Structure\Syntax\AbstractSyntaxStructureProvider.cs (1)
20SyntaxTrivia trivia,
Structure\Syntax\BlockSpanCollector.cs (1)
84foreach (var trivia in triviaList)
TaskList\AbstractTaskListService.cs (6)
19protected abstract bool PreprocessorHasComment(SyntaxTrivia trivia); 20protected abstract bool IsSingleLineComment(SyntaxTrivia trivia); 21protected abstract bool IsMultilineComment(SyntaxTrivia trivia); 26protected abstract void AppendTaskListItems(ImmutableArray<TaskListItemDescriptor> descriptors, SyntacticDocument document, SyntaxTrivia trivia, ArrayBuilder<TaskListItem> items); 79private bool ContainsComments(SyntaxTrivia trivia) 124SyntaxTrivia trivia, int postfixLength,
Wrapping\Edit.cs (2)
45foreach (var trivia in triviaList) 59SyntaxTrivia rightLeadingTrivia, SyntaxNodeOrToken right)
Wrapping\SeparatedSyntaxList\SeparatedSyntaxListCodeActionComputer.cs (8)
39private readonly SyntaxTrivia _afterOpenTokenIndentationTrivia; 49private readonly AsyncLazy<SyntaxTrivia> _singleIndentationTrivia; 58private readonly AsyncLazy<SyntaxTrivia> _braceIndentationTrivia; 123private async Task<SyntaxTrivia> GetIndentationTriviaAsync(WrappingStyle wrappingStyle, CancellationToken cancellationToken) 280var indentationTrivia = await GetIndentationTriviaAsync(wrappingStyle, cancellationToken).ConfigureAwait(false); 290WrappingStyle wrappingStyle, SyntaxTrivia indentationTrivia, int wrappingColumn, CancellationToken cancellationToken) 407var indentationTrivia = await GetIndentationTriviaAsync(wrappingStyle, cancellationToken).ConfigureAwait(false); 425WrappingStyle wrappingStyle, SyntaxTrivia indentationTrivia, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.Test.Utilities (10)
Diagnostics\SuppressMessageAttributeTests.DiagnosticAnalyzers.cs (1)
211foreach (var comment in comments)
Syntax\NodeHelpers.cs (7)
41public static string GetKind(this SyntaxTrivia n) 62public static bool IsComment(this SyntaxTrivia n) 67public static bool IsDocumentationComment(this SyntaxTrivia n) 72public static bool IsDisabledOrSkippedText(this SyntaxTrivia n) 118public static SyntaxNode GetRootNode(this SyntaxTrivia node) 169public static NodeInfo GetNodeInfo(this SyntaxTrivia trivia) 218private static NodeInfo.FieldInfo GetFieldInfo(PropertyInfo prop, SyntaxTrivia trivia)
Syntax\XmlHelpers.cs (2)
76public static void AddInfo(SyntaxTrivia node, XElement xml) 210public static XElement ToXml(this SyntaxTrivia trivia, SyntaxTree syntaxTree, XmlOptions options = null)
Microsoft.CodeAnalysis.UnitTests (20)
CommonSyntaxTests.cs (20)
89SyntaxTrivia trivia = CSharp.SyntaxFactory.Whitespace("test"); 105SyntaxTrivia trivia = VB.SyntaxFactory.Whitespace("test"); 116var csharpTrivia = csharpTriviaList.ElementAt(1); 123var commonTrivia = (SyntaxTrivia)csharpTrivia; //direct conversion 128var commonTrivia2 = commonTriviaList[1]; //from converted list 134var commonTrivia3 = commonTriviaList2[1]; //from converted token 137var csharpTrivia2 = (SyntaxTrivia)commonTrivia; //direct conversion 142var csharpTrivia3 = csharpTriviaList2.ElementAt(1); //from converted list 153var vbTrivia = vbTriviaList.ElementAt(1); 160var commonTrivia = (SyntaxTrivia)vbTrivia; //direct conversion 165var commonTrivia2 = commonTriviaList[1]; //from converted list 171var commonTrivia3 = commonTriviaList2[1]; //from converted token 174var vbTrivia2 = (SyntaxTrivia)commonTrivia; //direct conversion 179var vbTrivia3 = vbTriviaList2.ElementAt(1); //from converted list 190var trivia = CSharp.SyntaxFactory.Comment("c"); 201var trivia = VisualBasic.SyntaxFactory.CommentTrivia("c");
Microsoft.CodeAnalysis.VisualBasic (155)
Binding\BinderFactory.vb (1)
453Dim trivia As SyntaxTrivia = node.ParentTrivia
Binding\MemberSemanticModel.vb (2)
1271Dim trivia As SyntaxTrivia = DirectCast(current, DocumentationCommentTriviaSyntax).ParentTrivia 1983Dim trivia As SyntaxTrivia = DirectCast(node, DocumentationCommentTriviaSyntax).ParentTrivia
Compilation\DocumentationComments\UnprocessedDocumentationCommentFinder.vb (1)
130Public Overrides Sub VisitTrivia(trivia As SyntaxTrivia)
Compilation\SyntaxTreeSemanticModel.vb (1)
587Dim trivia As SyntaxTrivia = DirectCast(parent, DocumentationCommentTriviaSyntax).ParentTrivia
Compilation\VisualBasicCompilation.vb (2)
2323Dim isComment As Func(Of SyntaxTrivia, Boolean) = Function(trivia As SyntaxTrivia) trivia.Kind() = SyntaxKind.CommentTrivia
Generated\Syntax.xml.Main.Generated.vb (9)
42784Public Shared Function WhitespaceTrivia(text as String) As SyntaxTrivia 42800Public Shared Function EndOfLineTrivia(text as String) As SyntaxTrivia 42816Public Shared Function ColonTrivia(text as String) As SyntaxTrivia 42832Public Shared Function CommentTrivia(text as String) As SyntaxTrivia 42848Public Shared Function ConflictMarkerTrivia(text as String) As SyntaxTrivia 42864Public Shared Function LineContinuationTrivia(text as String) As SyntaxTrivia 42880Public Shared Function DocumentationCommentExteriorTrivia(text as String) As SyntaxTrivia 42896Public Shared Function DisabledTextTrivia(text as String) As SyntaxTrivia 42918Public Shared Function SyntaxTrivia(ByVal kind As SyntaxKind, text as String) As SyntaxTrivia
Syntax\StructuredTriviaSyntax.vb (3)
18Private _parentTrivia As SyntaxTrivia 24Friend Shared Function Create(trivia As SyntaxTrivia) As StructuredTriviaSyntax 32Public Overrides ReadOnly Property ParentTrivia As SyntaxTrivia Implements IStructuredTriviaSyntax.ParentTrivia
Syntax\SyntaxExtensions.vb (1)
19Public Function ToSyntaxTriviaList(sequence As IEnumerable(Of SyntaxTrivia)) As SyntaxTriviaList
Syntax\SyntaxFactory.vb (38)
17Public Shared ReadOnly Property CarriageReturnLineFeed As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.CarriageReturnLineFeed, SyntaxTrivia) 22Public Shared ReadOnly Property LineFeed As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.LineFeed, SyntaxTrivia) 27Public Shared ReadOnly Property CarriageReturn As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.CarriageReturn, SyntaxTrivia) 32Public Shared ReadOnly Property Space As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.Space, SyntaxTrivia) 37Public Shared ReadOnly Property Tab As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.Tab, SyntaxTrivia) 44Public Shared ReadOnly Property ElasticCarriageReturnLineFeed As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.ElasticCarriageReturnLineFeed, SyntaxTrivia) 51Public Shared ReadOnly Property ElasticLineFeed As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.ElasticLineFeed, SyntaxTrivia) 58Public Shared ReadOnly Property ElasticCarriageReturn As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.ElasticCarriageReturn, SyntaxTrivia) 64Public Shared ReadOnly Property ElasticSpace As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.ElasticSpace, SyntaxTrivia) 70Public Shared ReadOnly Property ElasticTab As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.ElasticTab, SyntaxTrivia) 77Public Shared ReadOnly Property ElasticMarker As SyntaxTrivia = CType(InternalSyntax.SyntaxFactory.ElasticZeroSpace, SyntaxTrivia) 78Private Shared ReadOnly s_elasticMarkerList As SyntaxTriviaList = SyntaxFactory.TriviaList(CType(InternalSyntax.SyntaxFactory.ElasticZeroSpace, SyntaxTrivia)) 85Public Shared Function EndOfLine(text As String) As SyntaxTrivia 86Return CType(InternalSyntax.SyntaxFactory.EndOfLine(text, elastic:=False), SyntaxTrivia) 95Public Shared Function ElasticEndOfLine(text As String) As SyntaxTrivia 96Return CType(InternalSyntax.SyntaxFactory.EndOfLine(text, elastic:=True), SyntaxTrivia) 101Public Shared Function EndOfLine(text As String, elastic As Boolean) As SyntaxTrivia 102Return CType(InternalSyntax.SyntaxFactory.EndOfLine(text, elastic), SyntaxTrivia) 110Public Shared Function Whitespace(text As String) As SyntaxTrivia 111Return CType(InternalSyntax.SyntaxFactory.Whitespace(text, elastic:=False), SyntaxTrivia) 120Public Shared Function ElasticWhitespace(text As String) As SyntaxTrivia 121Return CType(InternalSyntax.SyntaxFactory.Whitespace(text, elastic:=True), SyntaxTrivia) 126Public Shared Function Whitespace(text As String, elastic As Boolean) As SyntaxTrivia 127Return CType(InternalSyntax.SyntaxFactory.Whitespace(text, elastic), SyntaxTrivia) 189Friend Shared Function Token(kind As SyntaxKind, trailing As SyntaxTrivia, Optional text As String = Nothing) As SyntaxToken 203Friend Shared Function Token(leading As SyntaxTrivia, kind As SyntaxKind, trailing As SyntaxTrivia, Optional text As String = Nothing) As SyntaxToken
Syntax\SyntaxNodeFactories.vb (8)
340Friend Shared Function Identifier(leadingTrivia As SyntaxTrivia, text As String, isBracketed As Boolean, identifierText As String, typeCharacter As TypeCharacter, trailingTrivia As SyntaxTrivia) As SyntaxToken 356Friend Shared Function Identifier(leadingTrivia As SyntaxTrivia, text As String, trailingTrivia As SyntaxTrivia) As SyntaxToken 760Public Shared Function Trivia(node As StructuredTriviaSyntax) As SyntaxTrivia 836Public Shared Function TriviaList(trivia As SyntaxTrivia) As SyntaxTriviaList 844Public Shared Function TriviaList(ParamArray trivias As SyntaxTrivia()) As SyntaxTriviaList 852Public Shared Function TriviaList(trivias As IEnumerable(Of SyntaxTrivia)) As SyntaxTriviaList
Syntax\SyntaxNodePartials.vb (1)
32Dim tr As SyntaxTrivia
Syntax\SyntaxNodeRemover.vb (2)
86Private Shared Function IsEndOfLine(trivia As SyntaxTrivia) As Boolean 340Private Shared Function GetTriviaListAndIndex(trivia As SyntaxTrivia) As (triviaList As SyntaxTriviaList, Index As Integer)
Syntax\SyntaxNormalizer.vb (21)
18Private ReadOnly _eolTrivia As SyntaxTrivia 34Private _indentations As ArrayBuilder(Of SyntaxTrivia) 88Private Function GetIndentation(count As Integer) As SyntaxTrivia 91_indentations = ArrayBuilder(Of SyntaxTrivia).GetInstance(capacity) 190Dim currentTriviaList As ArrayBuilder(Of SyntaxTrivia) = ArrayBuilder(Of SyntaxTrivia).GetInstance() 241Dim structuredTrivia As SyntaxTrivia = Me.VisitStructuredTrivia(trivia) 330Private Function GetIndentationDepth(trivia As SyntaxTrivia) As Integer 338Private Function GetSpace() As SyntaxTrivia 342Private Function GetEndOfLine() As SyntaxTrivia 346Private Function NeedsSeparatorBetween(trivia As SyntaxTrivia) As Boolean 359Private Function NeedsLineBreakBetween(trivia As SyntaxTrivia, nextTrivia As SyntaxTrivia, isTrailingTrivia As Boolean) As Boolean 388Private Function NeedsLineBreakAfter(trivia As SyntaxTrivia) As Boolean 392Private Function NeedsLineBreakBefore(trivia As SyntaxTrivia) As Boolean 402Private Function NeedsIndentAfterLineBreak(trivia As SyntaxTrivia) As Boolean 618Private Function EndsInLineBreak(trivia As SyntaxTrivia) As Boolean 654Private Overloads Function VisitStructuredTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 661Dim result As SyntaxTrivia = VisitTrivia(trivia) 672End Function, Function(t As SyntaxTrivia) False)
Syntax\SyntaxReplacer.vb (35)
21Optional trivia As IEnumerable(Of SyntaxTrivia) = Nothing, 22Optional computeReplacementTrivia As Func(Of SyntaxTrivia, SyntaxTrivia, SyntaxTrivia) = Nothing) As SyntaxNode 39Optional trivia As IEnumerable(Of SyntaxTrivia) = Nothing, 40Optional computeReplacementTrivia As Func(Of SyntaxTrivia, SyntaxTrivia, SyntaxTrivia) = Nothing) As SyntaxToken 56Private ReadOnly _computeReplacementTrivia As Func(Of SyntaxTrivia, SyntaxTrivia, SyntaxTrivia) 60Private ReadOnly _triviaSet As HashSet(Of SyntaxTrivia) 72trivia As IEnumerable(Of SyntaxTrivia), 73computeReplacementTrivia As Func(Of SyntaxTrivia, SyntaxTrivia, SyntaxTrivia)) 81Me._triviaSet = If(trivia IsNot Nothing, New HashSet(Of SyntaxTrivia)(trivia), s_noTrivia) 98Private Shared ReadOnly s_noTrivia As HashSet(Of SyntaxTrivia) = New HashSet(Of SyntaxTrivia)() 174Public Overrides Function VisitListElement(trivia As SyntaxTrivia) As SyntaxTrivia 205Public Shared Function ReplaceTriviaInList(root As SyntaxNode, triviaInList As SyntaxTrivia, newTrivia As IEnumerable(Of SyntaxTrivia)) As SyntaxNode 209Public Shared Function InsertTriviaInList(root As SyntaxNode, triviaInList As SyntaxTrivia, newTrivia As IEnumerable(Of SyntaxTrivia), insertBefore As Boolean) As SyntaxNode 213Public Shared Function ReplaceTriviaInList(root As SyntaxToken, triviaInList As SyntaxTrivia, newTrivia As IEnumerable(Of SyntaxTrivia)) As SyntaxToken 217Public Shared Function InsertTriviaInList(root As SyntaxToken, triviaInList As SyntaxTrivia, newTrivia As IEnumerable(Of SyntaxTrivia), insertBefore As Boolean) As SyntaxToken 276Public Overrides Function VisitListElement(element As SyntaxTrivia) As SyntaxTrivia 379Private ReadOnly _originalTrivia As SyntaxTrivia 380Private ReadOnly _newTrivia As IEnumerable(Of SyntaxTrivia) 382Public Sub New(originalTrivia As SyntaxTrivia, newTrivia As IEnumerable(Of SyntaxTrivia), editKind As ListEditKind)
Syntax\VisualBasicSyntaxNode.vb (10)
278Private Shared Function CreateSyntaxError(tree As SyntaxTree, nodeOrToken As SyntaxTrivia, errorInfo As DiagnosticInfo) As Diagnostic 344Dim tr As SyntaxTrivia 398Optional trivia As IEnumerable(Of SyntaxTrivia) = Nothing, 399Optional computeReplacementTrivia As Func(Of SyntaxTrivia, SyntaxTrivia, SyntaxTrivia) = Nothing) As SyntaxNode 424Protected Overrides Function ReplaceTriviaInListCore(originalTrivia As SyntaxTrivia, newTrivia As IEnumerable(Of SyntaxTrivia)) As SyntaxNode 428Protected Overrides Function InsertTriviaInListCore(originalTrivia As SyntaxTrivia, newTrivia As IEnumerable(Of SyntaxTrivia), insertBefore As Boolean) As SyntaxNode
Syntax\VisualBasicSyntaxNode_TreeTraversalHelpers.vb (1)
23Public Shadows Function FindTrivia(textPosition As Integer, Optional findInsideTrivia As Boolean = False) As SyntaxTrivia
Syntax\VisualBasicSyntaxRewriter.vb (4)
60Public Overridable Function VisitTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 219Public Overridable Function VisitListElement(element As SyntaxTrivia) As SyntaxTrivia
Syntax\VisualBasicSyntaxTree.vb (2)
339Public Overrides Function GetDiagnostics(trivia As SyntaxTrivia) As IEnumerable(Of Diagnostic) 410Private Function InDocumentationComment(trivia As SyntaxTrivia) As Boolean
Syntax\VisualBasicSyntaxWalker.vb (1)
78Public Overridable Sub VisitTrivia(trivia As SyntaxTrivia)
VisualBasicExtensions.vb (12)
23''' Determines if <see cref="SyntaxTrivia"/> is of a specified kind. 29Public Function IsKind(trivia As SyntaxTrivia, kind As SyntaxKind) As Boolean 187''' Returns <see cref="SyntaxKind"/> for <see cref="SyntaxTrivia"/> from <see cref="SyntaxTrivia.RawKind"/> property. 190Public Function Kind(trivia As SyntaxTrivia) As SyntaxKind 270Friend Function Errors(trivia As SyntaxTrivia) As InternalSyntax.SyntaxDiagnosticInfoList 440Public Function ReplaceTrivia(token As SyntaxToken, oldTrivia As SyntaxTrivia, newTrivia As SyntaxTrivia) As SyntaxToken 448Public Function ReplaceTrivia(token As SyntaxToken, trivia As IEnumerable(Of SyntaxTrivia), computeReplacementTrivia As Func(Of SyntaxTrivia, SyntaxTrivia, SyntaxTrivia)) As SyntaxToken
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (81)
src\Analyzers\VisualBasic\Analyzers\FileHeaders\VisualBasicFileHeaderHelper.vb (1)
24Protected Overrides Function GetTextContextOfComment(commentTrivia As SyntaxTrivia) As ReadOnlyMemory(Of Char)
src\Analyzers\VisualBasic\Analyzers\RemoveUnnecessaryImports\VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb (1)
29Protected Overrides Function IsRegularCommentOrDocComment(trivia As SyntaxTrivia) As Boolean
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SingleLineRewriter.vb (1)
22token = token.WithLeadingTrivia(Enumerable.Empty(Of SyntaxTrivia)())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxNodeExtensions.vb (5)
405trivia As SyntaxTrivia, 438Public Function GetLeadingBlankLines(Of TSyntaxNode As SyntaxNode)(node As TSyntaxNode) As ImmutableArray(Of SyntaxTrivia) 448Public Function GetNodeWithoutLeadingBlankLines(Of TSyntaxNode As SyntaxNode)(node As TSyntaxNode, ByRef strippedTrivia As ImmutableArray(Of SyntaxTrivia)) As TSyntaxNode 453Public Function GetLeadingBannerAndPreprocessorDirectives(Of TSyntaxNode As SyntaxNode)(node As TSyntaxNode) As ImmutableArray(Of SyntaxTrivia) 463Public Function GetNodeWithoutLeadingBannerAndPreprocessorDirectives(Of TSyntaxNode As SyntaxNode)(node As TSyntaxNode, ByRef strippedTrivia As ImmutableArray(Of SyntaxTrivia)) As TSyntaxNode
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTreeExtensions.vb (3)
78Private Function GetTrailingColonTrivia(statement As StatementSyntax) As SyntaxTrivia? 121Public Function FindTriviaToLeft(syntaxTree As SyntaxTree, position As Integer, cancellationToken As CancellationToken) As SyntaxTrivia 125Private Function FindTriviaToLeft(nodeOrToken As SyntaxNodeOrToken, position As Integer) As SyntaxTrivia
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTriviaExtensions.vb (7)
11Public Function IsKind(trivia As SyntaxTrivia, kind1 As SyntaxKind, kind2 As SyntaxKind) As Boolean 17Public Function IsKind(trivia As SyntaxTrivia, kind1 As SyntaxKind, kind2 As SyntaxKind, kind3 As SyntaxKind) As Boolean 24Public Function IsWhitespaceOrEndOfLine(trivia As SyntaxTrivia) As Boolean 29Public Function IsWhitespace(trivia As SyntaxTrivia) As Boolean 34Public Function IsEndOfLine(trivia As SyntaxTrivia) As Boolean 39Public Function IsRegularOrDocComment(trivia As SyntaxTrivia) As Boolean 44Public Function IsPragmaDirective(trivia As SyntaxTrivia, ByRef isDisable As Boolean, ByRef isActive As Boolean, ByRef errorCodes As SeparatedSyntaxList(Of SyntaxNode)) As Boolean
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTriviaListExtensions.vb (1)
17Public Function WithoutLeadingWhitespaceOrEndOfLine(list As IEnumerable(Of SyntaxTrivia)) As SyntaxTriviaList
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicFileBannerFacts.vb (2)
28Public Overrides Function CreateTrivia(trivia As SyntaxTrivia, text As String) As SyntaxTrivia
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicSyntaxFacts.vb (9)
40Public ReadOnly Property ElasticMarker As SyntaxTrivia = SyntaxFactory.ElasticMarker Implements ISyntaxFacts.ElasticMarker 42Public ReadOnly Property ElasticCarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.ElasticCarriageReturnLineFeed Implements ISyntaxFacts.ElasticCarriageReturnLineFeed 1468Public Function IsPreprocessorDirective(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsPreprocessorDirective 1480Public Function IsRegularComment(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsRegularComment 1484Public Function IsDocumentationComment(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsDocumentationComment 1488Public Function IsElastic(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsElastic 1492Public Function IsPragmaDirective(trivia As SyntaxTrivia, ByRef isDisable As Boolean, ByRef isActive As Boolean, ByRef errorCodes As SeparatedSyntaxList(Of SyntaxNode)) As Boolean Implements ISyntaxFacts.IsPragmaDirective 1500Public Function IsDocumentationCommentExteriorTrivia(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsDocumentationCommentExteriorTrivia 1649Public Function GetContentFromDocumentationCommentTriviaSyntax(trivia As SyntaxTrivia) As SyntaxList(Of SyntaxNode) Implements ISyntaxFacts.GetContentFromDocumentationCommentTriviaSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\ImportsOrganizer.vb (6)
15newLineTrivia As SyntaxTrivia) As SyntaxList(Of ImportsStatementSyntax) 74newLineTrivia As SyntaxTrivia) As SyntaxList(Of ImportsStatementSyntax) 80Dim leadingTrivia As ImmutableArray(Of SyntaxTrivia) = Nothing 104Private Shared Sub EnsureNewLines(list As List(Of ImportsStatementSyntax), newLineTrivia As SyntaxTrivia) 118Private Shared Function GetExistingEndOfLineTrivia(list As List(Of ImportsStatementSyntax)) As SyntaxTrivia 119Dim endOfLine As SyntaxTrivia
src\Workspaces\VisualBasic\Portable\Formatting\DefaultOperationProvider.vb (4)
65Function(trivia As SyntaxTrivia) ColonOrLineContinuationTrivia(trivia)) 156Private Shared Function ColonOrLineContinuationTrivia(trivia As SyntaxTrivia) As Boolean 161Private Shared Function LastOrDefaultTrivia(triviaListPair As (SyntaxTriviaList, SyntaxTriviaList), predicate As Func(Of SyntaxTrivia, Boolean)) As SyntaxTrivia
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.vb (4)
63Private Shared Sub AnalyzeLineContinuation(trivia As SyntaxTrivia, ByRef result As AnalysisResult) 75Private Shared Sub AnalyzeLineBreak(previousTrivia As SyntaxTrivia, trivia As SyntaxTrivia, ByRef result As AnalysisResult) 90Private Shared Sub AnalyzeWhitespacesInTrivia(trivia As SyntaxTrivia, ByRef result As AnalysisResult)
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.vb (10)
100Private Shared Function OnElastic(trivia As SyntaxTrivia) As Boolean 105Private Function OnWhitespace(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 152Private Function OnEndOfLine(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 177Private Function OnLineContinuation(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 194Private Shared Function OnColon(trivia As SyntaxTrivia) As Boolean 203Private Function OnComment(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 229Private Shared Function OnSkippedTokensOrText(trivia As SyntaxTrivia) As Boolean 237Private Function OnRegion(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 255Private Shared Function OnPreprocessor(trivia As SyntaxTrivia) As Boolean 284Private Shared Function ShouldFormatDocumentationComment(indentation As Integer, tabSize As Integer, trivia As SyntaxTrivia) As Boolean
src\Workspaces\VisualBasic\Portable\Formatting\Engine\Trivia\VisualBasicTriviaFormatter.vb (24)
16Private ReadOnly _lineContinuationTrivia As SyntaxTrivia = SyntaxFactory.LineContinuationTrivia("_") 17Private _newLine As SyntaxTrivia 35Protected Overrides Function IsWhitespace(trivia As SyntaxTrivia) As Boolean 39Protected Overrides Function IsEndOfLine(trivia As SyntaxTrivia) As Boolean 51Protected Overrides Function CreateWhitespace(text As String) As SyntaxTrivia 55Protected Overrides Function CreateEndOfLine() As SyntaxTrivia 63Protected Overrides Function GetLineColumnRuleBetween(trivia1 As SyntaxTrivia, existingWhitespaceBetween As LineColumnDelta, implicitLineBreak As Boolean, trivia2 As SyntaxTrivia, cancellationToken As CancellationToken) As LineColumnRule 150Protected Overrides Function ContainsImplicitLineBreak(syntaxTrivia As SyntaxTrivia) As Boolean 154Private Function IsStartOrEndOfFile(trivia1 As SyntaxTrivia, trivia2 As SyntaxTrivia) As Boolean 159trivia As SyntaxTrivia, 160changes As ArrayBuilder(Of SyntaxTrivia), 175trivia As SyntaxTrivia, 195Private Function FormatLineContinuationTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 204trivia As SyntaxTrivia, 205changes As ArrayBuilder(Of SyntaxTrivia), 231trivia As SyntaxTrivia, 263Private Function FormatDocumentComment(lineColumn As LineColumn, trivia As SyntaxTrivia) As SyntaxTrivia 301Protected Overrides Function LineContinuationFollowedByWhitespaceComment(trivia As SyntaxTrivia, nextTrivia As SyntaxTrivia) As Boolean 305Protected Overrides Function IsVisualBasicComment(trivia As SyntaxTrivia) As Boolean
src\Workspaces\VisualBasic\Portable\Formatting\Engine\VisualBasicStructuredTriviaFormatEngine.vb (2)
15Public Shared Function FormatTrivia(trivia As SyntaxTrivia, 25Private Sub New(trivia As SyntaxTrivia,
src\Workspaces\VisualBasic\Portable\Formatting\Rules\ElasticTriviaFormattingRule.vb (1)
363Private Shared Function GetNumberOfLines(list As IEnumerable(Of SyntaxTrivia)) As Integer
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (18)
src\Analyzers\VisualBasic\CodeFixes\UseCollectionInitializer\VisualBasicUseCollectionInitializerCodeFixProvider.vb (1)
56Dim totalTrivia = ArrayBuilder(Of SyntaxTrivia).GetInstance()
src\Analyzers\VisualBasic\CodeFixes\UseObjectInitializer\VisualBasicUseObjectInitializerCodeFixProvider.vb (2)
45Protected Overrides Function Whitespace(text As String) As SyntaxTrivia 58Dim totalTrivia = ArrayBuilder(Of SyntaxTrivia).GetInstance()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationService.vb (3)
415Dim trivia As IEnumerable(Of SyntaxTrivia) = Nothing 419ComputePositionAndTriviaForRemoveAttributeList(attributeList, Function(t As SyntaxTrivia) t.IsKind(SyntaxKind.EndOfLineTrivia), positionOfRemovedNode, trivia) 511Dim strippedTrivia As ImmutableArray(Of SyntaxTrivia) = Nothing
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\MemberAccessExpressionSyntaxExtensions.vb (2)
36Private Function WithoutElasticTrivia(list As IEnumerable(Of SyntaxTrivia)) As IEnumerable(Of SyntaxTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (6)
54triviaOpt As SyntaxTrivia?) As IndentationResult? 73Dim firstTrivia As SyntaxTrivia = indenter.Tree.GetRoot(indenter.CancellationToken).FindTrivia(tokenOpt.Value.Span.End + 1) 101Private Shared Function GetTokenOnLeft(trivia As SyntaxTrivia) As SyntaxToken 110Private Shared Function GetIndentationBasedOnToken(indenter As Indenter, token As SyntaxToken, Optional trivia As SyntaxTrivia = Nothing) As IndentationResult 170Private Shared Function IsLineContinuable(lastVisibleTokenOnPreviousLine As SyntaxToken, trivia As SyntaxTrivia) As Boolean 261Private Shared Function GetIndentationFromTokenLineAfterLineContinuation(indenter As Indenter, token As SyntaxToken, trivia As SyntaxTrivia) As IndentationResult
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSyntaxGeneratorInternal.vb (4)
39Public Overrides ReadOnly Property CarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.CarriageReturnLineFeed 41Public Overrides ReadOnly Property ElasticCarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.ElasticCarriageReturnLineFeed 49Public Overrides Function EndOfLine(text As String) As SyntaxTrivia 53Public Overrides Function SingleLineComment(text As String) As SyntaxTrivia
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (9)
AutomaticCompletion\AutomaticLineEnderCommandHandler.vb (1)
121Private Shared Function HasSkippedText(trivia As SyntaxTrivia) As Boolean
EndConstructGeneration\EndConstructStatementVisitor_IfStatement.vb (4)
66Dim triviaLeftForNextStatement As IEnumerable(Of SyntaxTrivia) = New List(Of SyntaxTrivia) 86Dim trailingTrivia = New List(Of SyntaxTrivia) 87Dim separator As SyntaxTrivia = Nothing
LineCommit\ContainingStatementInfo.vb (2)
32Public Sub New(trivia As SyntaxTrivia) 131Private Shared Function GetContainingStatementInfoForTrivia(trivia As SyntaxTrivia, snapshot As ITextSnapshot, pointLineNumber As Integer) As ContainingStatementInfo
SplitComment\VisualBasicSplitCommentService.vb (1)
25Public Function IsAllowed(root As SyntaxNode, trivia As SyntaxTrivia) As Boolean Implements ISplitCommentService.IsAllowed
TextStructureNavigation\VisualBasicTextStructureNavigatorProvider.vb (1)
27Protected Overrides Function ShouldSelectEntireTriviaFromStart(trivia As SyntaxTrivia) As Boolean
Microsoft.CodeAnalysis.VisualBasic.Features (49)
ChangeSignature\VisualBasicChangeSignatureService.vb (2)
612lineFormattingOption As LineFormattingOptions) As ImmutableArray(Of SyntaxTrivia) 615Return ImmutableArray(Of SyntaxTrivia).Empty
CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.vb (1)
161Private Shared Function FindLastContiguousStatement(nodes As IEnumerable(Of SyntaxNode), trivia As IEnumerable(Of SyntaxTrivia)) As Integer
CodeFixes\Suppression\VisualBasicSuppressionCodeFixProvider.vb (4)
108Protected Overrides Function IsEndOfLine(trivia As SyntaxTrivia) As Boolean 219Protected Overrides Function IsAnyPragmaDirectiveForId(trivia As SyntaxTrivia, id As String, ByRef enableDirective As Boolean, ByRef hasMultipleIds As Boolean) As Boolean 243Protected Overrides Function TogglePragmaDirective(trivia As SyntaxTrivia) As SyntaxTrivia
DocumentationComments\VisualBasicDocumentationCommentSnippetService.vb (1)
251Protected Overrides Function IsEndOfLineTrivia(trivia As SyntaxTrivia) As Boolean
ExtractMethod\Extensions.vb (3)
213Public Function GetAllTrivia(ByVal tokens As IEnumerable(Of SyntaxToken)) As IEnumerable(Of SyntaxTrivia) 214Dim list = New List(Of SyntaxTrivia)() 396triviaList As List(Of SyntaxTrivia)) As Boolean
ExtractMethod\VisualBasicMethodExtractor.TriviaResult.vb (16)
77method As MethodBlockBaseSyntax) As IEnumerable(Of SyntaxTrivia) 87SpecializedCollections.SingletonEnumerable(Of SyntaxTrivia)(SyntaxFactory.ElasticMarker), 88SpecializedCollections.EmptyEnumerable(Of SyntaxTrivia)()) 93previousTriviaPair.TrailingTrivia, SpecializedCollections.EmptyEnumerable(Of SyntaxTrivia)()) 97nextTriviaPair.LeadingTrivia, SpecializedCollections.EmptyEnumerable(Of SyntaxTrivia)()) 116token1 As SyntaxToken, list As IEnumerable(Of SyntaxTrivia), token2 As SyntaxToken) As IEnumerable(Of SyntaxTrivia) 133token1 As SyntaxToken, list As IEnumerable(Of SyntaxTrivia), token2 As SyntaxToken) As IEnumerable(Of SyntaxTrivia) 146Private Shared Function RemoveLeadingElasticTrivia(list As IEnumerable(Of SyntaxTrivia)) As IEnumerable(Of SyntaxTrivia) 164Private Shared Function ReplaceElasticToEndOfLine(list As IEnumerable(Of SyntaxTrivia)) As IEnumerable(Of SyntaxTrivia) 183Private Shared Function RemoveElasticAfterColon(list As IEnumerable(Of SyntaxTrivia)) As IEnumerable(Of SyntaxTrivia) 186Dim result = New List(Of SyntaxTrivia)()
ExtractMethod\VisualBasicMethodExtractor.VisualBasicCodeGenerator.CallSiteContainerRewriter.vb (2)
67Dim triviaList = New List(Of SyntaxTrivia)() 350Dim removeEndOfLine = Function(t As SyntaxTrivia) Not t.IsElastic() AndAlso t.Kind <> SyntaxKind.EndOfLineTrivia
ExtractMethod\VisualBasicMethodExtractor.VisualBasicCodeGenerator.vb (1)
250Dim triviaList = New List(Of SyntaxTrivia)()
MetadataAsSource\VisualBasicMetadataAsSourceService.vb (2)
174Dim newLeadingTrivia = New List(Of SyntaxTrivia)() 194Private Iterator Function ConvertDocCommentToRegularComment(structuredTrivia As DocumentationCommentTriviaSyntax) As IEnumerable(Of SyntaxTrivia)
ReplacePropertyWithMethods\VisualBasicReplacePropertyWithMethods.vb (2)
192Private Shared Function ConvertTrivia(trivia As SyntaxTrivia, documentationCommentRewriter As VisualBasicSyntaxRewriter) As SyntaxTrivia
src\Analyzers\VisualBasic\Analyzers\FileHeaders\VisualBasicFileHeaderHelper.vb (1)
24Protected Overrides Function GetTextContextOfComment(commentTrivia As SyntaxTrivia) As ReadOnlyMemory(Of Char)
src\Analyzers\VisualBasic\Analyzers\RemoveUnnecessaryImports\VisualBasicRemoveUnnecessaryImportsDiagnosticAnalyzer.vb (1)
29Protected Overrides Function IsRegularCommentOrDocComment(trivia As SyntaxTrivia) As Boolean
src\Analyzers\VisualBasic\CodeFixes\UseCollectionInitializer\VisualBasicUseCollectionInitializerCodeFixProvider.vb (1)
56Dim totalTrivia = ArrayBuilder(Of SyntaxTrivia).GetInstance()
src\Analyzers\VisualBasic\CodeFixes\UseObjectInitializer\VisualBasicUseObjectInitializerCodeFixProvider.vb (2)
45Protected Overrides Function Whitespace(text As String) As SyntaxTrivia 58Dim totalTrivia = ArrayBuilder(Of SyntaxTrivia).GetInstance()
Structure\Providers\DisabledTextTriviaStructureProvider.vb (1)
15Public Overrides Sub CollectBlockSpans(trivia As SyntaxTrivia,
Structure\VisualBasicStructureHelpers.vb (5)
23Private Function GetCommentBannerText(comment As SyntaxTrivia) As String 27Private Function CreateCommentsRegion(startComment As SyntaxTrivia, 28endComment As SyntaxTrivia) As BlockSpan? 49Dim startComment As SyntaxTrivia? = Nothing 50Dim endComment As SyntaxTrivia? = Nothing
TaskList\VisualBasicTaskListService.vb (4)
25trivia As SyntaxTrivia, 95Protected Overrides Function IsMultilineComment(trivia As SyntaxTrivia) As Boolean 100Protected Overrides Function IsSingleLineComment(trivia As SyntaxTrivia) As Boolean 104Protected Overrides Function PreprocessorHasComment(trivia As SyntaxTrivia) As Boolean
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (1)
Semantics\SyntaxTreeRootTests.vb (1)
106Dim trivia As SyntaxTrivia = Nothing
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (42)
Generated\Syntax.Test.xml.Generated.vb (8)
17947Private Shared Function GenerateRedWhitespaceTrivia() As SyntaxTrivia 17960Private Shared Function GenerateRedEndOfLineTrivia() As SyntaxTrivia 17973Private Shared Function GenerateRedColonTrivia() As SyntaxTrivia 17986Private Shared Function GenerateRedCommentTrivia() As SyntaxTrivia 17999Private Shared Function GenerateRedConflictMarkerTrivia() As SyntaxTrivia 18012Private Shared Function GenerateRedLineContinuationTrivia() As SyntaxTrivia 18025Private Shared Function GenerateRedDocumentationCommentExteriorTrivia() As SyntaxTrivia 18038Private Shared Function GenerateRedDisabledTextTrivia() As SyntaxTrivia
Syntax\SyntaxAnnotationTests.vb (22)
39Dim oldTrivia As SyntaxTrivia = Nothing 88Dim fromTrivia As SyntaxTrivia = Nothing 97Dim toTrivia As SyntaxTrivia = Nothing 420Dim triviaMap = New Dictionary(Of SyntaxTrivia, SyntaxTrivia)() 583Private Sub TestAnnotation(annotation As SyntaxAnnotation, root As SyntaxNode, oldTrivia As SyntaxTrivia) 596Private Function GetAllTrivia(root As SyntaxNode) As List(Of SyntaxTrivia) 622Private _privateTrivia As List(Of SyntaxTrivia) 623Public Property Trivia() As List(Of SyntaxTrivia) 627Private Set(value As List(Of SyntaxTrivia)) 635Me.Trivia = New List(Of SyntaxTrivia)() 654Public Overrides Sub VisitTrivia(trivia As SyntaxTrivia) 688Public Overrides Function VisitTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 730Public Overrides Function VisitTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 748Private ReadOnly _triviaMap As Dictionary(Of SyntaxTrivia, SyntaxTrivia) 750Public Sub New(nodeOrTokenMap As Dictionary(Of SyntaxNodeOrToken, SyntaxNodeOrToken), triviaMap As Dictionary(Of SyntaxTrivia, SyntaxTrivia)) 772Public Overrides Function VisitTrivia(trivia As SyntaxTrivia) As SyntaxTrivia
Syntax\SyntaxRewriterTests.vb (10)
645Dim newField = field.ReplaceTrivia(comment1, New SyntaxTrivia() {newComment1, newComment2}) 651Dim newRoot2 = field.ReplaceTrivia(comment1, New SyntaxTrivia() {}) 672Dim newField = field.InsertTriviaAfter(comment1, New SyntaxTrivia() {newComment1, newComment2}) 816Private ReadOnly _rewriteTrivia As Func(Of SyntaxTrivia, SyntaxTrivia) 821Optional rewriteTrivia As Func(Of SyntaxTrivia, SyntaxTrivia) = Nothing) 845Public Overrides Function VisitTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 846Dim visited As SyntaxTrivia = MyBase.VisitTrivia(trivia)
TestSyntaxNodes.vb (2)
18Private ReadOnly _spaceTrivia As SyntaxTrivia = SyntaxFactory.WhitespaceTrivia(" ") 1606Dim ex3 = ex.ReplaceTrivia(comment1, New SyntaxTrivia() {})
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (2)
ParserTestUtilities.vb (2)
347Dim ticktickticknode As SyntaxTrivia = Nothing 833Dim prev As SyntaxTrivia? = Nothing
Microsoft.CodeAnalysis.VisualBasic.Workspaces (129)
CaseCorrection\VisualBasicCaseCorrectionService.Rewriter.vb (2)
301Public Overrides Function VisitTrivia(trivia As SyntaxTrivia) As SyntaxTrivia
Classification\Worker.DocumentationCommentClassifier.vb (1)
73Private Sub ClassifyExteriorTrivia(trivia As SyntaxTrivia)
Classification\Worker.vb (4)
53Private Sub AddClassification(trivia As SyntaxTrivia, classificationType As String) 116Private Sub ClassifyTrivia(trivia As SyntaxTrivia, triviaList As SyntaxTriviaList) 153Private Sub ClassifyConflictMarker(trivia As SyntaxTrivia) 157Private Sub ClassifyDisabledText(trivia As SyntaxTrivia, triviaList As SyntaxTriviaList)
CodeCleanup\Providers\FixIncorrectTokensCodeCleanupProvider.vb (9)
64Public Overrides Function VisitTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 185Dim leadingTriviaBuilder As Queue(Of SyntaxTrivia) = Nothing 186Dim trailingTriviaBuilder As Queue(Of SyntaxTrivia) = Nothing 226Private Shared Sub ProcessTrivia(triviaList As IEnumerable(Of SyntaxTrivia), 228ByRef leadingTriviaBuilder As Queue(Of SyntaxTrivia), 229ByRef trailingTriviaBuilder As Queue(Of SyntaxTrivia)) 245leadingTriviaBuilder = New Queue(Of SyntaxTrivia) 252trailingTriviaBuilder = New Queue(Of SyntaxTrivia)
CodeCleanup\Providers\RemoveUnnecessaryLineContinuationCodeCleanupProvider.vb (8)
233Private Shared Function RemoveTrailingColonTrivia(token1 As SyntaxToken, trailing As IEnumerable(Of SyntaxTrivia)) As IEnumerable(Of SyntaxTrivia) 273Private Shared Iterator Function RemoveConsecutiveColons(trivia As SyntaxTriviaList) As IEnumerable(Of SyntaxTrivia) 274Dim last As SyntaxTrivia = Nothing 288Dim trailing = New List(Of SyntaxTrivia) 289Dim leading = New List(Of SyntaxTrivia) 337Private Shared Function ReplaceLineContinuationToEndOfLine(trivia As IEnumerable(Of SyntaxTrivia)) As IEnumerable(Of SyntaxTrivia)
CodeGeneration\VisualBasicSyntaxGenerator.vb (5)
28Friend Overrides ReadOnly Property ElasticMarker As SyntaxTrivia = SyntaxFactory.ElasticMarker 32Friend Overrides Function Whitespace(text As String) As SyntaxTrivia 52Friend Overrides Function Trivia(node As SyntaxNode) As SyntaxTrivia 69Friend Overrides Function DocumentationCommentTriviaWithUpdatedContent(trivia As SyntaxTrivia, content As IEnumerable(Of SyntaxNode)) As SyntaxNode 3684Friend Overrides Function IsRegularOrDocComment(trivia As SyntaxTrivia) As Boolean
Formatting\DefaultOperationProvider.vb (4)
65Function(trivia As SyntaxTrivia) ColonOrLineContinuationTrivia(trivia)) 156Private Shared Function ColonOrLineContinuationTrivia(trivia As SyntaxTrivia) As Boolean 161Private Shared Function LastOrDefaultTrivia(triviaListPair As (SyntaxTriviaList, SyntaxTriviaList), predicate As Func(Of SyntaxTrivia, Boolean)) As SyntaxTrivia
Formatting\Engine\Trivia\TriviaDataFactory.Analyzer.vb (4)
63Private Shared Sub AnalyzeLineContinuation(trivia As SyntaxTrivia, ByRef result As AnalysisResult) 75Private Shared Sub AnalyzeLineBreak(previousTrivia As SyntaxTrivia, trivia As SyntaxTrivia, ByRef result As AnalysisResult) 90Private Shared Sub AnalyzeWhitespacesInTrivia(trivia As SyntaxTrivia, ByRef result As AnalysisResult)
Formatting\Engine\Trivia\TriviaDataFactory.CodeShapeAnalyzer.vb (10)
100Private Shared Function OnElastic(trivia As SyntaxTrivia) As Boolean 105Private Function OnWhitespace(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 152Private Function OnEndOfLine(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 177Private Function OnLineContinuation(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 194Private Shared Function OnColon(trivia As SyntaxTrivia) As Boolean 203Private Function OnComment(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 229Private Shared Function OnSkippedTokensOrText(trivia As SyntaxTrivia) As Boolean 237Private Function OnRegion(trivia As SyntaxTrivia, currentIndex As Integer) As Boolean 255Private Shared Function OnPreprocessor(trivia As SyntaxTrivia) As Boolean 284Private Shared Function ShouldFormatDocumentationComment(indentation As Integer, tabSize As Integer, trivia As SyntaxTrivia) As Boolean
Formatting\Engine\Trivia\VisualBasicTriviaFormatter.vb (24)
16Private ReadOnly _lineContinuationTrivia As SyntaxTrivia = SyntaxFactory.LineContinuationTrivia("_") 17Private _newLine As SyntaxTrivia 35Protected Overrides Function IsWhitespace(trivia As SyntaxTrivia) As Boolean 39Protected Overrides Function IsEndOfLine(trivia As SyntaxTrivia) As Boolean 51Protected Overrides Function CreateWhitespace(text As String) As SyntaxTrivia 55Protected Overrides Function CreateEndOfLine() As SyntaxTrivia 63Protected Overrides Function GetLineColumnRuleBetween(trivia1 As SyntaxTrivia, existingWhitespaceBetween As LineColumnDelta, implicitLineBreak As Boolean, trivia2 As SyntaxTrivia, cancellationToken As CancellationToken) As LineColumnRule 150Protected Overrides Function ContainsImplicitLineBreak(syntaxTrivia As SyntaxTrivia) As Boolean 154Private Function IsStartOrEndOfFile(trivia1 As SyntaxTrivia, trivia2 As SyntaxTrivia) As Boolean 159trivia As SyntaxTrivia, 160changes As ArrayBuilder(Of SyntaxTrivia), 175trivia As SyntaxTrivia, 195Private Function FormatLineContinuationTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 204trivia As SyntaxTrivia, 205changes As ArrayBuilder(Of SyntaxTrivia), 231trivia As SyntaxTrivia, 263Private Function FormatDocumentComment(lineColumn As LineColumn, trivia As SyntaxTrivia) As SyntaxTrivia 301Protected Overrides Function LineContinuationFollowedByWhitespaceComment(trivia As SyntaxTrivia, nextTrivia As SyntaxTrivia) As Boolean 305Protected Overrides Function IsVisualBasicComment(trivia As SyntaxTrivia) As Boolean
Formatting\Engine\VisualBasicStructuredTriviaFormatEngine.vb (2)
15Public Shared Function FormatTrivia(trivia As SyntaxTrivia, 25Private Sub New(trivia As SyntaxTrivia,
Formatting\Rules\ElasticTriviaFormattingRule.vb (1)
363Private Shared Function GetNumberOfLines(list As IEnumerable(Of SyntaxTrivia)) As Integer
OrganizeImports\VisualBasicOrganizeImportsService.Rewriter.vb (1)
18Private ReadOnly _newLineTrivia As SyntaxTrivia
Rename\VisualBasicRenameRewriterLanguageService.vb (3)
602Private Function RenameInCommentTrivia(trivia As SyntaxTrivia) As SyntaxTrivia 615Private Function RenameInTrivia(token As SyntaxToken, leadingOrTrailingTriviaList As IEnumerable(Of SyntaxTrivia)) As SyntaxToken
Simplification\VisualBasicSimplificationService.NodesAndTokensToReduceComputer.vb (2)
109Public Overrides Function VisitTrivia(trivia As SyntaxTrivia) As SyntaxTrivia
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SingleLineRewriter.vb (1)
22token = token.WithLeadingTrivia(Enumerable.Empty(Of SyntaxTrivia)())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxNodeExtensions.vb (5)
405trivia As SyntaxTrivia, 438Public Function GetLeadingBlankLines(Of TSyntaxNode As SyntaxNode)(node As TSyntaxNode) As ImmutableArray(Of SyntaxTrivia) 448Public Function GetNodeWithoutLeadingBlankLines(Of TSyntaxNode As SyntaxNode)(node As TSyntaxNode, ByRef strippedTrivia As ImmutableArray(Of SyntaxTrivia)) As TSyntaxNode 453Public Function GetLeadingBannerAndPreprocessorDirectives(Of TSyntaxNode As SyntaxNode)(node As TSyntaxNode) As ImmutableArray(Of SyntaxTrivia) 463Public Function GetNodeWithoutLeadingBannerAndPreprocessorDirectives(Of TSyntaxNode As SyntaxNode)(node As TSyntaxNode, ByRef strippedTrivia As ImmutableArray(Of SyntaxTrivia)) As TSyntaxNode
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTreeExtensions.vb (3)
78Private Function GetTrailingColonTrivia(statement As StatementSyntax) As SyntaxTrivia? 121Public Function FindTriviaToLeft(syntaxTree As SyntaxTree, position As Integer, cancellationToken As CancellationToken) As SyntaxTrivia 125Private Function FindTriviaToLeft(nodeOrToken As SyntaxNodeOrToken, position As Integer) As SyntaxTrivia
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTriviaExtensions.vb (7)
11Public Function IsKind(trivia As SyntaxTrivia, kind1 As SyntaxKind, kind2 As SyntaxKind) As Boolean 17Public Function IsKind(trivia As SyntaxTrivia, kind1 As SyntaxKind, kind2 As SyntaxKind, kind3 As SyntaxKind) As Boolean 24Public Function IsWhitespaceOrEndOfLine(trivia As SyntaxTrivia) As Boolean 29Public Function IsWhitespace(trivia As SyntaxTrivia) As Boolean 34Public Function IsEndOfLine(trivia As SyntaxTrivia) As Boolean 39Public Function IsRegularOrDocComment(trivia As SyntaxTrivia) As Boolean 44Public Function IsPragmaDirective(trivia As SyntaxTrivia, ByRef isDisable As Boolean, ByRef isActive As Boolean, ByRef errorCodes As SeparatedSyntaxList(Of SyntaxNode)) As Boolean
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Extensions\SyntaxTriviaListExtensions.vb (1)
17Public Function WithoutLeadingWhitespaceOrEndOfLine(list As IEnumerable(Of SyntaxTrivia)) As SyntaxTriviaList
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicFileBannerFacts.vb (2)
28Public Overrides Function CreateTrivia(trivia As SyntaxTrivia, text As String) As SyntaxTrivia
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SyntaxFacts\VisualBasicSyntaxFacts.vb (9)
40Public ReadOnly Property ElasticMarker As SyntaxTrivia = SyntaxFactory.ElasticMarker Implements ISyntaxFacts.ElasticMarker 42Public ReadOnly Property ElasticCarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.ElasticCarriageReturnLineFeed Implements ISyntaxFacts.ElasticCarriageReturnLineFeed 1468Public Function IsPreprocessorDirective(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsPreprocessorDirective 1480Public Function IsRegularComment(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsRegularComment 1484Public Function IsDocumentationComment(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsDocumentationComment 1488Public Function IsElastic(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsElastic 1492Public Function IsPragmaDirective(trivia As SyntaxTrivia, ByRef isDisable As Boolean, ByRef isActive As Boolean, ByRef errorCodes As SeparatedSyntaxList(Of SyntaxNode)) As Boolean Implements ISyntaxFacts.IsPragmaDirective 1500Public Function IsDocumentationCommentExteriorTrivia(trivia As SyntaxTrivia) As Boolean Implements ISyntaxFacts.IsDocumentationCommentExteriorTrivia 1649Public Function GetContentFromDocumentationCommentTriviaSyntax(trivia As SyntaxTrivia) As SyntaxList(Of SyntaxNode) Implements ISyntaxFacts.GetContentFromDocumentationCommentTriviaSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\ImportsOrganizer.vb (6)
15newLineTrivia As SyntaxTrivia) As SyntaxList(Of ImportsStatementSyntax) 74newLineTrivia As SyntaxTrivia) As SyntaxList(Of ImportsStatementSyntax) 80Dim leadingTrivia As ImmutableArray(Of SyntaxTrivia) = Nothing 104Private Shared Sub EnsureNewLines(list As List(Of ImportsStatementSyntax), newLineTrivia As SyntaxTrivia) 118Private Shared Function GetExistingEndOfLineTrivia(list As List(Of ImportsStatementSyntax)) As SyntaxTrivia 119Dim endOfLine As SyntaxTrivia
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationService.vb (3)
415Dim trivia As IEnumerable(Of SyntaxTrivia) = Nothing 419ComputePositionAndTriviaForRemoveAttributeList(attributeList, Function(t As SyntaxTrivia) t.IsKind(SyntaxKind.EndOfLineTrivia), positionOfRemovedNode, trivia) 511Dim strippedTrivia As ImmutableArray(Of SyntaxTrivia) = Nothing
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Extensions\MemberAccessExpressionSyntaxExtensions.vb (2)
36Private Function WithoutElasticTrivia(list As IEnumerable(Of SyntaxTrivia)) As IEnumerable(Of SyntaxTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\VisualBasicIndentationService.Indenter.vb (6)
54triviaOpt As SyntaxTrivia?) As IndentationResult? 73Dim firstTrivia As SyntaxTrivia = indenter.Tree.GetRoot(indenter.CancellationToken).FindTrivia(tokenOpt.Value.Span.End + 1) 101Private Shared Function GetTokenOnLeft(trivia As SyntaxTrivia) As SyntaxToken 110Private Shared Function GetIndentationBasedOnToken(indenter As Indenter, token As SyntaxToken, Optional trivia As SyntaxTrivia = Nothing) As IndentationResult 170Private Shared Function IsLineContinuable(lastVisibleTokenOnPreviousLine As SyntaxToken, trivia As SyntaxTrivia) As Boolean 261Private Shared Function GetIndentationFromTokenLineAfterLineContinuation(indenter As Indenter, token As SyntaxToken, trivia As SyntaxTrivia) As IndentationResult
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSyntaxGeneratorInternal.vb (4)
39Public Overrides ReadOnly Property CarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.CarriageReturnLineFeed 41Public Overrides ReadOnly Property ElasticCarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.ElasticCarriageReturnLineFeed 49Public Overrides Function EndOfLine(text As String) As SyntaxTrivia 53Public Overrides Function SingleLineComment(text As String) As SyntaxTrivia
Microsoft.CodeAnalysis.Workspaces (201)
Classification\SyntaxClassification\AbstractSyntaxClassificationService.Worker.cs (1)
171foreach (var trivia in triviaList)
Editing\SyntaxGenerator.cs (8)
38internal SyntaxTrivia CarriageReturnLineFeed => this.SyntaxGeneratorInternal.CarriageReturnLineFeed; 39internal SyntaxTrivia ElasticCarriageReturnLineFeed => this.SyntaxGeneratorInternal.ElasticCarriageReturnLineFeed; 40internal abstract SyntaxTrivia ElasticMarker { get; } 48internal abstract SyntaxTrivia Whitespace(string text); 50internal SyntaxTrivia SingleLineComment(string text) 1078internal abstract bool IsRegularOrDocComment(SyntaxTrivia trivia); 2412internal abstract SyntaxTrivia Trivia(SyntaxNode node); 2416internal abstract SyntaxNode? DocumentationCommentTriviaWithUpdatedContent(SyntaxTrivia trivia, IEnumerable<SyntaxNode> content);
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)
94foreach (var trivia in triviaList)
src\Compilers\Core\Portable\SourceGeneration\GeneratedCodeUtilities.cs (6)
49SyntaxTree tree, Func<SyntaxTrivia, bool> isComment, CancellationToken cancellationToken) 55internal static bool IsGeneratedCode(string? filePath, SyntaxNode root, Func<SyntaxTrivia, bool> isComment) 88private static bool BeginsWithAutoGeneratedComment(SyntaxNode root, Func<SyntaxTrivia, bool> isComment) 94foreach (var trivia in leadingTrivia) 118SyntaxTree tree, Func<SyntaxTrivia, bool> isComment, CancellationToken cancellationToken) 125foreach (var trivia in leadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (23)
376IEnumerable<SyntaxTrivia> trivia, 377Func<SyntaxTrivia, SyntaxTrivia, CancellationToken, Task<SyntaxTrivia>> computeReplacementAsync, 393IEnumerable<SyntaxTrivia>? trivia, 394Func<SyntaxTrivia, SyntaxTrivia, CancellationToken, Task<SyntaxTrivia>>? computeReplacementTriviaAsync, 405var triviaReplacements = new Dictionary<SyntaxTrivia, SyntaxTrivia>(); 453var original = (SyntaxTrivia?)retryAnnotations.GetAnnotations(currentTrivia).SingleOrDefault() ?? currentTrivia; 498if (!triviaReplacements.TryGetValue(original, out var replaced)) 547foreach (var trivia in triviaList) 577foreach (var trivia in triviaList.Reverse()) 690params SyntaxTrivia[] trivia) where T : SyntaxNode 697return node.WithPrependedLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia); 714IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode 724params SyntaxTrivia[] trivia) where T : SyntaxNode 731return node.WithAppendedTrailingTrivia((IEnumerable<SyntaxTrivia>)trivia); 748IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode 758IEnumerable<SyntaxTrivia> leadingTrivia, 759IEnumerable<SyntaxTrivia> trailingTrivia) where T : SyntaxNode 874foreach (var trivia in token.LeadingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeOrTokenExtensions.cs (4)
53public static SyntaxTrivia[] GetTrivia(params SyntaxNodeOrToken[] nodesOrTokens) 56public static SyntaxNodeOrToken WithAppendedTrailingTrivia(this SyntaxNodeOrToken nodeOrToken, params SyntaxTrivia[] trivia) 57=> WithAppendedTrailingTrivia(nodeOrToken, (IEnumerable<SyntaxTrivia>)trivia); 59public static SyntaxNodeOrToken WithAppendedTrailingTrivia(this SyntaxNodeOrToken nodeOrToken, IEnumerable<SyntaxTrivia> trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (7)
115params SyntaxTrivia[] trivia) 122return token.WithPrependedLeadingTrivia((IEnumerable<SyntaxTrivia>)trivia); 139IEnumerable<SyntaxTrivia> trivia) 149params SyntaxTrivia[] trivia) 151return token.WithAppendedTrailingTrivia((IEnumerable<SyntaxTrivia>)trivia); 156IEnumerable<SyntaxTrivia> trivia) 161public static SyntaxTrivia[] GetTrivia(this IEnumerable<SyntaxToken> tokens)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTreeExtensions.cs (3)
148foreach (var trivia in triviaList.Reverse()) 168internal static SyntaxTrivia FindTriviaAndAdjustForEndOfFile( 172var trivia = root.FindTrivia(position, findInsideTrivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTriviaExtensions.cs (5)
9public static int Width(this SyntaxTrivia trivia) 12public static int FullWidth(this SyntaxTrivia trivia) 15public static bool IsElastic(this SyntaxTrivia trivia) 18public static SyntaxTrivia AsElastic(this SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTriviaListExtensions.cs (4)
11public static SyntaxTrivia? FirstOrNull(this SyntaxTriviaList triviaList, Func<SyntaxTrivia, bool> predicate) 13foreach (var trivia in triviaList) 24public static SyntaxTrivia LastOrDefault(this SyntaxTriviaList triviaList)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.cs (1)
33public static TreeData Create(SyntaxTrivia trivia, int initialColumn)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\TreeData.StructuredTrivia.cs (2)
16private readonly SyntaxTrivia _trivia; 19public StructuredTrivia(SyntaxTrivia trivia, int initialColumn)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
64foreach (var trivia in list)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (45)
41private delegate LineColumnDelta Formatter<T>(LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<T> changes, CancellationToken cancellationToken); 117protected abstract bool IsWhitespace(SyntaxTrivia trivia); 122protected abstract bool IsEndOfLine(SyntaxTrivia trivia); 127protected abstract bool LineContinuationFollowedByWhitespaceComment(SyntaxTrivia previousTrivia, SyntaxTrivia nextTrivia); 134protected abstract bool IsVisualBasicComment(SyntaxTrivia trivia); 170protected abstract SyntaxTrivia CreateWhitespace(string text); 175protected abstract SyntaxTrivia CreateEndOfLine(); 180protected abstract LineColumnRule GetLineColumnRuleBetween(SyntaxTrivia trivia1, LineColumnDelta existingWhitespaceBetween, bool implicitLineBreak, SyntaxTrivia trivia2, CancellationToken cancellationToken); 185protected abstract LineColumnDelta Format(LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<SyntaxTrivia> changes, CancellationToken cancellationToken); 190protected abstract LineColumnDelta Format(LineColumn lineColumn, SyntaxTrivia trivia, ArrayBuilder<TextChange> changes, CancellationToken cancellationToken); 195protected abstract bool ContainsImplicitLineBreak(SyntaxTrivia trivia); 240using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var triviaList); 260private static void AddRange(ArrayBuilder<SyntaxTrivia> result, SyntaxTriviaList triviaList) 262foreach (var trivia in triviaList) 289var previousWhitespaceTrivia = default(SyntaxTrivia); 290var previousTrivia = default(SyntaxTrivia); 297SyntaxTrivia trivia; 373SyntaxTrivia trivia1, 375SyntaxTrivia trivia2, 397private LineColumnRule GetOverallLineColumnRuleBetween(SyntaxTrivia trivia1, LineColumnDelta existingWhitespaceBetween, bool implicitLineBreak, SyntaxTrivia trivia2, CancellationToken cancellationToken) 464private void GetTokensAtEdgeOfStructureTrivia(SyntaxTrivia trivia1, SyntaxTrivia trivia2, out SyntaxToken token1, out SyntaxToken token2) 544LineColumn lineColumnBeforeTrivia1, SyntaxTrivia trivia1, LineColumn lineColumnAfterTrivia1, LineColumnDelta existingWhitespaceBetween, SyntaxTrivia trivia2, LineColumnRule rule) 566LineColumn lineColumnBeforeTrivia1, LineColumn lineColumnAfterTrivia1, LineColumnDelta existingWhitespaceBetween, SyntaxTrivia trivia2, LineColumnRule rule) 625private void AddExtraLines(int linesBetweenTokens, ArrayBuilder<SyntaxTrivia> changes) 629using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var lineBreaks); 642private int GetInsertionIndex(ArrayBuilder<SyntaxTrivia> changes) 758ArrayBuilder<SyntaxTrivia> changes) 767ArrayBuilder<SyntaxTrivia> changes) 832private TextSpan GetTextSpan(SyntaxTrivia trivia1, SyntaxTrivia trivia2) 847private bool IsWhitespaceOrEndOfLine(SyntaxTrivia trivia) 852SyntaxTrivia previousTrivia, 853SyntaxTrivia trivia1, 855SyntaxTrivia trivia2) 904protected LineColumn GetLineColumn(LineColumn lineColumn, SyntaxTrivia trivia) 911protected LineColumnDelta GetLineColumnDelta(LineColumn lineColumn, SyntaxTrivia trivia) 936protected int GetExistingIndentation(SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\TriviaHelpers.cs (1)
19using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var builder);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\TriviaList.cs (2)
14public SyntaxTrivia this[int index] 48public SyntaxTrivia Current => _enumerator.Current;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.cs (1)
32Indenter indenter, SyntaxToken? token, SyntaxTrivia? trivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (2)
107private readonly SyntaxTrivia? TryGetImmediatelyPrecedingVisibleTrivia() 117var trivia = Root.FindTrivia(lastPos.Value);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\FileBannerFacts\AbstractFileBannerFacts.cs (24)
19private readonly Matcher<SyntaxTrivia> _oneOrMoreBlankLines; 24private readonly Matcher<SyntaxTrivia> _bannerMatcher; 29private readonly Matcher<SyntaxTrivia> _fileBannerMatcher; 34Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsWhitespaceTrivia, "\\b")); 35var endOfLine = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsEndOfLineTrivia, "\\n"); 38var shebangComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsShebangDirectiveTrivia, "#!"); 39var singleLineComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsSingleLineCommentTrivia, "//"); 40var multiLineComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsMultiLineCommentTrivia, "/**/"); 41var singleLineDocumentationComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsSingleLineDocCommentTrivia, "///"); 42var multiLineDocumentationComment = Matcher.Single<SyntaxTrivia>(this.SyntaxFacts.IsMultiLineDocCommentTrivia, "/** */"); 61public abstract SyntaxTrivia CreateTrivia(SyntaxTrivia trivia, string text); 66public ImmutableArray<SyntaxTrivia> GetLeadingBlankLines(SyntaxNode node) 69public ImmutableArray<SyntaxTrivia> GetLeadingBlankLines<TSyntaxNode>(TSyntaxNode node) 83TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) 86var leadingTriviaToKeep = new List<SyntaxTrivia>(node.GetLeadingTrivia()); 96public ImmutableArray<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(TSyntaxNode node) 111TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) 125List<SyntaxTrivia> leadingTriviaToStrip, leadingTriviaToKeep; 140leadingTriviaToStrip = new List<SyntaxTrivia>(leadingTrivia.Take(ppIndex + 1)); 141leadingTriviaToKeep = new List<SyntaxTrivia>(leadingTrivia.Skip(ppIndex + 1)); 145leadingTriviaToKeep = new List<SyntaxTrivia>(leadingTrivia); 166public ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxNode root) 172public ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxToken firstToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\FileBannerFacts\IFileBannerFacts.cs (8)
12SyntaxTrivia CreateTrivia(SyntaxTrivia trivia, string text); 14ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxNode root); 15ImmutableArray<SyntaxTrivia> GetFileBanner(SyntaxToken firstToken); 18ImmutableArray<SyntaxTrivia> GetLeadingBlankLines(SyntaxNode node); 22TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode; 24ImmutableArray<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(TSyntaxNode node) where TSyntaxNode : SyntaxNode; 27TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\FileBannerFacts\IFileBannerFactsExtensions.cs (1)
12public static ImmutableArray<SyntaxTrivia> GetTriviaAfterLeadingBlankLines(
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFacts.cs (9)
89SyntaxTrivia ElasticMarker { get; } 90SyntaxTrivia ElasticCarriageReturnLineFeed { get; } 177bool IsRegularComment(SyntaxTrivia trivia); 178bool IsDocumentationComment(SyntaxTrivia trivia); 179bool IsElastic(SyntaxTrivia trivia); 180bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes); 182bool IsPreprocessorDirective(SyntaxTrivia trivia); 287bool IsDocumentationCommentExteriorTrivia(SyntaxTrivia trivia); 490SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (10)
123foreach (var trivia in triviaList) 282public static bool IsRegularOrDocumentationComment(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 389public static bool IsWhitespaceOrEndOfLineTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 684public static bool IsEndOfLineTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 687public static bool IsMultiLineCommentTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 690public static bool IsMultiLineDocCommentTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 693public static bool IsShebangDirectiveTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 696public static bool IsSingleLineCommentTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 699public static bool IsSingleLineDocCommentTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia) 702public static bool IsWhitespaceTrivia(this ISyntaxFacts syntaxFacts, SyntaxTrivia trivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AnnotationTable.cs (11)
81public SyntaxTrivia WithAdditionalAnnotations(SyntaxTrivia trivia, params TAnnotation[] annotations) 93public SyntaxTrivia WithoutAnnotations(SyntaxTrivia trivia, params TAnnotation[] annotations) 117public IEnumerable<TAnnotation> GetAnnotations(SyntaxTrivia trivia) 129public IEnumerable<TSpecificAnnotation> GetAnnotations<TSpecificAnnotation>(SyntaxTrivia trivia) where TSpecificAnnotation : TAnnotation 141public bool HasAnnotations(SyntaxTrivia trivia) 153public bool HasAnnotations<TSpecificAnnotation>(SyntaxTrivia trivia) where TSpecificAnnotation : TAnnotation 165public bool HasAnnotation(SyntaxTrivia trivia, TAnnotation annotation) 180public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia(SyntaxNode node) 192public IEnumerable<SyntaxTrivia> GetAnnotatedTrivia<TSpecificAnnotation>(SyntaxNode node) where TSpecificAnnotation : TAnnotation
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (3)
214foreach (var trivia in token.LeadingTrivia) 231foreach (var trivia in token.LeadingTrivia) 249foreach (var trivia in token.TrailingTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (3)
502Func<SyntaxTrivia, bool> isEndOfLineTrivia, 504out IEnumerable<SyntaxTrivia> triviaOfRemovedNode) 524out IEnumerable<SyntaxTrivia> triviaOfRemovedNode)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\AddParameterEditor.cs (5)
121private static ImmutableArray<SyntaxTrivia> GetDesiredLeadingIndentation( 124using var _ = ArrayBuilder<SyntaxTrivia>.GetInstance(out var triviaList); 130var lastWhitespace = default(SyntaxTrivia); 131foreach (var trivia in node.GetLeadingTrivia().Reverse())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AddImportHelpers.cs (3)
36var endOfLine = root.DescendantTrivia().FirstOrNull((trivia, syntaxFacts) => syntaxFacts.IsEndOfLineTrivia(trivia), syntaxFacts) ?? syntaxFacts.ElasticCarriageReturnLineFeed; 66var originalFirstUsingLineEnding = originalFirstUsingTrailingTrivia.Any() && syntaxFacts.IsEndOfLineTrivia(originalFirstUsingTrailingTrivia[^1]) 99private static bool IsDocCommentOrElastic(ISyntaxFacts syntaxFacts, SyntaxTrivia t)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs (1)
176private static ImmutableArray<SyntaxTrivia> GetMergedTrivia(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SyntaxGeneratorInternalExtensions\SyntaxGeneratorInternal.cs (4)
23public abstract SyntaxTrivia CarriageReturnLineFeed { get; } 24public abstract SyntaxTrivia ElasticCarriageReturnLineFeed { get; } 26public abstract SyntaxTrivia EndOfLine(string text); 27public abstract SyntaxTrivia SingleLineComment(string text);
Microsoft.Gen.Logging (1)
Parsing\Parser.cs (1)
458foreach (var trivia in triviaList)
Microsoft.VisualStudio.LanguageServices (1)
Extensions\DocumentExtensions.cs (1)
31var trivia = document.GetSyntaxRootSynchronously(cancellationToken).FindTrivia(line.Start);
Microsoft.VisualStudio.LanguageServices.CSharp (10)
CodeModel\CSharpCodeModelService.cs (8)
1220private static IList<SyntaxTrivia> CollectComments(IList<SyntaxTrivia> triviaList) 1222var commentList = new List<SyntaxTrivia>(); 1226var trivia = triviaList[i]; 1254foreach (var trivia in commentList) 1314foreach (var trivia in newTriviaList.Reverse()) 1436foreach (var triviaElement in newTriviaList.Reverse()) 2851foreach (var trivia in node.GetLeadingTrivia().Reverse())
CodeModel\CSharpCodeModelService.NodeLocator.cs (1)
163.Where(t => t is not SyntaxTrivia(SyntaxKind.WhitespaceTrivia or SyntaxKind.EndOfLineTrivia))
CodeModel\MethodXml\MethodXmlBuilder.cs (1)
39foreach (var trivia in triviaList)
Microsoft.VisualStudio.LanguageServices.VisualBasic (4)
CodeModel\VisualBasicCodeModelService.NodeLocator.vb (1)
972Private Shared Function GetTrailingColonTrivia(statement As StatementSyntax) As SyntaxTrivia?
CodeModel\VisualBasicCodeModelService.vb (3)
2198Private Shared Function CollectComments(triviaList As IList(Of SyntaxTrivia)) As IList(Of SyntaxTrivia) 2199Dim commentList = New List(Of SyntaxTrivia)