diff options
author | corysmith <corysmith@google.com> | 2018-08-06 10:48:22 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-08-06 10:50:09 -0700 |
commit | e140ab6cef2f79d992ab6695e8dfcd5675ff6e47 (patch) | |
tree | 3e3e88598abef4c4186810660617fc87d9417d02 /src/main/java/com/google/devtools/build/lib/rules | |
parent | 0a0273ad76d9a8ef3901c282a789ac8852e5ca4e (diff) |
Inline static functions.
RELNOTES: None
PiperOrigin-RevId: 207570533
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java b/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java index d760a3501d..9564643e8e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/DataBinding.java @@ -103,8 +103,8 @@ public final class DataBinding { /** * Adds data binding's annotation processor as a plugin to the given Java compilation context. * - * <p>This, in conjunction with {@link #createAnnotationFile} extends the Java compilation to - * translate data binding .xml into corresponding classes. + * <p>This extends the Java compilation to translate data binding .xml into corresponding + * classes. */ default void supplyAnnotationProcessor( RuleContext ruleContext, BiConsumer<JavaPluginInfoProvider, Iterable<Artifact>> consumer) {} @@ -240,11 +240,18 @@ public final class DataBinding { // binding didn't reprocess a library's data binding expressions redundantly up the dependency // chain (meaning each depender processes them again as if they were its own), this problem // wouldn't happen. - final Artifact annotationFile = createAnnotationFile(ruleContext); - if (annotationFile != null) { + try { + String contents = + ResourceFileLoader.loadResource( + DataBinding.class, "databinding_annotation_template.txt"); + Artifact annotationFile = getDataBindingArtifact(ruleContext, "DataBindingInfo.java"); + ruleContext.registerAction( + FileWriteAction.create(ruleContext, annotationFile, contents, false)); return ImmutableList.<Artifact>builder().addAll(srcs).add(annotationFile).build(); + } catch (IOException e) { + ruleContext.ruleError("Cannot load annotation processor template: " + e.getMessage()); + return ImmutableList.of(); } - return ImmutableList.of(); } @Override @@ -355,27 +362,6 @@ public final class DataBinding { } /** - * Creates and returns the generated Java source that data binding's annotation processor reads to - * translate layout info xml into the classes that end user code consumes. - * - * <p>This mostly just triggers the annotation processor. Annotation processor settings are - * configured separately. - */ - private static Artifact createAnnotationFile(RuleContext ruleContext) { - String contents; - try { - contents = - ResourceFileLoader.loadResource(DataBinding.class, "databinding_annotation_template.txt"); - } catch (IOException e) { - ruleContext.ruleError("Cannot load annotation processor template: " + e.getMessage()); - return null; - } - Artifact output = getDataBindingArtifact(ruleContext, "DataBindingInfo.java"); - ruleContext.registerAction(FileWriteAction.create(ruleContext, output, contents, false)); - return output; - } - - /** * Adds the appropriate {@link UsesDataBindingProvider} for a rule if it should expose one. * * <p>A rule exposes {@link UsesDataBindingProvider} if either it or its deps set {@code |