Reputation: 81352
I'm looking at creating an extension that can essentially generate code at the cursor position.
So to use the extension you would click anywhere (for example in a method), and then right click, context menu comes up, select a custom menu option (something that is part of the extension), and then after this selection it would run some business logic and generate code at the cursor position.
As far as I know T4 templates are only good for generating whole files. So I guess the route to go is create an extension.
Just to be clear I'm not looking for a full solution, just a overview of what to how to go about doing this. I've started by creating a Visual Studio package.
And now would like to just get some basic grips with what objects to use to implement the custom right click command and how to deal with the active document.
Just a push in the right direction would be great.
Upvotes: 2
Views: 160
Reputation: 888203
You need to create a command in your VSCT, handle it using MenuCommandService, get the active text view, and replace or insert text into its buffer.
Upvotes: 3