Search in sources :

Example 6 with ProjectViewSet

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);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 7 with ProjectViewSet

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);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) File(java.io.File) Test(org.junit.Test)

Example 8 with ProjectViewSet

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);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) File(java.io.File) Test(org.junit.Test)

Example 9 with ProjectViewSet

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");
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ImmutableList(com.google.common.collect.ImmutableList) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Example 10 with ProjectViewSet

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)));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Aggregations

ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)74 File (java.io.File)30 Test (org.junit.Test)29 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)21 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)17 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)17 ImmutableList (com.google.common.collect.ImmutableList)16 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)16 Project (com.intellij.openapi.project.Project)16 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)15 Nullable (javax.annotation.Nullable)15 List (java.util.List)14 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)12 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)11 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)11 Kind (com.google.idea.blaze.base.model.primitives.Kind)11 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)11 Set (java.util.Set)11 Lists (com.google.common.collect.Lists)10 Collectors (java.util.stream.Collectors)10