Table of Contents

Class ModuleNodeExtensions

Namespace
RDCore.SDK.Model.AST.Declarations
Assembly
RDCore.SDK.dll

Helpers over a parsed ModuleNode.

public static class ModuleNodeExtensions
Inheritance
ModuleNodeExtensions
Inherited Members

Methods

GetDeclaredName(ModuleNode)

The module name declared by the module-level Attribute VB_Name directive, or null when the module declares none.

public static string? GetDeclaredName(this ModuleNode module)

Parameters

module ModuleNode

Returns

string

Remarks

This is the authoritative programmatic name of a module; callers that also need the file-name fallback should route through ModuleName.Resolve. A member-qualified attribute (Attribute Foo.VB_Description) carries a Binding and is not a module name.

GetImplementedInterfaceNames(ModuleNode)

The interface names named by this module's own Implements directives (MS-VBAL §5.2.4.2), exactly as written — unresolved, in source order. A project-qualified name (Implements Project.IFoo) yields just IFoo: RDCore only ever composes one project's modules at a time, so the qualifier can only ever mean this same project. A half-typed Implements with no name at all is skipped.

public static ImmutableArray<string> GetImplementedInterfaceNames(this ModuleNode module)

Parameters

module ModuleNode

Returns

ImmutableArray<string>

GetImplementedInterfaceRanges(ModuleNode)

Where each of GetImplementedInterfaceNames(ModuleNode) is written: the source range of its Implements directive, one for each name and in the same order.

public static ImmutableArray<SourceRange> GetImplementedInterfaceRanges(this ModuleNode module)

Parameters

module ModuleNode

Returns

ImmutableArray<SourceRange>

GetMemberDescription(ModuleNode, string)

The text of a member's own Attribute <member>.VB_Description directive - what the member does, as the VBE's Object Browser and a completion list show it - or null when the module declares none for that member.

public static string? GetMemberDescription(this ModuleNode module, string memberName)

Parameters

module ModuleNode
memberName string

Returns

string

Remarks

The value is a string literal: its quotes are not part of the text, and a doubled quote in it is one.

GetMemberUserMemId(ModuleNode, string)

The value of a member's own Attribute <member>.VB_UserMemId directive, or null when the module declares none for that member. RD-VBA's own use of the value: WellKnownDispIds.Value (0) denotes the class's default member, WellKnownDispIds.NewEnum (-4) its enumeration member.

public static int? GetMemberUserMemId(this ModuleNode module, string memberName)

Parameters

module ModuleNode

The module that declares the member.

memberName string

The name of the member.

Returns

int?

Remarks

Unlike a module-level attribute (VB_Name, VB_Creatable, ...), a member-qualified attribute statement is written lexically inside the member's own body — the parser attaches it as a child of that member's own MemberDeclarationNode, not the module's — so this searches the named member's Children, not the module's own Children directly.

GetModuleDirectives(ModuleNode?)

The ModuleDirectives a module declares, read from its Option directives and its Attribute VB_PredeclaredId, VB_Creatable, VB_Exposed and VB_Extensible declarations.

public static ModuleDirectives GetModuleDirectives(this ModuleNode? module)

Parameters

module ModuleNode

The module, or null for a module that did not parse.

Returns

ModuleDirectives

The module's directives, or None when module is null: a module nobody could read declares nothing, which is also what every default says.

Remarks

Every consumer that needs the whole set reads it here rather than assembling its own, so a directive added to ModuleDirectives reaches all of them at once. Strict is not among them: it comes from an RD-VBA annotation rather than an Option directive.

GetOptionBase(ModuleNode)

The lower bound an array dimension declared without one takes in this module (MS-VBAL §5.2.1.2): 1 when the module declares Option Base 1, and 0 when it declares Option Base 0 or no Option Base at all.

public static int GetOptionBase(this ModuleNode module)

Parameters

module ModuleNode

Returns

int

GetOptionCompare(ModuleNode)

The comparison mode the module declares with an Option Compare directive (MS-VBAL §5.2.1.1), Binary when it declares none.

public static OptionCompare GetOptionCompare(this ModuleNode module)

Parameters

module ModuleNode

Returns

OptionCompare

HasOptionExplicit(ModuleNode)

Whether the module declares Option Explicit (MS-VBAL §5.2.1.3).

public static bool HasOptionExplicit(this ModuleNode module)

Parameters

module ModuleNode

Returns

bool

HasOptionPrivateModule(ModuleNode)

Whether the module declares Option Private Module (MS-VBAL §5.2.1.4).

public static bool HasOptionPrivateModule(this ModuleNode module)

Parameters

module ModuleNode

Returns

bool

IsCreatable(ModuleNode)

Whether a class module is instantiable via New, per its Attribute VB_Creatable directive. Defaults to true — VBE's own default for a class module that declares no such attribute — so this is meaningful to call on any module, not just class modules.

public static bool IsCreatable(this ModuleNode module)

Parameters

module ModuleNode

Returns

bool

IsExposed(ModuleNode)

Whether a class module is accessible within the projects that reference its project, per its Attribute VB_Exposed directive (MS-VBAL §5.2.4.1.1). Defaults to false, the Private instancing mode, for a module that declares no such attribute.

public static bool IsExposed(this ModuleNode module)

Parameters

module ModuleNode

The module.

Returns

bool

IsExtensible(ModuleNode)

Whether a module is an extensible module (MS-VBAL §4.2.1) - what a host's document modules are - per its Attribute VB_Extensible directive. Defaults to false: a module that declares no such attribute is an ordinary one.

public static bool IsExtensible(this ModuleNode module)

Parameters

module ModuleNode

Returns

bool

IsPredeclared(ModuleNode)

Whether a class module has a predeclared default instance, per its Attribute VB_PredeclaredId directive (MS-VBAL §5.2.4.1.2). Defaults to false — VBE's own default for a class module that declares no such attribute.

public static bool IsPredeclared(this ModuleNode module)

Parameters

module ModuleNode

Returns

bool