Share via


How to: Add Member Completion

Statement completion allows the user to select a property or method from a list after typing a member operator, such as -> in C++.

This topic is based on the Visual Studio Language Package solution, which provides a basic implementation of the Babel package. For more information about creating one of these solutions, see Walkthrough: Creating a Language Service Package.

Methods of the Babel Service

The startName and qualifyName methods specify how a member is selected, The startName method is called whenever an identifier is used in an expression. The qualifyName method is called for every identifier that is selected.

The following example shows how both the startName and qualifyName methods are called in the Identifier rule in a parser source file. Note how the qualifyName method is called with the '.' character plus the following identifier: the qualifyName method assumes that the preceding identifier was set by a call to the startName method.

Identifier
    : IDENTIFIER                 { g_service->startName($1); }
    | Identifier '.' IDENTIFIER  { g_service->qualifyName( $2, $3 ); }
    | Identifier '.' error       { g_service->qualifyName( $2, $2 ); }
    ;

Adding Member List Triggers

Member completion is caused by the TriggerMemberSelect trigger(see TriggerClass Enumeration for more information on triggers). Tokens are assigned triggers in the Service::getTokenInfo methodYou can add a token '.' with member completion by adding the following member to the tokenInfoTable array:

{ '.',  ClassText,  "'.'", CharDelimiter, TriggerMemberSelect }   

Change History

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.