SwiftSemantics Documentation Beta

Structure Protocol

public struct Protocol: Declaration, Hashable, Codable

A protocol declaration.

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

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

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

name

let name: String

The protocol name.

inheritance

let inheritance: [String]

A list of adopted protocols.

For example, given the following declarations, the inheritance of protocol P is ["Q"]:

protocol Q {}
protocol P: Q {}

description

var description: String