From 2b3b3babfafed81c9efb800e908fab0086784ef8 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Wed, 27 Dec 2023 16:23:43 -0800 Subject: [PATCH] Delete unused code and simplify catchall defaults --- Sources/SafeDICore/Models/Dependency.swift | 5 --- Sources/SafeDICore/Models/Property.swift | 27 +------------ .../SafeDICore/Models/TypeDescription.swift | 38 +------------------ 3 files changed, 4 insertions(+), 66 deletions(-) diff --git a/Sources/SafeDICore/Models/Dependency.swift b/Sources/SafeDICore/Models/Dependency.swift index 36f434bc..197c0f52 100644 --- a/Sources/SafeDICore/Models/Dependency.swift +++ b/Sources/SafeDICore/Models/Dependency.swift @@ -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" } diff --git a/Sources/SafeDICore/Models/Property.swift b/Sources/SafeDICore/Models/Property.swift index 41de58ea..fd2157f4 100644 --- a/Sources/SafeDICore/Models/Property.swift +++ b/Sources/SafeDICore/Models/Property.swift @@ -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 } } @@ -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 [] } } diff --git a/Sources/SafeDICore/Models/TypeDescription.swift b/Sources/SafeDICore/Models/TypeDescription.swift index e23cdf3e..46bc4ee5 100644 --- a/Sources/SafeDICore/Models/TypeDescription.swift +++ b/Sources/SafeDICore/Models/TypeDescription.swift @@ -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: []) @@ -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 } } @@ -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) {