Example #1
0
  private SourceWriter getSourceWriter(
      TreeLogger logger, GeneratorContextExt ctx, JClassType serviceAsync) {
    JPackage serviceIntfPkg = serviceAsync.getPackage();
    String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
    PrintWriter printWriter = ctx.tryCreate(logger, packageName, getProxySimpleName());
    if (printWriter == null) {
      return null;
    }

    ClassSourceFileComposerFactory composerFactory =
        new ClassSourceFileComposerFactory(packageName, getProxySimpleName());

    String[] imports =
        new String[] {
          getProxySupertype().getCanonicalName(),
          getStreamWriterClass().getCanonicalName(),
          SerializationStreamWriter.class.getCanonicalName(),
          GWT.class.getCanonicalName(),
          ResponseReader.class.getCanonicalName(),
          SerializationException.class.getCanonicalName(),
          RpcToken.class.getCanonicalName(),
          RpcTokenException.class.getCanonicalName(),
          Impl.class.getCanonicalName(),
          RpcStatsContext.class.getCanonicalName()
        };
    for (String imp : imports) {
      composerFactory.addImport(imp);
    }

    composerFactory.setSuperclass(getProxySupertype().getSimpleName());
    composerFactory.addImplementedInterface(serviceAsync.getErasedType().getQualifiedSourceName());

    return composerFactory.createSourceWriter(ctx, printWriter);
  }
 private JClassType eraseType(JClassType classType) {
   return classType == null ? null : classType.getErasedType();
 }