use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class ProjectViewParserTest method testMultipleImports.
@Test
public void testMultipleImports() {
projectViewStorageManager.add("/grandparent.blazeproject", "directories:", " grandparent");
projectViewStorageManager.add("/mother.blazeproject", "import grandparent.blazeproject", "directories:", " mother");
projectViewStorageManager.add("/father.blazeproject", "import grandparent.blazeproject", "directories:", " father");
projectViewStorageManager.add("/child.blazeproject", "import mother.blazeproject", "directories:", " child1", "import father.blazeproject", "directories:", " child2");
projectViewParser.parseProjectView(new File("/child.blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
// Ensures we don't parse grandfather twice
assertThat(projectViewSet.getProjectViewFiles()).hasSize(4);
Collection<DirectoryEntry> entries = projectViewSet.listItems(DirectorySection.KEY);
// All imports' contributions appear before the children, no matter where they appear
assertThat(entries).containsExactly(new DirectoryEntry(new WorkspacePath("grandparent"), true), new DirectoryEntry(new WorkspacePath("mother"), true), new DirectoryEntry(new WorkspacePath("father"), true), new DirectoryEntry(new WorkspacePath("child1"), true), new DirectoryEntry(new WorkspacePath("child2"), true)).inOrder();
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class LanguageSupportTest method testSimpleCase.
@Test
public void testSimpleCase() {
syncPlugins.registerExtension(new BlazeSyncPlugin() {
@Override
public Set<LanguageClass> getSupportedLanguagesInWorkspace(WorkspaceType workspaceType) {
return ImmutableSet.of(LanguageClass.C);
}
@Override
public ImmutableList<WorkspaceType> getSupportedWorkspaceTypes() {
return ImmutableList.of(WorkspaceType.C);
}
@Override
public WorkspaceType getDefaultWorkspaceType() {
return WorkspaceType.C;
}
});
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.C)).build()).build();
WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
errorCollector.assertNoIssues();
assertThat(workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.C, ImmutableSet.of(LanguageClass.C, LanguageClass.GENERIC)));
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet 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.projectview.ProjectViewSet 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.projectview.ProjectViewSet 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