Search in sources :

Example 11 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class BlazePackage method hasBlazePackageChild.

public static boolean hasBlazePackageChild(PsiDirectory directory) {
    ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(directory.getProject());
    BuildSystemProvider buildSystemProvider = Blaze.getBuildSystemProvider(directory.getProject());
    return hasBlazePackageChild(index, buildSystemProvider, directory);
}
Also used : ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider)

Example 12 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class ExecutionRootPathResolverTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    ExtensionPoint<BuildSystemProvider> extensionPoint = registerExtensionPoint(BuildSystemProvider.EP_NAME, BuildSystemProvider.class);
    extensionPoint.registerExtension(new BazelBuildSystemProvider());
    pathResolver = new ExecutionRootPathResolver(BuildSystem.Bazel, WORKSPACE_ROOT, new File(EXECUTION_ROOT), new WorkspacePathResolverImpl(WORKSPACE_ROOT));
}
Also used : BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) File(java.io.File)

Example 13 with BuildSystemProvider

use of com.google.idea.blaze.base.bazel.BuildSystemProvider in project intellij by bazelbuild.

the class PackageLister method expandPackageTargets.

/**
 * Expands all-in-package-recursive wildcard targets into all-in-single-package targets by
 * traversing the file system, looking for child blaze packages.
 *
 * <p>Returns null if directory traversal failed or was cancelled.
 */
@Nullable
static Map<TargetExpression, List<TargetExpression>> expandPackageTargets(BuildSystemProvider provider, BlazeContext context, WorkspacePathResolver pathResolver, Collection<WildcardTargetPattern> wildcardPatterns) {
    List<ListenableFuture<Entry<TargetExpression, List<TargetExpression>>>> futures = Lists.newArrayList();
    for (WildcardTargetPattern pattern : wildcardPatterns) {
        if (!pattern.isRecursive() || pattern.toString().startsWith("-")) {
            continue;
        }
        File dir = pathResolver.resolveToFile(pattern.getBasePackage());
        if (!FileOperationProvider.getInstance().isDirectory(dir)) {
            continue;
        }
        futures.add(FetchExecutor.EXECUTOR.submit(() -> {
            List<TargetExpression> expandedTargets = new ArrayList<>();
            traversePackageRecursively(provider, pathResolver, dir, expandedTargets);
            return Maps.immutableEntry(pattern.originalPattern, expandedTargets);
        }));
    }
    if (futures.isEmpty()) {
        return ImmutableMap.of();
    }
    FutureResult<List<Entry<TargetExpression, List<TargetExpression>>>> result = FutureUtil.waitForFuture(context, Futures.allAsList(futures)).withProgressMessage("Expanding wildcard target patterns...").timed("ExpandWildcardTargets", EventType.Other).onError("Expanding wildcard target patterns failed").run();
    if (!result.success()) {
        return null;
    }
    return result.result().stream().collect(Collectors.toMap(Entry::getKey, Entry::getValue, (x, y) -> x));
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) Map(java.util.Map) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) Nullable(javax.annotation.Nullable) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) WorkspacePathUtil(com.google.idea.blaze.base.util.WorkspacePathUtil) Collection(java.util.Collection) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) FutureUtil(com.google.idea.blaze.base.async.FutureUtil) FutureResult(com.google.idea.blaze.base.async.FutureUtil.FutureResult) Set(java.util.Set) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) File(java.io.File) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) Entry(java.util.Map.Entry) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) FetchExecutor(com.google.idea.blaze.base.prefetch.FetchExecutor) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) Nullable(javax.annotation.Nullable)

Aggregations

BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)13 File (java.io.File)6 BazelBuildSystemProvider (com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)5 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)4 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)4 WorkspacePathResolver (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver)4 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)4 Nullable (javax.annotation.Nullable)3 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)2 VirtualFileSystemProvider (com.google.idea.blaze.base.io.VirtualFileSystemProvider)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)2 ProgressManagerImpl (com.intellij.openapi.progress.impl.ProgressManagerImpl)2 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Futures (com.google.common.util.concurrent.Futures)1