Extensibility Overview
See Also
Extensibility is the capacity to extend, or stretch, the functionality of the Microsoft Visual Studio integrated development environment (IDE). The IDE provides you with a programming interface known as the Extensibility object model, a set of powerful, easy-to-understand interfaces for customizing the environment. It allows you to hook into the IDE to create extensions known as add-ins.
There are two types of extensibility: built-in and user-designed.
-
Built-in extensibility features are already contained in the development environment. They're conveniences such as keyboard rebinding, customizable command bars, docked and tab-linked window configurations that you can name and return to at any time, new templates that you can create for the Template wizard, and so forth.
-
User-designed extensibility features are constructed with code. They take two different forms: add-ins and wizards.
-
Add-ins are time- and labor-saving automation tools that snap into the IDE. These tools are Microsoft ActiveX servers that communicate with the IDE through the Extensibility object model and accessed through the
IDTExtensibility2
interface.
-
Wizards are variations of add-ins that lead a user step-by-step through a series of actions to accomplish a complex or difficult task. Wizards are created using the
IDTWizard
interface.
In addition to the object model provided by the Visual Studio IDE, each of the Visual Studio development languages provides additions to the Extensibility object model to support specific features of the environment. This means that you can write add-ins to automate the common IDE using the common environment's Extensibility object model and specific features in Microsoft Visual J++, or any of the other development languages using the object model provided for that language.
The Extensibility object model consists of four related groups of individual code objects that control major facets of the common IDE. Each functional group enables you to create tools to customize the development environment and help you accomplish your programming tasks more quickly and easily. These groups are:
-
Window manipulation objects
-
Event objects
-
Add-in management objects
-
Project manipulation objects
Each group consists of one or more collections and objects that contribute to a particular purpose. For example, the primary function of the events object group is to provide access to events occurring in the development environment. One object in this group is the CommandBarEvents object, which allows you to trap events occurring on menus and toolbars. Another is the BuildEvents object, which exposes events occurring at the beginning and end of solution builds.
Extensibility Ideas
There are many ways you can use add-ins and wizards to enhance, extend, and automate the IDE:
-
Manipulate environment-wide properties such as those found in the Options dialog box from the Tools menu.
-
Navigate the solution and project structure by adding and removing projects and project items, opening project items in one of several views (for example, designer or source), modifying project items, and so on.
-
Add and remove commands and get events when commands fire.
-
Access and control all the windows in the environment: close them, dock them, hide them, set the focus, and even create new tool windows that are dockable and behave like built-in tool windows. You can also access the text buffer for source editor windows.
-
Sink events that occur when solutions are opened and closed, builds begin and end, projects and project items are added or removed, or when the selection changes.
-
Access the Visual J++ code model from any Visual J++ project's .java item to navigate and manipulate the code in that file. You can also access the code model from the root of the add-in object model to access a particular package, class, or file by name.
-
With .java files, access objects from the code model object for the package into which the code is compiled, the collection of imports at the top of the file, and a collection of classes in the file.
-
Add or remove imports.
-
With class objects, access or modify a collection of interfaces implemented by the class, a collection of members, a collection of superclasses, a collection of subclasses, and the modifiers for the class.
-
With members, distinguish fields from methods, get type information for fields and signature information for methods, return to the class object, get the initializer expression for a field, access the modifiers, access the statements in methods, and add and remove members, as well as modify these properties.
-
With statements, query their type (for example, if, for, sync, etc.) and add and remove statements from blocks of code.
-
For source elements (classes and members), access their JavaDoc comments as an object. This object lets you get the comment as a synopsis, a short description, or the entire text. You can index the object by name for various tags. Some standard tags that are likely to occur repeatedly in a single comment are available also in special collections. For example, you can index
@param
tags by the name of the parameter to get the text of the tag.
These are just a few ideas. Add-ins give you the freedom to create custom programming solutions to save you time and help you become more productive. Just think of the possibilities!