Language Service Objects
Your language service object must implement the IVsLanguageInfo interface. 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 instance.
Your VSPackage creates only one IVsLanguageInfo object. The integrated development environment (IDE) cannot anticipate that this language service object is attached to any particular text buffer or document view, that is, to any particular editor instance. Therefore, when you request from the IDE an operation of your language service object, you must identify the appropriate editor instance as a parameter.
Common Interfaces Associated with Language Services
The editor requests the IVsLanguageInfo object by calling QueryService on the appropriate VSPackage. The service ID (SID) passed in this call identifies the language service being requested. This means that you can implement the core language service interfaces on any number of separate objects. However, a common approach is to implement the following interfaces all on one object:
Required Language Service Interfaces
The following table shows the interface required to implement a language service.
Interface |
Description |
---|---|
Provides information about your language service, such as the localized name of the language, what file name extensions are associated with the language service, and how to retrieve a colorizer object. |
Additional Language Service Interfaces
Other interfaces can be provided with your language service. The IDE 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 |
---|---|
Manages code window adornments, such as the drop-down bar. This object is retrieved using the GetCodeWindowManager method. There is one IVsCodeWindowManager per code window. |
|
Colorizes language syntax. This object is retrieved using the GetColorizer method. IVsColorizer is called at paint time, because efficiency is high priority. Avoid computation-intensive work inside IVsColorizer or performance could suffer. |
|
Provides IntelliSense Parameter Info Tooltips. When the language service recognizes a character that indicates that method data should be displayed, such as an opening 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 Parameter Info ToolTip. |
|
Provides IntelliSense statement completion. When the language service is ready to display a completion list, it calls the UpdateCompletionStatus method on the text view object. The text view then calls back into the language service by using methods on the IVsCompletionSet object. Your language service object must also implement IOleCommandTarget. To pass your IOleCommandTarget object to the text view, call AddCommandFilter. The command filter intercepts commands that the user types into the code window. Monitor this command information to determine when to display statement completion information to the user. |
|
Allows for modification of the text view using the command handler. When you implement the IVsTextViewFilter interface on your object, you must also provide an IOleCommandTarget interface off of the object. 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. |
|
Intercepts commands. Monitor output from your IOleCommandTarget implementation to provide custom completion information and view modification. |