Extending Visual Studio

Code snippet implementation with the Managed Package Framework

I have had the opportunity to implement the Code Snippet support for the IronPython integration that is in the VS SDK.  The Code Snippet feature is new in Visual Studio 8.0 and it is a very nice addition to any language integration.  It allows users to decrease the investment required to master the syntax of a new language and it eliminates the tediousness of writing code that is used often.  For C# and VB, Visual Studio 8.0 comes with a plethora of simple code snippets like foreach loops, class definitions, if statements, etc.  The nice thing about snippets is that it is simple to add new ones.  You can find the directory where the snippets for a particular language are and create a new file there.  Visual Studio should have access to this newly created snippet immediately.

 

As for adding support for Snippets into a language integration, there are some challenges but most of them are covered by the VS SDK documentation topic:

ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.VSSDK.v80/dv_vsintegration/html/7490325b-acee-4c2d-ac56-1cd5db1a1083.htm

 

An interesting point that is not extensively covered by the documentation today is the glyph selection for the Statement Completion window.  The idea is to reuse the resources that Visual Studio provides in order to maintain the native feel of the integration.  All of the icons reside in a managed dll named “Microsoft.VisualStudio.Package.LanguageService.dll”.  However, there is no list of definitions of those icons.  One way to get the list is to use Reflector to inspect the resources within this managed dll and figure out the indexes of the interesting glyphs.  The snippet one is "205" so the GetGlyph(index) method of your Declaration class can return that to display snippets correctly.  

 

The SDK team is working on getting this process documented but in the meantime, you can view how it is implemented in the PythonDeclaration.cs in the LanguageService project of the latest version of the SDK. 

Published Friday, June 02, 2006 10:05 AM by cbrochu
Anonymous comments are disabled

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker