@@ -32,7 +32,7 @@ extension SignatureSyntax.Autographer
32
32
}
33
33
34
34
mutating
35
- func encode( type: TypeSyntax )
35
+ func encode( type: TypeSyntax , stem : Bool = false )
36
36
{
37
37
if let type: AttributedTypeSyntax = type. as ( AttributedTypeSyntax . self)
38
38
{
@@ -56,14 +56,18 @@ extension SignatureSyntax.Autographer
56
56
else if
57
57
let type: IdentifierTypeSyntax = type. as ( IdentifierTypeSyntax . self)
58
58
{
59
- self . encode ( type: type. name, generics: type. genericArgumentClause? . arguments)
59
+ self . encode ( type: type. name,
60
+ arguments: type. genericArgumentClause? . arguments,
61
+ resugar: !stem)
60
62
}
61
63
else if
62
64
let type: MemberTypeSyntax = type. as ( MemberTypeSyntax . self)
63
65
{
64
- self . encode ( type: type. baseType)
66
+ self . encode ( type: type. baseType, stem : true )
65
67
self . autograph. append ( " . " )
66
- self . encode ( type: type. name, generics: type. genericArgumentClause? . arguments)
68
+ self . encode ( type: type. name,
69
+ arguments: type. genericArgumentClause? . arguments,
70
+ resugar: false )
67
71
}
68
72
else if
69
73
let type: ArrayTypeSyntax = type. as ( ArrayTypeSyntax . self)
@@ -183,32 +187,32 @@ extension SignatureSyntax.Autographer
183
187
}
184
188
185
189
private mutating
186
- func encode( type name: TokenSyntax , generics : GenericArgumentListSyntax ? )
190
+ func encode( type name: TokenSyntax , arguments : GenericArgumentListSyntax ? , resugar : Bool )
187
191
{
188
- if let generics : GenericArgumentListSyntax
192
+ if let arguments : GenericArgumentListSyntax , resugar
189
193
{
190
- let generics : [ TypeSyntax ] = generics . map ( \. argument)
194
+ let arguments : [ TypeSyntax ] = arguments . map ( \. argument)
191
195
let position : Int = name. positionAfterSkippingLeadingTrivia. utf8Offset
192
196
193
- if self . sugarMap. arrays. contains ( position) , generics . count == 1
197
+ if self . sugarMap. arrays. contains ( position) , arguments . count == 1
194
198
{
195
199
self . autograph. append ( " [ " )
196
- self . encode ( type: generics [ 0 ] )
200
+ self . encode ( type: arguments [ 0 ] )
197
201
self . autograph. append ( " ] " )
198
202
return
199
203
}
200
- if self . sugarMap. dictionaries. contains ( position) , generics . count == 2
204
+ if self . sugarMap. dictionaries. contains ( position) , arguments . count == 2
201
205
{
202
206
self . autograph. append ( " [ " )
203
- self . encode ( type: generics [ 0 ] )
207
+ self . encode ( type: arguments [ 0 ] )
204
208
self . autograph. append ( " : " )
205
- self . encode ( type: generics [ 1 ] )
209
+ self . encode ( type: arguments [ 1 ] )
206
210
self . autograph. append ( " ] " )
207
211
return
208
212
}
209
- if self . sugarMap. optionals. contains ( position) , generics . count == 1
213
+ if self . sugarMap. optionals. contains ( position) , arguments . count == 1
210
214
{
211
- self . encode ( type: generics [ 0 ] )
215
+ self . encode ( type: arguments [ 0 ] )
212
216
self . autograph. append ( " ? " )
213
217
return
214
218
}
@@ -224,12 +228,12 @@ extension SignatureSyntax.Autographer
224
228
225
229
self . autograph. append ( name. text)
226
230
227
- if let generics : GenericArgumentListSyntax
231
+ if let arguments : GenericArgumentListSyntax
228
232
{
229
233
self . autograph. append ( " < " )
230
234
231
235
var first : Bool = true
232
- for generic : GenericArgumentSyntax in generics
236
+ for type : GenericArgumentSyntax in arguments
233
237
{
234
238
if first
235
239
{
@@ -240,7 +244,7 @@ extension SignatureSyntax.Autographer
240
244
self . autograph. append ( " , " )
241
245
}
242
246
243
- self . encode ( type: generic . argument)
247
+ self . encode ( type: type . argument)
244
248
}
245
249
246
250
self . autograph. append ( " > " )
0 commit comments