Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19ed7094 authored by Jacky Wang's avatar Jacky Wang
Browse files

[Catalyst] Clean up try-catch for Filer.createSourceFile

Bug: 385793553
Flag: EXEMPT library
Test: manual
Change-Id: I0b4356513d0ecd37ace60ca59f4fa6fa2db4f7e4
parent 059a03de
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -114,15 +114,7 @@ class PreferenceScreenAnnotationProcessor : AbstractProcessor() {
    private fun generateCode(outputPkg: String, outputClass: String, outputFun: String) {
        // sort by screen keys to make the output deterministic and naturally fit to FixedArrayMap
        screens.sort()
        val javaFileObject =
            try {
                processingEnv.filer.createSourceFile("$outputPkg.$outputClass")
            } catch (e: Exception) {
                // quick fix: gradle runs this processor twice unexpectedly
                warn("cannot createSourceFile: $e")
                return
            }
        javaFileObject.openWriter().use {
        processingEnv.filer.createSourceFile("$outputPkg.$outputClass").openWriter().use {
            it.write("package $outputPkg;\n\n")
            it.write("import $PACKAGE.FixedArrayMap;\n")
            it.write("import $PACKAGE.FixedArrayMap.OrderedInitializer;\n")