Class NamespaceExpressions
Recognizing the expressions that name a project or a procedural module rather than a value
(MS-VBAL §5.6.12): the left-hand side of Strings.LenB, and of VBA.Strings.LenB.
public static class NamespaceExpressions
- Inheritance
-
NamespaceExpressions
- Inherited Members
Remarks
Such an expression is a namespace. It has no value to evaluate and no declared type, and a member access on it resolves the member in the namespace — ResolveMember(Symbol, string, Uri) — instead of looking it up among the members of a value's type. Which of the two a left-hand side is has to be settled by what it resolves to, from the scope it is written in, and the answer is the same whether the question is asked while compiling the expression or while running it, so it is answered here once.
Methods
IsNamespace(Symbol)
Whether symbol is a namespace: a project, or a procedural module.
public static bool IsNamespace(Symbol symbol)
Parameters
symbolSymbolThe symbol to classify.
Returns
Remarks
A class module is not one: its members are reached through an instance of it.
NamespaceOf(ISymbolResolver, ExpressionNode, Uri)
The project or procedural module expression names, when it names one.
public static Symbol? NamespaceOf(this ISymbolResolver resolver, ExpressionNode expression, Uri scope)
Parameters
resolverISymbolResolverThe resolver names are bound by.
expressionExpressionNodeThe left-hand side of a member access.
scopeUriThe Uri of the symbol the expression is written in.
Returns
- Symbol
The VBProjectSymbol or VBStandardModuleSymbol it names, or null.
Remarks
Classification is by what the name resolves to, so whatever is nearer than a module of that name — a local, a
parameter, a variable of the module — is what the name means, as it is anywhere else. A member access whose own
left-hand side is a namespace is one too, when its member is a project or a module: VBA.Strings in
VBA.Strings.LenB.