@@ -313,39 +313,102 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
313
313
314
314
}
315
315
316
- def printTrees (trees : List [Tree ], sep : String ): Buffer = printSeparated(trees, sep, printTree)
317
- def printCases (cases : List [CaseDef ], sep : String ): Buffer = printSeparated(cases, sep, printCase)
318
- def printPatterns (patterns : List [Pattern ], sep : String ): Buffer = printSeparated(patterns, sep, printPattern)
319
- def printTypeTrees (typesTrees : List [TypeTree ], sep : String ): Buffer = printSeparated(typesTrees, sep, printTypeTree)
320
- def printTypesOrBounds (types : List [TypeOrBounds ], sep : String ): Buffer = printSeparated(types, sep, printTypeOrBound)
321
-
322
- def printTargsDefs (targs : List [TypeDef ]): Unit = {
323
- if (! targs.isEmpty) {
324
- this += " ["
325
- printSeparated(targs, " , " , printTargDef)
326
- this += " ]"
316
+ def printTrees (trees : List [Tree ], sep : String ): Buffer = {
317
+ def printSeparated (list : List [Tree ]): Unit = list match {
318
+ case Nil =>
319
+ case x :: Nil => printTree(x)
320
+ case x :: xs =>
321
+ printTree(x)
322
+ this += sep
323
+ printSeparated(xs)
327
324
}
325
+ printSeparated(trees)
326
+ this
328
327
}
329
328
330
329
def printImportSelectors (selectors : List [ImportSelector ]): Buffer = {
330
+ def printSeparated (list : List [ImportSelector ]): Unit = list match {
331
+ case Nil =>
332
+ case x :: Nil => printImportSelector(x)
333
+ case x :: xs =>
334
+ printImportSelector(x)
335
+ this += " , "
336
+ printSeparated(xs)
337
+ }
331
338
this += " {"
332
- printSeparated(selectors, " , " , printImportSelector )
339
+ printSeparated(selectors)
333
340
this += " }"
334
341
}
335
342
336
- def printSeparated [ U ]( typesTrees : List [U ], sep : String , print : U => Unit ): Buffer = {
337
- def printSeparated (list : List [U ]): Unit = list match {
343
+ def printCases ( cases : List [CaseDef ], sep : String ): Buffer = {
344
+ def printSeparated (list : List [CaseDef ]): Unit = list match {
338
345
case Nil =>
339
- case x :: Nil => print (x)
346
+ case x :: Nil => printCase (x)
340
347
case x :: xs =>
341
- print(x)
348
+ printCase(x)
349
+ this += sep
350
+ printSeparated(xs)
351
+ }
352
+ printSeparated(cases)
353
+ this
354
+ }
355
+
356
+ def printPatterns (cases : List [Pattern ], sep : String ): Buffer = {
357
+ def printSeparated (list : List [Pattern ]): Unit = list match {
358
+ case Nil =>
359
+ case x :: Nil => printPattern(x)
360
+ case x :: xs =>
361
+ printPattern(x)
362
+ this += sep
363
+ printSeparated(xs)
364
+ }
365
+ printSeparated(cases)
366
+ this
367
+ }
368
+
369
+ def printTypeTrees (typesTrees : List [TypeTree ], sep : String ): Buffer = {
370
+ def printSeparated (list : List [TypeTree ]): Unit = list match {
371
+ case Nil =>
372
+ case x :: Nil => printTypeTree(x)
373
+ case x :: xs =>
374
+ printTypeTree(x)
342
375
this += sep
343
376
printSeparated(xs)
344
377
}
345
378
printSeparated(typesTrees)
346
379
this
347
380
}
348
381
382
+ def printTypesOrBounds (types : List [TypeOrBounds ], sep : String ): Buffer = {
383
+ def printSeparated (list : List [TypeOrBounds ]): Unit = list match {
384
+ case Nil =>
385
+ case x :: Nil => printTypeOrBound(x)
386
+ case x :: xs =>
387
+ printTypeOrBound(x)
388
+ this += sep
389
+ printSeparated(xs)
390
+ }
391
+ printSeparated(types)
392
+ this
393
+ }
394
+
395
+ def printTargsDefs (targs : List [TypeDef ]): Unit = {
396
+ if (! targs.isEmpty) {
397
+ def printSeparated (list : List [TypeDef ]): Unit = list match {
398
+ case Nil =>
399
+ case x :: Nil => printTargDef(x)
400
+ case x :: xs =>
401
+ printTargDef(x)
402
+ this += " , "
403
+ printSeparated(xs)
404
+ }
405
+
406
+ this += " ["
407
+ printSeparated(targs)
408
+ this += " ]"
409
+ }
410
+ }
411
+
349
412
def printTargDef (arg : TypeDef ): Buffer = {
350
413
val TypeDef (name, rhs) = arg
351
414
this += name
@@ -371,7 +434,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
371
434
372
435
def printArgsDefs (args : List [ValDef ]): Unit = {
373
436
this += " ("
374
- printSeparated(args, " , " , printArgDef)
437
+
438
+ def printSeparated (list : List [ValDef ]): Unit = list match {
439
+ case Nil =>
440
+ case x :: Nil => printArgDef(x)
441
+ case x :: xs =>
442
+ printArgDef(x)
443
+ this += " , "
444
+ printSeparated(xs)
445
+ }
446
+
447
+ printSeparated(args)
375
448
this += " )"
376
449
}
377
450
0 commit comments