Search in sources :

Example 66 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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 67 with WorkspacePath

use of com.google.idea.blaze.base.model.primitives.WorkspacePath 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 68 with WorkspacePath

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

the class TestTargetSourcesHeuristicTest method testFilterNoMatchesFallBackToFirstRule.

@Test
public void testFilterNoMatchesFallBackToFirstRule() throws Exception {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    ImmutableList<TargetInfo> rules = ImmutableList.of(TargetIdeInfo.builder().setLabel("//foo:test1").setKind("java_test").addSource(sourceRoot("java/com/bar/OtherTest.java")).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:test2").setKind("java_test").build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(project, null, source, rules, null);
    assertThat(match.label).isEqualTo(Label.create("//foo:test1"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Example 69 with WorkspacePath

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

the class TestTargetSourcesHeuristicTest method testPredicateNoMatchingSource.

@Test
public void testPredicateNoMatchingSource() {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    TargetInfo target = TargetIdeInfo.builder().setLabel("//foo:test").setKind("java_test").addSource(sourceRoot("java/com/bar/OtherTest.java")).build().toTargetInfo();
    assertThat(new TestTargetSourcesHeuristic().matchesSource(project, target, null, source, null)).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) Test(org.junit.Test)

Example 70 with WorkspacePath

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

the class TestTargetSourcesHeuristicTest method testFilterOneMatch.

@Test
public void testFilterOneMatch() throws Exception {
    File source = workspaceRoot.fileForPath(new WorkspacePath("java/com/foo/FooTest.java"));
    ImmutableList<TargetInfo> rules = ImmutableList.of(TargetIdeInfo.builder().setLabel("//foo:test1").setKind("java_test").addSource(sourceRoot("java/com/bar/OtherTest.java")).build().toTargetInfo(), TargetIdeInfo.builder().setLabel("//foo:test2").setKind("java_test").addSource(sourceRoot("java/com/foo/FooTest.java")).build().toTargetInfo());
    TargetInfo match = TestTargetHeuristic.chooseTestTargetForSourceFile(project, null, source, rules, null);
    assertThat(match.label).isEqualTo(Label.create("//foo:test2"));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) File(java.io.File) 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