aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/buildtool
diff options
context:
space:
mode:
authorGravatar twerth <twerth@google.com>2018-07-10 05:59:01 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-10 06:00:38 -0700
commit8c11fe9415e6d30069bdba559f6943747dd56e9f (patch)
treebd47cfafc521b2ec821adc422ada68690f85cd28 /src/main/java/com/google/devtools/build/lib/buildtool
parentc45606ebc029303f3ef533aeaf8ff9b0406f27d9 (diff)
Use generic classes instead of cquery specific class.
Also introduce NamedThreadSafeOutputFormatterCallback for common code. RELNOTES: None PiperOrigin-RevId: 203932877
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/buildtool')
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java
index 31681b1af0..b2018a23fa 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/PostAnalysisQueryBuildTool.java
@@ -18,8 +18,8 @@ import com.google.devtools.build.lib.analysis.TargetAndConfiguration;
import com.google.devtools.build.lib.analysis.ViewCreationFailedException;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.events.Event;
-import com.google.devtools.build.lib.query2.ConfiguredTargetQueryEnvironment;
-import com.google.devtools.build.lib.query2.CqueryThreadsafeCallback;
+import com.google.devtools.build.lib.query2.NamedThreadSafeOutputFormatterCallback;
+import com.google.devtools.build.lib.query2.PostAnalysisQueryEnvironment;
import com.google.devtools.build.lib.query2.engine.QueryEvalResult;
import com.google.devtools.build.lib.query2.engine.QueryException;
import com.google.devtools.build.lib.query2.engine.QueryExpression;
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
* Version of {@link BuildTool} that handles all work for queries based on results from the analysis
* phase.
*/
-public abstract class PostAnalysisQueryBuildTool extends BuildTool {
+public abstract class PostAnalysisQueryBuildTool<T> extends BuildTool {
private final QueryExpression queryExpression;
@@ -76,8 +76,7 @@ public abstract class PostAnalysisQueryBuildTool extends BuildTool {
}
}
- // TODO(twerth): Make this more generic when introducting a PostAnalysisQueryEnvironment.
- protected abstract ConfiguredTargetQueryEnvironment getQueryEnvironment(
+ protected abstract PostAnalysisQueryEnvironment<T> getQueryEnvironment(
BuildRequest request,
BuildConfiguration hostConfiguration,
BuildConfiguration targetConfig,
@@ -125,30 +124,30 @@ public abstract class PostAnalysisQueryBuildTool extends BuildTool {
WalkableGraph walkableGraph =
SkyframeExecutorWrappingWalkableGraph.of(env.getSkyframeExecutor());
- ConfiguredTargetQueryEnvironment configuredTargetQueryEnvironment =
+ PostAnalysisQueryEnvironment<T> postAnalysisQueryEnvironment =
getQueryEnvironment(request, hostConfiguration, targetConfig, walkableGraph);
- Iterable<CqueryThreadsafeCallback> callbacks =
- configuredTargetQueryEnvironment.getDefaultOutputFormatters(
- configuredTargetQueryEnvironment.getAccessor(),
+ Iterable<NamedThreadSafeOutputFormatterCallback<T>> callbacks =
+ postAnalysisQueryEnvironment.getDefaultOutputFormatters(
+ postAnalysisQueryEnvironment.getAccessor(),
env.getReporter(),
env.getSkyframeExecutor(),
hostConfiguration,
runtime.getRuleClassProvider().getTrimmingTransitionFactory(),
env.getPackageManager());
- String outputFormat = configuredTargetQueryEnvironment.getOutputFormat();
- CqueryThreadsafeCallback callback =
- CqueryThreadsafeCallback.getCallback(outputFormat, callbacks);
+ String outputFormat = postAnalysisQueryEnvironment.getOutputFormat();
+ NamedThreadSafeOutputFormatterCallback<T> callback =
+ NamedThreadSafeOutputFormatterCallback.selectCallback(outputFormat, callbacks);
if (callback == null) {
env.getReporter()
.handle(
Event.error(
String.format(
"Invalid output format '%s'. Valid values are: %s",
- outputFormat, CqueryThreadsafeCallback.callbackNames(callbacks))));
+ outputFormat,
+ NamedThreadSafeOutputFormatterCallback.callbackNames(callbacks))));
return;
}
- QueryEvalResult result =
- configuredTargetQueryEnvironment.evaluateQuery(queryExpression, callback);
+ QueryEvalResult result = postAnalysisQueryEnvironment.evaluateQuery(queryExpression, callback);
if (result.isEmpty()) {
env.getReporter().handle(Event.info("Empty query results"));
}