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();
}
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();
}
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();
}
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());
}
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());
}
Aggregations