Ejemplo n.º 1
0
        // Helpers/Trivia
        private static IEnumerable <SyntaxTrivia> Format(IEnumerable <SyntaxTrivia> trivia, string indent)
        {
            foreach (var trivia_ in trivia.Where(IsNotTrash))
            {
                if (trivia_.Kind() is not SyntaxKind.EndOfLineTrivia)
                {
                    yield return(SyntaxFactory.Whitespace(indent));

                    yield return(trivia_);

                    yield return(SyntaxFactoryUtils.EndOfLine());
                }
Ejemplo n.º 2
0
 // Format/Trailing
 private static IEnumerable <SyntaxTrivia> FormatTrailingTrivia(SyntaxToken token)
 {
     // ... token [space] comment [eol]
     // ... token [eol]
     // ... token [space]
     if (ShouldBeLast(token))
     {
         var indent = GetIndent(token);
         var trivia = Format(token.TrailingTrivia, indent).Skip(1);
         if (trivia.Any())
         {
             return(SyntaxFactory.Space.Append(trivia));
         }
         else
         {
             return(SyntaxFactoryUtils.EndOfLine().AsEnumerable());
         }
     }
     if (ShouldHaveSpace(token))
     {
         return(SyntaxFactory.Space.AsEnumerable());
     }
     return(Enumerable.Empty <SyntaxTrivia>());
 }