use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.
the class WildcardTargetPatternTest method testRecursiveWildcardPatternAllTargets.
@Test
public void testRecursiveWildcardPatternAllTargets() {
TargetExpression target = TargetExpression.fromStringSafe("//java/com/google/...:all-targets");
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()).isFalse();
}
use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern in project intellij by bazelbuild.
the class WildcardTargetPatternTest method testNonRecursiveAllTargetsWildcardPattern.
@Test
public void testNonRecursiveAllTargetsWildcardPattern() {
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"))).isFalse();
assertThat(wildcardPattern.isRecursive()).isFalse();
assertThat(wildcardPattern.getBasePackage()).isEqualTo(new WorkspacePath("java/com/google"));
assertThat(wildcardPattern.rulesOnly()).isFalse();
}
use of com.google.idea.blaze.base.model.primitives.WildcardTargetPattern 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.WildcardTargetPattern in project intellij by bazelbuild.
the class WildcardTargetPatternTest method testNonWildcardPattern.
@Test
public void testNonWildcardPattern() {
TargetExpression target = TargetExpression.fromStringSafe("//java/com/google:single_target");
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 testRecursiveWildcardPatternAllTargetsAlternativeFormat.
@Test
public void testRecursiveWildcardPatternAllTargetsAlternativeFormat() {
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()).isFalse();
}
Aggregations