use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.
the class LanguageSupportTest method testFailWithUnsupportedWorkspaceType.
@Test
public void testFailWithUnsupportedWorkspaceType() {
syncPlugins.registerExtension(new BlazeSyncPlugin() {
@Override
public WorkspaceType getDefaultWorkspaceType() {
return WorkspaceType.JAVA;
}
});
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.C)).build()).build();
WorkspaceLanguageSettings settings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
LanguageSupport.validateLanguageSettings(context, settings);
errorCollector.assertIssues("Workspace type 'c' is not supported by this plugin");
}
use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.
the class LanguageSupportTest method testWorkspaceTypeImpliesLanguages.
/**
* Tests that we ask for java and android when the workspace type is android.
*/
@Test
public void testWorkspaceTypeImpliesLanguages() {
syncPlugins.registerExtension(new BlazeSyncPlugin() {
@Override
public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
return ImmutableSet.of(LanguageClass.ANDROID, LanguageClass.JAVA, LanguageClass.C);
}
@Override
public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
return ImmutableList.of(WorkspaceType.ANDROID);
}
@Override
public WorkspaceType getDefaultWorkspaceType() {
return WorkspaceType.ANDROID;
}
});
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.ANDROID)).build()).build();
WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
assertThat(workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.ANDROID, ImmutableSet.of(LanguageClass.JAVA, LanguageClass.ANDROID, LanguageClass.GENERIC)));
}
use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.
the class ScalaSyncTest method testSimpleSync.
@Test
public void testSimpleSync() 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/Source.scala"), "package com.google;", "public class Source {}");
workspace.createFile(new WorkspacePath("src/main/scala/com/google/Other.scala"), "package com.google;", "public class Other {}");
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/Source.scala")).addSource(sourceRoot("src/main/scala/com/google/Other.scala"))).build();
setTargetMap(targetMap);
runBlazeSync(new BlazeSyncParams.Builder("Sync", SyncMode.INCREMENTAL).addProjectViewTargets(true).build());
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.SCALA, LanguageClass.JAVA)));
}
use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings 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());
}
use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.
the class BlazeScalaSyncPluginTest method testScalaValidAdditionalLanguage.
@Test
public void testScalaValidAdditionalLanguage() {
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.SCALA)).build()).build();
WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
LanguageSupport.validateLanguageSettings(context, workspaceLanguageSettings);
errorCollector.assertNoIssues();
assertThat(workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.JAVA, LanguageClass.SCALA)));
}
Aggregations