code: public TypeSpec generateType(Type type) {
      AdapterConstant adapterConstant = profile.getAdapter(type.type());
      if (adapterConstant != null) {
        return generateAdapterForCustomType(type);
      }
      if (type instanceof MessageType) {
        //noinspection deprecation: Only deprecated as a public API.
        return generateMessage((MessageType) type);
      }
      if (type instanceof EnumType) {
        //noinspection deprecation: Only deprecated as a public API.
        return generateEnum((EnumType) type);
      }
      if (type instanceof EnclosingType) {
        return generateEnclosingType((EnclosingType) type);
      }
      throw new IllegalStateException("Unknown type: " + type);
    }
docs: Returns the generated code for {@code type}, which may be a top-level or a nested type.