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

Commit 785cd310 authored by Hai Zhang's avatar Hai Zhang
Browse files

Minor fixes for XML persistence generation.

The Android checkstyle configuration requires exactly the string
"CHECKSTYLE: OFF Generated Code" in its SuppressionCommentFilter.

JLS 4.12.4 says try-with-resources declaration is implicitly final,
hence drop the redundant final modifier in generated code.

Test: manual
Change-Id: Idbb703d950601c32aececfc45e480698657ef764
parent 692f27bf
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ val FILE_HEADER = """
     */

    // Generated by xmlpersistence. DO NOT MODIFY!
    // CHECKSTYLE:OFF
    // CHECKSTYLE:OFF Generated code
    // @formatter:off
""".trimIndent() + "\n\n"

@@ -128,9 +128,7 @@ private fun generateReadMethod(rootField: ClassFieldInfo): MethodSpec =
        .addAnnotation(nullableType)
        .addModifiers(Modifier.PUBLIC)
        .returns(rootField.type)
        .addControlFlow(
            "try (final \$1T inputStream = mFile.openRead())", FileInputStream::class.java
        ) {
        .addControlFlow("try (\$1T inputStream = mFile.openRead())", FileInputStream::class.java) {
            addStatement("final \$1T parser = \$2T.newPullParser()", xmlPullParserType, xmlType)
            addStatement("parser.setInput(inputStream, null)")
            addStatement("return parse(parser)")