Search in sources :

Example 6 with BlazeSourceDirectory

use of com.google.idea.blaze.java.sync.model.BlazeSourceDirectory in project intellij by bazelbuild.

the class ScalaSyncTest method testScalaClassesPresentInClassPath.

@Test
public void testScalaClassesPresentInClassPath() throws Exception {
    setProjectView("directories:", "  src/main/scala/com/google", "targets:", "  //src/main/scala/com/google:lib", "additional_languages:", "  scala");
    workspace.createFile(new WorkspacePath("src/main/scala/com/google/ClassWithUniqueName1.scala"), "package com.google;", "public class ClassWithUniqueName1 {}");
    workspace.createFile(new WorkspacePath("src/main/scala/com/google/ClassWithUniqueName2.scala"), "package com.google;", "public class ClassWithUniqueName2 {}");
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("src/main/scala/com/google/BUILD")).setLabel("//src/main/scala/com/google:lib").setKind("scala_library").addSource(sourceRoot("src/main/scala/com/google/ClassWithUniqueName1.scala")).addSource(sourceRoot("src/main/scala/com/google/ClassWithUniqueName2.scala")).setJavaInfo(JavaIdeInfo.builder())).build();
    setTargetMap(targetMap);
    BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
    runBlazeSync(syncParams);
    errorCollector.assertNoIssues();
    BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
    assertThat(blazeProjectData).isNotNull();
    assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
    assertThat(blazeProjectData.workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.JAVA, LanguageClass.SCALA)));
    BlazeJavaSyncData javaSyncData = blazeProjectData.syncState.get(BlazeJavaSyncData.class);
    assertThat(javaSyncData).isNotNull();
    List<BlazeContentEntry> contentEntries = javaSyncData.importResult.contentEntries;
    assertThat(contentEntries).hasSize(1);
    BlazeContentEntry contentEntry = contentEntries.get(0);
    assertThat(contentEntry.contentRoot.getPath()).isEqualTo(workspaceRoot.fileForPath(new WorkspacePath("src/main/scala/com/google")).getPath());
    assertThat(contentEntry.sources).hasSize(1);
    BlazeSourceDirectory sourceDir = contentEntry.sources.get(0);
    assertThat(sourceDir.getPackagePrefix()).isEqualTo("com.google");
    assertThat(sourceDir.getDirectory().getPath()).isEqualTo(workspaceRoot.fileForPath(new WorkspacePath("src/main/scala/com/google")).getPath());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BlazeContentEntry(com.google.idea.blaze.java.sync.model.BlazeContentEntry) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) BlazeJavaSyncData(com.google.idea.blaze.java.sync.model.BlazeJavaSyncData) BlazeSourceDirectory(com.google.idea.blaze.java.sync.model.BlazeSourceDirectory) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Aggregations

BlazeContentEntry (com.google.idea.blaze.java.sync.model.BlazeContentEntry)6 BlazeSourceDirectory (com.google.idea.blaze.java.sync.model.BlazeSourceDirectory)6 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)5 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)3 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)3 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)3 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)3 BlazeJavaSyncData (com.google.idea.blaze.java.sync.model.BlazeJavaSyncData)3 File (java.io.File)3 Joiner (com.google.common.base.Joiner)2 Objects (com.google.common.base.Objects)2 Splitter (com.google.common.base.Splitter)2 Strings (com.google.common.base.Strings)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 HashMultiset (com.google.common.collect.HashMultiset)2 ImmutableList (com.google.common.collect.ImmutableList)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 Multimap (com.google.common.collect.Multimap)2 Multiset (com.google.common.collect.Multiset)2