Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Enumeration

mattt edited this page Feb 7, 2020 · 8 revisions

Enumeration

An enumeration declaration.

public struct Enumeration: Declaration, Hashable, Codable

Inheritance

Codable, Hashable, Declaration

Nested Types

Enumeration.Case

Initializers

init?(element:)

private init?(element node: EnumCaseElementSyntax)

init(_:)

Creates an instance initialized with the given syntax node.

public init(_ node: EnumDeclSyntax)

init(_:)

Creates an instance initialized with the given syntax node.

@available(swift, introduced: 0.0.1, deprecated: 0.0.1, message: "Use Enumeration.Case.cases(from:) instead") public init(_ node: EnumCaseDeclSyntax)

Properties

keyword

The enumeration declaration keyword (enum).

let keyword: String

context

A dot-delimited (.) path used to qualify the enumeration name within the module scope of the declaration, or nil if the enumeration isn't nested (that is, declared at the top-level scope of a module).

let context: String?

For example, given the following declaration of an enumeration C, the context is "A.B":

enum A { enum B { enum C {} }

genericParameters

The generic parameters for the declaration.

let genericParameters: [GenericParameter]

For example, the following declaration of enumeration E has a single generic parameter whose name is "T" and type is "Equatable":

enum E<T: Equatable> {}

attributes

The enumeration declaration attributes.

let attributes: [Attribute]

modifiers

The enumeration declaration modifiers.

let modifiers: [Modifier]

description

var description: String

inheritance

A list of inherited type names.

let inheritance: [String]

If the enumeration is raw representable, the first element is the raw value type. Any other elements are names of protocols.

For example, given the following declarations, the inheritance of enumeration E is ["Int", "P"]:

protocol P {}
enum E: Int, P {}

name

The name of the enumeration.

let name: String

genericRequirements

The generic parameter requirements for the declaration.

let genericRequirements: [GenericRequirement]

For example, the following declaration of enumeration E has a single requirement that its generic parameter identified as "T" conforms to the type identified as "Hahable":

enum E<T> where T: Hashable {}

description

var description: String

Methods

cases(from:)

Creates and returns enumeration cases from an enumeration case declaration.

public static func cases(from node: EnumCaseDeclSyntax) -> [Enumeration.Case]

Clone this wiki locally