rust-analyzer / rowan

Apache License 2.0
689 stars 57 forks source link

Add smart debugging function for `GreenNodeBuilder` #76

Open K4rakara opened 3 years ago

K4rakara commented 3 years ago

As it is, debugging issues with GreenNodeBuilder isn't easy. Sure, you can dbg! it, but it doesn't label what the SyntaxKinds are, rather, it just displays them with their raw value.

I think it would be great to add a function that helps with this. Ideally it would log something like this:

Root@0..21
    Member@0..21
        Public@0..3 "pub"
        Ignore@3..4 " "
        TypeAlias@4..21
            Ignore@4..8 "type"
            Ignore@8..9 " "
            TypeAliasName@9..12
                Ident@9..12 "Foo"
            Ignore@12..13 " "
            Ignore@13..14 "="

The last node (and/or token) would likely be highlighted in green to signify that it is the current node.

If this would be a welcome addition, I would be more than happy to implement it, but I wanted to ask first.