Search in sources :

Example 21 with WorkspacePath

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

the class ImportRootsTest method testContainsWorkspacePath_differentRoot.

@Test
public void testContainsWorkspacePath_differentRoot() throws Exception {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(DirectoryEntry.include(new WorkspacePath("root"))).build();
    assertThat(importRoots.containsWorkspacePath(new WorkspacePath("otherroot"))).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) Test(org.junit.Test)

Example 22 with WorkspacePath

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

the class ImportRootsTest method testContainsWorkspacePath_similarRoot.

@Test
public void testContainsWorkspacePath_similarRoot() throws Exception {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(DirectoryEntry.include(new WorkspacePath("root"))).build();
    assertThat(importRoots.containsWorkspacePath(new WorkspacePath("root2/subdir"))).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) Test(org.junit.Test)

Example 23 with WorkspacePath

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

the class ImportRootsTest method testNoAddedExclusionsForBlaze.

@Test
public void testNoAddedExclusionsForBlaze() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(new DirectoryEntry(new WorkspacePath(""), true)).build();
    assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath(""));
    assertThat(importRoots.excludeDirectories()).isEmpty();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) Test(org.junit.Test)

Example 24 with WorkspacePath

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

the class LoadedSkylarkExtensionTest method testOverridenBuiltInSymbolReference.

@Test
public void testOverridenBuiltInSymbolReference() {
    setBuiltInRuleNames("java_library");
    BuildFile extFile = createBuildFile(new WorkspacePath("java/com/google/tools/build_defs.bzl"), "java_library = rule()");
    BuildFile buildFile = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "load(", "\"//java/com/google/tools:build_defs.bzl\",", "\"java_library\"", ")", "java_library(name = 'name')");
    TargetExpression target = PsiUtils.findFirstChildOfClassRecursive(extFile, TargetExpression.class);
    FuncallExpression funcall = buildFile.firstChildOfClass(FuncallExpression.class);
    LoadedSymbol loadElement = PsiUtils.findFirstChildOfClassRecursive(buildFile, LoadedSymbol.class);
    assertThat(target).isNotNull();
    assertThat(funcall.getReferencedElement()).isEqualTo(target);
    assertThat(loadElement.getImport().getReferencedElement()).isEqualTo(target);
    assertThat(Arrays.stream(FindUsages.findAllReferences(target)).map(PsiReference::getElement).collect(Collectors.toList())).containsExactly(funcall, loadElement.getImport());
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) LoadedSymbol(com.google.idea.blaze.base.lang.buildfile.psi.LoadedSymbol) TargetExpression(com.google.idea.blaze.base.lang.buildfile.psi.TargetExpression) FuncallExpression(com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression) Test(org.junit.Test)

Example 25 with WorkspacePath

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

the class LoadedSkylarkExtensionTest method testAliasedFuncallReference.

@Test
public void testAliasedFuncallReference() {
    createBuildFile(new WorkspacePath("java/com/google/tools/build_defs.bzl"), "def function(name, deps)");
    BuildFile buildFile = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "load('//java/com/google/tools:build_defs.bzl', newName = 'function'),", "newName(name = \"name\", deps = []");
    LoadedSymbol loadedSymbol = PsiUtils.findFirstChildOfClassRecursive(buildFile, LoadedSymbol.class);
    FuncallExpression funcall = buildFile.firstChildOfClass(FuncallExpression.class);
    assertThat(funcall.getReferencedElement()).isEqualTo(loadedSymbol.getVisibleElement());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) LoadedSymbol(com.google.idea.blaze.base.lang.buildfile.psi.LoadedSymbol) FuncallExpression(com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression) 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