Search in sources :

Example 1 with TimingScope

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

the class BuildLangSyncPlugin method getBuildLanguageSpec.

@Nullable
private static LanguageSpecResult getBuildLanguageSpec(Project project, WorkspaceRoot workspace, ProjectViewSet projectViewSet, @Nullable SyncState previousSyncState, BlazeContext parentContext) {
    LanguageSpecResult oldResult = previousSyncState != null ? previousSyncState.get(LanguageSpecResult.class) : null;
    if (oldResult != null && !oldResult.shouldRecalculateSpec()) {
        return oldResult;
    }
    LanguageSpecResult result = Scope.push(parentContext, (context) -> {
        context.push(new TimingScope("BUILD language spec", EventType.BlazeInvocation));
        BuildLanguageSpec spec = parseLanguageSpec(project, workspace, projectViewSet, context);
        if (spec != null) {
            return new LanguageSpecResult(spec, System.currentTimeMillis());
        }
        return null;
    });
    return result != null ? result : oldResult;
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BuildLanguageSpec(com.google.idea.blaze.base.lang.buildfile.language.semantics.BuildLanguageSpec) Nullable(javax.annotation.Nullable)

Example 2 with TimingScope

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

the class BlazeBuildService method buildTargetExpressions.

@VisibleForTesting
void buildTargetExpressions(Project project, List<TargetExpression> targets, ProjectViewSet projectViewSet, NotificationScope notificationScope) {
    if (targets.isEmpty() || projectViewSet == null) {
        return;
    }
    BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
    if (blazeProjectData == null) {
        return;
    }
    // go/futurereturn-lsc
    @SuppressWarnings("unused") Future<?> possiblyIgnoredError = ProgressiveTaskWithProgressIndicator.builder(project).setTitle("Building targets").submitTaskWithResult(new ScopedTask<Void>() {

        @Override
        public Void execute(BlazeContext context) {
            context.push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.Sync, true)).build()).push(new IssuesScope(project, true)).push(new IdeaLogScope()).push(new TimingScope("Make", EventType.BlazeInvocation)).push(notificationScope);
            WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
            SaveUtil.saveAllFiles();
            ShardedTargetsResult shardedTargets = BlazeBuildTargetSharder.expandAndShardTargets(project, context, workspaceRoot, projectViewSet, blazeProjectData.workspacePathResolver, targets);
            if (shardedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
                return null;
            }
            BuildResult buildResult = BlazeIdeInterface.getInstance().compileIdeArtifacts(project, context, workspaceRoot, projectViewSet, blazeProjectData.blazeVersionData, blazeProjectData.workspaceLanguageSettings, shardedTargets.shardedTargets);
            FileCaches.refresh(project);
            if (buildResult.status != BuildResult.Status.SUCCESS) {
                context.setHasError();
            }
            return null;
        }
    });
}
Also used : ShardedTargetsResult(com.google.idea.blaze.base.sync.sharding.BlazeBuildTargetSharder.ShardedTargetsResult) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BuildResult(com.google.idea.blaze.base.sync.aspects.BuildResult) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) IssuesScope(com.google.idea.blaze.base.scope.scopes.IssuesScope) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with TimingScope

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

the class BlazeAndroidSyncPlugin 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 (!isAndroidWorkspace(workspaceLanguageSettings)) {
        return;
    }
    AndroidSdkPlatform androidSdkPlatform = AndroidSdkFromProjectView.getAndroidSdkPlatform(context, projectViewSet);
    JavaSourceFilter sourceFilter = new JavaSourceFilter(project, workspaceRoot, projectViewSet, targetMap);
    BlazeAndroidWorkspaceImporter workspaceImporter = new BlazeAndroidWorkspaceImporter(project, context, workspaceRoot, projectViewSet, targetMap, sourceFilter, artifactLocationDecoder);
    BlazeAndroidImportResult importResult = Scope.push(context, (childContext) -> {
        childContext.push(new TimingScope("AndroidWorkspaceImporter", EventType.Other));
        return workspaceImporter.importWorkspace();
    });
    BlazeAndroidSyncData syncData = new BlazeAndroidSyncData(importResult, androidSdkPlatform);
    syncStateBuilder.put(BlazeAndroidSyncData.class, syncData);
}
Also used : BlazeAndroidWorkspaceImporter(com.google.idea.blaze.android.sync.importer.BlazeAndroidWorkspaceImporter) AndroidSdkPlatform(com.google.idea.blaze.android.sync.model.AndroidSdkPlatform) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) BlazeAndroidImportResult(com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult) BlazeAndroidSyncData(com.google.idea.blaze.android.sync.model.BlazeAndroidSyncData)

