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); }
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); }
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); } }
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); }
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))); }