/// <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)); }
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)); }
/// <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); }
protected internal override SyntaxNode NormalizeWhitespaceCore( string indentation, string eol, bool elasticTrivia ) { return(SyntaxNormalizer .Normalize(this, indentation, eol, elasticTrivia) .AsRootOfNewTreeWithOptionsFrom(this.SyntaxTree)); }
/// <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 )); }
public static SyntaxNode Normalize(this SyntaxNode self) { var normalizer = new SyntaxNormalizer(); return(normalizer.Visit(self)); }
protected internal override SyntaxNode NormalizeWhitespaceCore(string indentation, bool elasticTrivia) { return(SyntaxNormalizer.Normalize(this, indentation, elasticTrivia)); }
/// <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)); }
/// <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); }
/// <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)); }