JetBrains / resharper-rider-plugin

https://www.jetbrains.com/help/resharper/sdk/
https://www.jetbrains.org/intellij/sdk/docs/
Apache License 2.0
172 stars 44 forks source link

Create new ITreeNode element as a child node #26

Closed RoVluche closed 4 years ago

RoVluche commented 4 years ago

I'm not quite sure if this is the right place to ask this but Matthias told me on stackoverflow to post it here. I'm trying to make a ReSharper plugin that has a QuickFix which creates a new class with a specific name and adds it as a child to the body of a given ICSharpNamespaceDeclaration.

So basically I want a quickfix that changes this:

namespace ClassLibraryProject
{
}

Into this:

namespace ClassLibraryProject
{
    public class NewClass
    {
    }
}

I'm new to the ReSharper API/SDK and I'm mainly trying to follow the DevGuide and the sample files from this template but the example shown here only changes the name of the node. I haven't been able to find any information on how to create new ITreeNodes so I hope anyone knows what I can do.

matkoch commented 4 years ago

Hi @RoVluche, sorry I must have missed the notification.

I think the relevant part for you is here. You would use the factory to create a proper IClassDeclaration and then use it to set the body of your INamespaceDeclaration element.