当前位置: 首页>>代码示例>>Java>>正文


Java ClassSourceFileComposerFactory.createSourceWriter方法代码示例

本文整理汇总了Java中com.google.gwt.user.rebind.ClassSourceFileComposerFactory.createSourceWriter方法的典型用法代码示例。如果您正苦于以下问题:Java ClassSourceFileComposerFactory.createSourceWriter方法的具体用法?Java ClassSourceFileComposerFactory.createSourceWriter怎么用?Java ClassSourceFileComposerFactory.createSourceWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.user.rebind.ClassSourceFileComposerFactory的用法示例。


在下文中一共展示了ClassSourceFileComposerFactory.createSourceWriter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGetSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
@Override
protected SourceWriter doGetSourceWriter(JClassType classType) {
	String packageName = classType.getPackage().getName();
	String simpleName = getSimpleUnitName(classType);
	ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
			packageName, simpleName);
	composer.setSuperclass(TypeOracleImpl.class.getCanonicalName());
	composer.addImport("org.lirazs.gbackbone.reflection.client.*");
	composer.addImport("java.util.*");
	composer.addImport(classType.getPackage().getName() + ".*");

	PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
	if (printWriter == null) {
		return null;
	} else {
		SourceWriter sw = composer.createSourceWriter(context, printWriter);
		return sw;
	}
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:20,代码来源:SourceVisitor.java

示例2: createModule

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private String createModule(TreeLogger logger, GeneratorContext context, JClassType requestedType,
    String packageName, String requestedName) {
  String moduleName = requestedName + "Module";
  ClassSourceFileComposerFactory moduleFactory =
      new ClassSourceFileComposerFactory(packageName, moduleName);
  moduleFactory.setSuperclass(AbstractGinModule.class.getCanonicalName());
  moduleFactory.addImport(Names.class.getCanonicalName());
  SourceWriter moduleWriter = moduleFactory.createSourceWriter(context,
      context.tryCreate(logger, packageName, moduleName));

  moduleWriter.println("public void configure() {");
  moduleWriter.indent();
  for (JMethod method : requestedType.getMethods()) {
    if (method.getName().startsWith("set")) {
      String name = method.getParameters()[0].getAnnotation(Named.class).value();
      moduleWriter.println("bindConstant().annotatedWith(Names.named(\"" + name + "\")).to(\""
          + Math.pow(Integer.parseInt(name), 2) + "\");");
    }
  }
  moduleWriter.outdent();
  moduleWriter.println("}");
  moduleWriter.commit(logger);
  return moduleName;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:25,代码来源:FrameworkGenerator.java

示例3: getSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
/**
 * get source writer for the generator.
 *
 * @param pclassType class type
 * @param pcontext generator context
 * @param plogger tree logger
 * @return SourceWriter to write the generated sources to
 */
private SourceWriter getSourceWriter(final JClassType pclassType, final GeneratorContext pcontext,
    final TreeLogger plogger) {
  final String packageName = this.getClassPackage(pclassType);
  final String simpleName = this.getClassName(pclassType);
  final ClassSourceFileComposerFactory composer =
      new ClassSourceFileComposerFactory(packageName, simpleName);
  composer
      .addImplementedInterface("de.knightsoftnet.validators.client.GwtReflectGetterInterface");

  final PrintWriter printWriter = pcontext.tryCreate(plogger, packageName, simpleName);
  if (printWriter == null) {
    return null;
  }
  return composer.createSourceWriter(pcontext, printWriter);
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:24,代码来源:GwtReflectGetterGenerator.java

示例4: getSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger,
                                     GeneratorContext context,
                                     JClassType originalType,
                                     String packageName,
                                     String simpleSourceName)
    throws UnableToCompleteException {

  logger.log(TreeLogger.INFO,
             "Generating writer for " + packageName + "." + simpleSourceName,
             null);

  PrintWriter printWriter = context.tryCreate(logger,
                                              packageName,
                                              simpleSourceName);
  if (printWriter == null) {
    return null;
  }

  ClassSourceFileComposerFactory classFactory = new ClassSourceFileComposerFactory(packageName,
                                                                                   simpleSourceName);
  classFactory.addImplementedInterface(originalType.getName());

  return classFactory.createSourceWriter(context,
                                         printWriter);
}
 
开发者ID:gwt4e,项目名称:gwt4e,代码行数:26,代码来源:BindingPropertyGenerator.java

示例5: generateDataProxyFastJSOClasses

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
void generateDataProxyFastJSOClasses()
{
	for( JType type : dataProxyFastFactories )
	{
		String jsoPackage = getDataProxyFastImplPackageName( type );
		String jsoSimpleClassName = getDataProxyFastImplSimpleName( type );

		PrintWriter pw2 = context.tryCreate( logger, jsoPackage, jsoSimpleClassName );
		if( pw2 == null )
			continue;

		ClassSourceFileComposerFactory cf2 = new ClassSourceFileComposerFactory( jsoPackage, jsoSimpleClassName );
		cf2.addImport( "fr.lteconsulting.hexa.client.comm.GenericJSO" );
		cf2.addImport( "com.google.gwt.core.client.JavaScriptObject" );
		cf2.addImport( "com.google.gwt.core.client.GWT" );
		cf2.addImport( "fr.lteconsulting.hexa.client.tools.HexaTools" );
		cf2.addImplementedInterface( type.getParameterizedQualifiedSourceName() );
		cf2.setSuperclass( "GenericJSO" );
		SourceWriter sw2 = cf2.createSourceWriter( context, pw2 );
		generateDataProxyFastJSOImpl( jsoSimpleClassName, type, sw2, logger );
		sw2.commit( logger );
	}
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:24,代码来源:ServiceGenerator.java

示例6: getSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) {

		String packageName = this.binderType.getPackage().getName();
		String className = this.binderProxySimpleName;

		ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);

		composerFactory.addImport(GWT.class.getName());
		composerFactory.addImport(UiBinder.class.getName());
		composerFactory.addImport(UiBinderLocalized.class.getName());
		composerFactory.addImport(UiTemplate.class.getName());

		composerFactory.addImport(this.binderType.getQualifiedSourceName());
		composerFactory.addImport(this.widgetType.getQualifiedSourceName());
		composerFactory.addImport(this.targetType.getQualifiedSourceName());

		composerFactory.addImplementedInterface(UiBinderLocalized.class.getSimpleName() + "<"
			+ this.widgetType.getSimpleSourceName() + "," + this.targetType.getSimpleSourceName() + ">");
		composerFactory.addImplementedInterface(UiBinder.class.getSimpleName() + "<"
			+ this.widgetType.getSimpleSourceName() + "," + this.targetType.getSimpleSourceName() + ">");
		composerFactory.addImplementedInterface(this.binderType.getSimpleSourceName());

		return composerFactory.createSourceWriter(ctx, printWriter);
	}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:25,代码来源:UiBinderLocalizedCreator.java

