Search in sources :

Example 31 with WorkspacePath

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

the class BlazePackageTest method testScopeIncludesSubdirectoriesWhichAreNotBlazePackages.

@Test
public void testScopeIncludesSubdirectoriesWhichAreNotBlazePackages() {
    BuildFile pkg = createBuildFile(new WorkspacePath("java/com/google/BUILD"));
    createBuildFile(new WorkspacePath("java/com/google/foo/bar/BUILD"));
    PsiFile subDirFile = workspace.createPsiFile(new WorkspacePath("java/com/google/foo/test.txt"));
    BlazePackage blazePackage = BlazePackage.getContainingPackage(subDirFile);
    assertThat(blazePackage.buildFile).isEqualTo(pkg);
    assertThat(blazePackage.getSearchScope(false).contains(subDirFile.getVirtualFile())).isTrue();
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) PsiFile(com.intellij.psi.PsiFile) Test(org.junit.Test)

Example 32 with WorkspacePath

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

the class BlazePackageTest method testScopeDoesntCrossPackageBoundary.

@Test
public void testScopeDoesntCrossPackageBoundary() {
    BuildFile pkg = createBuildFile(new WorkspacePath("java/com/google/BUILD"));
    BuildFile subpkg = createBuildFile(new WorkspacePath("java/com/google/other/BUILD"));
    BlazePackage blazePackage = BlazePackage.getContainingPackage(pkg);
    assertThat(blazePackage.buildFile).isEqualTo(pkg);
    assertThat(blazePackage.getSearchScope(false).contains(subpkg.getVirtualFile())).isFalse();
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Test(org.junit.Test)

Example 33 with WorkspacePath

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

the class BlazePackageTest method testScopeLimitedToBlazeFiles.

@Test
public void testScopeLimitedToBlazeFiles() {
    BuildFile pkg = createBuildFile(new WorkspacePath("java/com/google/BUILD"));
    createBuildFile(new WorkspacePath("java/com/google/foo/bar/BUILD"));
    PsiFile subDirFile = workspace.createPsiFile(new WorkspacePath("java/com/google/foo/test.txt"));
    BlazePackage blazePackage = BlazePackage.getContainingPackage(subDirFile);
    assertThat(blazePackage.buildFile).isEqualTo(pkg);
    assertThat(blazePackage.getSearchScope(true).contains(subDirFile.getVirtualFile())).isFalse();
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) PsiFile(com.intellij.psi.PsiFile) Test(org.junit.Test)

Example 34 with WorkspacePath

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

the class GlobalWordIndexTest method testWordsInCode.

@Test
public void testWordsInCode() {
    VirtualFile file = workspace.createFile(new WorkspacePath("java/com/google/BUILD"), "java_library(", "name = \"long name with spaces\",", "src = [\"name_without_spaces\"]", ")");
    assertContainsWords(file, UsageSearchContext.IN_CODE, "java_library", "name", "src");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Test(org.junit.Test)

Example 35 with WorkspacePath

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

the class BuiltInRuleAnnotatorTest method testInvalidValueInsideParenthesizedExpression.

@Test
public void testInvalidValueInsideParenthesizedExpression() {
    specProvider.setRules(ImmutableMap.of(JAVA_TEST.name, JAVA_TEST));
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "java_test(", "    name = (1),", ")");
    assertHasError(file, String.format("Invalid value for attribute 'name'. Expected a value of type '%s'", Discriminator.STRING));
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) 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