src/Pure/General/toml.scala
changeset 78917 30e0c15a71f7
parent 78609 67492b2a3a62
child 78919 7847cbfe3a62
equal deleted inserted replaced
78916:e97fa2edf4b2 78917:30e0c15a71f7
   533 
   533 
   534     def keys(ks: Keys): Str = ks.mkString(".")
   534     def keys(ks: Keys): Str = ks.mkString(".")
   535 
   535 
   536     def inline(t: T, indent: Int = 0): Str = {
   536     def inline(t: T, indent: Int = 0): Str = {
   537       val result = new StringBuilder
   537       val result = new StringBuilder
   538       def indentation(i: Int): Unit = for (_ <- Range(0, i)) result ++= "  "
   538 
   539 
   539       result ++= Symbol.spaces(indent * 2)
   540       indentation(indent)
       
   541       t match {
   540       t match {
   542         case s: String =>
   541         case s: String =>
   543           if (s.rep.contains("\n") && s.rep.length > 20) result ++= multiline_basic_string(s.rep)
   542           if (s.rep.contains("\n") && s.rep.length > 20) result ++= multiline_basic_string(s.rep)
   544           else result ++= basic_string(s.rep)
   543           else result ++= basic_string(s.rep)
   545         case i: Integer => result ++= i.rep.toString
   544         case i: Integer => result ++= i.rep.toString
   555             result ++= "[\n"
   554             result ++= "[\n"
   556             a.any.values.foreach { elem =>
   555             a.any.values.foreach { elem =>
   557               result ++= inline(elem, indent + 1)
   556               result ++= inline(elem, indent + 1)
   558               result ++= ",\n"
   557               result ++= ",\n"
   559             }
   558             }
   560             indentation(indent)
   559             result ++= Symbol.spaces(indent * 2)
   561             result += ']'
   560             result += ']'
   562           }
   561           }
   563         case table: Table =>
   562         case table: Table =>
   564           if (table.is_empty) result ++= "{}"
   563           if (table.is_empty) result ++= "{}"
   565           else {
   564           else {