Share via


IParseSink::StartName Method

Called when an identifier is parsed.

HRESULT StartName ( 
   long line,
   long startIdx,
   long endIdx
);

Parameters

  • line
    [in] Specifies the line containing the identifier.

  • startIdx
    [in] Specifies the starting index in the line of the first character in the identifier.

  • endIdx
    [in] Specifies the ending index in the line of the last character in the identifier.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

Call this method only if your IBabelService::ParseSource Method implementation is called with any of the following ParseReason Enumeration values in the reason parameter:

  • ReasonMemberSelect

  • ReasonCompleteWord

  • ReasonQuickInfo

  • ReasonMethodTip

  • ReasonAutos

You should call IParseSink::StartName once for each start name (identifier) that is found in the span of text passed to you in the text parameter of IBabelService::ParseSource Method.

The Babel Package uses the information returned by this method and IParseSink::QualifyName Method in combination with a TriggerMemberSelect value to query the most recent IScope Interface object returned in IBabelService::ParseSource Method and determine the information needed to populate the method information window, for example.

The Default Babel Implementation in the Language Service Package, this method is called from the StdService::startName method that in turn can be called from within your grammar file. The Example in this topic shows how the startName method is called when an identifier is parsed.

For a more detailed discussion of using the StdService::startName method, see How to: Add Member Completion.

Example

This is a fragment from the default parser.y grammar file that is created using the Visual Studio Language Service Wizard. This fragment shows how identifiers and identifiers with member select are interpreted and the startName method is called on the language service (g_service). The startName method eventually calls the IParseSink::StartName method.

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

See Also

Tasks

How to: Add Member Completion

Reference

IParseSink Interface

IBabelService::ParseSource Method

ParseReason Enumeration