SwiftSemantics Documentation Beta

Structure Function

public struct Function: Declaration, Hashable, Codable

A function declaration.

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

Nested Types

Function.Signature

A function signature.

Function.Parameter

A function parameter.

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: FunctionDeclSyntax)

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 ("func").

identifier

let identifier: String

The function identifier.

signature

let signature: Signature

The function signature.

generic​Parameters

let genericParameters: [GenericParameter]

The generic parameters for the declaration.

For example, the following declaration of function f has a single generic parameter whose identifier is "T" and type is "Equatable":

func f<T: Equatable>(value: T) {}

generic​Requirements

let genericRequirements: [GenericRequirement]

The generic parameter requirements for the declaration.

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

func f<T>(value: T) where T: Hashable {}

is​Operator

var isOperator: Bool

Whether the function is an operator.

description

var description: String