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;
}
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;
}
});
}
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);
}
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));
}
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);
});
}
Aggregations