0

A want to get class's all methods, including it's extends class's methods.

for example:

interface A{
  void a();
}

interface B extends A {
  void B();
}

i want to get method a() and b() by Element.

Rohan Kumar
  • 5,427
  • 8
  • 25
  • 40
JingYeoh
  • 151
  • 1
  • 6

1 Answers1

2
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);
    }
}
JingYeoh
  • 151
  • 1
  • 6