Interface ISymbolResolver
A service that resolves an identifier name to a Symbol given a scope Uri
(MS-VBAL §5.6.4, §5.6.10).
public interface ISymbolResolver
- Extension Methods
Remarks
Name lookup: what a name binds to. The storage a running session binds its symbols to is ISymbolStorage, and a resolver of a running session is both (IRuntimeSymbolResolver). The static front end and the language server resolve names without a session, through this interface alone.
Methods
ResolveConditionalConstant(string, ScopeKind, Uri)
Resolves the specified identifier name as a reference to a conditional compilation
constant, as seen from the scope the symbol at handle belongs to.
SymbolResolutionResult ResolveConditionalConstant(string name, ScopeKind scope, Uri handle)
Parameters
namestringThe name of the constant to resolve.
scopeScopeKindA memory-scope hint; the compile-time resolver does not consult it.
handleUriThe Uri of the symbol the lookup originates from.
Returns
- SymbolResolutionResult
A SymbolResolutionResult carrying the bound constant, or an unbound result, which §5.6.16.2 gives a meaning of its own: a conditional compilation constant that names nothing evaluates to
0, not to an error.
Remarks
Its own binding context, and the reason is MS-VBAL §3.4.1: a #Const "defines
a constant binding accessible to <cc-expression> elements of the containing module",
and §5.6.16.2 is the only place a reference to one is defined at all. So a
conditional compilation constant is not a name in the default binding context (x = Win64
in ordinary source does not bind it, and ResolveValue(string, ScopeKind, Uri) never returns one), while a
#If Win64 Then resolves it only here.
§3.4.1 also gives the shadowing rule this follows: a module's own #Const shadows a
project-level constant of the same name.
ResolveMember(Symbol, string, Uri)
Resolves name as a member of owner, a project or a procedural module: the
right-hand side of a member access whose left-hand side is one of them (MS-VBAL §5.6.12):
Strings.LenB, VBA.Strings, VBA.LenB.
SymbolResolutionResult ResolveMember(Symbol owner, string name, Uri handle)
Parameters
ownerSymbolThe project or procedural module the member belongs to.
namestringThe name of the member to resolve.
handleUriThe Uri of the symbol the lookup originates from, which decides what is accessible.
Returns
- SymbolResolutionResult
A SymbolResolutionResult carrying the member, an unbound result when there is none, or an Ambiguous name detected (
VBC09301) error with the colliding candidates.
Remarks
What the member of a procedural module can be is what the module declares and the lookup can reach:
a variable, property, function, subroutine or value, and not one declared Private unless the lookup
originates in the module itself.
What the member of a project can be is, in the order the specification gives them: a project, when
owner is the enclosing project; a procedural module of the project of that name; and, only
when there is no such module, the one accessible member of that name that exactly one of the project's
procedural modules has: a name two of them declare is ambiguous, and the reference has to qualify it.
👉 A class module is not an owner here: its members are reached through an instance of it, which is a member access on a value and not on a namespace.
ResolveProjectType(VBProjectSymbol, string)
Resolves the type name that a project declares: the last part of Project.Name
(MS-VBAL §5.6.12).
SymbolResolutionResult ResolveProjectType(VBProjectSymbol project, string name)
Parameters
projectVBProjectSymbolThe project, as ResolveQualifier(string, ScopeKind, Uri) bound it.
namestringThe name of the type.
Returns
Remarks
The project tier is shared by the enclosing project and every library the project references, and the types of two of them can be of one name - a host
library and the library of its editor both have an Application. What the qualifier says is which of the candidates is meant, so the candidates are
those of the project and no others before it is decided that the name is ambiguous. A project is told from another by the library its symbols
say they are of (Library), which the enclosing project's own are not of any.
The default asks ResolveType(string, ScopeKind, Uri) and accepts what it gives if it is the project's, which is right for a resolver that has one candidate of a name to give; one that decides ambiguity itself overrides it.
ResolveQualifier(string, ScopeKind, Uri)
Resolves the specified identifier name as the qualifier of a qualified type name (the
A in A.B) in the type binding context (MS-VBAL §5.6.4), as seen from
the scope the symbol at handle belongs to. A qualifier is a namespace: it binds the project,
or a procedural or class module, and never a user-defined type or an Enum type, however the name ranks in
ResolveType(string, ScopeKind, Uri): neither can contain a type. A local, parameter, constant, variable or procedure is
never a candidate either.
SymbolResolutionResult ResolveQualifier(string name, ScopeKind scope, Uri handle)
Parameters
namestringThe name of the Symbol to resolve.
scopeScopeKindA memory-scope hint; the compile-time resolver does not consult it.
handleUriThe Uri of the symbol the lookup originates from.
Returns
- SymbolResolutionResult
A SymbolResolutionResult: the bound Symbol, an unbound result, or an Ambiguous name detected (
VBC09301) error with the colliding candidates.
Remarks
Which lookup a name uses is positional: the last part of A.B, like a bare name, is bound by
ResolveType(string, ScopeKind, Uri); only what precedes a dot is bound here. This holds wherever a type name appears:
an As clause, As New, the operand of New.
ResolveType(string, ScopeKind, Uri)
Resolves the specified identifier name in the type binding context
(MS-VBAL §5.6.4), as seen from the scope the symbol at handle
belongs to. This is the context of an expression that expects a type or class name: an
As clause, the operand of New: it binds a user-defined type, an Enum type, a class or
procedural module, or the project. A local, parameter, constant, variable or procedure is never a
candidate, however it is named, so it can neither be bound nor hide the type it shadows in
ResolveValue(string, ScopeKind, Uri). The qualifier of a qualified type name (A in A.B) is bound by
ResolveQualifier(string, ScopeKind, Uri) instead.
SymbolResolutionResult ResolveType(string name, ScopeKind scope, Uri handle)
Parameters
namestringThe name of the Symbol to resolve.
scopeScopeKindA memory-scope hint; the compile-time resolver does not consult it.
handleUriThe Uri of the symbol the lookup originates from.
Returns
- SymbolResolutionResult
A SymbolResolutionResult: the bound Symbol, an unbound result, or a Duplicate declaration in current scope (
VBC09303) / Ambiguous name detected (VBC09301) error with the colliding candidates.
ResolveValue(string, ScopeKind, Uri)
Resolves the specified identifier name in the default binding context
(MS-VBAL §5.6.4), as seen from the scope the symbol at handle
belongs to. This is the context of a simple name expression: it binds a variable, constant,
Enum type or member, property, function, subroutine, procedural module or project
(§5.6.10), and never a user-defined type or a class module, which are only ever
candidates in the type binding context (ResolveType(string, ScopeKind, Uri)). A class module is a name here
only through its predeclared instance (§5.2.4.1.2): a variable named after the class.
SymbolResolutionResult ResolveValue(string name, ScopeKind scope, Uri handle)
Parameters
namestringThe name of the Symbol to resolve.
scopeScopeKindA memory-scope hint; the compile-time resolver does not consult it.
handleUriThe Uri of the symbol the lookup originates from.
Returns
- SymbolResolutionResult
A SymbolResolutionResult: the bound Symbol, an unbound result, or a Duplicate declaration in current scope (
VBC09303) / Ambiguous name detected (VBC09301) error with the colliding candidates.