Skip to content

How to rename multiple symbols? #50147

Answered by Denis535
Denis535 asked this question in Q&A
Dec 27, 2020 · 5 comments · 17 replies
Discussion options

You must be logged in to vote

Ahaha, DescendantTokens returns nodes in parent-child order, so I just need to use Reverse function to get child-parent order.

    var symbols = GetSymbols( root, model, context.Span, context.CancellationToken ).Where( CanBeRenamed ).Reverse().ToArray();

    private static IEnumerable<ISymbol> GetSymbols(SyntaxNode root, SemanticModel model, TextSpan span, CancellationToken cancellationToken) {
        // Note: GetDeclaredSymbol() returns symbol for MemberDeclarationSyntax nodes
        // Note: GetSymbolInfo() returns symbol for other nodes (IdentifierNameSyntax for example)
        var symbols = new HashSet<ISymbol>( SymbolEqualityComparer.Default );
        foreach (var node in root.D…

Replies: 5 comments 17 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Denis535
Comment options

Comment options

You must be logged in to vote
4 replies
@Denis535
Comment options

@CyrusNajmabadi
Comment options

@Denis535
Comment options

@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
4 replies
@Denis535
Comment options

@CyrusNajmabadi
Comment options

@Denis535
Comment options

@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
8 replies
@Denis535
Comment options

@CyrusNajmabadi
Comment options

@Denis535
Comment options

@CyrusNajmabadi
Comment options

@CyrusNajmabadi
Comment options

Answer selected by Denis535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants