Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8140442

Add getOutermostTypeElement to javax.lang.model utility class

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 18
    • 9
    • core-libs
    • b11
    • generic
    • generic

    Description

      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;
          }

      Attachments

        Issue Links

          Activity

            People

              darcy Joe Darcy
              ksrini Kumar Srinivasan
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: