Quick Info in a Legacy Language Service

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Quick Info in a Legacy Language Service.

IntelliSense Quick Info shows information about an identifier in the source when the user either places the caret in the identifier and selects Quick Info from the IntelliSense menu or holds the mouse cursor over the identifier. This causes a tool tip to appear with information about the identifier. This information typically consists of the identifier type. When the debug engine is active, this information might include the current value. The debug engine supplies expression values , while the language service handles only identifiers.

Legacy language services are implemented as part of a VSPackage, but the newer way to implement language service features is to use MEF extensions. To find out more, see Walkthrough: Displaying QuickInfo Tooltips.

System_CAPS_ICON_note.jpg Note

We recommend that you begin to use the new editor API as soon as possible. This will improve the performance of your language service and let you take advantage of new editor features.

The managed package framework (MPF) language service classes provide full support for displaying the IntelliSense Quick Info tool tip. All you have to do is supply the text to be displayed and enable the quick info feature.

The text to be displayed is obtained by calling the ParseSource method parser with a parse reason value of QuickInfo. This reason tells the parser to obtain the type information (or whatever is appropriate to be displayed in the Quick Info tool tip) for the identifier at the location specified in the ParseRequest object. The ParseRequest object is what was passed to the ParseSource method.

The parser must parse everything up to the position in the ParseRequest object in order to determine the types of all identifiers. Then the parser must get the identifier at the parse request location. Finally, the parser must pass the tool tip data associated with that identifier to the AuthoringScope object so that object can return the text from the GetDataTipText method.

To enable the Quick Info feature, you must set the CodeSense and QuickInfo named parameters of the ProvideLanguageServiceAttribute.These attributes set the EnableCodeSense and EnableQuickInfo properties.

The ViewFilter class handles the IntelliSense Quick Info operation. When the ViewFilter class receives the QUICKINFO command, the class calls the ParseSource method with the parse reason of QuickInfo and the location of the caret at the time the QUICKINFO command was sent. The ParseSource method parser must then parse the source up to the given location and then parse the identifier at the given location to determine what to display in the Quick Info tool tip.

Most parsers do an initial parse of the entire source file and store the results in a parse tree. The complete parse is carried out when Check is passed to ParseSource method. Other kinds of parsing can then use the parse tree to obtain the desired information.

For example, the parse reason value of QuickInfo can find the identifier at the source location and look it up in the parse tree to obtain the type information. This type information is then passed to the AuthoringScope class, and is returned by the GetDataTipText method.

Show: