private SyntaxFirstTokenReplacer(InternalSyntaxToken oldToken, InternalSyntaxToken newToken, int diagnosticOffsetDelta)
 {
     _oldToken = oldToken;
     _newToken = newToken;
     _diagnosticOffsetDelta = diagnosticOffsetDelta;
     _foundOldToken         = false;
 }
        internal static TRoot Replace <TRoot>(TRoot root, InternalSyntaxToken oldToken, InternalSyntaxToken newToken, int diagnosticOffsetDelta)
            where TRoot : InternalSyntaxNode
        {
            var replacer = new SyntaxFirstTokenReplacer(oldToken, newToken, diagnosticOffsetDelta);
            var newRoot  = (TRoot)replacer.Visit(root);

            Debug.Assert(replacer._foundOldToken);
            return(newRoot);
        }
예제 #3
0
        internal static TRoot Replace <TRoot>(TRoot root, InternalSyntaxToken newToken)
            where TRoot : InternalSyntaxNode
        {
            var oldToken = root.GetLastToken();
            var replacer = new SyntaxLastTokenReplacer(oldToken, newToken);
            var newRoot  = (TRoot)replacer.Visit(root);

            Debug.Assert(replacer._found);
            return(newRoot);
        }
예제 #4
0
            private void PushToken(Syntax.InternalSyntax.InternalSyntaxToken token)
            {
                var trailing = token.GetTrailingTrivia();

                if (trailing != null)
                {
                    this.Push(trailing);
                }

                this.Push(token);
                var leading = token.GetLeadingTrivia();

                if (leading != null)
                {
                    this.Push(leading);
                }
            }
예제 #5
0
        public override InternalSyntaxNode VisitToken(InternalSyntaxToken token)
        {
            var leading  = this.VisitList(token.LeadingTrivia);
            var trailing = this.VisitList(token.TrailingTrivia);

            if (leading != token.LeadingTrivia || trailing != token.TrailingTrivia)
            {
                if (leading != token.LeadingTrivia)
                {
                    token = token.TokenWithLeadingTrivia(leading.Node);
                }

                if (trailing != token.TrailingTrivia)
                {
                    token = token.TokenWithTrailingTrivia(trailing.Node);
                }
            }

            return(token);
        }
예제 #6
0
 private SyntaxLastTokenReplacer(InternalSyntaxToken oldToken, InternalSyntaxToken newToken)
 {
     _oldToken = oldToken;
     _newToken = newToken;
 }
 public Internal.SeparatedSyntaxList <TNode> SeparatedList <TNode>(TNode node1, InternalSyntaxToken token, TNode node2) where TNode : InternalSyntaxNode
 {
     return(new Internal.SeparatedSyntaxList <TNode>(new Internal.SyntaxList <InternalSyntaxNode>(Internal.SyntaxList.List(node1, token, node2))));
 }
 public Internal.SeparatedSyntaxList <TNode> SeparatedList <TNode>(InternalSyntaxToken token) where TNode : InternalSyntaxNode
 {
     return(new Internal.SeparatedSyntaxList <TNode>(new Internal.SyntaxList <InternalSyntaxNode>(token)));
 }