Search in sources :

Example 16 with TimingScope

use of com.google.idea.blaze.base.scope.scopes.TimingScope in project intellij by bazelbuild.

the class SourceDirectoryCalculator method calculateContentEntries.

public ImmutableList<BlazeContentEntry> calculateContentEntries(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ArtifactLocationDecoder artifactLocationDecoder, ImportRoots importRoots, Collection<SourceArtifact> sources, Map<TargetKey, ArtifactLocation> javaPackageManifests) {
    ManifestFilePackageReader manifestFilePackageReader = Scope.push(context, (childContext) -> {
        childContext.push(new TimingScope("ReadPackageManifests", EventType.Other));
        Map<TargetKey, Map<ArtifactLocation, String>> manifestMap = PackageManifestReader.getInstance().readPackageManifestFiles(project, childContext, artifactLocationDecoder, javaPackageManifests, packageReaderExecutorService);
        return new ManifestFilePackageReader(manifestMap);
    });
    final List<JavaPackageReader> javaPackageReaders = Lists.newArrayList(manifestFilePackageReader, JavaSourcePackageReader.getInstance(), generatedFileJavaPackageReader);
    Collection<SourceArtifact> nonGeneratedSources = filterGeneratedArtifacts(sources);
    // Sort artifacts and excludes into their respective workspace paths
    Multimap<WorkspacePath, SourceArtifact> sourcesUnderDirectoryRoot = sortArtifactLocationsByRootDirectory(context, importRoots, nonGeneratedSources);
    List<BlazeContentEntry> result = Lists.newArrayList();
    Scope.push(context, (childContext) -> {
        childContext.push(new TimingScope("CalculateSourceDirectories", EventType.Other));
        for (WorkspacePath workspacePath : importRoots.rootDirectories()) {
            File contentRoot = workspaceRoot.fileForPath(workspacePath);
            ImmutableList<BlazeSourceDirectory> sourceDirectories = calculateSourceDirectoriesForContentRoot(context, workspaceRoot, artifactLocationDecoder, workspacePath, sourcesUnderDirectoryRoot.get(workspacePath), javaPackageReaders);
            if (!sourceDirectories.isEmpty()) {
                result.add(new BlazeContentEntry(contentRoot, sourceDirectories));
            }
        }
        result.sort(Comparator.comparing(lhs -> lhs.contentRoot));
    });
    return ImmutableList.copyOf(result);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ArrayListMultimap(com.google.common.collect.ArrayListMultimap) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) TransientExecutor(com.google.idea.blaze.base.async.executor.TransientExecutor) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Multiset(com.google.common.collect.Multiset) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) HashMultiset(com.google.common.collect.HashMultiset) Scope(com.google.idea.blaze.base.scope.Scope) Map(java.util.Map) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Project(com.intellij.openapi.project.Project) Objects(com.google.common.base.Objects) Logger(com.intellij.openapi.diagnostic.Logger) Splitter(com.google.common.base.Splitter) Nullable(javax.annotation.Nullable) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BlazeSourceDirectory(com.google.idea.blaze.java.sync.model.BlazeSourceDirectory) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Comparator(java.util.Comparator) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) PackagePrefixCalculator(com.google.idea.blaze.base.util.PackagePrefixCalculator) Collections(java.util.Collections) Joiner(com.google.common.base.Joiner) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BlazeSourceDirectory(com.google.idea.blaze.java.sync.model.BlazeSourceDirectory) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

Example 17 with TimingScope

use of com.google.idea.blaze.base.scope.scopes.TimingScope in project intellij by bazelbuild.

the class BlazeScalaSyncPlugin method updateSyncState.

@Override
public void updateSyncState(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspaceLanguageSettings workspaceLanguageSettings, BlazeInfo blazeInfo, @Nullable WorkingSet workingSet, WorkspacePathResolver workspacePathResolver, ArtifactLocationDecoder artifactLocationDecoder, TargetMap targetMap, Builder syncStateBuilder, @Nullable SyncState previousSyncState) {
    if (!workspaceLanguageSettings.isLanguageActive(LanguageClass.SCALA)) {
        return;
    }
    BlazeScalaWorkspaceImporter blazeScalaWorkspaceImporter = new BlazeScalaWorkspaceImporter(project, workspaceRoot, projectViewSet, targetMap);
    BlazeScalaImportResult importResult = Scope.push(context, (childContext) -> {
        childContext.push(new TimingScope("ScalaWorkspaceImporter", EventType.Other));
        return blazeScalaWorkspaceImporter.importWorkspace();
    });
    BlazeScalaSyncData syncData = new BlazeScalaSyncData(importResult);
    syncStateBuilder.put(BlazeScalaSyncData.class, syncData);
}
Also used : BlazeScalaWorkspaceImporter(com.google.idea.blaze.scala.sync.importer.BlazeScalaWorkspaceImporter) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BlazeScalaImportResult(com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult) BlazeScalaSyncData(com.google.idea.blaze.scala.sync.model.BlazeScalaSyncData)

