Editor Extension Points

The Visual Studio code editor has its own sort of API that it exposes via MEF. In MEF terms, the editor publishes a set of exports that you can then use within your own MEF parts to extend the editor in virtually unboundless ways.

With nearly 100% coverage of the editor’s features, the following feature areas are valid extension points that the Visual Studio editor exposes:

Image Content types—A content type in the context of a Visual Studio code editor is the type of text and syntax that the editor can parse and understand. If you think about this from a languages perspective, Visual Studio content types map directly to the various syntax and text formats that Visual Studio understands, such as C#, plain text, Hypertext Markup Language (HTML), XML, XAML, and so on.

Image Classification types and classification formats—Classification types are the types of text, appearing within a document, that the Visual Studio editor understands and looks for. In a typical C# file, for example, the editor recognizes numerical and string instances within the document because those are default classification types built in to Visual Studio. For each classification type, a format can be defined as well. A classic example of this is the highlighting and text coloring that you see within the editor for things like string literals or comments.

Image Margins and scrollbars—If you think of the physical layout of a code editor, its visual surface is dominated by the text area where the code actually lives, and this is surrounded by scrollbars and by a margin area (for instance, the area where you see breakpoint information). Both the margins and scrollbars are artifacts that can be customized with MEF parts.

Image Tags—Tags are objects that enable you to associate data with different recognized types of text within an editor. For instance, the SquiggleTag is implemented by Visual Studio to associate things like syntax errors with a chunk of text that is unrecognized. In this case, the data associated with the squiggle is the actual syntax error generated by the compiler; this data is manifested as a tooltip when you hover the mouse over the squiggle.

Image Adornments—Adornments are visual objects that can appear within an editor. Physically, they are implemented as Windows Presentation Foundation (WPF) objects, and they can exist at several different “layers” within the editor, so the adornment can actually occupy the same physical space as the text within the editor or float above text within the editor.

Image Mouse processors—Mouse processors are extension points that enable you to capture and handle mouse input.

Image Drop handlers—Drop handlers enable you to react to different types of objects as they are dropped on the editor surface. Visual Studio has a library of stock format types that it recognizes, including files, pen data, XAML, and TIFF or bitmap images.

Image Options—Using MEF, it is possible to define, store, and react to your own set of custom options within the editor.

Image IntelliSenseChapter 7, “Working with Visual Studio’s Productivity Aids,” discusses IntelliSense extensively. You can write your own IntelliSense functionality using MEF.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset