use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.
the class WildcardTargetPatternTest method testRecursiveWildcardPattern.
@Test
public void testRecursiveWildcardPattern() {
TargetExpression target = TargetExpression.fromStringSafe("//java/com/google/...");
WildcardTargetPattern wildcardPattern = WildcardTargetPattern.fromExpression(target);
assertThat(wildcardPattern).isNotNull();
assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google"))).isTrue();
assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google/foo"))).isTrue();
assertThat(wildcardPattern.isRecursive()).isTrue();
assertThat(wildcardPattern.getBasePackage()).isEqualTo(new WorkspacePath("java/com/google"));
assertThat(wildcardPattern.rulesOnly()).isTrue();
}
use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.
the class WildcardTargetPatternTest method testNonWildcardImplicitTargetName.
@Test
public void testNonWildcardImplicitTargetName() {
TargetExpression target = TargetExpression.fromStringSafe("//java/com/google/foo");
WildcardTargetPattern wildcardPattern = WildcardTargetPattern.fromExpression(target);
assertThat(wildcardPattern).isNull();
}
use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.
the class WildcardTargetPatternTest method testNonRecursiveWildcardPattern.
@Test
public void testNonRecursiveWildcardPattern() {
TargetExpression target = TargetExpression.fromStringSafe("//java/com/google:all");
WildcardTargetPattern wildcardPattern = WildcardTargetPattern.fromExpression(target);
assertThat(wildcardPattern).isNotNull();
assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google"))).isTrue();
assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google/foo"))).isFalse();
assertThat(wildcardPattern.isRecursive()).isFalse();
assertThat(wildcardPattern.getBasePackage()).isEqualTo(new WorkspacePath("java/com/google"));
assertThat(wildcardPattern.rulesOnly()).isTrue();
}
use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.
the class WildcardTargetPatternTest method testRecursiveWildcardPatternAlternativeFormat.
@Test
public void testRecursiveWildcardPatternAlternativeFormat() {
TargetExpression target = TargetExpression.fromStringSafe("//java/com/google/...:all");
WildcardTargetPattern wildcardPattern = WildcardTargetPattern.fromExpression(target);
assertThat(wildcardPattern).isNotNull();
assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google"))).isTrue();
assertThat(wildcardPattern.coversPackage(new WorkspacePath("java/com/google/foo"))).isTrue();
assertThat(wildcardPattern.isRecursive()).isTrue();
assertThat(wildcardPattern.getBasePackage()).isEqualTo(new WorkspacePath("java/com/google"));
assertThat(wildcardPattern.rulesOnly()).isTrue();
}
use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.
the class BlazeBuildTargetSharder method expandAndShardTargets.
/**
* Expand wildcard target patterns and partition the resulting target list.
*/
public static ShardedTargetsResult expandAndShardTargets(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspacePathResolver pathResolver, List<TargetExpression> targets) {
if (!shardingEnabled(projectViewSet)) {
return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of(targets)), BuildResult.SUCCESS);
}
List<WildcardTargetPattern> wildcardIncludes = getWildcardPatterns(targets);
if (wildcardIncludes.isEmpty()) {
return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of(targets)), BuildResult.SUCCESS);
}
ExpandedTargetsResult expandedTargets = expandWildcardTargets(project, context, workspaceRoot, projectViewSet, pathResolver, targets);
if (expandedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of()), expandedTargets.buildResult);
}
return new ShardedTargetsResult(shardTargets(expandedTargets.singleTargets, getTargetShardSize(projectViewSet)), expandedTargets.buildResult);
}
Aggregations