コード例 #1
0
ファイル: SyntaxExtensions.cs プロジェクト: stark-lang/stark
 /// <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));
 }
コード例 #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));
 }
コード例 #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));
 }
コード例 #4
0
        private void TestNormalizeTrivia(string text, string expected)
        {
            var list   = SyntaxFactory.ParseLeadingTrivia(text);
            var actual = SyntaxNormalizer.Normalize(list, "    ").ToFullString();

            Assert.Equal(expected, actual);
        }
コード例 #5
0
 protected internal override SyntaxNode NormalizeWhitespaceCore(
     string indentation,
     string eol,
     bool elasticTrivia
     )
 {
     return(SyntaxNormalizer
            .Normalize(this, indentation, eol, elasticTrivia)
            .AsRootOfNewTreeWithOptionsFrom(this.SyntaxTree));
 }
コード例 #6
0
ファイル: SyntaxExtensions.cs プロジェクト: belav/roslyn
 /// <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
                ));
 }
コード例 #7
0
ファイル: CSharpSyntaxNode.cs プロジェクト: marksantos/roslyn
 protected internal override SyntaxNode NormalizeWhitespaceCore(string indentation, bool elasticTrivia)
 {
     return(SyntaxNormalizer.Normalize(this, indentation, elasticTrivia));
 }
コード例 #8
0
ファイル: SyntaxExtensions.cs プロジェクト: stark-lang/stark
 /// <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));
 }
コード例 #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);
コード例 #10
0
        private void TestNormalize(SyntaxTriviaList trivia, string expected)
        {
            var actual = SyntaxNormalizer.Normalize(trivia, "    ").ToFullString();

            Assert.Equal(expected, actual);
        }
コード例 #11
0
ファイル: SyntaxExtensions.cs プロジェクト: tsasioglu/roslyn
 /// <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));
 }