Search in sources :

Example 61 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class ProjectViewVerifierTest method testExcludingExactRootResultsInIssue.

@Test
public void testExcludingExactRootResultsInIssue() {
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/com/google/android/apps/example"))).add(DirectoryEntry.exclude(new WorkspacePath("java/com/google/android/apps/example")))).build()).build();
    fileOperationProvider.addProjectView(projectViewSet);
    ProjectViewVerifier.verifyProjectView(project, context, workspacePathResolver, projectViewSet, workspaceLanguageSettings);
    errorCollector.assertIssues("java/com/google/android/apps/example is included, " + "but that contradicts java/com/google/android/apps/example which was excluded");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Test(org.junit.Test)

Example 62 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class ProjectViewParserTest method testDirectoriesAndTargets.

@Test
public void testDirectoriesAndTargets() throws Exception {
    projectViewStorageManager.add(".blazeproject", "directories:", "  java/com/google", "  java/com/google/android", "  -java/com/google/android/notme", "", "targets:", "  //java/com/google:all", "  //java/com/google/...:all", "  -//java/com/google:thistarget");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
    assertThat(projectViewFile).isNotNull();
    assertThat(projectViewFile.projectViewFile).isEqualTo(new File(".blazeproject"));
    assertThat(projectViewSet.getProjectViewFiles()).containsExactly(projectViewFile);
    ProjectView projectView = projectViewFile.projectView;
    assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android/notme"), false));
    assertThat(projectView.getSectionsOfType(TargetSection.KEY).get(0).items()).containsExactly(TargetExpression.fromStringSafe("//java/com/google:all"), TargetExpression.fromStringSafe("//java/com/google/...:all"), TargetExpression.fromStringSafe("-//java/com/google:thistarget"));
}
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) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 63 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class ProjectViewParserTest method testPrint.

@Test
public void testPrint() {
    ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/com/google/one"))).add(DirectoryEntry.exclude(new WorkspacePath("java/com/google/two")))).add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//java/com/google:one")).add(TargetExpression.fromStringSafe("//java/com/google:two"))).add(ScalarSection.builder(ImportSection.KEY).set(new WorkspacePath("some/file.blazeproject"))).build();
    String text = ProjectViewParser.projectViewToString(projectView);
    assertThat(text).isEqualTo(Joiner.on('\n').join("directories:", "  java/com/google/one", "  -java/com/google/two", "targets:", "  //java/com/google:one", "  //java/com/google:two", "import some/file.blazeproject"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Example 64 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class ProjectViewParserTest method testCanParseWithMissingCarriageReturnAtEndOfSection.

@Test
public void testCanParseWithMissingCarriageReturnAtEndOfSection() {
    projectViewStorageManager.add(".blazeproject", "directories:", "  java/com/google");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    ProjectView projectView = projectViewParser.getResult().getTopLevelProjectViewFile().projectView;
    assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 65 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath in project intellij by bazelbuild.

the class ProjectViewParserTest method testCommentsAreParsed.

@Test
public void testCommentsAreParsed() throws Exception {
    projectViewStorageManager.add(".blazeproject", "# comment", "directories:", "  # another comment", "  java/com/google", "  # comment", "  java/com/google/android", "");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
    ProjectView projectView = projectViewFile.projectView;
    assertThat(projectView.getSectionsOfType(TextBlockSection.KEY).get(0).getTextBlock()).isEqualTo(new TextBlock(ImmutableList.of("# comment")));
    assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android"), true));
}
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) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) TextBlock(com.google.idea.blaze.base.projectview.section.sections.TextBlock) Test(org.junit.Test)

Aggregations

WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)509 Test (org.junit.Test)454 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)197 PsiFile (com.intellij.psi.PsiFile)84 File (java.io.File)75 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)53 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)48 Editor (com.intellij.openapi.editor.Editor)46 VirtualFile (com.intellij.openapi.vfs.VirtualFile)41 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)40 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)37 PsiReference (com.intellij.psi.PsiReference)37 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)34 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)34 BlazeContentEntry (com.google.idea.blaze.java.sync.model.BlazeContentEntry)33 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)29 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)26 ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)26 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)25 PsiElement (com.intellij.psi.PsiElement)25