20

I want to develop an extension for VS2010 that will allow me make some additional features to syntax-highlighting.

I installed the SDK, how do I start from?

Please give a little snippet (or a link to code) where I can see how to start.

Note: do I have to check the whole block of code, or the SDK tells me on each word what it is, how it's declared etc.?

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
  • Microsoft have a site dedicated to this http://msdn.microsoft.com/en-us/vstudio/vextend.aspx is there nothing there that helps? – Chris Diver Jul 15 '10 at 07:09
  • Not specifically regarding syntax highlighting. I thought I am gonna ask the extentension Ninjas here to save the unnecessary steps (i dont want to focus in other fields, just syntax highlighting). Also note my note, it's very important for me to know before I start so I can evaluate time-cost. Thanks – Shimmy Weitzhandler Jul 15 '10 at 08:07

2 Answers2

21

There's a decent bit of information out there for writing classifiers. I wrote a blog article about it awhile back.

As for samples/code, there's:

The answer to the other part of your question about if the SDK tells you what each word is, the answer is "no", with a few "kinda" caveats. In general, the underlying language models are not exposed, though you can do things like consume the classification information from other classifiers in the hope that they give you enough information; some, like C#, tend to give a good deal of information that may not show up in the IDE in the default fonts and colors settings (check the Tools->Options->Environment->Fonts and Colors settings to see if you want to change may already be there), and others, like VB, tend not to. You can also use things like DTE's CodeModel, but I've never heard of someone having really good experiences with it.

If you want an example of consuming classification information, you can see how this CommentTextTagger.cs (part of a spellchecker extension) does it.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Noah Richards
  • 6,777
  • 2
  • 31
  • 28
  • Actually, that's exactly what I wanna do; I want to make the highlighting in VB for classes, enums, structures, methods, namespaces just like C# does (partially) and make local variables bold, static variables italic etc. etc. – Shimmy Weitzhandler Jul 16 '10 at 08:40
  • Also, I want to improve the existing VB/C# intellisense so it has a filter like Karl Shifflett did in the XAML intellisense. – Shimmy Weitzhandler Jul 16 '10 at 08:46
  • Shimmy, did you have any success in your effort? I'd like to do the same thing, starting with giving method parameters a bit of colour. Now I'm sitting in front of the classifier template and have all purple text. I have no idea how to get the linked tagger thing to work. – ygoe Nov 13 '14 at 22:01
2

You might check out

http://code.msdn.microsoft.com/ookLanguage

which has a syntax highlighter in "OokTokenTag.cs" in the C# sample. You do have to parse a whole block of text, of course, but this is not too hard.

(Found that link from http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/657212c1-1685-4ed6-be2f-cbf34fcc5b20 )

Brian
  • 117,631
  • 17
  • 236
  • 300
  • But this only talks about individual words, I wanna find out if a word is a class, enum, private etc. – Shimmy Weitzhandler Jul 18 '10 at 17:33
  • There is a video that introduces the Ook sample: http://channel9.msdn.com/Blogs/VSIPMarketing/VSX212-Adding-a-Language-Service-into-Visual-Studio-2010 -- unfortunately the video keeps referring to a presentation "from yesterday" that does not seem to exist on the web. Related SO Q: http://stackoverflow.com/questions/4283072/how-to-create-a-new-language-for-use-in-visual-studio – Qwertie Oct 20 '13 at 19:24