Checklist: Creating a Language Service
The following checklist summarizes the basic steps you must take in order to create a language service for the Visual Studio core editor. To integrate your language service into Visual Studio, you must create a debug expression evaluator. For more information, see Writing a Common Language Runtime Expression Evaluator in the Visual Studio Debugger Extensibility.
Steps for Creating a Language Service
Implement the IVsPackage interface.
In your VSPackage, implement the IServiceProvider interface to provide the language service.
Make your language service available to the integrated development environment (IDE) in your SetSite implementation.
Implement the IVsLanguageInfo interface in the main language service class.
The IVsLanguageInfo interface is the starting point of interaction between the core editor and the language service.
Optional Features
The following features are optional and can be implemented in any order. These features increase the functionality of your language service.
Syntax coloring
Implement the IVsColorizer interface. Your implementation of this interface should the parser information to return the appropriate color information.
The GetColorizer method returns the IVsColorizer interface. A separate colorizer instance is created for each text buffer, so you should implement the IVsColorizer interface separately. For more information, see Syntax Coloring.
Code window
Implement the IVsCodeWindowManager interface to enable the language service to receive notification of when a new code window is created.
The GetCodeWindowManager method returns the IVsCodeWindowManager interface. The language service can then add special UI to the code window in AddAdornments. The language service can also do any special processing, such as adding a text view filter in OnNewView.
Text view filter
To provide IntelliSense statement completion in a language service, you must intercept some of the commands that the text view would otherwise handle. To intercept these commands, complete the following steps:
Implement IOleCommandTarget to participate in the command chain and handle editor commands.
Call the AddCommandFilter method and pass in your IOleCommandTarget implementation.
Call the RemoveCommandFilter method when you detach from the view so that these commands are no longer passed to you.
Commands that must be handled depend on the services that are provided. For more information, see Important Commands for Language Service Filters.
Hinweis
The IVsTextViewFilter interface must be implemented on the same object as the IOleCommandTarget interface.
Statement completion
Implement the IVsCompletionSet interface.
Support the statement completion command (that is, COMPLETEWORD) and call the UpdateCompletionStatus method in the IVsTextView interface, passing the IVsCompletionSet interface. For more information, see Statement Completion.
Method tips
Implement the IVsMethodData interface to provide data for the method tip window.
Install the text view filter to handle commands appropriately, so that you know when to show a method data tip window. For more information, see Parameter Info Tooltips.
Error markers
Implement the IVsTextMarkerClient interface.
Create the error marker objects that implement the IVsTextMarkerClient interface and call the CreateLineMarker method, passing the IVsTextMarkerClient interface of the error marker object.
Typically each error marker manages an item in the task list window.
Task List items
Implement a task item class providing the IVsTaskItem interface.
Implement a task provider class providing the IVsTaskProvider interface and the IVsTaskProvider2 interface.
Implement a task enumerator class providing the IVsEnumTaskItems interface.
Register the task provider with the task list's RegisterTaskProvider method.
Obtain the IVsTaskList interface by calling the language service's service provider with the service GUID SVsTaskList.
Create task item objects and call the RefreshTasks method in the IVsTaskList interface when there are new or updated tasks.
Comment task items
Use the IVsCommentTaskInfo interface and the IVsEnumCommentTaskTokens interface to obtain the comment task tokens.
Obtain an IVsCommentTaskInfo interface from the SVsTaskList service.
Obtain the IVsEnumCommentTaskTokens interface from the EnumTokens method.
Implement the IVsTaskListEvents interface to listen for changes in the token list.
Outlining
There are several options for supporting outlining. For example, you can support the Collapse to Definitions command, provide editor-controlled outline regions, or support client-controlled regions. For more information, see How to: Provide Expanded Outlining Support.
Language service registration
For more information about how to register a language service, see Registering a Language Service and Loading VSPackages.
Context-sensitive Help
Provide context to the editor in one of the following ways:
- Provide context for text markers by implementing the IVsTextMarkerContextProvider interface.
Provide all user context by implementing the IVsLanguageContextProvider interface.