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
IdentitySyntaxNodeIdA unique identifier for this specific syntax node.
SourceLocationSourceLocationThe source location of this module; the
SourceRangeis invalid.ChildrenImmutableArray<SyntaxNode>An immutable array containing all AST nodes of this module.
NamestringThe declared identifier name of the member.
MemberKindMemberKindSpecifies the kind of member.
AccessModifierAccessModifierAn access modifier, if one was supplied.
IsStaticbooltruewhen the procedure is declared with theStatickeyword (MS-VBAL §5.3.1.2): every local variable of it then has module extent, as if each were declaredStatic. Only aSub, aFunctionor a property can be.TypeHintstringThe 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 anAsclause. Only a member that returns a value can have one.NameRangeSourceRange?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
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
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
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
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
MemberKind
Specifies the kind of member.
public MemberKind MemberKind { get; init; }
Property Value
Name
The declared identifier name of the member.
public string Name { get; init; }
Property Value
NameRange
Where the name is written, with its type-declaration character; null when it is not known.
public SourceRange? NameRange { get; init; }
Property Value
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
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
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
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()