Search in sources :

Example 11 with TimingScope

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

the class BlazeSyncTask method updateInMemoryState.

private void updateInMemoryState(Project project, BlazeContext parentContext, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData) {
    Scope.push(parentContext, context -> {
        context.push(new TimingScope("UpdateInMemoryState", EventType.Other));
        context.output(new StatusOutput("Updating in-memory state..."));
        ApplicationManager.getApplication().runReadAction(() -> {
            Module workspaceModule = ModuleFinder.getInstance(project).findModuleByName(BlazeDataStorage.WORKSPACE_MODULE_NAME);
            for (BlazeSyncPlugin blazeSyncPlugin : BlazeSyncPlugin.EP_NAME.getExtensions()) {
                blazeSyncPlugin.updateInMemoryState(project, context, workspaceRoot, projectViewSet, blazeProjectData, workspaceModule);
            }
        });
    });
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) Module(com.intellij.openapi.module.Module)

Example 12 with TimingScope

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

the class BlazeSyncTask method getIdeQueryResult.

private BlazeIdeInterface.IdeResult getIdeQueryResult(Project project, BlazeContext parentContext, ProjectViewSet projectViewSet, BlazeVersionData blazeVersionData, BlazeConfigurationHandler configHandler, ShardedTargetList shardedTargets, WorkspaceLanguageSettings workspaceLanguageSettings, ArtifactLocationDecoder artifactLocationDecoder, Builder syncStateBuilder, @Nullable SyncState previousSyncState, boolean mergeWithOldState) {
    return Scope.push(parentContext, context -> {
        context.push(new TimingScope("IdeQuery", EventType.BlazeInvocation));
        context.output(new StatusOutput("Building IDE info files..."));
        context.setPropagatesErrors(false);
        BlazeIdeInterface blazeIdeInterface = BlazeIdeInterface.getInstance();
        return blazeIdeInterface.updateTargetMap(project, context, workspaceRoot, projectViewSet, blazeVersionData, configHandler, shardedTargets, workspaceLanguageSettings, artifactLocationDecoder, syncStateBuilder, previousSyncState, mergeWithOldState);
    });
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) BlazeIdeInterface(com.google.idea.blaze.base.sync.aspects.BlazeIdeInterface)

Example 13 with TimingScope

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

the class BlazeBuildTargetSharder method expandWildcardTargets.

/**
 * Expand wildcard target patterns into individual blaze targets.
 */
private static ExpandedTargetsResult expandWildcardTargets(Project project, BlazeContext parentContext, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspacePathResolver pathResolver, List<TargetExpression> targets) {
    return Scope.push(parentContext, context -> {
        context.push(new TimingScope("ShardSyncTargets", EventType.Other));
        context.output(new StatusOutput("Sharding: expanding wildcard target patterns..."));
        context.setPropagatesErrors(false);
        return doExpandWildcardTargets(project, context, workspaceRoot, projectViewSet, pathResolver, targets);
    });
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput)

Example 14 with TimingScope

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

the class BlazeCSyncPlugin method updateInMemoryState.

@Override
public void updateInMemoryState(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, Module workspaceModule) {
    if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.C)) {
        return;
    }
    Scope.push(context, childContext -> {
        childContext.push(new TimingScope("Setup C Workspace", EventType.Other));
        OCWorkspace workspace = OCWorkspaceProvider.getWorkspace(project);
        if (workspace instanceof BlazeCWorkspace) {
            BlazeCWorkspace blazeCWorkspace = (BlazeCWorkspace) workspace;
            blazeCWorkspace.update(childContext, workspaceRoot, projectViewSet, blazeProjectData);
        }
    });
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) OCWorkspace(com.jetbrains.cidr.lang.workspace.OCWorkspace)

Example 15 with TimingScope

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

the class BlazeConfigurationToolchainResolver method buildToolchainLookupMap.

/**
 * Returns the toolchain used by each target
 */
static ImmutableMap<TargetKey, CToolchainIdeInfo> buildToolchainLookupMap(BlazeContext context, TargetMap targetMap) {
    return Scope.push(context, childContext -> {
        childContext.push(new TimingScope("Build toolchain lookup map", EventType.Other));
        Map<TargetKey, CToolchainIdeInfo> toolchains = Maps.newLinkedHashMap();
        for (TargetIdeInfo target : targetMap.targets()) {
            CToolchainIdeInfo cToolchainIdeInfo = target.cToolchainIdeInfo;
            if (cToolchainIdeInfo != null) {
                toolchains.put(target.key, cToolchainIdeInfo);
            }
        }
        ImmutableMap.Builder<TargetKey, CToolchainIdeInfo> lookupTable = ImmutableMap.builder();
        for (TargetIdeInfo target : targetMap.targets()) {
            if (target.kind.languageClass != LanguageClass.C || target.kind == Kind.CC_TOOLCHAIN) {
                continue;
            }
            List<TargetKey> toolchainDeps = target.dependencies.stream().map(dep -> dep.targetKey).filter(toolchains::containsKey).collect(Collectors.toList());
            if (toolchainDeps.size() != 1) {
                issueToolchainWarning(context, target, toolchainDeps);
            }
            if (!toolchainDeps.isEmpty()) {
                TargetKey toolchainKey = toolchainDeps.get(0);
                CToolchainIdeInfo toolchainInfo = toolchains.get(toolchainKey);
                lookupTable.put(target.key, toolchainInfo);
            } else {
                CToolchainIdeInfo arbitraryToolchain = Iterables.getFirst(toolchains.values(), null);
                if (arbitraryToolchain != null) {
                    lookupTable.put(target.key, arbitraryToolchain);
                }
            }
        }
        return lookupTable.build();
    });
}
Also used : TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) CToolchainIdeInfo(com.google.idea.blaze.base.ideinfo.CToolchainIdeInfo) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) ImmutableMap(com.google.common.collect.ImmutableMap)

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