SwiftSemantics Documentation Beta

Structure Variable

public struct Variable: Declaration, Hashable, Codable

A declaration for a property or a top-level variable or constant.

%3 Variable Variable ExpressibleBySyntax ExpressibleBySyntax Variable->ExpressibleBySyntax CustomStringConvertible CustomStringConvertible Variable->CustomStringConvertible Declaration Declaration Variable->Declaration Hashable Hashable Variable->Hashable Codable Codable Variable->Codable

Nested Types

Variable.Accessor

A computed variable or computed property accessor.

Conforms To

Declaration

A Swift declaration.

ExpressibleBySyntax

A type that can be initialized with a Swift syntax node.

Codable
CustomStringConvertible
Hashable

Initializers

init?(_:​)

public init?(_ node: PatternBindingSyntax)

Creates an instance initialized with the given syntax node.

Properties

attributes

let attributes: [Attribute]

The declaration attributes.

modifiers

let modifiers: [Modifier]

The declaration modifiers.

keyword

let keyword: String

The declaration keyword ("let" or "var").

name

let name: String

The name of the property or top-level variable or constant.

type​Annotation

let typeAnnotation: String?

The type annotation for the declaration, if any.

initialized​Value

let initializedValue: String?

The initialized value for the declaration, if any.

accessors

let accessors: [Accessor]

The variable or property accessors.

description

var description: String

Methods

variables(from:​)

public static func variables(from node: VariableDeclSyntax) -> [Variable]

Creates and returns variables from a variable declaration, which may contain one or more pattern bindings, such as let x: Int = 1, y: Int = 2.