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


Java SourceWriter.beginJavaDocComment方法代码示例

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


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

示例1: outputInterfaceField

import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
/**
 * Writes code to store and retrieve the current injector interface, if one is
 * bound.
 */
private void outputInterfaceField(GinjectorBindings bindings, SourceWriteUtil sourceWriteUtil,
    SourceWriter writer) {

  // Only the root injector has an interface binding.
  if (bindings.getParent() != null) {
    return;
  }

  Class<?> boundGinjectorInterface = getBoundGinjector(bindings);

  if (boundGinjectorInterface == null) {
    // Sanity-check: if this fails, then we somehow didn't bind the injector
    // interface in the root module (the root module should always generate a
    // binding for the injector).
    errorManager.logError("Injector interface not bound in the root module.");
    return;
  }

  NameGenerator nameGenerator = bindings.getNameGenerator();
  String fieldName = nameGenerator.getGinjectorInterfaceFieldName();
  String getterName = nameGenerator.getGinjectorInterfaceGetterMethodName();

  writer.beginJavaDocComment();
  writer.print("The implementation of " + boundGinjectorInterface);
  writer.endJavaDocComment();
  writer.println("private final %s %s;", boundGinjectorInterface.getCanonicalName(), fieldName);

  sourceWriteUtil.writeMethod(writer,
      String.format("public %s %s()", boundGinjectorInterface.getCanonicalName(), getterName),
      String.format("return %s;", fieldName));
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:36,代码来源:GinjectorBindingsOutputter.java

示例2: outputFragments

import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
/**
 * For each fragment in the given {@link FragmentMap}, writes the field that
 * stores it and a getter for that field, and adds code to invoke the
 * fragment's initializers.
 */
private void outputFragments(GinjectorBindings bindings,
    FragmentMap fragments, StringBuilder initializeEagerSingletonsBody,
    StringBuilder initializeStaticInjectionsBody, SourceWriteUtil sourceWriteUtil,
    SourceWriter writer) {
  String implClassName = ginjectorNameGenerator.getClassName(bindings);
  NameGenerator nameGenerator = bindings.getNameGenerator();

  for (FragmentPackageName fragmentPackageName : fragments.getFragmentPackages()) {
    String fragmentCanonicalClassName =
        nameGenerator.getFragmentCanonicalClassName(implClassName,
            fragmentPackageName);
    String fieldName = nameGenerator.getFragmentFieldName(fragmentPackageName);
    String getterName = nameGenerator.getFragmentGetterMethodName(fragmentPackageName);

    // Create the field.
    writer.beginJavaDocComment();
    writer.print("Injector fragment for %s", fragmentPackageName);
    writer.endJavaDocComment();
    writer.print("private %s %s = null;", fragmentCanonicalClassName, fieldName);

    // Write the getter.
    writer.beginJavaDocComment();
    writer.print("Getter for injector fragment for %s", fragmentPackageName);
    writer.endJavaDocComment();
    sourceWriteUtil.writeMethod(writer,
        "public " + fragmentCanonicalClassName + " " + getterName + "()", String.format(
        "if (%2$s == null) {\n"
      + "    %2$s = new %1$s(this);\n"
      + "}\n\n"
      + "return %2$s;", fragmentCanonicalClassName, fieldName));

    if (fragments.get(fragmentPackageName).hasEagerSingletonInitialization()) {
      initializeEagerSingletonsBody.append(getterName + "().initializeEagerSingletons();\n");
    }

    if (fragments.get(fragmentPackageName).hasStaticInjectionInitialization()) {
      initializeStaticInjectionsBody.append(getterName + "().initializeStaticInjections();\n");
    }
  }
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:46,代码来源:GinjectorBindingsOutputter.java

示例3: writeInterface

import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
private void writeInterface(TypeLiteral<?> ginjectorInterface, String packageName,
    String implClassName, PrintWriter printWriter, GinjectorBindings rootBindings)
    throws UnableToCompleteException {
  ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
      implClassName);

  SourceWriter writer = null;

  try {
    composerFactory.addImplementedInterface(ReflectUtil.getSourceName(ginjectorInterface));

    writer = composerFactory.createSourceWriter(ctx, printWriter);

    String rootInjectorClass = ginjectorNameGenerator.getClassName(rootBindings);
    String rootFieldName = ginjectorNameGenerator.getFieldName(rootBindings);
    writer.beginJavaDocComment();
    writer.print("Top-level injector instance for injector " + rootBindings.getModule() + ".");
    writer.endJavaDocComment();
    writer.println("private final %1$s %2$s = new %1$s(this);", rootInjectorClass, rootFieldName);

    SourceWriteUtil sourceWriteUtil = sourceWriteUtilFactory.create(rootBindings);

    String staticInjectionInitialization = rootBindings.hasStaticInjectionRequestInSubtree()
        ? String.format("%s.initializeStaticInjections();\n", rootFieldName)
        : "";

    String eagerSingletonsInitialization = rootBindings.hasEagerSingletonBindingInSubtree()
        ? String.format("%s.initializeEagerSingletons();\n", rootFieldName)
        : "";

    sourceWriteUtil.writeMethod(writer, "public " + implClassName + "()", String.format(
        // To imitate the behavior of Guice and provide more predictable
        // bootstrap ordering, we initialize the injectors in two phases:
        // static injections first, followed by eager singletons.  Each of
        // these method calls performs all necessary initialization of the
        // given type in all fragments, ensuring that the initializers run in
        // the proper order.
        //
        // See http://code.google.com/p/google-guice/wiki/Bootstrap
        "%s%s", staticInjectionInitialization, eagerSingletonsInitialization));

    outputInterfaceMethods(rootBindings, ginjectorInterface, sourceWriteUtil, writer);
  } catch (NoSourceNameException e) {
    // TODO(schmitt): Collect errors and log list of them.
    logger.log(TreeLogger.Type.ERROR, e.getMessage(), e);
  }

  if (writer != null) {
    writer.commit(logger);
  }
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:52,代码来源:GinjectorImplOutputter.java

示例4: writeBindingContextJavadoc

import com.google.gwt.user.rebind.SourceWriter; //导入方法依赖的package包/类
/**
 * Write a Javadoc comment for a binding, including its context.
 *
 * @param description The description of the binding printed before its
 *     location, such as "Foo bound at: "
 * @param writer The writer to use in displaying the context.
 * @param bindingContext The context of the binding.
 */
public void writeBindingContextJavadoc(SourceWriter writer, Context bindingContext,
    String description) {
  writer.beginJavaDocComment();
  writer.println(description);
  writeBindingContext(writer, bindingContext);
  writer.endJavaDocComment();
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:16,代码来源:SourceWriteUtil.java


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