in scrooge-generator/src/main/scala/com/twitter/scrooge/backend/ScalaGenerator.scala [218:251]
def genType(t: FunctionType, immutable: Boolean = false): CodeFragment = {
val prefix = if (immutable) "_root_.scala.collection.immutable." else "_root_.scala.collection."
@scala.annotation.tailrec
def getCode(t: FunctionType): String = t match {
case at: AnnotatedFieldType => getCode(at.unwrap)
case Void => "Unit"
case OnewayVoid => "Unit"
case TBool => "Boolean"
case TByte => "Byte"
case TI16 => "Short"
case TI32 => "Int"
case TI64 => "Long"
case TDouble => "Double"
case TString => "String"
case TBinary => "_root_.java.nio.ByteBuffer"
case MapType(k, v, _) =>
prefix + "Map[" + genType(k, immutable).toData + ", " + genType(v, immutable).toData + "]"
case SetType(x, _) =>
prefix + "Set[" + genType(x, immutable).toData + "]"
case ListType(x, _) =>
// for historical reasons, only use immutable sequences if explicitly requested
val listPrefix =
if (immutableSequences) "_root_.scala.collection.immutable."
else "_root_.scala.collection."
listPrefix + "Seq[" + genType(x, immutable).toData + "]"
case t: NamedType =>
val id = resolvedDoc.qualifyName(t, namespaceLanguage, defaultNamespace)
// Named types are capitalized.
genID(id.toTitleCase).toData
case r: ReferenceType =>
throw new ScroogeInternalException("ReferenceType should not appear in backend")
}
v(getCode(t))
}