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


Java JavaWriter.emitSingleLineComment方法代码示例

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


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

示例1: generateTo

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
final void generateTo(final Writer out) throws IOException {
  JavaWriter w = new JavaWriter(out);

  w.emitSingleLineComment("Code generated by Enroscar. Do not edit. %s",
      new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()));
  w.emitPackage(packageName);

  w.emitImports(imports);
  w.emitEmptyLine();

  classJavaDoc(w);
  w.beginType(className, "class", modifiers(operationsClass), extendsClass);
  w.emitEmptyLine();

  writeClassBody(w);

  w.endType();
}
 
开发者ID:stanfy,项目名称:enroscar-async,代码行数:19,代码来源:BaseGenerator.java

示例2: generate

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
/**
 * Generates the BuildConfig class.
 */
public void generate() throws IOException {
    File pkgFolder = getFolderPath();
    if (!pkgFolder.isDirectory()) {
        if (!pkgFolder.mkdirs()) {
            throw new RuntimeException("Failed to create " + pkgFolder.getAbsolutePath());
        }
    }

    File buildConfigJava = new File(pkgFolder, BUILD_CONFIG_NAME);

    Closer closer = Closer.create();
    try {
        FileOutputStream fos = closer.register(new FileOutputStream(buildConfigJava));
        OutputStreamWriter out = closer.register(new OutputStreamWriter(fos, Charsets.UTF_8));
        JavaWriter writer = closer.register(new JavaWriter(out));

        writer.emitJavadoc("Automatically generated file. DO NOT MODIFY")
                .emitPackage(mBuildConfigPackageName)
                .beginType("BuildConfig", "class", PUBLIC_FINAL);

        for (ClassField field : mFields) {
            emitClassField(writer, field);
        }

        for (Object item : mItems) {
            if (item instanceof ClassField) {
                emitClassField(writer, (ClassField) item);
            } else if (item instanceof String) {
                writer.emitSingleLineComment((String) item);
            }
        }

        writer.endType();
    } catch (Throwable e) {
        throw closer.rethrow(e);
    } finally {
        closer.close();
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:BuildConfigGenerator.java

示例3: writeParseChildrenMethod

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void writeParseChildrenMethod(TypeElement classElement, JavaWriter writer)
        throws IOException {

    List<String> parameters = new ArrayList<String>(4);
    parameters.add(classElement.getSimpleName().toString());
    parameters.add("object");
    parameters.add(XmlStreamReader.class.getSimpleName());
    parameters.add("reader");

    List<String> throwsTypes = CollectionUtils.newArrayList(
            ParseException.class.getSimpleName(),
            UnknownElementException.class.getSimpleName(),
            UnexpectedChildException.class.getSimpleName());

    writer.beginMethod("void",
                       "parseChildren",
                       EnumSet.of(Modifier.PRIVATE),
                       parameters,
                       throwsTypes);

    initializeSetters(writer);

    writer.beginControlFlow("while (!reader.isEndElement())");
    writer.emitStatement(
            "Preconditions.checkState(reader.isStartElement(), \"Expected to be at a start "
                    + "element\")");
    writer.emitStatement("String name = reader.getName()");
    writer.emitStatement("Object child = ParserUtils.parseCurrentElement(reader)");

    boolean first = true;
    first = writeChildIfStatements(writer, first);

    String unexpectedChildStatement =
            String.format("%s.handleUnexpectedChild(object, child, name)",
                          UnexpectedElementHandler.class.getSimpleName());
    if (first) {
        writer.emitStatement(unexpectedChildStatement);
    } else {
        writer.nextControlFlow("else if (child == null)");
        writer.emitSingleLineComment("do nothing");
        writer.nextControlFlow("else");
        writer.emitStatement(unexpectedChildStatement);
        writer.endControlFlow();
    }

    writer.endControlFlow();

    writeSetterAssignments(writer);
    writer.endMethod();
}
 
开发者ID:Workday,项目名称:autoparse-xml,代码行数:51,代码来源:ParseChildrenMethodWriter.java

示例4: writeClassBody

import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
@Override
protected void writeClassBody(JavaWriter w) throws IOException {
  w.emitSingleLineComment("construction");

  w.beginConstructor(EnumSet.of(PRIVATE), "final " + operatorContext(operationsClass), "context");
  w.emitStatement("super(new %s(context), context)", loaderDescription(packageName, operationsClass));
  w.endConstructor();

  String buildClass = OPERATOR_BUILDER_CLASS
      + "<" + getFqcn() + ", " + operationsClass.getQualifiedName() + ">";
  w.beginMethod(buildClass, "build", EnumSet.of(PUBLIC, STATIC));
  w.emitStatement(
      "return new " + simpleName(OPERATOR_BUILDER_BASE_CLASS)
      + "<" + getFqcn() + ", " + operationsClass.getQualifiedName() + ">() {\n"
      + "  @Override\n"
      + "  protected " + getFqcn() + " create(final " + operatorContext(operationsClass) + " context) {\n"
      + "    return new " + getFqcn() + "(context);\n"
      + "  }\n"
      + "}"
  );
  w.endMethod();

  w.emitEmptyLine();
  w.emitSingleLineComment("invocation");

  for (MethodData data : methods) {
    ExecutableElement m = data.method;

    boolean load = isLoadMethod(m);
    int loaderId = getLoaderId(m);

    w.beginMethod("void", m.getSimpleName().toString(), EnumSet.of(PUBLIC), parameters(w, m), null);
    w.emitStatement(data.operatorTypeSupport.asyncProvider(w, m));
    w.emitStatement("%sLoader(%d, provider, %b)", load ? "init" : "restart", loaderId, !load);
    w.endMethod();
    w.emitEmptyLine();

    if (load) {
      // force method
      w.beginMethod("void", "force" + capitalize(m.getSimpleName().toString()),
          EnumSet.of(PUBLIC), parameters(w, m), null);
      w.emitStatement(data.operatorTypeSupport.asyncProvider(w, m));
      w.emitStatement("restartLoader(%d, provider, false)", loaderId);
      w.endMethod();
      w.emitEmptyLine();
    }

    w.beginMethod("void", "cancel" + capitalize(m.getSimpleName().toString()),
        EnumSet.of(PUBLIC));
    w.emitStatement("destroyLoader(%d)", loaderId);
    w.endMethod();
    w.emitEmptyLine();

  }

}
 
开发者ID:stanfy,项目名称:enroscar-async,代码行数:57,代码来源:OperatorGenerator.java


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