Variable

@objcMembers
public final class Variable : NSObject, SourceryModel, Typed, Annotated, Documented, Definition, Diffable
extension Variable: NSCoding

Defines variable

  • Variable name

    Declaration

    Swift

    public let name: String
  • Variable type name

    Declaration

    Swift

    public let typeName: TypeName
  • Variable type, if known, i.e. if the type is declared in the scanned sources. For explanation, see https://cdn.rawgit.com/krzysztofzablocki/Sourcery/master/docs/writing-templates.html#what-are-em-known-em-and-em-unknown-em-types

    Declaration

    Swift

    public var type: Type?
  • Whether variable is computed and not stored

    Declaration

    Swift

    public let isComputed: Bool
  • Whether variable is async

    Declaration

    Swift

    public let isAsync: Bool
  • Whether variable throws

    Declaration

    Swift

    public let `throws`: Bool
  • Whether variable is static

    Declaration

    Swift

    public let isStatic: Bool
  • Variable read access level, i.e. internal, private, fileprivate, public, open

    Declaration

    Swift

    public let readAccess: String
  • Variable write access, i.e. internal, private, fileprivate, public, open. For immutable variables this value is empty string

    Declaration

    Swift

    public let writeAccess: String
  • composed access level sourcery: skipJSExport

    Declaration

    Swift

    public var accessLevel: (read: AccessLevel, write: AccessLevel) { get }
  • Whether variable is mutable or not

    Declaration

    Swift

    public var isMutable: Bool { get }
  • Variable default value expression

    Declaration

    Swift

    public var defaultValue: String?
  • Annotations, that were created with // sourcery: annotation1, other = “annotation value”, alterantive = 2

    Declaration

    Swift

    public var annotations: Annotations
  • Declaration

    Swift

    public var documentation: Documentation
  • Variable attributes, i.e. @IBOutlet, @IBInspectable

    Declaration

    Swift

    public var attributes: AttributeList
  • Modifiers, i.e. private

    Declaration

    Swift

    public var modifiers: [SourceryModifier]
  • Whether variable is final or not

    Declaration

    Swift

    public var isFinal: Bool { get }
  • Whether variable is lazy or not

    Declaration

    Swift

    public var isLazy: Bool { get }
  • Whether variable is dynamic or not

    Declaration

    Swift

    public var isDynamic: Bool { get }
  • Reference to type name where the variable is defined, nil if defined outside of any enum, struct, class etc

    Declaration

    Swift

    public internal(set) var definedInTypeName: TypeName? { get }
  • Reference to actual type name where the method is defined if declaration uses typealias, otherwise just a definedInTypeName

    Declaration

    Swift

    public var actualDefinedInTypeName: TypeName? { get }
  • 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?
  • Declaration

    Swift

    public func diffAgainst(_ object: Any?) -> DiffableResult
  • Whether type is optional. Shorthand for typeName.isOptional

    Declaration

    Swift

    public var isOptional: Bool { get }
  • Whether type is implicitly unwrapped optional. Shorthand for typeName.isImplicitlyUnwrappedOptional

    Declaration

    Swift

    public var isImplicitlyUnwrappedOptional: Bool { get }
  • Type name without attributes and optional type information. Shorthand for typeName.unwrappedTypeName

    Declaration

    Swift

    public var unwrappedTypeName: String { get }
  • Actual type name if declaration uses typealias, otherwise just a typeName. Shorthand for typeName.actualTypeName

    Declaration

    Swift

    public var actualTypeName: TypeName? { get }
  • Whether type is a tuple. Shorthand for typeName.isTuple

    Declaration

    Swift

    public var isTuple: Bool { get }
  • Whether type is a closure. Shorthand for typeName.isClosure

    Declaration

    Swift

    public var isClosure: Bool { get }
  • Whether type is an array. Shorthand for typeName.isArray

    Declaration

    Swift

    public var isArray: Bool { get }
  • Whether type is a set. Shorthand for typeName.isSet

    Declaration

    Swift

    public var isSet: Bool { get }
  • Whether type is a dictionary. Shorthand for typeName.isDictionary

    Declaration

    Swift

    public var isDictionary: Bool { get }