Skip to content

GenDecl

1 min read

Import: import system.codegen;

GenDecl

A class, struct, union, enum or interface the generator's triggers selected.

public class GenDecl

id

Identity of this model node; pass it to GenContext.error_at to report a diagnostic here.

public id: string

name

Unqualified declaration name (User).

public name: string

kind

Whether this declares a class, struct, union, enum, or interface.

public kind: DeclKind

module_name

Fully qualified module containing the declaration.

public module_name: string

visibility

Declared access level of this symbol.

public visibility: string

location

Where the declaration is written in source.

public location: GenLocation

generics

Names of the declared type parameters, in order.

public generics: List<string>

interfaces

Interfaces implemented by the declaration.

public interfaces: List<GenTypeRef>

attributes

Attributes attached to this declaration.

public attributes: List<GenAttribute>

fields

Fields of this type, in declaration order.

public fields: List<GenField>

methods

Methods declared by this type.

public methods: List<GenFunction>

variants

Choices declared by this union or enum, in declaration order.

public variants: List<GenVariant>

constructor

Creates a GenDecl from its parts. Generators normally receive these from GenContext rather than constructing them.

public constructor(
    id: string,
    name: string,
    kind: DeclKind,
    module_name: string,
    visibility: string,
    location: GenLocation,
    generics: List<string>,
    interfaces: List<GenTypeRef>,
    attributes: List<GenAttribute>,
    fields: List<GenField>,
    methods: List<GenFunction>,
    variants: List<GenVariant>
)

attribute

The first @A attached to this declaration, decoded into A, or None when absent.

public fun attribute<A>(): Option<A>

has

Whether this declaration carries at least one @A attribute.

public fun has<A>(): bool

self_type

Name or Name<T, U>: the spelling of this type inside its own generic scope.

public fun self_type(): string