use of com.google.idea.blaze.base.lang.buildfile.psi.LoadStatement in project intellij by bazelbuild.
the class LoadedSkylarkExtensionTest method testMultipleImportedFunctions.
@Test
public void testMultipleImportedFunctions() {
BuildFile extFile = createBuildFile(new WorkspacePath("java/com/google/build_defs.bzl"), "def fn1(name, deps)", "def fn2(name, deps)");
BuildFile buildFile = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "load(", "\"//java/com/google:build_defs.bzl\",", "\"fn1\"", "\"fn2\"", ")");
LoadStatement load = buildFile.firstChildOfClass(LoadStatement.class);
assertThat(load.getImportPsiElement().getReferencedElement()).isEqualTo(extFile);
FunctionStatement[] functions = extFile.childrenOfClass(FunctionStatement.class);
assertThat(functions).hasLength(2);
assertThat(load.getImportedFunctionReferences()).isEqualTo(functions);
}
use of com.google.idea.blaze.base.lang.buildfile.psi.LoadStatement in project intellij by bazelbuild.
the class LoadedSkylarkExtensionTest method testStandardLoadReference.
@Test
public void testStandardLoadReference() {
BuildFile extFile = createBuildFile(new WorkspacePath("java/com/google/build_defs.bzl"), "def function(name, deps)");
BuildFile buildFile = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "load(", "\"//java/com/google:build_defs.bzl\",", "\"function\"", ")");
LoadStatement load = buildFile.firstChildOfClass(LoadStatement.class);
assertThat(load.getImportPsiElement().getReferencedElement()).isEqualTo(extFile);
FunctionStatement function = extFile.firstChildOfClass(FunctionStatement.class);
assertThat(function).isNotNull();
assertThat(load.getImportedSymbolElements()).hasLength(1);
assertThat(load.getImportedSymbolElements()[0].getLoadedElement()).isEqualTo(function);
}
Aggregations