Example 4 with TimingScope

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

the class GitWorkingSetProvider method calculateWorkingSet.

/**
 * Finds all changes between HEAD and the git commit specified by the provided SHA.<br>
 * Returns null if an error occurred.
 */
@Nullable
public static WorkingSet calculateWorkingSet(WorkspaceRoot workspaceRoot, String upstreamSha, BlazeContext context) {
    String gitRoot = getConsoleOutput(workspaceRoot, "git", "rev-parse", "--show-toplevel");
    if (gitRoot == null) {
        return null;
    }
    GitStatusLineProcessor processor = new GitStatusLineProcessor(workspaceRoot, gitRoot);
    ByteArrayOutputStream stderr = new ByteArrayOutputStream();
    // Do a git diff to find all modified files we know about
    int retVal = ExternalTask.builder(workspaceRoot).args("git", "diff", "--name-status", "--no-renames", upstreamSha).context(context).stdout(LineProcessingOutputStream.of(processor)).stderr(stderr).build().run(new TimingScope("GitDiff", EventType.Other));
    if (retVal != 0) {
        logger.error(stderr);
        return null;
    }
    // Finally list all untracked files, as they're not caught by the git diff step above
    String untrackedFilesOutput = getConsoleOutput(workspaceRoot, "git", "ls-files", "--others", "--exclude-standard");
    if (untrackedFilesOutput == null) {
        return null;
    }
    List<WorkspacePath> untrackedFiles = Arrays.asList(untrackedFilesOutput.split("\n")).stream().filter(s -> !Strings.isNullOrEmpty(s)).filter(WorkspacePath::isValid).map(WorkspacePath::new).collect(Collectors.toList());
    return new WorkingSet(ImmutableList.<WorkspacePath>builder().addAll(processor.addedFiles).addAll(untrackedFiles).build(), ImmutableList.copyOf(processor.modifiedFiles), ImmutableList.copyOf(processor.deletedFiles));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ExternalTask(com.google.idea.blaze.base.async.process.ExternalTask) Arrays(java.util.Arrays) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StringUtil(com.intellij.openapi.util.text.StringUtil) Collectors(java.util.stream.Collectors) Strings(com.google.common.base.Strings) List(java.util.List) LineProcessingOutputStream(com.google.idea.blaze.base.async.process.LineProcessingOutputStream) ImmutableList(com.google.common.collect.ImmutableList) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Logger(com.intellij.openapi.diagnostic.Logger) WorkingSet(com.google.idea.blaze.base.sync.workspace.WorkingSet) Nullable(javax.annotation.Nullable) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) ByteArrayOutputStream(java.io.ByteArrayOutputStream) WorkingSet(com.google.idea.blaze.base.sync.workspace.WorkingSet) Nullable(javax.annotation.Nullable)

Example 5 with TimingScope

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

the class BlazeGoSyncPlugin method updateProjectStructure.

@Override
public void updateProjectStructure(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, BlazeProjectData blazeProjectData, @Nullable BlazeProjectData oldBlazeProjectData, ModuleEditor moduleEditor, Module workspaceModule, ModifiableRootModel workspaceModifiableModel) {
    if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.GO)) {
        return;
    }
    for (Library lib : getGoLibraries(project)) {
        if (workspaceModifiableModel.findLibraryOrderEntry(lib) == null) {
            workspaceModifiableModel.addLibraryEntry(lib);
        }
    }
    Scope.push(context, (childContext) -> {
        childContext.push(new TimingScope("BuildGoSymbolicLinks", EventType.Other));
        BlazeGoRootsProvider.createGoPathSourceRoot(project, blazeProjectData);
    });
}
Also used : TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) Library(com.intellij.openapi.roots.libraries.Library)

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