Example 18 with TimingScope

use of com.google.idea.blaze.base.scope.scopes.TimingScope in project intellij by bazelbuild.

the class BlazeKotlinSyncPlugin method updateSyncState.

@Override
public void updateSyncState(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspaceLanguageSettings workspaceLanguageSettings, BlazeInfo blazeInfo, @Nullable WorkingSet workingSet, WorkspacePathResolver workspacePathResolver, ArtifactLocationDecoder artifactLocationDecoder, TargetMap targetMap, SyncState.Builder syncStateBuilder, @Nullable SyncState previousSyncState) {
    if (!workspaceLanguageSettings.isLanguageActive(LanguageClass.KOTLIN)) {
        return;
    }
    BlazeKotlinWorkspaceImporter blazeKotlinWorkspaceImporter = new BlazeKotlinWorkspaceImporter(project, workspaceRoot, projectViewSet, targetMap);
    BlazeKotlinImportResult importResult = Scope.push(context, (childContext) -> {
        childContext.push(new TimingScope("KotlinWorkspaceImporter", TimingScope.EventType.Other));
        return blazeKotlinWorkspaceImporter.importWorkspace();
    });
    BlazeKotlinSyncData syncData = new BlazeKotlinSyncData(importResult);
    syncStateBuilder.put(BlazeKotlinSyncData.class, syncData);
}
Also used : BlazeKotlinImportResult(com.google.idea.blaze.kotlin.sync.model.BlazeKotlinImportResult) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BlazeKotlinSyncData(com.google.idea.blaze.kotlin.sync.model.BlazeKotlinSyncData) BlazeKotlinWorkspaceImporter(com.google.idea.blaze.kotlin.sync.importer.BlazeKotlinWorkspaceImporter)

Example 19 with TimingScope

use of com.google.idea.blaze.base.scope.scopes.TimingScope in project intellij by bazelbuild.

the class BlazeConfigurationResolver method buildBlazeConfigurationData.

private void buildBlazeConfigurationData(BlazeContext parentContext, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, ImmutableMap<TargetKey, CToolchainIdeInfo> toolchainLookupMap, ImmutableMap<File, VirtualFile> headerRoots, ImmutableMap<CToolchainIdeInfo, BlazeCompilerSettings> compilerSettings, CompilerInfoCache compilerInfoCache, ExecutionRootPathResolver executionRootPathResolver, BlazeConfigurationResolverResult oldConfigurationData, BlazeConfigurationResolverResult.Builder builder) {
    // Type specification needed to avoid incorrect type inference during command line build.
    Scope.push(parentContext, (ScopedOperation) context -> {
        context.push(new TimingScope("Build C configuration map", EventType.Other));
        ProjectViewTargetImportFilter filter = new ProjectViewTargetImportFilter(project, workspaceRoot, projectViewSet);
        ConcurrentMap<TargetKey, BlazeResolveConfigurationData> targetToData = Maps.newConcurrentMap();
        List<ListenableFuture<?>> targetToDataFutures = blazeProjectData.targetMap.targets().stream().filter(target -> target.kind.languageClass == LanguageClass.C).filter(target -> target.kind != Kind.CC_TOOLCHAIN).filter(filter::isSourceTarget).filter(BlazeConfigurationResolver::containsCompiledSources).map(target -> submit(() -> {
            BlazeResolveConfigurationData data = createResolveConfiguration(target, toolchainLookupMap, headerRoots, compilerSettings, compilerInfoCache, executionRootPathResolver);
            if (data != null) {
                targetToData.put(target.key, data);
            }
            return null;
        })).collect(Collectors.toList());
        try {
            Futures.allAsList(targetToDataFutures).get();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            context.setCancelled();
            return;
        } catch (ExecutionException e) {
            IssueOutput.error("Could not build C resolve configurations: " + e).submit(context);
            logger.error("Could not build C resolve configurations", e);
            return;
        }
        findEquivalenceClasses(context, project, blazeProjectData.workspacePathResolver, targetToData, oldConfigurationData, builder);
    });
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) FileUtilRt(com.intellij.openapi.util.io.FileUtilRt) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ScopedFunction(com.google.idea.blaze.base.scope.ScopedFunction) ExecutionRootPathResolver(com.google.idea.blaze.base.sync.workspace.ExecutionRootPathResolver) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Logger(com.intellij.openapi.diagnostic.Logger) Blaze(com.google.idea.blaze.base.settings.Blaze) ImmutableMap(com.google.common.collect.ImmutableMap) CompilerInfoCache(com.jetbrains.cidr.toolchains.CompilerInfoCache) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) CIdeInfo(com.google.idea.blaze.base.ideinfo.CIdeInfo) List(java.util.List) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) BlazeInfo(com.google.idea.blaze.base.command.info.BlazeInfo) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) Queue(java.util.Queue) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) Multimap(com.google.common.collect.Multimap) VfsUtils(com.google.idea.blaze.base.io.VfsUtils) ConcurrentMap(java.util.concurrent.ConcurrentMap) Kind(com.google.idea.blaze.base.model.primitives.Kind) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Scope(com.google.idea.blaze.base.scope.Scope) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) Project(com.intellij.openapi.project.Project) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) ProjectViewTargetImportFilter(com.google.idea.blaze.base.sync.projectview.ProjectViewTargetImportFilter) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Maps(com.google.common.collect.Maps) File(java.io.File) CToolchainIdeInfo(com.google.idea.blaze.base.ideinfo.CToolchainIdeInfo) ExecutionException(java.util.concurrent.ExecutionException) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) Futures(com.google.common.util.concurrent.Futures) ExecutionRootPath(com.google.idea.blaze.base.model.primitives.ExecutionRootPath) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) ArrayDeque(java.util.ArrayDeque) ScopedOperation(com.google.idea.blaze.base.scope.ScopedOperation) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) ProjectViewTargetImportFilter(com.google.idea.blaze.base.sync.projectview.ProjectViewTargetImportFilter) ConcurrentMap(java.util.concurrent.ConcurrentMap) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ExecutionException(java.util.concurrent.ExecutionException)

