Search in sources :

Example 1 with BlazeJavaWorkspaceImporter

use of com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter in project intellij by bazelbuild.

the class BlazeAndroidWorkspaceImporterTest method importJavaWorkspace.

private BlazeJavaImportResult importJavaWorkspace(WorkspaceRoot workspaceRoot, TargetMapBuilder targetMapBuilder, ProjectView projectView) {
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(projectView).build();
    TargetMap targetMap = targetMapBuilder.build();
    JavaSourceFilter sourceFilter = new JavaSourceFilter(project, workspaceRoot, projectViewSet, targetMap);
    BlazeJavaWorkspaceImporter blazeWorkspaceImporter = new BlazeJavaWorkspaceImporter(project, workspaceRoot, projectViewSet, workspaceLanguageSettings, targetMap, sourceFilter, jdepsMap, workingSet, FAKE_ARTIFACT_DECODER);
    return blazeWorkspaceImporter.importWorkspace(context);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) BlazeJavaWorkspaceImporter(com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap)

Example 2 with BlazeJavaWorkspaceImporter

use of com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter 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);
}
Also used : JdepsMap(com.google.idea.blaze.java.sync.jdeps.JdepsMap) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) BlazeJavaSyncData(com.google.idea.blaze.java.sync.model.BlazeJavaSyncData) Glob(com.google.idea.blaze.base.projectview.section.Glob) JavaWorkingSet(com.google.idea.blaze.java.sync.workingset.JavaWorkingSet) BlazeJavaWorkspaceImporter(com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter)

Example 3 with BlazeJavaWorkspaceImporter

use of com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter in project intellij by bazelbuild.

the class BlazeScalaWorkspaceImporterTest method importJava.

private BlazeJavaImportResult importJava(ProjectView projectView, TargetMap targetMap) {
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(projectView).build();
    WorkspaceLanguageSettings languageSettings = new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.SCALA, LanguageClass.JAVA));
    JavaSourceFilter sourceFilter = new JavaSourceFilter(project, workspaceRoot, projectViewSet, targetMap);
    JdepsMap jdepsMap = key -> ImmutableList.of();
    ArtifactLocationDecoder decoder = location -> new File(location.getRelativePath());
    return new BlazeJavaWorkspaceImporter(project, workspaceRoot, projectViewSet, languageSettings, targetMap, sourceFilter, jdepsMap, null, decoder).importWorkspace(context);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) LibraryKey(com.google.idea.blaze.base.model.LibraryKey) PrefetchService(com.google.idea.blaze.base.prefetch.PrefetchService) Map(java.util.Map) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) ImmutableSet(com.google.common.collect.ImmutableSet) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) ErrorCollector(com.google.idea.blaze.base.scope.ErrorCollector) BlazeSourceDirectory(com.google.idea.blaze.java.sync.model.BlazeSourceDirectory) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) ScalaJavaLikeLanguage(com.google.idea.blaze.scala.sync.source.ScalaJavaLikeLanguage) NotNull(org.jetbrains.annotations.NotNull) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) DirectorySection(com.google.idea.blaze.base.projectview.section.sections.DirectorySection) RunWith(org.junit.runner.RunWith) BlazeJavaWorkspaceImporter(com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter) JavaIdeInfo(com.google.idea.blaze.base.ideinfo.JavaIdeInfo) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableList(com.google.common.collect.ImmutableList) BuildSystem(com.google.idea.blaze.base.settings.Blaze.BuildSystem) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) Nullable(javax.annotation.Nullable) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) BlazeTestCase(com.google.idea.blaze.base.BlazeTestCase) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) BlazeJavaSyncAugmenter(com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter) BlazeScalaImportResult(com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult) File(java.io.File) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) JdepsMap(com.google.idea.blaze.java.sync.jdeps.JdepsMap) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ListSection(com.google.idea.blaze.base.projectview.section.ListSection) JdepsMap(com.google.idea.blaze.java.sync.jdeps.JdepsMap) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) BlazeJavaWorkspaceImporter(com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter) File(java.io.File)

Aggregations

BlazeJavaWorkspaceImporter (com.google.idea.blaze.java.sync.importer.BlazeJavaWorkspaceImporter)3 JavaSourceFilter (com.google.idea.blaze.java.sync.importer.JavaSourceFilter)3 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)2 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)2 JdepsMap (com.google.idea.blaze.java.sync.jdeps.JdepsMap)2 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 BlazeTestCase (com.google.idea.blaze.base.BlazeTestCase)1 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)1 JavaIdeInfo (com.google.idea.blaze.base.ideinfo.JavaIdeInfo)1 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)1 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)1 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)1 LibraryKey (com.google.idea.blaze.base.model.LibraryKey)1 LanguageClass (com.google.idea.blaze.base.model.primitives.LanguageClass)1 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)1 WorkspaceType (com.google.idea.blaze.base.model.primitives.WorkspaceType)1