use of com.google.idea.blaze.base.sync.projectview.TargetExpressionList in project intellij by bazelbuild.
the class BlazeBuildTargetSharder method doExpandWildcardTargets.
private static ExpandedTargetsResult doExpandWildcardTargets(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, BlazeBuildParams buildParams, ProjectViewSet projectViewSet, WorkspacePathResolver pathResolver, List<TargetExpression> targets) {
List<WildcardTargetPattern> includes = getWildcardPatterns(targets);
if (includes.isEmpty()) {
return new ExpandedTargetsResult(targets, BuildResult.SUCCESS);
}
Map<TargetExpression, List<TargetExpression>> expandedTargets = WildcardTargetExpander.expandToNonRecursiveWildcardTargets(project, context, pathResolver, includes);
if (expandedTargets == null) {
return new ExpandedTargetsResult(ImmutableList.of(), BuildResult.FATAL_ERROR);
}
// replace original recursive targets with expanded list, retaining relative ordering
List<TargetExpression> fullList = new ArrayList<>();
for (TargetExpression target : targets) {
List<TargetExpression> expanded = expandedTargets.get(target);
if (expanded == null) {
fullList.add(target);
} else {
fullList.addAll(expanded);
}
}
ExpandedTargetsResult result = WildcardTargetExpander.expandToSingleTargets(project, context, workspaceRoot, buildParams, projectViewSet, fullList);
// finally add back any explicitly-specified, unexcluded single targets which may have been
// removed by the query (for example, because they have the 'manual' tag)
TargetExpressionList helper = TargetExpressionList.create(targets);
List<TargetExpression> singleTargets = targets.stream().filter(t -> !t.isExcluded()).filter(t -> !isWildcardPattern(t)).filter(t -> t instanceof Label).filter(t -> helper.includesTarget((Label) t)).collect(toImmutableList());
return ExpandedTargetsResult.merge(result, new ExpandedTargetsResult(singleTargets, result.buildResult));
}
Aggregations