use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class ProjectViewParserTest method testMultipleSections.
@Test
public void testMultipleSections() throws Exception {
projectViewStorageManager.add(".blazeproject", "directories:", " java/com/google", "directories:", " java/com/google2", "", "workspace_type: java", "workspace_type: android");
projectViewParser.parseProjectView(new File(".blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
assertThat(projectViewSet.listItems(DirectorySection.KEY)).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true), new DirectoryEntry(new WorkspacePath("java/com/google2"), true));
assertThat(projectViewSet.listScalarItems(WorkspaceTypeSection.KEY)).containsExactly(WorkspaceType.JAVA, WorkspaceType.ANDROID);
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class ProjectViewParserTest method testListParserAcceptsWhitespace.
@Test
public void testListParserAcceptsWhitespace() throws Exception {
String text = Joiner.on('\n').join("directories:", " dir0", " ", "", " dir1", " ", " ", "# comment", " dir2", "", " # commented out dir", " ", "# comment", "# comment");
projectViewStorageManager.add(".blazeproject", text);
projectViewParser.parseProjectView(new File(".blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
assert projectViewFile != null;
ProjectView projectView = projectViewFile.projectView;
assertThat(projectView).isEqualTo(ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("dir0"))).add(TextBlock.of(" ")).add(TextBlock.of("")).add(DirectoryEntry.include(new WorkspacePath("dir1"))).add(TextBlock.of(" ", " ")).add(TextBlock.of("# comment")).add(DirectoryEntry.include(new WorkspacePath("dir2"))).add(TextBlock.of("")).add(TextBlock.of(" # commented out dir")).add(TextBlock.of(" "))).add(TextBlockSection.of(TextBlock.of("# comment", "# comment"))).build());
String outputString = ProjectViewParser.projectViewToString(projectView);
assertThat(outputString).isEqualTo(text);
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class ProjectViewParserTest method testCommentsAndWhitespacePreserved.
@Test
public void testCommentsAndWhitespacePreserved() throws Exception {
String text = Joiner.on('\n').join("", "# comment", " ", " ", "directories:", " # another comment", " java/com/google", " # comment", "#unindented comment", " java/com/google/android", "", " # needlessly indented comment", "", "directories:", " java/com/google", " # trailing comment", "directories:", " java/com/google");
projectViewStorageManager.add(".blazeproject", text);
projectViewParser.parseProjectView(new File(".blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
ProjectView projectView = projectViewFile.projectView;
String outputString = ProjectViewParser.projectViewToString(projectView);
assertThat(outputString).isEqualTo(text);
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class LanguageSupportTest method testFailWithUnsupportedLanguageType.
@Test
public void testFailWithUnsupportedLanguageType() {
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)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.PYTHON)).build()).build();
WorkspaceLanguageSettings settings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
LanguageSupport.validateLanguageSettings(context, settings);
errorCollector.assertIssues("Language 'python' is not supported by this plugin");
}
use of com.google.idea.blaze.base.projectview.ProjectViewSet in project intellij by bazelbuild.
the class BlazeKotlinSyncPluginTest method testKotlinValidAdditionalLanguage.
@Test
public void testKotlinValidAdditionalLanguage() {
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.KOTLIN)).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.KOTLIN)));
}
Aggregations