From 61bd7210563ab31c3666de56d6974c75388be2a2 Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Thu, 12 Oct 2023 15:25:10 -0700 Subject: [PATCH] Add an overload of `bind` that accepts a log To support clients that want to retrieve partial bindings results for compilations with errors. PiperOrigin-RevId: 573027552 --- java/com/google/turbine/binder/Binder.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/java/com/google/turbine/binder/Binder.java b/java/com/google/turbine/binder/Binder.java index d2ce948c..d5f1ed7a 100644 --- a/java/com/google/turbine/binder/Binder.java +++ b/java/com/google/turbine/binder/Binder.java @@ -91,6 +91,19 @@ public final class Binder { ClassPath bootclasspath, Optional moduleVersion) { TurbineLog log = new TurbineLog(); + BindingResult br = bind(log, units, classpath, processorInfo, bootclasspath, moduleVersion); + log.maybeThrow(); + return br; + } + + /** Binds symbols and types to the given compilation units. */ + public static @Nullable BindingResult bind( + TurbineLog log, + ImmutableList units, + ClassPath classpath, + ProcessorInfo processorInfo, + ClassPath bootclasspath, + Optional moduleVersion) { BindingResult br; try { br = @@ -114,7 +127,6 @@ public final class Binder { .addAll(turbineError.diagnostics()) .build()); } - log.maybeThrow(); return br; }