Search in sources :

Example 11 with TargetExpression

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;
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) File(java.io.File)

Example 12 with TargetExpression

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()));
}
Also used : TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression)

Example 13 with TargetExpression

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);
}
Also used : WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) ArrayList(java.util.ArrayList) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ExpandedTargetsResult(com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult)

Example 14 with TargetExpression

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;
}
Also used : Matcher(java.util.regex.Matcher) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression)

Example 15 with TargetExpression

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));
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) BlazeTestEventsHandler(com.google.idea.blaze.base.run.smrunner.BlazeTestEventsHandler) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) Location(com.intellij.execution.Location)

Aggregations

TargetExpression (com.google.idea.blaze.base.model.primitives.TargetExpression)31 Test (org.junit.Test)11 WildcardTargetPattern (com.google.idea.blaze.base.model.primitives.WildcardTargetPattern)10 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)8 File (java.io.File)6 Label (com.google.idea.blaze.base.model.primitives.Label)5 ImmutableList (com.google.common.collect.ImmutableList)3 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)3 BlazeCommandRunConfigurationCommonState (com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 Futures (com.google.common.util.concurrent.Futures)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)2 FutureUtil (com.google.idea.blaze.base.async.FutureUtil)2 BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)2 BlazeCommand (com.google.idea.blaze.base.command.BlazeCommand)2 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)2 Kind (com.google.idea.blaze.base.model.primitives.Kind)2