in thrifty-compiler/src/main/kotlin/com/microsoft/thrifty/compiler/ThriftyCompiler.kt [266:319]
override fun run() {
val loader = Loader()
for (thriftFile in thriftFiles) {
loader.addThriftFile(thriftFile)
}
loader.addIncludePath(Paths.get(System.getProperty("user.dir")))
for (dir in searchPath) {
loader.addIncludePath(dir)
}
val schema: Schema
try {
schema = loader.load()
} catch (e: LoadFailedException) {
if (!e.errorReporter.hasError && e.cause != null) {
println(e.cause)
}
for (report in e.errorReporter.formattedReports()) {
println(report)
}
Runtime.getRuntime().exit(1)
return
}
val impliedLanguage = when {
kotlinStructBuilders -> Language.KOTLIN
kotlinBuilderRequiredConstructor -> Language.KOTLIN
kotlinFilePerType -> Language.KOTLIN
kotlinEmitJvmName -> Language.KOTLIN
kotlinEmitJvmStatic -> Language.KOTLIN
kotlinBigEnums -> Language.KOTLIN
serviceType == ServiceInterfaceType.COROUTINE -> Language.KOTLIN
nullabilityAnnotationType != NullabilityAnnotationType.NONE -> Language.JAVA
else -> null
}
if (language != null && impliedLanguage != null && impliedLanguage != language) {
TermUi.echo(
"You specified $language, but provided options implying $impliedLanguage (which will be ignored).",
err = true)
}
if (emitNullabilityAnnotations) {
TermUi.echo("Warning: --use-android-annotations is deprecated and superseded by the --nullability-annotation-type option.")
}
when (language ?: impliedLanguage) {
null,
Language.KOTLIN -> generateKotlin(schema)
Language.JAVA -> generateJava(schema)
}
}