예제 #1
0
        public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node)
        {
            node = (FieldDeclarationSyntax)base.VisitFieldDeclaration(node);

            if ((Options & WrapRewriterOptions.IndentFieldInitializer) != 0)
            {
                SyntaxToken equalsToken = node.Declaration.Variables[0].Initializer.EqualsToken;

                int count = _maxFieldDeclarationLength - (equalsToken.SpanStart - node.SpanStart);

                SyntaxToken newEqualsToken = equalsToken.AppendToLeadingTrivia(Whitespace(new string(' ', count)));

                node = node.ReplaceToken(equalsToken, newEqualsToken);
            }

            if ((Options & WrapRewriterOptions.WrapArguments) != 0)
            {
                return(node.AppendToTrailingTrivia(NewLine()));
            }
            else
            {
                return(node);
            }
        }
예제 #2
0
        public static SyntaxToken AppendEndOfLineToLeadingTrivia(this SyntaxToken token)
        {
            SyntaxTrivia endOfLine = SyntaxTriviaAnalysis.GetEndOfLine(token);

            return(token.AppendToLeadingTrivia(endOfLine));
        }