javax.lang.model.element.ExecutableElement#getReceiverType ( )源码实例Demo

下面列出了javax.lang.model.element.ExecutableElement#getReceiverType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: buck   文件: TreeBackedExecutableElementTest.java
/** The docs claim this should be a NoType of TypeKind.NONE. The docs lie. */
@Test
public void testGetReceiverTypeOfStaticIsNull() throws IOException {
  compile(Joiner.on('\n').join("class Foo {", "  static void foo() { }", "}"));

  ExecutableElement element = findMethod("foo", elements.getTypeElement("Foo"));
  TypeMirror receiverType = element.getReceiverType();

  assertNull(receiverType);
}
 
源代码2 项目: buck   文件: TreeBackedExecutableElementTest.java
/** The docs claim this should be a NoType of TypeKind.NONE. The docs lie. */
@Test
public void testGetReceiverTypeOfTopLevelConstructorIsNull() throws IOException {
  compile(Joiner.on('\n').join("class Foo {", "  Foo () { }", "}"));

  ExecutableElement element = findDefaultConstructor(elements.getTypeElement("Foo"));
  TypeMirror receiverType = element.getReceiverType();

  assertNull(receiverType);
}
 
源代码3 项目: buck   文件: TreeBackedExecutableElementTest.java
@Test
public void testGetReceiverTypeOfInnerConstructorIsEnclosingType() throws IOException {
  compile(
      Joiner.on('\n')
          .join("class Foo {", "  class Bar {", "  Bar (Foo Foo.this) { }", "  }", "}"));

  ExecutableElement element = findDefaultConstructor(elements.getTypeElement("Foo.Bar"));
  TypeMirror receiverType = element.getReceiverType();

  assertSameType(elements.getTypeElement("Foo").asType(), receiverType);
}
 
源代码4 项目: buck   文件: TreeBackedExecutableElementTest.java
@Test
public void testGetReceiverTypeOfInnerConstructorIsEnclosingTypeGeneric() throws IOException {
  compile(
      Joiner.on('\n')
          .join("class Foo<T> {", "  class Bar {", "  Bar (Foo<T> Foo.this) { }", "  }", "}"));

  ExecutableElement element = findDefaultConstructor(elements.getTypeElement("Foo.Bar"));
  TypeMirror receiverType = element.getReceiverType();

  assertSameType(elements.getTypeElement("Foo").asType(), receiverType);
}
 
源代码5 项目: buck   文件: TreeBackedExecutableElementTest.java
@Test
public void testGetReceiverTypeOfInstanceMethodIsEnclosingType() throws IOException {
  compile(Joiner.on('\n').join("class Foo {", "  void foo(Foo this) { }", "}"));

  TypeElement fooClass = elements.getTypeElement("Foo");
  ExecutableElement fooMethod = findMethod("foo", fooClass);
  TypeMirror receiverType = fooMethod.getReceiverType();

  assertSameType(fooClass.asType(), receiverType);
}
 
源代码6 项目: buck   文件: TreeBackedExecutableElementTest.java
@Test
public void testGetReceiverTypeOfInstanceMethodIsEnclosingTypeGeneric() throws IOException {
  compile(Joiner.on('\n').join("class Foo<T> {", "  void foo(Foo<T> this) { }", "}"));

  TypeElement fooClass = elements.getTypeElement("Foo");
  ExecutableElement fooMethod = findMethod("foo", fooClass);
  TypeMirror receiverType = fooMethod.getReceiverType();

  assertSameType(fooClass.asType(), receiverType);
}
 
源代码7 项目: openjdk-jdk9   文件: HtmlDocletWriter.java
public void addReceiverAnnotationInfo(ExecutableElement method, TypeMirror rcvrTypeMirror,
        List<? extends AnnotationMirror> annotationMirrors, Content htmltree) {
    TypeMirror rcvrType = method.getReceiverType();
    List<? extends AnnotationMirror> annotationMirrors1 = rcvrType.getAnnotationMirrors();
    addAnnotationInfo(0, method, annotationMirrors1, false, htmltree);
}