示例7: createSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter createSourceWriter(
    TreeLogger logger,
    GeneratorContext context,
    JClassType eventBinderType,
    JClassType targetType) {
  String simpleName = getSimpleGeneratedClassName(eventBinderType);
  String packageName = eventBinderType.getPackage().getName();
  ClassSourceFileComposerFactory composer =
      new ClassSourceFileComposerFactory(packageName, simpleName);

  composer.setSuperclass(AbstractEventBinder.class.getCanonicalName()
      + "<" + targetType.getQualifiedSourceName() + ">");
  composer.addImplementedInterface(eventBinderType.getName());

  composer.addImport(EventBinder.class.getCanonicalName());
  composer.addImport(EventBus.class.getCanonicalName());
  composer.addImport(GenericEvent.class.getCanonicalName());
  composer.addImport(GenericEventHandler.class.getCanonicalName());
  composer.addImport(HandlerRegistration.class.getCanonicalName());
  composer.addImport(LinkedList.class.getCanonicalName());
  composer.addImport(List.class.getCanonicalName());

  PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
  return (printWriter != null) ? composer.createSourceWriter(context, printWriter) : null;
}
 
开发者ID:google,项目名称:gwteventbinder,代码行数:26,代码来源:EventBinderGenerator.java

示例8: createSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter createSourceWriter(TreeLogger logger, GeneratorContext context,
    JClassType eventBinderType, JClassType targetType) {
  String simpleName = getSimpleGeneratedClassName(eventBinderType);
  String packageName = eventBinderType.getPackage().getName();
  ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
      packageName, simpleName);

  composer.addImplementedInterface(eventBinderType.getName());
  composer.addImport(EventHandlerMethod.class.getCanonicalName());
  composer.addImport(LinkedList.class.getCanonicalName());
  composer.addImport(List.class.getCanonicalName());
  composer.addImport(MultiEvent.class.getCanonicalName());

  PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
  return printWriter != null ? composer.createSourceWriter(context, printWriter) : null;
}
 
