Skip to content

Commit df9b3eb

Browse files
committed
[DEBUG] generate debug info for momentArray JSON key
1 parent 23a242f commit df9b3eb

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ test: sourcery
1919
cd Tests; $(SOURCERY)
2020
swift test -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.12"
2121
$(SWIFTLINT)
22+
git --no-pager diff
2223
.PHONY: test
2324

2425
## run sourcery to generate code from the root templates

Sources/AutoJSONSerialization/Extensions/AutoJSONDeserializable.generated.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ extension TypealiasedDateArrayProperty: JSONDeserializable {
432432
throw AutoJSONDeserializableError.typeMismatchError([String: Any].self)
433433
}
434434
if let momentArrayRawValue = JSONDictionary["momentArray"], !(momentArrayRawValue is NSNull) {
435+
// variable: Variable: name = momentArray, typeName = [Moment], isComputed = false, isStatic = false, readAccess = internal, writeAccess = , isMutable = false, defaultValue = nil, annotations = [:], attributes = [:], isFinal = false, definedInTypeName = Optional(TypealiasedDateArrayProperty), actualDefinedInTypeName = Optional(TypealiasedDateArrayProperty)
436+
// variable.isArray: 1
437+
// variable.typeName: [Moment]
438+
// variable.typeName.array.elementType: Type: module = nil, typealiases = [:], isExtension = true, kind = extension, accessLevel = , name = Date, isGeneric = false, localName = Date, variables = [], methods = [Method: name = toJSONObject(), selectorName = toJSONObject, parameters = [], returnTypeName = Any, `throws` = false, `rethrows` = false, accessLevel = public, isStatic = false, isClass = false, isFailableInitializer = false, annotations = [:], definedInTypeName = Optional(Date), attributes = [:], Method: name = init(JSONObject: Any), selectorName = init(JSONObject:), parameters = [MethodParameter: argumentLabel = Optional("JSONObject"), name = JSONObject, typeName = Any, `inout` = false, typeAttributes = [:], defaultValue = nil, annotations = [:]], returnTypeName = Date, `throws` = true, `rethrows` = false, accessLevel = public, isStatic = false, isClass = false, isFailableInitializer = false, annotations = [:], definedInTypeName = Optional(Date), attributes = [:]], subscripts = [], initializers = [Method: name = init(JSONObject: Any), selectorName = init(JSONObject:), parameters = [MethodParameter: argumentLabel = Optional("JSONObject"), name = JSONObject, typeName = Any, `inout` = false, typeAttributes = [:], defaultValue = nil, annotations = [:]], returnTypeName = Date, `throws` = true, `rethrows` = false, accessLevel = public, isStatic = false, isClass = false, isFailableInitializer = false, annotations = [:], definedInTypeName = Optional(Date), attributes = [:]], annotations = [:], staticVariables = [], staticMethods = [], classMethods = [], instanceVariables = [], instanceMethods = [Method: name = toJSONObject(), selectorName = toJSONObject, parameters = [], returnTypeName = Any, `throws` = false, `rethrows` = false, accessLevel = public, isStatic = false, isClass = false, isFailableInitializer = false, annotations = [:], definedInTypeName = Optional(Date), attributes = [:], Method: name = init(JSONObject: Any), selectorName = init(JSONObject:), parameters = [MethodParameter: argumentLabel = Optional("JSONObject"), name = JSONObject, typeName = Any, `inout` = false, typeAttributes = [:], defaultValue = nil, annotations = [:]], returnTypeName = Date, `throws` = true, `rethrows` = false, accessLevel = public, isStatic = false, isClass = false, isFailableInitializer = false, annotations = [:], definedInTypeName = Optional(Date), attributes = [:]], computedVariables = [], storedVariables = [], inheritedTypes = ["JSONSerializable", "JSONDeserializable"], containedTypes = [], parentName = nil, parentTypes = AnyIterator<Type>(_box: Swift._IteratorBox<Swift._ClosureBasedIterator<SourceryRuntime.Type>>), attributes = [:]
435439
do {
436440
guard let castedArray = momentArrayRawValue as? [Any] else {
437441
throw AutoJSONDeserializableError.typeMismatchError([Date].self)

Templates/AutoJSONDeserializable.stencil

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ extension {{ type.name }}: JSONDeserializable {
2222
{% set jsonKey %}{{ variable.annotations.JSONKey|default:variable.name }}{% endset %}
2323
{% set rawVariableName %}{{ variable.name }}RawValue{% endset %}
2424
if let {{rawVariableName }} = JSONDictionary["{{ jsonKey }}"], !({{ rawVariableName }} is NSNull) {
25+
{% if jsonKey == "momentArray" %}
26+
// variable: {{ variable }}
27+
// variable.isArray: {{ variable.isArray }}
28+
{% endif %}
2529
{% ifnot variable.isArray %}
2630
{% if variable.type|annotated:"AutoJSONDeserializable" or variable.type.based.JSONDeserializable %}
2731
do {
@@ -45,6 +49,10 @@ extension {{ type.name }}: JSONDeserializable {
4549
self.{{ variable.name }} = {{ rawVariableName }}
4650
{% endif %}
4751
{% else %}
52+
{% if jsonKey == "momentArray" %}
53+
// variable.typeName: {{ variable.typeName }}
54+
// variable.typeName.array.elementType: {{ variable.typeName.array.elementType }}
55+
{% endif %}
4856
{% if variable.typeName.array.elementType|annotated:"AutoJSONDeserializable" or variable.typeName.array.elementType.based.JSONDeserializable %}
4957
do {
5058
guard let castedArray = {{ rawVariableName }} as? [Any] else {

0 commit comments

Comments
 (0)