use of com.google.idea.blaze.base.sync.projectview.ProjectViewTargetImportFilter in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporter method importWorkspace.
public BlazeScalaImportResult importWorkspace() {
ProjectViewTargetImportFilter importFilter = new ProjectViewTargetImportFilter(project, workspaceRoot, projectViewSet);
Collection<Kind> scalaKinds = Kind.allKindsForLanguage(LanguageClass.SCALA);
List<TargetKey> scalaSourceTargets = targetMap.targets().stream().filter(target -> target.javaIdeInfo != null).filter(target -> target.kindIsOneOf(scalaKinds)).filter(importFilter::isSourceTarget).map(target -> target.key).collect(Collectors.toList());
Map<LibraryKey, BlazeJarLibrary> libraries = Maps.newHashMap();
// but since they'll all merged into one set, we will end up with exactly one of each.
for (TargetKey dependency : TransitiveDependencyMap.getTransitiveDependencies(scalaSourceTargets, targetMap)) {
TargetIdeInfo target = targetMap.get(dependency);
if (target == null) {
continue;
}
// Except source targets.
if (JavaSourceFilter.importAsSource(importFilter, target)) {
continue;
}
if (target.javaIdeInfo != null) {
target.javaIdeInfo.jars.stream().map(BlazeJarLibrary::new).forEach(library -> libraries.putIfAbsent(library.key, library));
}
}
return new BlazeScalaImportResult(ImmutableMap.copyOf(libraries));
}
use of com.google.idea.blaze.base.sync.projectview.ProjectViewTargetImportFilter 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);
});
}
Aggregations