Search in sources :

Example 1 with ProjectViewPsiSectionItem

use of com.google.idea.blaze.base.lang.projectview.psi.ProjectViewPsiSectionItem in project intellij by bazelbuild.

the class ProjectViewLabelReferenceTest method testDirectoryReference.

@Test
public void testDirectoryReference() {
    PsiDirectory directory = workspace.createPsiDirectory(new WorkspacePath("foo/bar"));
    PsiFile projectView = workspace.createPsiFile(new WorkspacePath(".bazelproject"), "directories:", "  foo/bar");
    ProjectViewPsiSectionItem importItem = PsiUtils.findFirstChildOfClassRecursive(projectView, ProjectViewPsiSectionItem.class);
    assertThat(importItem).isNotNull();
    assertThat(importItem.getReference().resolve()).isEqualTo(directory);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) PsiDirectory(com.intellij.psi.PsiDirectory) ProjectViewPsiSectionItem(com.google.idea.blaze.base.lang.projectview.psi.ProjectViewPsiSectionItem) PsiFile(com.intellij.psi.PsiFile) Test(org.junit.Test)

Example 2 with ProjectViewPsiSectionItem

use of com.google.idea.blaze.base.lang.projectview.psi.ProjectViewPsiSectionItem in project intellij by bazelbuild.

the class ProjectViewLabelReferenceTest method testFileReference.

@Test
public void testFileReference() {
    PsiFile referencedFile = workspace.createPsiFile(new WorkspacePath("ijwb.bazelproject"), "directories:", "  java/com/google/foo", "targets:", "  //java/com/google/foo/...");
    PsiFile file = workspace.createPsiFile(new WorkspacePath(".bazelproject"), "import ijwb.bazelproject");
    ProjectViewPsiSectionItem importItem = PsiUtils.findFirstChildOfClassRecursive(file, ProjectViewPsiSectionItem.class);
    assertThat(importItem).isNotNull();
    assertThat(importItem.getReference().resolve()).isEqualTo(referencedFile);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectViewPsiSectionItem(com.google.idea.blaze.base.lang.projectview.psi.ProjectViewPsiSectionItem) PsiFile(com.intellij.psi.PsiFile) Test(org.junit.Test)

Example 3 with ProjectViewPsiSectionItem

use of com.google.idea.blaze.base.lang.projectview.psi.ProjectViewPsiSectionItem in project intellij by bazelbuild.

the class ProjectViewLabelReferenceTest method testTargetReference.

@Test
public void testTargetReference() {
    PsiFile buildFile = workspace.createPsiFile(new WorkspacePath("foo/bar/BUILD"), "java_library(", "    name = 'lib',", ")");
    PsiFile projectView = workspace.createPsiFile(new WorkspacePath(".bazelproject"), "targets:", "  //foo/bar:lib");
    FuncallExpression target = ((BuildFile) buildFile).findRule("lib");
    ProjectViewPsiSectionItem importItem = PsiUtils.findFirstChildOfClassRecursive(projectView, ProjectViewPsiSectionItem.class);
    assertThat(importItem).isNotNull();
    assertThat(importItem.getReference().resolve()).isEqualTo(target);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) ProjectViewPsiSectionItem(com.google.idea.blaze.base.lang.projectview.psi.ProjectViewPsiSectionItem) PsiFile(com.intellij.psi.PsiFile) FuncallExpression(com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression) Test(org.junit.Test)

Aggregations

ProjectViewPsiSectionItem (com.google.idea.blaze.base.lang.projectview.psi.ProjectViewPsiSectionItem)3 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)3 PsiFile (com.intellij.psi.PsiFile)3 Test (org.junit.Test)3 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)1 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)1 PsiDirectory (com.intellij.psi.PsiDirectory)1