Class

public struct Class : Declaration, Hashable, Codable
extension Class: ExpressibleBySyntax
extension Class: CustomStringConvertible

A class declaration.

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

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

    class A { class B { class C {} }
    

    Declaration

    Swift

    public let context: String?
  • The declaration attributes.

    Declaration

    Swift

    public let attributes: [Attribute]
  • The declaration modifiers.

    Declaration

    Swift

    public let modifiers: [Modifier]
  • The declaration keyword ("class").

    Declaration

    Swift

    public let keyword: String
  • The class name.

    Declaration

    Swift

    public let name: 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 {}
    

    Declaration

    Swift

    public let inheritance: [String]
  • 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> {}
    

    Declaration

    Swift

    public let genericParameters: [GenericParameter]
  • 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 {}
    

    Declaration

    Swift

    public let genericRequirements: [GenericRequirement]

ExpressibleBySyntax

  • Creates an instance initialized with the given syntax node.

    Declaration

    Swift

    public init(_ node: ClassDeclSyntax)

CustomStringConvertible

  • Declaration

    Swift

    public var description: String { get }