Search in sources :

Example 11 with BlazeJavaSyncData

use of com.google.idea.blaze.java.sync.model.BlazeJavaSyncData 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

BlazeJavaSyncData (com.google.idea.blaze.java.sync.model.BlazeJavaSyncData)11 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)6 BlazeContentEntry (com.google.idea.blaze.java.sync.model.BlazeContentEntry)6 Test (org.junit.Test)6 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)4 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 GlobSet (com.google.idea.blaze.base.projectview.section.Glob.GlobSet)3 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)3 BlazeSourceDirectory (com.google.idea.blaze.java.sync.model.BlazeSourceDirectory)3 SourceFolder (com.intellij.openapi.roots.SourceFolder)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 File (java.io.File)3 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)2 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)2 ContentEntry (com.intellij.openapi.roots.ContentEntry)2 BlazeLibrary (com.google.idea.blaze.base.model.BlazeLibrary)1 LibraryKey (com.google.idea.blaze.base.model.LibraryKey)1 Glob (com.google.idea.blaze.base.projectview.section.Glob)1