@@ -313,39 +313,102 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
313313
314314 }
315315
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)
327324 }
325+ printSeparated(trees)
326+ this
328327 }
329328
330329 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+ }
331338 this += " {"
332- printSeparated(selectors, " , " , printImportSelector )
339+ printSeparated(selectors)
333340 this += " }"
334341 }
335342
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 {
338345 case Nil =>
339- case x :: Nil => print (x)
346+ case x :: Nil => printCase (x)
340347 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)
342375 this += sep
343376 printSeparated(xs)
344377 }
345378 printSeparated(typesTrees)
346379 this
347380 }
348381
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+
349412 def printTargDef (arg : TypeDef ): Buffer = {
350413 val TypeDef (name, rhs) = arg
351414 this += name
@@ -371,7 +434,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
371434
372435 def printArgsDefs (args : List [ValDef ]): Unit = {
373436 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)
375448 this += " )"
376449 }
377450
0 commit comments