code: public String enclosingTypeOrPackage() {
      int dot = string.lastIndexOf('.');
      return dot == -1 ? null : string.substring(0, dot);
    }
docs: Returns the enclosing type, or null if this type is not nested in another type.