Example #1
0
 /// <summary>
 /// Creates a new syntax token with all whitespace and end of line trivia replaced with
 /// regularly formatted trivia.
 /// </summary>
 /// <param name="token">The token to normalize.</param>
 /// <param name="indentation">An optional sequence of whitespace characters that defines a
 /// single level of indentation.</param>
 /// <param name="eol">An optional sequence of whitespace characters used for end of line.</param>
 /// <param name="elasticTrivia">If true the replaced trivia is elastic trivia.</param>
 public static SyntaxToken NormalizeWhitespace(this SyntaxToken token,
                                               string indentation = StarkPlatform.Compiler.SyntaxNodeExtensions.DefaultIndentation,
                                               string eol         = StarkPlatform.Compiler.SyntaxNodeExtensions.DefaultEOL,
                                               bool elasticTrivia = false)
 {
     return(SyntaxNormalizer.Normalize(token, indentation, eol, elasticTrivia));
 }
Example #2
0
 public static SyntaxTriviaList NormalizeWhitespace(this SyntaxTriviaList list,
                                                    string indentation = CodeAnalysis.SyntaxNodeExtensions.DefaultIndentation,
                                                    string eol         = CodeAnalysis.SyntaxNodeExtensions.DefaultEOL,
                                                    bool elasticTrivia = false)
 {
     return(SyntaxNormalizer.Normalize(list, indentation, eol, elasticTrivia));
 }
Example #3
0
 /// <summary>
 /// Creates a new syntax token with all whitespace and end of line trivia replaced with
 /// regularly formatted trivia.
 /// </summary>
 /// <param name="token">The token to normalize.</param>
 /// <param name="indentation">An optional sequence of whitespace characters that defines a
 /// single level of indentation.</param>
 /// <param name="eol">An optional sequence of whitespace characters used for end of line.</param>
 /// <param name="elasticTrivia">If true the replaced trivia is elastic trivia.</param>
 public static SyntaxToken NormalizeWhitespace(this SyntaxToken token,
                                               string indentation = Microsoft.CodeAnalysis.SyntaxNodeExtensions.DefaultIndentation,
                                               string eol         = Microsoft.CodeAnalysis.SyntaxNodeExtensions.DefaultEOL,
                                               bool elasticTrivia = false)
 {
     return(SyntaxNormalizer.Normalize(token, indentation, eol, elasticTrivia));
 }
        private void TestNormalizeTrivia(string text, string expected)
        {
            var list   = SyntaxFactory.ParseLeadingTrivia(text);
            var actual = SyntaxNormalizer.Normalize(list, "    ").ToFullString();

            Assert.Equal(expected, actual);
        }
Example #5
0
 protected internal override SyntaxNode NormalizeWhitespaceCore(
     string indentation,
     string eol,
     bool elasticTrivia
     )
 {
     return(SyntaxNormalizer
            .Normalize(this, indentation, eol, elasticTrivia)
            .AsRootOfNewTreeWithOptionsFrom(this.SyntaxTree));
 }
Example #6
0
 /// <summary>
 /// Creates a new syntax token with all whitespace and end of line trivia replaced with
 /// regularly formatted trivia.
 /// </summary>
 /// <param name="token">The token to normalize.</param>
 /// <param name="indentation">A sequence of whitespace characters that defines a single level of indentation.</param>
 /// <param name="elasticTrivia">If true the replaced trivia is elastic trivia.</param>
 public static SyntaxToken NormalizeWhitespace(
     this SyntaxToken token,
     string indentation,
     bool elasticTrivia
     )
 {
     return(SyntaxNormalizer.Normalize(
                token,
                indentation,
                CodeAnalysis.SyntaxNodeExtensions.DefaultEOL,
                elasticTrivia
                ));
 }
Example #7
0
 protected internal override SyntaxNode NormalizeWhitespaceCore(string indentation, bool elasticTrivia)
 {
     return(SyntaxNormalizer.Normalize(this, indentation, elasticTrivia));
 }
Example #8
0
 /// <summary>
 /// Creates a new syntax trivia list with all whitespace and end of line trivia replaced with
 /// regularly formatted trivia.
 /// </summary>
 /// <param name="list">The trivia list to normalize.</param>
 /// <param name="indentation">A sequence of whitespace characters that defines a single level of indentation.</param>
 /// <param name="elasticTrivia">If true the replaced trivia is elastic trivia.</param>
 public static SyntaxTriviaList NormalizeWhitespace(this SyntaxTriviaList list, string indentation, bool elasticTrivia)
 {
     return(SyntaxNormalizer.Normalize(list, indentation, StarkPlatform.Compiler.SyntaxNodeExtensions.DefaultEOL, elasticTrivia));
 }
Example #9
0
 /// <summary>
 /// Creates a new syntax trivia list with all whitespace and end of line trivia replaced with
 /// regularly formatted trivia.
 /// </summary>
 /// <param name="list">The trivia list to normalize.</param>
 /// <param name="indentation">A sequence of whitespace characters that defines a single level of indentation.</param>
 /// <param name="elasticTrivia">If true the replaced trivia is elastic trivia.</param>
 public static SyntaxTriviaList NormalizeWhitespace(this SyntaxTriviaList list, string indentation, bool elasticTrivia) =>
 SyntaxNormalizer.Normalize(list, indentation, CodeAnalysis.SyntaxNodeExtensions.DefaultEOL, elasticTrivia);
        private void TestNormalize(SyntaxTriviaList trivia, string expected)
        {
            var actual = SyntaxNormalizer.Normalize(trivia, "    ").ToFullString();

            Assert.Equal(expected, actual);
        }
Example #11
0
 /// <summary>
 /// Creates a new syntax trivia list with all whitespace and end of line trivia replaced with
 /// regularly formatted trivia.
 /// </summary>
 /// <param name="list">The trivia list to normalize.</param>
 /// <param name="indentation">An optional sequence of whitespace characters that defines a
 /// single level of indentation.</param>
 /// <param name="elasticTrivia">If true the replaced trivia is elastic trivia.</param>
 public static SyntaxTriviaList NormalizeWhitespace(this SyntaxTriviaList list, string indentation = DefaultIndentation, bool elasticTrivia = false)
 {
     return(SyntaxNormalizer.Normalize(list, indentation, elasticTrivia));
 }