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