How-to: Enable Parameter Info ToolTips

IntelliSense Parameter Info ToolTips are windows that display parameter information about the procedure or method being typed. A method tip typically opens whenever the user types a parameter list token, such as an open parenthesis. It can also be invoked manually by pressing CTRL+SHIFT+SPACEBAR. Parameter Info ToolTips are automatically supported by Babel when parameter information is added to the parser rules. Enabling Parameter info ToolTips is done in the following steps (see the following procedures for details):

  • Adding Parameter Information

  • Adding Parameter Triggers

注意

You must provide your own lex/yacc-compatible tools; these tools are not included in the VS SDK and the language service project will not build without them. To build the language service using the sample grammar and parser for the sample My C Package, you must use version 1.24 or later of Bison and version 2.5.4a or later of Flex. Place the Bison and Flex executables in the Babel Tools folder, for example, <InstallPath>\VisualStudioIntegration\Babel\Tools. These version numbers are specific to the My C sample.

Adding Parameter Information

The standard service has three methods that support parameter information:

void startParameters( in const Location& ) const;
void parameter(in const Location& ) const;
void endParameters(in const Location& ) const;

The startParameters method is called whenever a parameter list starts with the location of the parameter list start token. The parameter method is called for every parameter separator found and the endParameters method is called when the parameter list is terminated. The following is an example from the My C parser.y sample:

Example of Parameter Information in My C

ParenArguments
    : StartArg EndArg            { g_service->matchPair($1,$2); } 
    | StartArg Arguments1 EndArg { g_service->matchPair($1,$3); }
    | StartArg Arguments1 error  
                { g_service->endParameters(@3);
                  g_service->expectError( "unmatched parenthesis", ")" ); }
    ;

StartArg
    : '('       { g_service->startParameters($1); }
    ;

EndArg
    : ')'       { g_service->endParameters($1); }
    ;    

Arguments1
    : Expr ','  { g_service->parameter($2); }  Arguments1
    | Expr
    ;

In the My C language, parentheses enclose a parameter list. The example is complicated by the need to call the different methods exactly when one of those tokens is recognized. In the Arguments1 rule, a mid-rule action is needed in order to call the parameter method at the right moment. If the rule is written as follows:

Arguments1
    : Expr ','  Arguments1  { g_service->parameter($2); }  
    | Expr
    ;

the parameter method is called after the other arguments in the Arguments1 production are recognized. Now, all of the parameter method calls are performed in reverse order.

The same kind of problem occurs when calling the startParameter and endParameter methods, which is why the StartArg and EndArg productions are explicitly added.

Adding Parameter Triggers

Although Parameter Info ToolTips can be explicitly invoked, they are much more useful when they open automatically. The trigger values TriggerParamStart, TriggerParamEnd, and TriggerParamNext trigger a Parameter Info ToolTip (see TriggerClass for more details on these and other trigger values). Simply add the relevant entries to the token info table. The following is an example from the My C sample:

Example of Adding Parameter Triggers in My C

   ...
   { '(', ClassText,  "'('", 
          CharDelimiter, TriggerParamStart | TriggerMatchBraces }, 
   { ')', ClassText,  "')'", 
          CharDelimiter, TriggerParamEnd | TriggerMatchBraces   },
   { ',', ClassText,  "','", CharDelimiter, TriggerParamNext    },     
   ...

Not all languages distinguish the parameter list open token from the parameter separator or closing token. It is acceptable to combine triggers. Although triggers start a parser action in order to show or dismiss a Parameter info ToolTip, the distinction in triggers is only used to optimize some common cases. The parser always has the final decision in showing the appropriate information.

See Also

Concepts

Language Service How-to Topics