开发者ID:ekuefler,项目名称:gwt-supereventbus,代码行数:17,代码来源:EventRegistrationGenerator.java

示例9: writeTopSerializer

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private void writeTopSerializer(TreeLogger logger,
    GeneratorContext context, JClassType typeFor, JClassType subType) {
    ClassSourceFileComposerFactory mcf = new ClassSourceFileComposerFactory(typeFor.getPackage()
                                                                                   .getName(),
            typeFor.getSimpleSourceName() + "_Impl");
    mcf.addImplementedInterface(typeFor.getParameterizedQualifiedSourceName());
    mcf.setSuperclass(subType.getParameterizedQualifiedSourceName() +
        "_JSONCodec");

    PrintWriter printWriter = context.tryCreate(logger,
            typeFor.getPackage().getName(),
            typeFor.getSimpleSourceName() + "_Impl");

    if (printWriter == null) {
        logger.log(Type.INFO,
            "Already genned " + typeFor.getSimpleSourceName() + "_Impl");

        return;
    }

    SourceWriter writer = mcf.createSourceWriter(context, printWriter);
    writer.println(" public String getMimeType() { return MIME_TYPE; }");
    writer.println("}");
    context.commit(logger, printWriter);
}
 
开发者ID:kebernet,项目名称:gwittir,代码行数:26,代码来源:JSONCodecGenerator.java

示例10: createSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter createSourceWriter(TreeLogger logger, GeneratorContext context, JClassType eventBinderType, JClassType targetType) {
    String simpleName = getSimpleGeneratedClassName(eventBinderType);
    String packageName = eventBinderType.getPackage().getName();
    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, simpleName);

    composer.setSuperclass(AbstractDomEventBinder.class.getCanonicalName() + "<" + targetType.getName() + ">");
    composer.addImplementedInterface(eventBinderType.getName());

    composer.addImport(LinkedList.class.getCanonicalName());
    composer.addImport(List.class.getCanonicalName());
    composer.addImport(Element.class.getCanonicalName());
    composer.addImport(HandlerRegistration.class.getCanonicalName());
    composer.addImport(IsWidget.class.getCanonicalName());

    PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
    return (printWriter != null) ? composer.createSourceWriter(context, printWriter) : null;
}
 
开发者ID:rfilippone,项目名称:gwt-dom-event-binder,代码行数:18,代码来源:DomEventBinderGenerator.java

示例11: GinjectorFragmentOutputter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
@Inject
GinjectorFragmentOutputter(GeneratorContext ctx, GinjectorFragmentContext.Factory ginjectorFragmentContextFactory, ErrorManager errorManager,
                           TreeLogger logger, SourceWriteUtil.Factory sourceWriteUtilFactory, @Assisted GinjectorBindings bindings,
                           @Assisted FragmentPackageName fragmentPackageName, @Assisted("ginjectorPackageName") String ginjectorPackageName,
                           @Assisted("ginjectorClassName") String ginjectorClassName) {

    this.ctx = ctx;
    this.errorManager = errorManager;
    this.logger = logger;
    this.sourceWriteUtil = sourceWriteUtilFactory.create(bindings);

    this.fragmentPackageName = fragmentPackageName;
    this.ginjectorClassName = ginjectorClassName;
    this.nameGenerator = bindings.getNameGenerator();

    fragmentClassName = nameGenerator.getFragmentClassName(ginjectorClassName, fragmentPackageName);
    if (fragmentClassName.contains(".")) {
        errorManager.logError("Internal error: the fragment class name \"%s\" contains a full stop.", fragmentClassName);
    }

    PrintWriter printWriter = ctx.tryCreate(logger, fragmentPackageName.toString(), fragmentClassName);
    if (printWriter == null) {
        // Something is very wrong! We already created this fragment, but the
        // GinjectorBindingsOutputter should only create each fragment once.
        // Something bad will probably happen later on if we continue, so just
        // abort.
        logger.log(TreeLogger.Type.ERROR, "The fragment " + fragmentPackageName + "." + fragmentClassName + " already exists.");
        throw new IllegalStateException("The fragment " + fragmentClassName + " already exists.");
    }

    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(fragmentPackageName.toString(), fragmentClassName);

    composerFactory.addImport(GWT.class.getCanonicalName());
    composerFactory.addImport(ginjectorPackageName + "." + ginjectorClassName);
    writer = composerFactory.createSourceWriter(ctx, printWriter);

    injectorWriteContext = ginjectorFragmentContextFactory.create(bindings, fragmentPackageName, writer);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:39,代码来源:GinjectorFragmentOutputter.java

示例12: getSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext context, JClassType classType) {
	String packageName = packageNameFrom(classType);
	String simpleName = simpleNameFrom(classType);
	ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, simpleName);
	composer.addImplementedInterface(classType.getName());
	composer.addImport(classType.getQualifiedSourceName());
	PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
	if (printWriter == null) {
		return null; 
	} else {
		return composer.createSourceWriter(context, printWriter);
	} 
}
 
