use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeSyncTask method getWorkingSetTargets.
private Collection<? extends TargetExpression> getWorkingSetTargets(ProjectViewSet projectViewSet, WorkingSet workingSet) {
ImportRoots importRoots = ImportRoots.builder(workspaceRoot, importSettings.getBuildSystem()).add(projectViewSet).build();
BuildTargetFinder buildTargetFinder = new BuildTargetFinder(project, workspaceRoot, importRoots);
Set<TargetExpression> result = Sets.newHashSet();
for (WorkspacePath workspacePath : Iterables.concat(workingSet.addedFiles, workingSet.modifiedFiles)) {
File file = workspaceRoot.fileForPath(workspacePath);
TargetExpression targetExpression = buildTargetFinder.findTargetForFile(file);
if (targetExpression != null) {
result.add(targetExpression);
}
}
return result;
}
use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeSyncTask method printTargets.
private void printTargets(BlazeContext context, String owner, Collection<? extends TargetExpression> targets) {
StringBuilder sb = new StringBuilder("Sync targets from ");
sb.append(owner).append(':').append('\n');
for (TargetExpression targetExpression : targets) {
sb.append(" ").append(targetExpression).append('\n');
}
context.output(PrintOutput.log(sb.toString()));
}
use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeBuildTargetSharder method doExpandWildcardTargets.
private static ExpandedTargetsResult doExpandWildcardTargets(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, 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);
}
}
return WildcardTargetExpander.expandToSingleTargets(project, context, workspaceRoot, projectViewSet, fullList);
}
use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class QueryResultLineProcessor method processLine.
@Override
public boolean processLine(String line) {
Matcher match = RULE_PATTERN.matcher(line);
if (!match.find()) {
return true;
}
String ruleType = match.group(1);
String label = match.group(2);
if (targetFilter.test(new RuleTypeAndLabel(ruleType, label))) {
TargetExpression target = TargetExpression.fromStringSafe(label);
if (target != null) {
outputList.add(target);
}
}
return true;
}
use of com.google.idea.blaze.base.model.primitives.TargetExpression in project intellij by bazelbuild.
the class BlazeFilterExistingRunConfigurationProducer method getTestFilter.
private static Optional<String> getTestFilter(ConfigurationContext context) {
RunConfiguration base = context.getOriginalConfiguration(null);
if (!(base instanceof BlazeCommandRunConfiguration)) {
return Optional.empty();
}
TargetExpression target = ((BlazeCommandRunConfiguration) base).getTarget();
if (target == null) {
return Optional.empty();
}
List<Location<?>> selectedElements = SmRunnerUtils.getSelectedSmRunnerTreeElements(context);
if (selectedElements.isEmpty()) {
return null;
}
Optional<BlazeTestEventsHandler> testEventsHandler = BlazeTestEventsHandler.getHandlerForTarget(context.getProject(), target);
return testEventsHandler.map(handler -> handler.getTestFilter(context.getProject(), selectedElements));
}
Aggregations