SwiftSemantics Documentation Beta

Structure Class

public struct Class: Declaration, Hashable, Codable

A class declaration.

%3 Class Class Hashable Hashable Class->Hashable Declaration Declaration Class->Declaration ExpressibleBySyntax ExpressibleBySyntax Class->ExpressibleBySyntax CustomStringConvertible CustomStringConvertible Class->CustomStringConvertible Codable Codable Class->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: ClassDeclSyntax)

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

name

let name: String

The class name.

inheritance

let inheritance: [String]

A list of inherited type names.

If the class is a subclass, the first element is the superclass. Any other elements are names of protocols.

For example, given the following declarations, the inheritance of class C is ["B", "P"]:

protocol P {}
class A {}
class B: A {}
class C: B, P {}

generic​Parameters

let genericParameters: [GenericParameter]

The generic parameters for the declaration.

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

class C<T: Equatable> {}

generic​Requirements

let genericRequirements: [GenericRequirement]

The generic parameter requirements for the declaration.

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

class C<T> where T: Hashable {}

description

var description: String