use of com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method testSingleScalaBinary.
@Test
public void testSingleScalaBinary() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example")))).build();
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setBuildFile(source("src/main/scala/apps/example/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).addSource(source("src/main/scala/apps/example/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar"))))).build();
BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
errorCollector.assertNoIssues();
assertThat(javaImportResult.contentEntries).containsExactly(BlazeContentEntry.builder("/root/src/main/scala/apps/example").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/example").setPackagePrefix("apps.example").build()).build());
assertThat(javaImportResult.libraries).isEmpty();
assertThat(javaImportResult.javaSourceFiles).containsExactly(source("src/main/scala/apps/example/Main.scala"), source("src/main/scala/apps/example/subdir/SubdirHelper.scala"));
assertThat(scalaImportResult.libraries).isEmpty();
}
use of com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method testTwoScalaBinariesWithSharedLibrary.
@Test
public void testTwoScalaBinariesWithSharedLibrary() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example"))).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/other")))).build();
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setBuildFile(source("src/main/scala/apps/example/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).addSource(source("src/main/scala/apps/example/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar")))).addDependency("//src/main/scala/some/library:library")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/other:other").setBuildFile(source("src/main/scala/apps/other/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/other/Main.scala")).addSource(source("src/main/scala/apps/other/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/other/other.jar")).setClassJar(gen("src/main/scala/apps/other/other.jar")))).addDependency("//src/main/scala/some/library:library")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/some/library:library").setBuildFile(source("src/main/scala/some/library/BUILD")).setKind("scala_library").addSource(source("src/main/scala/some/library/Library.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/some/library/library_ijar.jar")).setClassJar(gen("src/main/scala/some/library/library.jar"))))).build();
BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
errorCollector.assertNoIssues();
assertThat(javaImportResult.contentEntries).containsExactly(BlazeContentEntry.builder("/root/src/main/scala/apps/example").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/example").setPackagePrefix("apps.example").build()).build(), BlazeContentEntry.builder("/root/src/main/scala/apps/other").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/other").setPackagePrefix("apps.other").build()).build());
// Direct library deps will be double counted.
assertThat(javaImportResult.libraries).hasSize(1);
assertThat(hasLibrary(javaImportResult.libraries, "library_ijar")).isTrue();
assertThat(javaImportResult.javaSourceFiles).containsExactly(source("src/main/scala/apps/example/Main.scala"), source("src/main/scala/apps/example/subdir/SubdirHelper.scala"), source("src/main/scala/apps/other/Main.scala"), source("src/main/scala/apps/other/subdir/SubdirHelper.scala"));
assertThat(scalaImportResult.libraries).hasSize(1);
assertThat(hasLibrary(scalaImportResult.libraries, "library_ijar")).isTrue();
}
use of com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method testEmptyProject.
@Test
public void testEmptyProject() {
ProjectView projectView = ProjectView.builder().build();
TargetMap targetMap = TargetMapBuilder.builder().build();
BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
errorCollector.assertNoIssues();
assertThat(javaImportResult.libraries).isEmpty();
assertThat(javaImportResult.contentEntries).isEmpty();
assertThat(javaImportResult.javaSourceFiles).isEmpty();
assertThat(javaImportResult.libraries).isEmpty();
assertThat(scalaImportResult.libraries).isEmpty();
}
use of com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method testScalaAndJavaBinary.
@Test
public void testScalaAndJavaBinary() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example"))).add(DirectoryEntry.include(new WorkspacePath("src/main/java/apps/example")))).build();
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setBuildFile(source("src/main/scala/apps/example/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).addSource(source("src/main/scala/apps/example/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//src/main/java/apps/example:example").setBuildFile(source("src/main/java/apps/example/BUILD")).setKind("java_binary").addSource(source("src/main/java/apps/example/Main.java")).addSource(source("src/main/java/apps/example/subdir/SubdirHelper.java")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/java/apps/example/example.jar")).setClassJar(gen("src/main/java/apps/example/example.jar"))))).build();
BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
errorCollector.assertNoIssues();
assertThat(javaImportResult.contentEntries).containsExactly(BlazeContentEntry.builder("/root/src/main/scala/apps/example").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/example").setPackagePrefix("apps.example").build()).build(), BlazeContentEntry.builder("/root/src/main/java/apps/example").addSource(BlazeSourceDirectory.builder("/root/src/main/java/apps/example").setPackagePrefix("apps.example").build()).build());
assertThat(javaImportResult.libraries).isEmpty();
assertThat(javaImportResult.javaSourceFiles).containsExactly(source("src/main/scala/apps/example/Main.scala"), source("src/main/scala/apps/example/subdir/SubdirHelper.scala"), source("src/main/java/apps/example/Main.java"), source("src/main/java/apps/example/subdir/SubdirHelper.java"));
assertThat(scalaImportResult.libraries).isEmpty();
}
use of com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult 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);
}
Aggregations