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

Add getOutermostTypeElement to javax.lang.model utility class

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 18
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b11
    • CPU:
      generic
    • OS:
      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

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

                Dates

                Created:
                Updated:
                Resolved: