use of com.google.idea.blaze.base.sync.sharding.QueryResultLineProcessor.RuleTypeAndLabel in project intellij by bazelbuild.
the class WildcardTargetExpander method queryIndividualTargets.
/**
* Runs a blaze query to expand the input target patterns to individual blaze targets.
*/
private static ExpandedTargetsResult queryIndividualTargets(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ImmutableSet<String> handledRuleTypes, List<TargetExpression> targetPatterns) {
String query = queryString(targetPatterns);
if (query.isEmpty()) {
// will be empty if there are no non-excluded targets
return new ExpandedTargetsResult(ImmutableList.of(), BuildResult.SUCCESS);
}
BlazeCommand.Builder builder = BlazeCommand.builder(getBinaryPath(project), BlazeCommandName.QUERY).addBlazeFlags(BlazeFlags.KEEP_GOING).addBlazeFlags("--output=label_kind").addBlazeFlags(queryString(targetPatterns));
ImmutableList.Builder<TargetExpression> output = ImmutableList.builder();
// it's fine to include wildcards here; they're guaranteed not to clash with actual labels.
Set<String> explicitTargets = targetPatterns.stream().map(TargetExpression::toString).collect(Collectors.toSet());
Predicate<RuleTypeAndLabel> filter = !filterByRuleType.getValue() ? t -> true : t -> handledRuleTypes.contains(t.ruleType) || explicitTargets.contains(t.label);
int retVal = ExternalTask.builder(workspaceRoot).addBlazeCommand(builder.build()).context(context).stdout(LineProcessingOutputStream.of(new QueryResultLineProcessor(output, filter))).stderr(LineProcessingOutputStream.of(BlazeConsoleLineProcessorProvider.getAllStderrLineProcessors(context))).build().run();
BuildResult buildResult = BuildResult.fromExitCode(retVal);
return new ExpandedTargetsResult(output.build(), buildResult);
}
Aggregations