use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeGoRootsProviderTest method testPackageToTargetMap.
@Test
public void testPackageToTargetMap() {
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(src("foo/bar/BUILD")).setLabel("//foo/bar:binary").setKind("go_binary").addSource(src("foo/bar/binary.go")).addDependency("//one/two:library").setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("foo/bar/binary.go"))).setImportPath("prefix/foo/bar/binary"))).addTarget(TargetIdeInfo.builder().setBuildFile(src("one/two/BUILD")).setLabel("//one/two:library").setKind("go_library").addSource(src("one/two/library.go")).addSource(src("one/two/three/library.go")).setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("one/two/library.go"), src("one/two/three/library.go"))).setImportPath("prefix/one/two/library"))).build();
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(new BlazeProjectData(0L, targetMap, null, null, null, null, new WorkspaceLanguageSettings(WorkspaceType.GO, ImmutableSet.of(LanguageClass.GO)), null, null)));
assertThat(BlazeGoRootsProvider.getPackageToTargetMap(getProject())).containsExactly("prefix/foo/bar/binary", TargetKey.forPlainTarget(Label.create("//foo/bar:binary")), "prefix/one/two/library", TargetKey.forPlainTarget(Label.create("//one/two:library")));
}
use of com.google.idea.blaze.base.ideinfo.TargetMap 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.base.ideinfo.TargetMap 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.base.ideinfo.TargetMap 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.base.ideinfo.TargetMap 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();
}
Aggregations