summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hai Zhang <zhanghai@google.com> 2020-10-06 16:50:50 -0700
committer Hai Zhang <zhanghai@google.com> 2020-10-06 16:50:50 -0700
commit785cd3105a4c5986310353e4cd5009388097883d (patch)
treef7486032aa30c0c32b2137ff613e0116ca8fb90c
parent692f27bfd6840f2a8fe5052b266485b935dc7638 (diff)
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
-rw-r--r--tools/xmlpersistence/src/main/kotlin/Generator.kt6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/xmlpersistence/src/main/kotlin/Generator.kt b/tools/xmlpersistence/src/main/kotlin/Generator.kt
index 28467b7fc0b0..b2c5f4ac767b 100644
--- a/tools/xmlpersistence/src/main/kotlin/Generator.kt
+++ b/tools/xmlpersistence/src/main/kotlin/Generator.kt
@@ -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)")