Method

@objc(SwiftMethod) @objcMembers public final class Method: NSObject, SourceryModel, Annotated, Definition

Describes method

  • Full method name, including generic constraints, i.e. foo<T>(bar: T)

    Declaration

    Swift

    public let name: String
  • Method name including arguments names, i.e. foo(bar:)

    Declaration

    Swift

    public var selectorName: String
  • Method name without arguments names and parenthesis, i.e. foo<T>

    Declaration

    Swift

    public var shortName: String
  • Method name without arguments names, parenthesis and generic types, i.e. foo (can be used to generate code for method call)

    Declaration

    Swift

    public var callName: String
  • Method parameters

    Declaration

    Swift

    public var parameters: [MethodParameter]
  • Return value type name used in declaration, including generic constraints, i.e. where T: Equatable

    Declaration

    Swift

    public var returnTypeName: TypeName
  • Actual return value type name if declaration uses typealias, otherwise just a returnTypeName

    Declaration

    Swift

    public var actualReturnTypeName: TypeName
  • Actual return value type, if known

    Declaration

    Swift

    public var returnType: Type?
  • Whether return value type is optional

    Declaration

    Swift

    public var isOptionalReturnType: Bool
  • Whether return value type is implicitly unwrapped optional

    Declaration

    Swift

    public var isImplicitlyUnwrappedOptionalReturnType: Bool
  • Return value type name without attributes and optional type information

    Declaration

    Swift

    public var unwrappedReturnTypeName: String
  • Whether method throws

    Declaration

    Swift

    public let `throws`: Bool
  • Whether method rethrows

    Declaration

    Swift

    public let `rethrows`: Bool
  • Method access level, i.e. internal, private, fileprivate, public, open

    Declaration

    Swift

    public let accessLevel: String
  • Whether method is a static method

    Declaration

    Swift

    public let isStatic: Bool
  • Whether method is a class method

    Declaration

    Swift

    public let isClass: Bool
  • Whether method is an initializer

    Declaration

    Swift

    public var isInitializer: Bool
  • Whether method is an deinitializer

    Declaration

    Swift

    public var isDeinitializer: Bool
  • Whether method is a failable initializer

    Declaration

    Swift

    public let isFailableInitializer: Bool
  • Whether method is a convenience initializer

    Declaration

    Swift

    public var isConvenienceInitializer: Bool
  • Whether method is required

    Declaration

    Swift

    public var isRequired: Bool
  • Whether method is final

    Declaration

    Swift

    public var isFinal: Bool
  • Whether method is mutating

    Declaration

    Swift

    public var isMutating: Bool
  • Whether method is generic

    Declaration

    Swift

    public var isGeneric: Bool
  • Annotations, that were created with // sourcery: annotation1, other = annotation value, alterantive = 2

    Declaration

    Swift

    public let annotations: [String: NSObject]
  • Reference to type name where the method is defined, nil if defined outside of any enum, struct, class etc

    Declaration

    Swift

    public let definedInTypeName: TypeName?
  • Reference to actual type name where the method is defined if declaration uses typealias, otherwise just a definedInTypeName

    Declaration

    Swift

    public var actualDefinedInTypeName: TypeName?
  • Reference to actual type where the object is defined, nil if defined outside of any enum, struct, class etc or type is unknown

    Declaration

    Swift

    public var definedInType: Type?
  • Method attributes, i.e. @discardableResult

    Declaration

    Swift

    public let attributes: [String: Attribute]