2

Add Syntax Highlighting to IElisonBuffer

I follow this question and implement my visual studio editor extension. I got everything working fine: syntax highlight, completion...but I cannot add breakpoint even thought the options was there in the right context menu (disabled)

Is there anything else I need to do to enable this feature for my editor?

Community
  • 1
  • 1
Quang
  • 51
  • 4

1 Answers1

1

Well, for the breakpoint to actually do anything, you'll need to implement a debugger (via the AD7 interfaces, etc.).

But to just get the actual breakpoint toggling working, all you need to do is implement the IVsLanguageDebugInfo interface (and optionally IVsLanguageDebugInfo2 and IVsLanguageDebugInfo3 too for more control). (I suggest you do so on the your language info object that's already implementing IVsLanguageInfo.) Don't forget to register your implementation so that VS knows about it.

ValidateBreakpointLocation() will be called when the user presses F9, etc., and in it you should set the breakpoint span to the appropriate bounds of the line (or portion of the line depending on your language, e.g. you might be in a lambda or want to highlight a statement except for any trailing comments on the line), then return VSConstants.S_OK.

Cameron
  • 96,106
  • 25
  • 196
  • 225
  • Thanks for the answer. Basically I just want the toggling to work, it is disabled in my editor window. This editor is default C# editor so I don't really want to customize it, just simply want it to work as the default one. These are the things I have: IVsTextLines docData, IVSCodeWindow codeWindow, IVsTextView textView, IVsTextBuffer textBuffer, IWpfTextViewHost textViewHost. So I am not sure after I implement the IVsLanguageDebugInfo how do I link my implementation to the aboves things that I already have. – Quang Dec 18 '14 at 08:33
  • More info: In this case, I just create an InvisibleEditor from a filepath (.cs), then get the DocData from this InvisibleEditor which should have the language service (C#). If the the DocData already have the language service, I am not sure why I have to provide IVsLangueDebugInfo. My assumption is that the default C# langue service should provide all the default implementation, because in this case I don't create any new language. – Quang Dec 18 '14 at 09:51
  • @user: Hmm, interesting. I didn't know it was possible to reuse an existing language service, and I agree that I'd expect the breakpoints to already work in that case. To proffer the info object to VS, I believe you need to implement the interface on the language service object itself (having just reread the documentation). But it sounds like you don't have one. Can you explain a bit more what you're trying to accomplish? Perhaps there's another way. – Cameron Dec 18 '14 at 15:37
  • Basically I want to have 2 editor views for a C# file. One is for full view and one is for a partial view (zoom into 1 function). I follow the tutorial in: http://joshvarty.wordpress.com/2014/08/01/ripping-the-visual-studio-editor-apart-with-projection-buffers/ and It works well as expected except inserting breakpoint in the custom editor. The idea is to reuse the default C# editor (with default language service maybe) and just give it different text span to display the partial view. – Quang Dec 19 '14 at 02:21
  • @user: Ah, I see. (Interesting idea, by the way.) I think I rather misunderstood your question. I'm afraid I don't know how breakpoints can be enabled in a custom editor, sorry. – Cameron Dec 19 '14 at 04:19