Search in sources :

Example 11 with BuildFile

use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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 12 with BuildFile

use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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 13 with BuildFile

use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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 14 with BuildFile

use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile 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)

Example 15 with BuildFile

use of com.google.idea.blaze.base.lang.buildfile.psi.BuildFile in project intellij by bazelbuild.

the class BuiltInRuleAnnotatorTest method testMissingMandatoryAttributeError.

@Test
public void testMissingMandatoryAttributeError() {
    specProvider.setRules(ImmutableMap.of(JAVA_TEST.name, JAVA_TEST));
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "java_test(", "    srcs = ['src'],", "    neverlink = 0,", ")");
    assertHasError(file, "Target missing required attribute(s): name");
}
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

BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)216 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)197 Test (org.junit.Test)196 Editor (com.intellij.openapi.editor.Editor)46 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)37 PsiReference (com.intellij.psi.PsiReference)32 PsiElement (com.intellij.psi.PsiElement)27 PsiFile (com.intellij.psi.PsiFile)27 StringLiteral (com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral)18 FunctionStatement (com.google.idea.blaze.base.lang.buildfile.psi.FunctionStatement)17 GlobExpression (com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression)16 LookupElement (com.intellij.codeInsight.lookup.LookupElement)13 Argument (com.google.idea.blaze.base.lang.buildfile.psi.Argument)10 TargetExpression (com.google.idea.blaze.base.lang.buildfile.psi.TargetExpression)8 Nullable (javax.annotation.Nullable)8 ReferenceExpression (com.google.idea.blaze.base.lang.buildfile.psi.ReferenceExpression)7 AssignmentStatement (com.google.idea.blaze.base.lang.buildfile.psi.AssignmentStatement)6 LoadStatement (com.google.idea.blaze.base.lang.buildfile.psi.LoadStatement)6 PsiDirectory (com.intellij.psi.PsiDirectory)6 Label (com.google.idea.blaze.base.model.primitives.Label)5