开发者ID:TOMOTON,项目名称:gwt-dagger2,代码行数:14,代码来源:VersionGenerator.java

示例13: generateClass

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
/**
 * Generate the content of the class
 *
 * @param logger
 * @param context
 * @param packageName
 * @param className
 * @param extensions
 * @throws UnableToCompleteException
 */
private void generateClass(
    TreeLogger logger,
    GeneratorContext context,
    String packageName,
    String className,
    List<JClassType> extensions)
    throws UnableToCompleteException {
  PrintWriter pw = context.tryCreate(logger, packageName, className);
  if (pw == null) {
    return;
  }

  ClassSourceFileComposerFactory composerFactory =
      new ClassSourceFileComposerFactory(packageName, className);
  // generate imports
  generateImports(extensions, composerFactory);

  // interface
  composerFactory.addImplementedInterface(ExtensionRegistry.class.getCanonicalName());

  // get source writer
  SourceWriter sw = composerFactory.createSourceWriter(context, pw);
  // begin class definition
  // fields
  sw.println("private final Map<String, ExtensionDescription> extensions = new HashMap<>();");

  generateConstructor(className, extensions, sw);

  // methods
  generateGetExtensionsMethod(sw);
  // close it out
  sw.outdent();
  sw.println("}");

  context.commit(logger, pw);
}
 
开发者ID:eclipse,项目名称:che,代码行数:47,代码来源:ExtensionRegistryGenerator.java

示例14: write

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
/**
 * Writes the Ginjector class for the given bindings object, and all its
 * package-specific fragments.
 */
void write(GinjectorBindings bindings) throws UnableToCompleteException {

  TypeLiteral<?> ginjectorInterface = bindings.getGinjectorInterface();
  String implClassName = ginjectorNameGenerator.getClassName(bindings);
  if (implClassName.contains(".")) {
    errorManager.logError("Internal error: the injector class name \"%s\" contains a full stop.",
        implClassName);
  }
  String packageName = ReflectUtil.getUserPackageName(TypeLiteral.get(bindings.getModule()));

  PrintWriter printWriter = ctx.tryCreate(logger, packageName, implClassName);
  if (printWriter == null) {
    // We already created this Ginjector.
    return;
  }

  ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
      implClassName);
  SourceWriter writer = composerFactory.createSourceWriter(ctx, printWriter);

  FragmentMap fragments = new FragmentMap(bindings, packageName, implClassName,
      fragmentOutputterFactory);

  outputBindings(bindings, fragments, writer);
  errorManager.checkForError();

  fragments.commitAll();
  writer.commit(logger);
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:34,代码来源:GinjectorBindingsOutputter.java

示例15: generate

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
    throws UnableToCompleteException {
  JClassType requestedType = context.getTypeOracle().findType(typeName);
  String packageName = requestedType.getPackage().getName();
  String requestedName = requestedType.getSimpleSourceName();
  String newClassName = requestedName + "Impl";

  String moduleName = createModule(logger, context, requestedType, packageName, requestedName);

  String ginjectorName =
      createGinjector(logger, context, packageName, requestedName, newClassName, moduleName);

  ClassSourceFileComposerFactory composerFactory =
      new ClassSourceFileComposerFactory(packageName, newClassName);
  composerFactory.setSuperclass(requestedType.getQualifiedSourceName());
  composerFactory.addImport(GWT.class.getCanonicalName());
  SourceWriter writer = composerFactory
      .createSourceWriter(context, context.tryCreate(logger, packageName, newClassName));
  writer.println("public void initialize() {");
  writer.indent();
  writer.println(
      "((" +  ginjectorName + ") GWT.create(" + ginjectorName + ".class)).injectMembers(this);");
  writer.outdent();
  writer.println("}");
  writer.commit(logger);

  return packageName + "." + newClassName;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:30,代码来源:FrameworkGenerator.java


注:本文中的com.google.gwt.user.rebind.ClassSourceFileComposerFactory.createSourceWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。