如何通过注解处理工具获取extends接口?

how to get extends interface by annotation process tools?

想获取 class 的所有方法,包括它扩展 class 的方法。

例如:

interface A{
  void a();
}

interface B extends A {
  void B();
}

我想通过 Element 获取方法 a() 和 b()。

TypeElement element;
getSuperElement(element.asType());

private void getSuperElement(TypeMirror mirror) {
    if (mirror == null ) return;
    List<? extends TypeMirror> mirrors = mTypeUtils.directSupertypes(mirror);
    if (mirrors == null || mirrors.isEmpty()) return;
    for (TypeMirror it : mirrors) {
        if (it.getKind() == TypeKind.DECLARED) {
            // this element is super class's element, you can do anything in here
            Element element = ((DeclaredType) it).asElement();
        }
        getSuperElement(methodBuilder, componentName, it);
    }
}