Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to draw to the editor from a resharper plugin? #46

Open
mterwoord opened this issue Sep 11, 2015 · 1 comment
Open

Is it possible to draw to the editor from a resharper plugin? #46

mterwoord opened this issue Sep 11, 2015 · 1 comment

Comments

@mterwoord
Copy link

What I'm trying to accomplish, is draw information after end } symbols of code blocks.

@hypersw
Copy link

hypersw commented Sep 11, 2015

Yes, but this involves connecting two component models, R#'s and WPF Text Editor's.
Basically, first you implement the drawing in the 100% Visual Studio way (MEF components, text editor layers, all that). VS will register all R#'s DLLs for MEF, including yours, so it will work. Then you got to tell this painter what to paint. The stuff is calculated by the code model part and made available to the painter through the property bag on the text editor or the document.

For example, in the painter you got an ITextBuffer for the current editor, then turn it into IVsTextBuffer via IVsEditorAdaptersFactoryService::GetBufferAdapter, then wrap it with the JetBrains.VsIntegration.Interop.Shim.TextManager.Documents.IVsTextBuffer accessor type, and it has the JetDocument property. This gives access to the code model's IDocument for the current editor from any editor's VS MEF component. There aren't any much other code model entities exposed into MEF though, so far every R# feature adds whatever it needs for itself in a similar way, by publishing on the text buffer bag.

For the very minimum, this JetDocument might suffice, if your data is fast to calculate and not too large. You can calculate it in a daemon stage and put into the IDocument's user-data-holder, and it will be available to the painter right away via the chain described above. The only issue is making the painter invalidate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants