Table of Contents

Class MemberDeclarationNode

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

An AST node representing a member of a module.

public record MemberDeclarationNode : SyntaxNode, IEquatable<SyntaxNode>, IEquatable<MemberDeclarationNode>
Inheritance
MemberDeclarationNode
Implements
Derived
Inherited Members
Extension Methods

Constructors

MemberDeclarationNode(SyntaxNodeId, SourceLocation, ImmutableArray<SyntaxNode>, string, MemberKind, AccessModifier, bool, string?, SourceRange?)

An AST node representing a member of a module.

public MemberDeclarationNode(SyntaxNodeId Identity, SourceLocation SourceLocation, ImmutableArray<SyntaxNode> Children, string Name, MemberKind MemberKind, AccessModifier AccessModifier = AccessModifier.Implicit, bool IsStatic = false, string? TypeHint = null, SourceRange? NameRange = null)

Parameters

Identity SyntaxNodeId

A unique identifier for this specific syntax node.

SourceLocation SourceLocation

The source location of this module; the SourceRange is invalid.

Children ImmutableArray<SyntaxNode>

An immutable array containing all AST nodes of this module.

Name string

The declared identifier name of the member.

MemberKind MemberKind

Specifies the kind of member.

AccessModifier AccessModifier

An access modifier, if one was supplied.

IsStatic bool

true when the procedure is declared with the Static keyword (MS-VBAL §5.3.1.2): every local variable of it then has module extent, as if each were declared Static. Only a Sub, a Function or a property can be.

TypeHint string

The type hint the name is written with, if any (Function Name$()): the declared type of what a function or a property getter returns, written in place of an As clause. Only a member that returns a value can have one.

NameRange SourceRange?

Where the name is written, with its type-declaration character; null when it is not known.

Properties

AccessModifier

An access modifier, if one was supplied.

public AccessModifier AccessModifier { get; init; }

Property Value

AccessModifier

EndRange

Where the statement that closes the procedure is written: its End Sub, End Function or End Property; null for a member that is not a procedure, for a procedure written without one, or when it is not known.

public SourceRange? EndRange { get; init; }

Property Value

SourceRange?

Remarks

The range of the member runs through the Attribute lines written after this statement, which belong to the procedure: this is where its body ends.

HeaderAlternatives

The other headers of a procedure whose header is written once in each branch of a #If block, around one body (MS-VBAL §3.4): #If VBA7 Then / Private Function F(p As LongPtr) As LongPtr / #Else / Private Function F(p As Long) As Long / #End If, then the body and one End Function. Empty for a procedure that has one header.

public ImmutableArray<MemberDeclarationNode> HeaderAlternatives { get; init; }

Property Value

ImmutableArray<MemberDeclarationNode>

Remarks

The parse is of every branch, whatever the constants evaluate to: this node is the procedure as its header in one branch declares it - the one whose kind its closing statement is of - and each alternative is a header of another branch, with its own access, kind, name, parameters and type, at its own location. Which one is compiled is decided where the constants are known.

An alternative has no body: the statements written in its branch after its header are in Children, in source order, with the rest of the body, and are compiled when its branch is (WithEachHeader()).

HeaderChildren

What the header declares, of Children: the parameters and the As clause, which come before the body.

[JsonIgnore]
public IEnumerable<SyntaxNode> HeaderChildren { get; }

Property Value

IEnumerable<SyntaxNode>

IsStatic

true when the procedure is declared with the Static keyword (MS-VBAL §5.3.1.2): every local variable of it then has module extent, as if each were declared Static. Only a Sub, a Function or a property can be.

public bool IsStatic { get; init; }

Property Value

bool

MemberKind

Specifies the kind of member.

public MemberKind MemberKind { get; init; }

Property Value

MemberKind

Name

The declared identifier name of the member.

public string Name { get; init; }

Property Value

string

NameRange

Where the name is written, with its type-declaration character; null when it is not known.

public SourceRange? NameRange { get; init; }

Property Value

SourceRange?

ParameterListRange

Where the parameter list of the header is written, from its ( through its ); null when the header has none (Sub Main), or when it is not known.

public SourceRange? ParameterListRange { get; init; }

Property Value

SourceRange?

Remarks

Its end is the end of the ), which is where an As clause written after the list begins to be written: a fix that declares what a function returns writes it there.

TypeHint

The type hint the name is written with, if any (Function Name$()): the declared type of what a function or a property getter returns, written in place of an As clause. Only a member that returns a value can have one.

public string? TypeHint { get; init; }

Property Value

string

TypeHintRange

Where the TypeHint is written, at the end of the name (the \(</code> of <code>Function Name\)()); null when the name is written without one, or when it is not known.

public SourceRange? TypeHintRange { get; init; }

Property Value

SourceRange?

Methods

WithEachHeader()

The procedure as each of its headers declares it: this node, then each alternative with this node's body.

public IEnumerable<MemberDeclarationNode> WithEachHeader()

Returns

IEnumerable<MemberDeclarationNode>