Freigeben über


Language Service Interfaces

For any particular programming language, there can be only one instance of a language service at a time. However, a single language service can serve more than one editor.

Visual Studio does not associate a language service with any particular editor. Therefore, when you request a language service operation, you must identify the appropriate editor as a parameter.

Common Interfaces Associated with Language Services

The editor gets your language service by calling QueryService on the appropriate VSPackage. The service ID (SID) passed in this call identifies the language service being requested.

You can implement the core language service interfaces on any number of separate classes. However, a common approach is to implement the following interfaces in a single class:

The IVsLanguageInfo interface must be implemented on all language services. It provides information about your language service, such as the localized name of the language, the file name extensions associated with the language service, and how to retrieve a colorizer.

Additional Language Service Interfaces

Other interfaces can be provided with your language service. Visual Studio requests a separate instance of these interfaces for each instance of the text buffer. Therefore, you should implement each of these interfaces on its own object. The following table shows interfaces that require one instance per text buffer instance.

Interface

Description

IVsCodeWindowManager

Manages code window adornments, such as the drop-down bar. You can get this interface by using the GetCodeWindowManager method. There is one IVsCodeWindowManager per code window.

IVsColorizer

Colorizes language keywords and delimiters. You can get this interface by using the GetColorizer method. IVsColorizer is called at paint time. Avoid computation-intensive work inside IVsColorizer or performance could suffer.

IVsMethodData

Provides IntelliSense parameter tooltips. When the language service recognizes a character that indicates that method data should be displayed, such as an open parenthesis, it calls the SetMethodData method to notify the text view that the language service is ready to display a Parameter Info ToolTip. The text view then calls back into the language service by using the methods of the IVsMethodData interface to get the required information to display the tooltip.

IVsCompletionSet

Provides IntelliSense statement completion. When the language service is ready to display a completion list, it calls the UpdateCompletionStatus method on the text view. The text view then calls back into the language service by using methods on the IVsCompletionSet object.

IVsTextViewFilter

Allows for modification of the text view using the command handler. The class in which you implement the IVsTextViewFilter interface must also implement the IOleCommandTarget interface. The text view retrieves the IVsTextViewFilter object by querying the IOleCommandTarget object that is passed into the AddCommandFilter method. There should be one IVsTextViewFilter object for each view.

IOleCommandTarget

Intercepts commands that the user types into the code window. Monitor output from your IOleCommandTarget implementation to provide custom completion information and view modification

To pass your IOleCommandTarget object to the text view, call AddCommandFilter.

See Also

Concepts

Checklist: Creating a Language Service

Other Resources

Developing a Language Service