次の方法で共有


Quick Info in a Legacy Language Service

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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.

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 ParseReason. 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.

Enabling the Quick Info Feature

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.

Implementing the Quick Info Feature

The ViewFilter class handles the IntelliSense Quick Info operation. When the ViewFilter class receives the VSConstants.VSStd2KCmdID command, the class calls the ParseSource method with the parse reason of ParseReason and the location of the caret at the time the VSConstants.VSStd2KCmdID 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 ParseReason 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 ParseReason 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.