extractScope

fun extractScope(node: HasNameAndLocation, scope: Scope? = currentScope): Pair<Scope?, Name>

This function extracts a scope for the Name, e.g. if the name is fully qualified. null is returned, if no scope can be extracted.

The pair returns the extracted scope and a name that is adjusted by possible import aliases. The extracted scope is "responsible" for the name (e.g. declares the parent namespace) and the returned name only differs from the provided name if aliasing was involved at the node location (e.g. because of imports).

Note: Currently only fully qualified names are properly resolved. This function will probably return imprecise results for partially qualified names, e.g. if a name A inside B points to A::B, rather than to A.

Return

a pair with the scope of node.name and the alias-adjusted name

Parameters

node

the nodes name references a namespace constituted by a scope

scope

the current scope relevant for the name resolution, e.g. parent of node


fun extractScope(name: Name, location: PhysicalLocation? = null, scope: Scope? = currentScope): Pair<Scope?, Name>

This function extracts a scope for the Name, e.g. if the name is fully qualified. null is returned, if no scope can be extracted.

The pair returns the extracted scope and a name that is adjusted by possible import aliases. The extracted scope is "responsible" for the name (e.g. declares the parent namespace) and the returned name only differs from the provided name if aliasing was involved at the node location (e.g. because of imports).

Note: Currently only fully qualified names are properly resolved. This function will probably return imprecise results for partially qualified names, e.g. if a name A inside B points to A::B, rather than to A.

Return

a pair with the scope of node.name and the alias-adjusted name

Parameters

name

the name

scope

the current scope relevant for the name resolution, e.g. parent of node