Add getOutermostTypeElement to javax.lang.model utility class

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 18
    • Affects Version/s: 9
    • Component/s: core-libs
    • b11
    • generic
    • generic

      This is a useful utility used in the doclet's new api and would be beneficial to other users of javax.lang.model.

      Suggested code:
          public TypeElement getOuterMostTypeElement(Element e) {
              if (e.getKind() == ElementKind.PACKAGE)
                  return null;
              Element encl = e.getEnclosingElement();
              ElementKind kind = encl.getKind();
              if (kind == ElementKind.PACKAGE)
                  return null;
              while (!(kind.isClass() || kind.isInterface())) {
                  encl = encl.getEnclosingElement();
              }
              return (TypeElement)encl;
          }

            Assignee:
            Joe Darcy
            Reporter:
            Kumar Srinivasan
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: