Skip to content

Instantly share code, notes, and snippets.

@belyaev-mikhail
Created May 6, 2018 16:53
Show Gist options
  • Save belyaev-mikhail/d04bbb22a89c18f377398a70cb1dbced to your computer and use it in GitHub Desktop.
Save belyaev-mikhail/d04bbb22a89c18f377398a70cb1dbced to your computer and use it in GitHub Desktop.
Generate kotlinx.warnings main file from kotlin-compiler-nostrip
fun main(args: Array<String>): Unit = runBlocking<Unit> {
val warnings =
org.jetbrains.kotlin.diagnostics.Errors::class.java.declaredFields
.map { it.name to it.get(null) as? DiagnosticFactory<*> }
.filter { it.second != null }
.filter { it.second?.severity == Severity.WARNING }
.map { it.first }
.map { """const val $it = "$it" """ }
.joinToString("\n")
println("package kotlinx.warnings")
println()
println("object Warnings { ")
println(warnings.prependIndent(" "))
println("}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment