IParseSink::AddScope Method
Adds to a symbol tree (or scope) using the default IScope Interface implementation.
HRESULT AddScope (
long startLine,
long startIdx,
long endLine,
long endIdx,
ScopeKind kind,
ScopeAccess access,
ScopeStorage storage,
long glyph,
BSTR name,
BSTR type,
BSTR display,
BSTR description,
VARIANT_BOOL merge
);
Parameters
startLine
[in] Specifies the starting line for an item of the scope.startIdx
[in] Specifies the starting index position on startLine for an item of the scope. The index in the line is zero-based.endLine
[in] Specifies the ending line for an item of the scope.endIdx
[in] Specifies the ending index position on endLine for an item of the scope. The index in the line is zero-based.kind
[in] Specifies the kind of scope, for example, class, interface, or procedure. For more information, see ScopeKind Enumeration. The information from this parameter is used by the Babel Package in conjunction with the access and storage parameters to determine the icon to display.access
[in] Specifies the scope access, for example, private, protected, or public. For more information, see ScopeAccess Enumeration. The information from this parameter is used by the Babel Package in conjunction with the kind and storage parameters to determine the icon to display.storage
[in] Specifies the scope storage, for example, member, result, or static. For more information, see ScopeStorage Enumeration. The information from this parameter is used by the Babel Package in conjunction with the kind and access parameters to determine the icon to display.glyph
[in] Specifies an icon to use with the scope item. If the value of the glyph parameter is -1 or too large (that is, greater than the glyph count returned in the IBabelService::GetImageList Method), the icon is automatically selected using the kind, access, and storage parameters.name
[in] Name of the scope item. Can be NULL.type
[in] Type of the scope item. Can be NULL.display
[in] Display string for the scope item. Can be NULL.description
[in] Description of the scope item. Can be NULL.merge
[in] Used to merge identically named declarations. This parameter is not currently implemented. Always specify a value of zero (FALSE).
Return Value
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
Remarks
Call this method repeatedly to build your IScope Interface object using the default implementation provided with Babel. The default implementation can be accessed using the AddScope, IParseSink::AddInclude Method, and IParseSink::AddExtern Method methods. If you want to provide your own IScope Interface implementation, do not call these methods, but instead, return your IScope object through the scope parameter of the IBabelService::ParseSource Method method.
The Default Babel Implementation in the Language Service Package, this method is called from the StdService::addScope method that in turn can be called from within your grammar file. The example in the IBabelPackage::LoadScope method shows how this looks in a parser.y grammar file. For a more detailed discussion of using the StdService::addScope method, see How to: Provide Statement 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 parameters are interpreted and the addScope method is called on the language service (g_service) to add the scope information for each parameter. The addScope method eventually calls the IParseSink::AddScope method.
Params1
: Params1 ',' Type IDENTIFIER { $$ = $4;
g_service->addScope( $3, $4,
ScopeVariable,
AccessPublic,
StorageParameter,
$4, $3, $4, &$3 ); }
| Type IDENTIFIER { $$ = $2;
g_service->addScope( $1, $2,
ScopeVariable,
AccessPublic,
StorageParameter,
$2, $1, $2, &$1 ); }
;
See Also
Concepts
How to: Provide Statement Completion