Example 20 with TimingScope

use of com.google.idea.blaze.base.scope.scopes.TimingScope in project intellij by bazelbuild.

the class BlazeJavaSyncPlugin method updateSyncState.

@Override
public void updateSyncState(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspaceLanguageSettings workspaceLanguageSettings, BlazeInfo blazeInfo, @Nullable WorkingSet workingSet, WorkspacePathResolver workspacePathResolver, ArtifactLocationDecoder artifactLocationDecoder, TargetMap targetMap, SyncState.Builder syncStateBuilder, @Nullable SyncState previousSyncState) {
    JavaWorkingSet javaWorkingSet = null;
    if (workingSet != null) {
        javaWorkingSet = new JavaWorkingSet(workspaceRoot, workingSet, Blaze.getBuildSystemProvider(project)::isBuildFile);
    }
    JavaSourceFilter sourceFilter = new JavaSourceFilter(project, workspaceRoot, projectViewSet, targetMap);
    JdepsMap jdepsMap = jdepsFileReader.loadJdepsFiles(project, context, artifactLocationDecoder, sourceFilter.getSourceTargets(), syncStateBuilder, previousSyncState);
    if (context.isCancelled()) {
        return;
    }
    BlazeJavaWorkspaceImporter blazeJavaWorkspaceImporter = new BlazeJavaWorkspaceImporter(project, workspaceRoot, projectViewSet, workspaceLanguageSettings, targetMap, sourceFilter, jdepsMap, javaWorkingSet, artifactLocationDecoder);
    BlazeJavaImportResult importResult = Scope.push(context, (childContext) -> {
        childContext.push(new TimingScope("JavaWorkspaceImporter", EventType.Other));
        return blazeJavaWorkspaceImporter.importWorkspace(childContext);
    });
    Glob.GlobSet excludedLibraries = new Glob.GlobSet(ImmutableList.<Glob>builder().addAll(projectViewSet.listItems(ExcludeLibrarySection.KEY)).addAll(projectViewSet.listItems(ExcludedLibrarySection.KEY)).build());
    BlazeJavaSyncData syncData = new BlazeJavaSyncData(importResult, excludedLibraries);
    syncStateBuilder.put(BlazeJavaSyncData.class, syncData);
}
Also used : JdepsMap(com.google.idea.blaze.java.sync.jdeps.JdepsMap) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) BlazeJavaSyncData(com.google.idea.blaze.java.sync.model.BlazeJavaSyncData) Glob(com.google.idea.blaze.base.projectview.section.Glob) JavaWorkingSet(com.google.idea.blaze.java.sync.workingset.JavaWorkingSet) BlazeJavaWorkspaceImporter(com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter)

Aggregations

TimingScope (com.google.idea.blaze.base.scope.scopes.TimingScope)27 StatusOutput (com.google.idea.blaze.base.scope.output.StatusOutput)8 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)7 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)7 Nullable (javax.annotation.Nullable)7 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)6 EventType (com.google.idea.blaze.base.scope.scopes.TimingScope.EventType)6 Logger (com.intellij.openapi.diagnostic.Logger)6 List (java.util.List)6 ImmutableList (com.google.common.collect.ImmutableList)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 Lists (com.google.common.collect.Lists)5 Maps (com.google.common.collect.Maps)5 Futures (com.google.common.util.concurrent.Futures)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)5 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)5 Scope (com.google.idea.blaze.base.scope.Scope)5 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)5 Project (com.intellij.openapi.project.Project)5