Skip to content

Commit

Permalink
update internal boilerplate code.
Browse files Browse the repository at this point in the history
  • Loading branch information
art-divin committed May 1, 2024
1 parent e7d1a3e commit 85a4dd0
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 16 deletions.
2 changes: 1 addition & 1 deletion SourceryRuntime/Sources/Generated/Coding.generated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace trailing_newline

Expand Down
3 changes: 2 additions & 1 deletion SourceryRuntime/Sources/Generated/JSExport.generated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace trailing_newline

Expand Down Expand Up @@ -348,6 +348,7 @@ extension Import: ImportAutoJSExport {}
var attributes: AttributeList { get }
var modifiers: [SourceryModifier] { get }
var genericRequirements: [GenericRequirement] { get }
var genericParameters: [GenericParameter] { get }
}

extension Method: MethodAutoJSExport {}
Expand Down
2 changes: 1 addition & 1 deletion SourceryRuntime/Sources/Generated/Typed.generated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace

Expand Down
46 changes: 40 additions & 6 deletions SourcerySwift/Sources/SourceryRuntime.content.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2650,8 +2650,14 @@ internal struct ParserResultsComposed {
} else
if let generic = lookupName.generic {
var needsUpdate = false
generic.typeParameters.forEach { parameter in
// Detect if the generic type is local to the method
if let method {
for genericParameter in method.genericParameters where parameter.typeName.name == genericParameter.name {
return
}
}
parameter.type = resolveTypeWithName(parameter.typeName)
if parameter.typeName.actualTypeName != nil {
needsUpdate = true
Expand Down Expand Up @@ -2738,6 +2744,10 @@ internal struct ParserResultsComposed {
// let variable: Module.ID.ID // should be resolved as MyView.ID type
let finalLookup = typeName.actualTypeName ?? typeName
var resolvedIdentifier = finalLookup.generic?.name ?? finalLookup.unwrappedTypeName
if let type = unique[resolvedIdentifier] {
return type
}
for alias in resolvedTypealiases {
/// iteratively replace all typealiases from the resolvedIdentifier to get to the actual type name requested
if resolvedIdentifier.contains(alias.value.name), let range = resolvedIdentifier.range(of: alias.value.name) {
Expand Down Expand Up @@ -5000,6 +5010,16 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
/// list of generic requirements
public var genericRequirements: [GenericRequirement]
/// List of generic parameters
///
/// - Example:
///
/// ```swift
/// func method<GenericParameter>(foo: GenericParameter)
/// ^ ~ a generic parameter
/// ```
public var genericParameters: [GenericParameter]
/// :nodoc:
public init(name: String,
selectorName: String? = nil,
Expand All @@ -5017,7 +5037,8 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
annotations: [String: NSObject] = [:],
documentation: [String] = [],
definedInTypeName: TypeName? = nil,
genericRequirements: [GenericRequirement] = []) {
genericRequirements: [GenericRequirement] = [],
genericParameters: [GenericParameter] = []) {
self.name = name
self.selectorName = selectorName ?? name
self.parameters = parameters
Expand All @@ -5035,6 +5056,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
self.documentation = documentation
self.definedInTypeName = definedInTypeName
self.genericRequirements = genericRequirements
self.genericParameters = genericParameters
}
/// :nodoc:
Expand All @@ -5057,7 +5079,8 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
string.append("definedInTypeName = \\(String(describing: self.definedInTypeName)), ")
string.append("attributes = \\(String(describing: self.attributes)), ")
string.append("modifiers = \\(String(describing: self.modifiers)), ")
string.append("genericRequirements = \\(String(describing: self.genericRequirements))")
string.append("genericRequirements = \\(String(describing: self.genericRequirements)), ")
string.append("genericRequirements = \\(String(describing: self.genericParameters))")
return string
}
Expand All @@ -5084,6 +5107,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
results.append(contentsOf: DiffableResult(identifier: "attributes").trackDifference(actual: self.attributes, expected: castObject.attributes))
results.append(contentsOf: DiffableResult(identifier: "modifiers").trackDifference(actual: self.modifiers, expected: castObject.modifiers))
results.append(contentsOf: DiffableResult(identifier: "genericRequirements").trackDifference(actual: self.genericRequirements, expected: castObject.genericRequirements))
results.append(contentsOf: DiffableResult(identifier: "genericParameters").trackDifference(actual: self.genericParameters, expected: castObject.genericParameters))
return results
}
Expand All @@ -5108,6 +5132,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
hasher.combine(self.attributes)
hasher.combine(self.modifiers)
hasher.combine(self.genericRequirements)
hasher.combine(self.genericParameters)
return hasher.finalize()
}
Expand All @@ -5132,6 +5157,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
if self.attributes != rhs.attributes { return false }
if self.modifiers != rhs.modifiers { return false }
if self.genericRequirements != rhs.genericRequirements { return false }
if self.genericParameters != rhs.genericParameters { return false }
return true
}
Expand Down Expand Up @@ -5208,6 +5234,12 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
}
fatalError()
}; self.genericRequirements = genericRequirements
guard let genericParameters: [GenericParameter] = aDecoder.decode(forKey: "genericParameters") else {
withVaList(["genericParameters"]) { arguments in
NSException.raise(NSExceptionName.parseErrorException, format: "Key '%@' not found.", arguments: arguments)
}
fatalError()
}; self.genericParameters = genericParameters
}
/// :nodoc:
Expand All @@ -5231,6 +5263,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
aCoder.encode(self.attributes, forKey: "attributes")
aCoder.encode(self.modifiers, forKey: "modifiers")
aCoder.encode(self.genericRequirements, forKey: "genericRequirements")
aCoder.encode(self.genericParameters, forKey: "genericParameters")
}
// sourcery:end
}
Expand Down Expand Up @@ -7603,7 +7636,7 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document
"""),
.init(name: "Coding.generated.swift", content:
"""
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace trailing_newline
Expand Down Expand Up @@ -7709,7 +7742,7 @@ extension Variable: NSCoding {}
"""),
.init(name: "JSExport.generated.swift", content:
"""
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace trailing_newline
Expand Down Expand Up @@ -8059,6 +8092,7 @@ extension Import: ImportAutoJSExport {}
var attributes: AttributeList { get }
var modifiers: [SourceryModifier] { get }
var genericRequirements: [GenericRequirement] { get }
var genericParameters: [GenericParameter] { get }
}
extension Method: MethodAutoJSExport {}
Expand Down Expand Up @@ -8446,7 +8480,7 @@ extension Variable: VariableAutoJSExport {}
"""),
.init(name: "Typed.generated.swift", content:
"""
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2650,8 +2650,14 @@ internal struct ParserResultsComposed {
} else
if let generic = lookupName.generic {
var needsUpdate = false
generic.typeParameters.forEach { parameter in
// Detect if the generic type is local to the method
if let method {
for genericParameter in method.genericParameters where parameter.typeName.name == genericParameter.name {
return
}
}
parameter.type = resolveTypeWithName(parameter.typeName)
if parameter.typeName.actualTypeName != nil {
needsUpdate = true
Expand Down Expand Up @@ -2738,6 +2744,10 @@ internal struct ParserResultsComposed {
// let variable: Module.ID.ID // should be resolved as MyView.ID type
let finalLookup = typeName.actualTypeName ?? typeName
var resolvedIdentifier = finalLookup.generic?.name ?? finalLookup.unwrappedTypeName
if let type = unique[resolvedIdentifier] {
return type
}
for alias in resolvedTypealiases {
/// iteratively replace all typealiases from the resolvedIdentifier to get to the actual type name requested
if resolvedIdentifier.contains(alias.value.name), let range = resolvedIdentifier.range(of: alias.value.name) {
Expand Down Expand Up @@ -5433,6 +5443,16 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
/// list of generic requirements
public var genericRequirements: [GenericRequirement]
/// List of generic parameters
///
/// - Example:
///
/// ```swift
/// func method<GenericParameter>(foo: GenericParameter)
/// ^ ~ a generic parameter
/// ```
public var genericParameters: [GenericParameter]
/// :nodoc:
public init(name: String,
selectorName: String? = nil,
Expand All @@ -5450,7 +5470,8 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
annotations: [String: NSObject] = [:],
documentation: [String] = [],
definedInTypeName: TypeName? = nil,
genericRequirements: [GenericRequirement] = []) {
genericRequirements: [GenericRequirement] = [],
genericParameters: [GenericParameter] = []) {
self.name = name
self.selectorName = selectorName ?? name
self.parameters = parameters
Expand All @@ -5468,6 +5489,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
self.documentation = documentation
self.definedInTypeName = definedInTypeName
self.genericRequirements = genericRequirements
self.genericParameters = genericParameters
}
/// :nodoc:
Expand All @@ -5490,7 +5512,8 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
string.append("definedInTypeName = \\(String(describing: self.definedInTypeName)), ")
string.append("attributes = \\(String(describing: self.attributes)), ")
string.append("modifiers = \\(String(describing: self.modifiers)), ")
string.append("genericRequirements = \\(String(describing: self.genericRequirements))")
string.append("genericRequirements = \\(String(describing: self.genericRequirements)), ")
string.append("genericRequirements = \\(String(describing: self.genericParameters))")
return string
}
Expand All @@ -5517,6 +5540,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
results.append(contentsOf: DiffableResult(identifier: "attributes").trackDifference(actual: self.attributes, expected: castObject.attributes))
results.append(contentsOf: DiffableResult(identifier: "modifiers").trackDifference(actual: self.modifiers, expected: castObject.modifiers))
results.append(contentsOf: DiffableResult(identifier: "genericRequirements").trackDifference(actual: self.genericRequirements, expected: castObject.genericRequirements))
results.append(contentsOf: DiffableResult(identifier: "genericParameters").trackDifference(actual: self.genericParameters, expected: castObject.genericParameters))
return results
}
Expand All @@ -5541,6 +5565,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
hasher.combine(self.attributes)
hasher.combine(self.modifiers)
hasher.combine(self.genericRequirements)
hasher.combine(self.genericParameters)
return hasher.finalize()
}
Expand All @@ -5565,6 +5590,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
if self.attributes != rhs.attributes { return false }
if self.modifiers != rhs.modifiers { return false }
if self.genericRequirements != rhs.genericRequirements { return false }
if self.genericParameters != rhs.genericParameters { return false }
return true
}
Expand Down Expand Up @@ -5641,6 +5667,12 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
}
fatalError()
}; self.genericRequirements = genericRequirements
guard let genericParameters: [GenericParameter] = aDecoder.decode(forKey: "genericParameters") else {
withVaList(["genericParameters"]) { arguments in
NSException.raise(NSExceptionName.parseErrorException, format: "Key '%@' not found.", arguments: arguments)
}
fatalError()
}; self.genericParameters = genericParameters
}
/// :nodoc:
Expand All @@ -5664,6 +5696,7 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin
aCoder.encode(self.attributes, forKey: "attributes")
aCoder.encode(self.modifiers, forKey: "modifiers")
aCoder.encode(self.genericRequirements, forKey: "genericRequirements")
aCoder.encode(self.genericParameters, forKey: "genericParameters")
}
// sourcery:end
}
Expand Down Expand Up @@ -8036,7 +8069,7 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document
"""),
.init(name: "Coding.generated.swift", content:
"""
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace trailing_newline
Expand Down Expand Up @@ -8142,7 +8175,7 @@ extension Variable: NSCoding {}
"""),
.init(name: "JSExport.generated.swift", content:
"""
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace trailing_newline
Expand Down Expand Up @@ -8492,6 +8525,7 @@ extension Import: ImportAutoJSExport {}
var attributes: AttributeList { get }
var modifiers: [SourceryModifier] { get }
var genericRequirements: [GenericRequirement] { get }
var genericParameters: [GenericParameter] { get }
}
extension Method: MethodAutoJSExport {}
Expand Down Expand Up @@ -8879,7 +8913,7 @@ extension Variable: VariableAutoJSExport {}
"""),
.init(name: "Typed.generated.swift", content:
"""
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable vertical_whitespace
Expand Down
2 changes: 1 addition & 1 deletion SourceryTests/Models/TypedSpec.generated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
import Quick
import Nimble
Expand Down

0 comments on commit 85a4dd0

Please sign in to comment.