Skip to content

Commit

Permalink
Delete unused code and simplify catchall defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
dfed committed Dec 28, 2023
1 parent fd3019f commit 2b3b3ba
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 66 deletions.
5 changes: 0 additions & 5 deletions Sources/SafeDICore/Models/Dependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public struct Dependency: Codable, Hashable {

// MARK: Internal

/// The label by which this property is referenced inside the `init` method.
var propertyLabelInInit: String {
property.label
}

static let instantiatorType = "Instantiator"
static let forwardingInstantiatorType = "ForwardingInstantiator"
}
27 changes: 2 additions & 25 deletions Sources/SafeDICore/Models/Property.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,7 @@ public struct Property: Codable, Hashable, Comparable, Sendable {
} else {
return .constant
}
case .any,
.array,
.attributed,
.closure,
.composition,
.dictionary,
.implicitlyUnwrappedOptional,
.metatype,
.nested,
.optional,
.some,
.tuple,
.unknown:
case .any, .array, .attributed, .closure, .composition, .dictionary, .implicitlyUnwrappedOptional, .metatype, .nested, .optional, .some, .tuple, .unknown:
return .constant
}
}
Expand All @@ -93,18 +81,7 @@ public struct Property: Codable, Hashable, Comparable, Sendable {
case let .simple(_, generics),
let .nested(_, _, generics):
return generics
case .any,
.array,
.attributed,
.closure,
.composition,
.dictionary,
.implicitlyUnwrappedOptional,
.metatype,
.optional,
.some,
.tuple,
.unknown:
case .any, .array, .attributed, .closure, .composition, .dictionary, .implicitlyUnwrappedOptional, .metatype, .optional, .some, .tuple, .unknown:
return []
}
}
Expand Down
38 changes: 2 additions & 36 deletions Sources/SafeDICore/Models/TypeDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,6 @@ public enum TypeDescription: Codable, Hashable, Comparable, Sendable {
/// A type that can't be represented by the above cases.
case unknown(text: String)

/// Creates a type description of case `.nested` with the given name as the name and the receiver as the parent type.
/// If no parent is provided, creates a type description of case `.simple`.
///
/// - Parameters:
/// - name: The simple name of the returned type.
/// - parent: The parent type for the returned type.
/// - Note: This method only makes sense when the `parent` is of case `simple`, `nested`, `optional`, and `implicitlyUnwrappedOptional`.
init(name: String, parent: TypeDescription?) {
if let parent = parent {
self = .nested(name: name, parentType: parent)
} else {
self = .simple(name: name)
}
}

/// A shortcut for creating a `simple` case without any generic types.
public static func simple(name: String) -> TypeDescription {
.simple(name: name, generics: [])
Expand Down Expand Up @@ -333,15 +318,7 @@ public enum TypeDescription: Codable, Hashable, Comparable, Sendable {
let .optional(typeDescription),
let .some(typeDescription):
return typeDescription.asInstantiatedType
case .array,
.attributed,
.closure,
.composition,
.dictionary,
.metatype,
.nested,
.tuple,
.unknown:
case .array, .attributed, .closure, .composition, .dictionary, .metatype, .nested, .tuple, .unknown:
return self
}
}
Expand Down Expand Up @@ -536,18 +513,7 @@ extension ExprSyntax {
name: name,
parentType: parentType, generics: genericTypeVisitor.genericArguments
)
case .any,
.array,
.attributed,
.closure,
.composition,
.dictionary,
.implicitlyUnwrappedOptional,
.metatype,
.optional,
.some,
.tuple,
.unknown:
case .any, .array, .attributed, .closure, .composition, .dictionary, .implicitlyUnwrappedOptional, .metatype, .optional, .some, .tuple, .unknown:
return .unknown(text: description)
}
} else if let tupleExpr = TupleExprSyntax(self) {
Expand Down

0 comments on commit 2b3b3ba

Please sign in to comment.