diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2/engine/TargetLiteral.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/query2/engine/TargetLiteral.java | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/engine/TargetLiteral.java b/src/main/java/com/google/devtools/build/lib/query2/engine/TargetLiteral.java index aeace9aa70..733bffb065 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/engine/TargetLiteral.java +++ b/src/main/java/com/google/devtools/build/lib/query2/engine/TargetLiteral.java @@ -13,11 +13,10 @@ // limitations under the License. package com.google.devtools.build.lib.query2.engine; +import com.google.devtools.build.lib.query2.engine.QueryEnvironment.QueryTaskFuture; import com.google.devtools.build.lib.util.Preconditions; - import java.util.Collection; import java.util.Set; -import java.util.concurrent.ForkJoinPool; /** * A literal set of targets, using 'blaze build' syntax. Or, a reference to a @@ -45,38 +44,31 @@ public final class TargetLiteral extends QueryExpression { return LetExpression.isValidVarReference(pattern); } - private <T> void evalVarReference(VariableContext<T> context, Callback<T> callback) - throws QueryException, InterruptedException { + private <T> QueryTaskFuture<Void> evalVarReference( + QueryEnvironment<T> env, VariableContext<T> context, Callback<T> callback) { String varName = LetExpression.getNameFromReference(pattern); Set<T> value = context.get(varName); if (value == null) { - throw new QueryException(this, "undefined variable '" + varName + "'"); + return env.immediateFailedFuture( + new QueryException(this, "undefined variable '" + varName + "'")); } - callback.process(value); - } - - @Override - protected <T> void evalImpl( - QueryEnvironment<T> env, VariableContext<T> context, Callback<T> callback) - throws QueryException, InterruptedException { - if (isVariableReference()) { - evalVarReference(context, callback); - } else { - env.getTargetsMatchingPattern(this, pattern, callback); + try { + callback.process(value); + return env.immediateSuccessfulFuture(null); + } catch (QueryException e) { + return env.immediateFailedFuture(e); + } catch (InterruptedException e) { + return env.immediateCancelledFuture(); } } @Override - protected <T> void parEvalImpl( - QueryEnvironment<T> env, - VariableContext<T> context, - ThreadSafeCallback<T> callback, - ForkJoinPool forkJoinPool) - throws QueryException, InterruptedException { + public <T> QueryTaskFuture<Void> eval( + QueryEnvironment<T> env, VariableContext<T> context, Callback<T> callback) { if (isVariableReference()) { - evalVarReference(context, callback); + return evalVarReference(env, context, callback); } else { - env.getTargetsMatchingPatternPar(this, pattern, callback, forkJoinPool); + return env.getTargetsMatchingPattern(this, pattern, callback); } } |