Search in sources :

Example 26 with SkylarkCallable

use of com.google.devtools.build.lib.skylarkinterface.SkylarkCallable in project bazel by bazelbuild.

the class SkylarkInterfaceUtilsTest method testGetSkylarkCallableTwoargForm.

@Test
public void testGetSkylarkCallableTwoargForm() throws Exception {
    // Ensure that when passing superclass in directly, we bypass subclass's annotation.
    Method method = MockClassC.class.getMethod("foo");
    SkylarkCallable ann = SkylarkInterfaceUtils.getSkylarkCallable(MockClassA.class, method);
    assertThat(ann).isNotNull();
    assertThat(ann.doc()).isEqualTo("MockClassA#foo");
}
Also used : SkylarkCallable(com.google.devtools.build.lib.skylarkinterface.SkylarkCallable) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 27 with SkylarkCallable

use of com.google.devtools.build.lib.skylarkinterface.SkylarkCallable in project bazel by bazelbuild.

the class SkylarkInterfaceUtilsTest method testGetSkylarkCallableInterface.

@Test
public void testGetSkylarkCallableInterface() throws Exception {
    // Search through parent interfaces. First interface takes priority.
    Method method = MockClassC.class.getMethod("baz");
    SkylarkCallable ann = SkylarkInterfaceUtils.getSkylarkCallable(method);
    assertThat(ann).isNotNull();
    assertThat(ann.doc()).isEqualTo("MockInterfaceB1#baz");
    // Make sure both are still traversed.
    method = MockClassC.class.getMethod("qux");
    ann = SkylarkInterfaceUtils.getSkylarkCallable(method);
    assertThat(ann).isNotNull();
    assertThat(ann.doc()).isEqualTo("MockInterfaceB2#qux");
}
Also used : SkylarkCallable(com.google.devtools.build.lib.skylarkinterface.SkylarkCallable) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

SkylarkCallable (com.google.devtools.build.lib.skylarkinterface.SkylarkCallable)27 Method (java.lang.reflect.Method)8 Test (org.junit.Test)7 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)6 ImmutableList (com.google.common.collect.ImmutableList)5 RepositoryFunctionException (com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException)5 IOException (java.io.IOException)5 ImmutableMap (com.google.common.collect.ImmutableMap)2 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)2 Param (com.google.devtools.build.lib.skylarkinterface.Param)2 OutputStream (java.io.OutputStream)2 URL (java.net.URL)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 SkylarkJavaMethodDoc (com.google.devtools.build.docgen.skylark.SkylarkJavaMethodDoc)1 SkylarkModuleDoc (com.google.devtools.build.docgen.skylark.SkylarkModuleDoc)1 Artifact (com.google.devtools.build.lib.actions.Artifact)1 Root (com.google.devtools.build.lib.actions.Root)1 MiddlemanProvider (com.google.devtools.build.lib.analysis.MiddlemanProvider)1