io.vertx.codegen.doc.Doc Java Examples

The following examples show how to use io.vertx.codegen.doc.Doc. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyModel.java    From vertx-service-proxy with Apache License 2.0 6 votes vote down vote up
@Override
protected MethodInfo createMethodInfo(Set<ClassTypeInfo> ownerTypes, String methodName, String comment, Doc doc, TypeInfo returnType, Text returnDescription, boolean isFluent, boolean isCacheReturn, List<ParamInfo> mParams, ExecutableElement methodElt, boolean isStatic, boolean isDefault, ArrayList<TypeParamInfo.Method> typeParams, TypeElement declaringElt, boolean methodDeprecated, Text methodDeprecatedDesc) {
  AnnotationMirror proxyIgnoreAnnotation = Helper.resolveMethodAnnotation(ProxyIgnore.class, elementUtils, typeUtils, declaringElt, methodElt);
  boolean isProxyIgnore = proxyIgnoreAnnotation != null;
  AnnotationMirror proxyCloseAnnotation = Helper.resolveMethodAnnotation(ProxyClose.class, elementUtils, typeUtils, declaringElt, methodElt);
  boolean isProxyClose = proxyCloseAnnotation != null;
  ProxyMethodInfo proxyMeth = new ProxyMethodInfo(ownerTypes, methodName, returnType, returnDescription,
    isFluent, isCacheReturn, mParams, comment, doc, isStatic, isDefault, typeParams, isProxyIgnore,
    isProxyClose, methodDeprecated, methodDeprecatedDesc);
  if (isProxyClose && mParams.size() > 0) {
    if (mParams.size() > 1) {
      throw new GenException(this.modelElt, "@ProxyClose methods can't have more than one parameter");
    }
    if (proxyMeth.getKind() != MethodKind.FUTURE) {
      throw new GenException(this.modelElt, "@ProxyClose parameter must be Handler<AsyncResult<Void>>");
    }
    TypeInfo type = mParams.get(0).getType();
    TypeInfo arg = ((ParameterizedTypeInfo) ((ParameterizedTypeInfo) type).getArgs().get(0)).getArgs().get(0);
    if (arg.getKind() != ClassKind.VOID) {
      throw new GenException(this.modelElt, "@ProxyClose parameter must be " +
          "Handler<AsyncResult<Void>> instead of " + type);
    }
  }
  return proxyMeth;
}
 
Example #2
Source File: MethodInfo.java    From vertx-codegen with Apache License 2.0 6 votes vote down vote up
public MethodInfo(Set<ClassTypeInfo> ownerTypes, String name,
                  TypeInfo returnType, Text returnDescription, boolean fluent,  boolean cacheReturn,
                  List<ParamInfo> params, String comment, Doc doc, boolean staticMethod, boolean defaultMethod,
                  List<TypeParamInfo.Method> typeParams, boolean deprecated, Text deprecatedDesc) {


  this.comment = comment;
  this.name = name;
  this.returnType = returnType;
  this.returnDescription = returnDescription;
  this.fluent = fluent;
  this.cacheReturn = cacheReturn;
  this.doc = doc;
  this.staticMethod = staticMethod;
  this.defaultMethod = defaultMethod;
  this.params = params;
  this.typeParams = typeParams;
  this.ownerTypes = ownerTypes;
  this.deprecated = deprecated;
  this.deprecatedDesc = deprecatedDesc;
}
 
Example #3
Source File: ClassTest.java    From vertx-codegen with Apache License 2.0 6 votes vote down vote up
@Test
public void testMethodComments() throws Exception {
  ClassModel model = new GeneratorHelper().generateClass(InterfaceWithComments.class);
  assertEquals(InterfaceWithComments.class.getName(), model.getIfaceFQCN());
  assertEquals(InterfaceWithComments.class.getSimpleName(), model.getIfaceSimpleName());
  assertTrue(model.getReferencedTypes().isEmpty());
  assertTrue(model.getSuperTypes().isEmpty());
  List<MethodInfo> methods = model.getMethods();
  assertEquals(2, methods.size());
  Doc comment1 = new Doc(" Comment 1 line 1\n Comment 1 line 2", null,
    Arrays.asList(new Tag("param", "str the_string"), new Tag("return", "the_return_value\n")));
  Doc comment2 = new Doc(" Comment 2 line 1\n Comment 2 line 2\n");
  checkMethod(methods.get(0), "foo", 1, String.class, MethodKind.OTHER, comment1);
  assertEquals("str", methods.get(0).getParams().get(0).getName());
  assertEquals("the_string", methods.get(0).getParams().get(0).getDescription().toString());
  checkMethod(methods.get(1), "bar", 1, "void", MethodKind.OTHER, comment2);
}
 
Example #4
Source File: ClassTestBase.java    From vertx-codegen with Apache License 2.0 6 votes vote down vote up
void checkMethod(MethodInfo meth, String name, int numParams, String returnType, MethodKind kind, Doc comment, MethodCheck... checks) {
  EnumSet<MethodCheck> checkSet = EnumSet.noneOf(MethodCheck.class);
  Collections.addAll(checkSet, checks);
  assertEquals(name, meth.getName());
  if (comment != null) {
    assertNotNull(meth.getComment());
    assertEquals(comment.getFirstSentence(), meth.getDoc().getFirstSentence());
    assertEquals(comment.getBody(), meth.getDoc().getBody());
    assertEquals(comment.getBlockTags(), meth.getDoc().getBlockTags());
  } else {
    assertNull(meth.getComment());
  }
  assertEquals(kind, meth.getKind());
  assertEquals(returnType, meth.getReturnType().toString());
  assertEquals(checkSet.contains(MethodCheck.CACHE_RETURN), meth.isCacheReturn());
  assertEquals(checkSet.contains(MethodCheck.FLUENT), meth.isFluent());
  assertEquals(checkSet.contains(MethodCheck.STATIC), meth.isStaticMethod());
  assertEquals(numParams, meth.getParams().size());
}
 
Example #5
Source File: AbstractRxGenerator.java    From vertx-rx with Apache License 2.0 6 votes vote down vote up
private void generateDoc(ClassModel model, PrintWriter writer) {
  ClassTypeInfo type = model.getType();
  Doc doc = model.getDoc();
  if (doc != null) {
    writer.println("/**");
    Token.toHtml(doc.getTokens(), " *", this::renderLinkToHtml, "\n", writer);
    writer.println(" *");
    writer.println(" * <p/>");
    writer.print(" * NOTE: This class has been automatically generated from the {@link ");
    writer.print(type.getName());
    writer.println(" original} non RX-ified interface using Vert.x codegen.");
    writer.println(" */");
  }


}
 
Example #6
Source File: DocTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testLinkLabel() throws Exception {
  ClassModel model = new GeneratorHelper().generateClass(LinkLabel.class);
  MethodInfo method = model.getMethodMap().get("m").get(0);
  Doc doc = method.getDoc();
  List<Token> tokens = doc.getTokens();
  String[] expectedLabels = {"","   "," the label value"};
  assertEquals(expectedLabels.length, tokens.size());
  for (int i = 0;i < tokens.size();i++) {
    Tag.Link link = (Tag.Link) ((Token.InlineTag) tokens.get(i)).getTag();
    assertEquals("" + i,expectedLabels[i], link.getLabel());
  }
}
 
Example #7
Source File: DocTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testLinkToEnum() throws Exception {
  ClassModel model = new GeneratorHelper().generateClass(LinkToEnum.class);
  MethodInfo method = model.getMethodMap().get("m").get(0);
  Doc doc = method.getDoc();
  List<Token> tokens = doc.getTokens();
  assertEquals(2, tokens.size());
  for (Token token : tokens) {
    Tag.Link link = (Tag.Link) ((Token.InlineTag) token).getTag();
    assertEquals(FooEnum.class.getName(), link.getTargetElement().toString());
  }
}
 
Example #8
Source File: DocTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testLinkToSameType() throws Exception {
  ClassModel model = new GeneratorHelper().generateClass(LinkToSameType.class);
  MethodInfo method = model.getMethodMap().get("m").get(0);
  Doc doc = method.getDoc();
  List<Token> tokens = doc.getTokens();
  assertEquals(2, tokens.size());
  for (Token token : tokens) {
    Tag.Link link = (Tag.Link) ((Token.InlineTag) token).getTag();
    assertEquals(LinkToSameType.class.getName(), link.getTargetElement().toString());
  }
}
 
Example #9
Source File: DocTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testLinkToMethodInSameType() throws Exception {
  ClassModel model = new GeneratorHelper().generateClass(LinkToMethodInSameType.class);
  MethodInfo method = model.getMethodMap().get("m").get(0);
  Doc doc = method.getDoc();
  List<Token> tokens = doc.getTokens();
  assertEquals(4, tokens.size());
  for (Token token : tokens) {
    Tag.Link link = (Tag.Link) ((Token.InlineTag) token).getTag();
    assertEquals(ElementKind.METHOD, link.getTargetElement().getKind());
    assertEquals("method(java.lang.String,int)", link.getTargetElement().toString());
  }
}
 
Example #10
Source File: ProxyMethodInfo.java    From vertx-service-proxy with Apache License 2.0 5 votes vote down vote up
public ProxyMethodInfo(Set<ClassTypeInfo> ownerTypes, String name, TypeInfo returnType, Text returnDescription, boolean fluent,
                       boolean cacheReturn, List<ParamInfo> params, String comment, Doc doc, boolean staticMethod, boolean defaultMethod,
                       List<TypeParamInfo.Method> typeParams, boolean proxyIgnore, boolean proxyClose, boolean deprecated, Text deprecatedDesc) {


  super(ownerTypes, name, returnType, returnDescription, fluent, cacheReturn, params, comment, doc, staticMethod, defaultMethod, typeParams, deprecated, deprecatedDesc);
  this.proxyIgnore = proxyIgnore;
  this.proxyClose = proxyClose;
}
 
Example #11
Source File: ClassTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testConstantComments() throws Exception {
  ClassModel model = new GeneratorHelper().generateClass(InterfaceWithComments.class);
  List<ConstantInfo> constants = model.getConstants();
  ConstantInfo constant = constants.get(0);
  assertEquals(1, constants.size());
  Doc comment = new Doc(" Comment 3 line 1\n Comment 3 line 2\n", null, Collections.emptyList());
  assertEquals(comment.getFirstSentence(), constant.getDoc().getFirstSentence());
  assertNull(constant.getDoc().getBody());
  assertEquals(Collections.emptyList(), constant.getDoc().getBlockTags());
}
 
Example #12
Source File: DataObjectTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testCommentedPropertyOverridesUncommentedProperty() throws Exception {
  DataObjectModel model = new GeneratorHelper().generateDataObject(CommentedPropertyOverridesUncommentedProperty.class, AbstractUncommentedProperty.class);
  PropertyInfo propertyInfo = model.getPropertyMap().get("theProperty");
  Doc propertyDoc = propertyInfo.getDoc();
  assertEquals(" The overriden property description.\n", propertyDoc.getFirstSentence().getValue());
}
 
Example #13
Source File: DataObjectTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testCommentedPropertyOverridesCommentedProperty() throws Exception {
  DataObjectModel model = new GeneratorHelper().generateDataObject(CommentedPropertyOverridesCommentedProperty.class, AbstractCommentedProperty.class);
  PropertyInfo propertyInfo = model.getPropertyMap().get("theProperty");
  Doc propertyDoc = propertyInfo.getDoc();
  assertEquals(" The overriden property description.\n", propertyDoc.getFirstSentence().getValue());
}
 
Example #14
Source File: DataObjectTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testUncommentedPropertyOverridesAncestorCommentedProperty() throws Exception {
  DataObjectModel model = new GeneratorHelper().generateDataObject(UncommentedPropertyOverridesAncestorSuperCommentedProperty.class, AbstractCommentedProperty.class);
  PropertyInfo propertyInfo = model.getPropertyMap().get("theProperty");
  Doc propertyDoc = propertyInfo.getDoc();
  assertEquals(" The property description.\n", propertyDoc.getFirstSentence().getValue());
}
 
Example #15
Source File: PropertyInfo.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
public PropertyInfo(boolean declared, String name, Doc doc, TypeInfo type, String setterMethod, String adderMethod, String getterMethod,
                    List<AnnotationValueInfo> annotations, PropertyKind kind, boolean jsonifiable, boolean deprecated, Text deprecatedDesc) {
  this.kind = kind;
  this.declared = declared;
  this.name = name;
  this.doc = doc;
  this.type = type;
  this.annotations = annotations.stream().collect(HashMap::new, (m, a) -> m.put(a.getName(), a), HashMap::putAll);
  this.adderMethod = adderMethod;
  this.setterMethod = setterMethod;
  this.getterMethod = getterMethod;
  this.jsonifiable = jsonifiable;
  this.deprecated = deprecated;
  this.deprecatedDesc = deprecatedDesc;
}
 
Example #16
Source File: DataObjectTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testUncommentedPropertyOverridesCommentedProperty() throws Exception {
  DataObjectModel model = new GeneratorHelper().generateDataObject(UncommentedPropertyOverridesSuperCommentedProperty.class, AbstractCommentedProperty.class);
  PropertyInfo propertyInfo = model.getPropertyMap().get("theProperty");
  Doc propertyDoc = propertyInfo.getDoc();
  assertEquals(" The property description.\n", propertyDoc.getFirstSentence().getValue());
}
 
Example #17
Source File: DataObjectTest.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Test
public void testCommentedPropertyInheritedFromCommentedProperty() throws Exception {
  DataObjectModel model = new GeneratorHelper().generateDataObject(CommentedPropertyInheritedFromCommentedProperty.class, AbstractCommentedProperty.class);
  PropertyInfo propertyInfo = model.getPropertyMap().get("theProperty");
  Doc propertyDoc = propertyInfo.getDoc();
  assertEquals(" The property description.\n", propertyDoc.getFirstSentence().getValue());
}
 
Example #18
Source File: DataObjectCheatsheetGen.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
private void render(DataObjectModel model, PrintWriter html) {
  html.append("[[").append(model.getType().getSimpleName()).append("]]\n");
  html.append("== ").append(model.getType().getSimpleName()).append("\n");
  html.append("\n");
  Doc doc = model.getDoc();
  if (doc != null) {
    html.append("++++\n");
    Token.toHtml(doc.getTokens(), "", Tag::getName, "\n", html);
    html.append("++++\n");
    html.append("'''\n");
  }
  html.append("\n");
  html.append("[cols=\">25%,25%,50%\"]\n");
  html.append("[frame=\"topbot\"]\n");
  html.append("|===\n");
  html.append("^|Name | Type ^| Description\n");
  model.getPropertyMap().values().forEach(property -> {
    String propertytype = getDataType(property.getType());
    if (propertytype != null) {
      String arrayPrefix = (property.isList() || property.isSet()) ? "Array of " : "";
      html.append("|[[").append(property.getName()).append("]]`@").append(property.getName()).append("`");
      html.append("|`").append(arrayPrefix).append(propertytype).append("`");
      html.append("|");
      if (property.getDoc() != null) {
        html.append("+++\n");
        html.append(Token.toHtml(property.getDoc().getTokens(), "", Tag::getName, "\n").trim()).append("\n");
        html.append("+++\n");
      } else {
        html.append("-\n");
      }
    }
  });
  html.append("|===\n");
}
 
Example #19
Source File: EnumCheatsheetGen.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
private void render(EnumModel model, PrintWriter html) {
  html.append("[[").append(model.getType().getSimpleName()).append("]]\n");
  html.append("== ").append(model.getType().getSimpleName()).append("\n");
  html.append("\n");
  Doc doc = model.getDoc();
  if (doc != null) {
    html.append("++++\n");
    Token.toHtml(doc.getTokens(), "", Tag::getName, "\n", html);
    html.append("++++\n");
    html.append("'''\n");
  }
  html.append("\n");
  html.append("[cols=\">25%,75%\"]\n");
  html.append("[frame=\"topbot\"]\n");
  html.append("|===\n");
  html.append("^|Name | Description\n");
  model.getValues().forEach(value -> {
    html.append("|[[").append(value.getIdentifier()).append("]]`").append(value.getIdentifier()).append("`");
    html.append("|");
    if (value.getDoc() != null) {
      html.append("+++\n");
      html.append(Token.toHtml(value.getDoc().getTokens(), "", Tag::getName, "\n").trim()).append("\n");
      html.append("+++\n");
    } else {
      html.append("-\n");
    }
  });
  html.append("|===\n");
}
 
Example #20
Source File: AbstractRxGenerator.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
private void genConstant(ClassModel model, ConstantInfo constant, PrintWriter writer) {
  Doc doc = constant.getDoc();
  if (doc != null) {
    writer.println("  /**");
    Token.toHtml(doc.getTokens(), "   *", this::renderLinkToHtml, "\n", writer);
    writer.println("   */");
  }
  writer.print(model.isConcrete() ? "  public static final" : "");
  writer.format(" %s %s = %s;\n",
    genTranslatedTypeName(constant.getType()),
    constant.getName(),
    genConvReturn(constant.getType(), null, model.getType().getName() + "." + constant.getName()));
}
 
Example #21
Source File: ClassModel.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
private ConstantInfo fieldMethod(VariableElement modelField, boolean allowAnyJavaType) {
  Set<Modifier> mods = modelField.getModifiers();
  if (!mods.contains(Modifier.PUBLIC)) {
    return null;
  }
  TypeInfo type = typeFactory.create(modelField.asType());
  TypeValidator.validateConstantType(modelField, type, modelField.asType(),allowAnyJavaType);
  Doc doc = docFactory.createDoc(modelField);
  return new ConstantInfo(doc, modelField.getSimpleName().toString(), type);
}
 
Example #22
Source File: WebApiProxyModel.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
@Override
protected MethodInfo createMethodInfo(Set<ClassTypeInfo> ownerTypes, String methodName, String comment, Doc doc, TypeInfo returnType, Text returnDescription, boolean isFluent, boolean isCacheReturn, List<ParamInfo> mParams, ExecutableElement methodElt, boolean isStatic, boolean isDefault, ArrayList<TypeParamInfo.Method> typeParams, TypeElement declaringElt, boolean methodDeprecated, Text deprecatedDesc) {
  ProxyMethodInfo baseInfo = (ProxyMethodInfo) super.createMethodInfo(ownerTypes, methodName, comment, doc, returnType, returnDescription, isFluent, isCacheReturn, mParams, methodElt, isStatic, isDefault, typeParams, declaringElt, methodDeprecated, deprecatedDesc);
  if (!isStatic && !baseInfo.isProxyClose()) {
    // Check signature constraints

    TypeInfo ret;
    if (baseInfo.getKind() == MethodKind.FUTURE) {
      ret = ((ParameterizedTypeInfo) ((ParameterizedTypeInfo) mParams.get(mParams.size() - 1).getType()).getArg(0)).getArg(0);
    } else {
      throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
    }
    if (!ServiceResponse.class.getName().equals(ret.getName())) {
      throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
    }

    TypeInfo shouldBeServiceRequest;
    if (baseInfo.getKind() == MethodKind.FUTURE) {
      if (mParams.size() <= 1) {
        throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
      }
      shouldBeServiceRequest = mParams.get(mParams.size() - 2).getType();
    } else {
      if (mParams.size() == 0) {
        throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
      }
      shouldBeServiceRequest = mParams.get(mParams.size() - 1).getType();
    }
    if (!ServiceRequest.class.getName().equals(shouldBeServiceRequest.getName())) {
      throw new GenException(methodElt, SIGNATURE_CONSTRAINT_ERROR);
    }

    return new WebApiProxyMethodInfo(baseInfo);
  } else {
    return baseInfo;
  }
}
 
Example #23
Source File: DataObjectModel.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
public DataObjectModel(ProcessingEnvironment env, TypeMirrorFactory typeFactory, TypeElement modelElt) {
  this.elementUtils = env.getElementUtils();
  this.typeUtils = env.getTypeUtils();
  this.typeFactory = typeFactory;
  this.docFactory = new Doc.Factory(env.getMessager(), elementUtils, typeUtils, typeFactory, modelElt);
  this.modelElt = modelElt;
  this.annotationValueInfoFactory = new AnnotationValueInfoFactory(typeFactory);
  this.deprecated = modelElt.getAnnotation(Deprecated.class) != null;
}
 
Example #24
Source File: EnumModel.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
public EnumModel(ProcessingEnvironment env, TypeElement modelElt) {
  this.typeUtils = env.getTypeUtils();
  this.elementUtils = env.getElementUtils();
  this.typeMirrorFactory = new TypeMirrorFactory(elementUtils, typeUtils);
  this.docFactory = new Doc.Factory(env.getMessager(), elementUtils, typeUtils, typeMirrorFactory, modelElt);
  this.modelElt = modelElt;
  this.annotationValueInfoFactory = new AnnotationValueInfoFactory(typeMirrorFactory);
  this.deprecated = modelElt.getAnnotation(Deprecated.class) != null;
}
 
Example #25
Source File: ClassModel.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
protected MethodInfo createMethodInfo(Set<ClassTypeInfo> ownerTypes, String methodName, String comment, Doc doc, TypeInfo returnType,
                                      Text returnDescription,
                                      boolean isFluent, boolean isCacheReturn, List<ParamInfo> mParams,
                                      ExecutableElement methodElt, boolean isStatic, boolean isDefault, ArrayList<TypeParamInfo.Method> typeParams,
                                      TypeElement declaringElt, boolean methodDeprecated, Text methodDeprecatedDesc) {
  return new MethodInfo(ownerTypes, methodName, returnType, returnDescription,
    isFluent, isCacheReturn, mParams, comment, doc, isStatic, isDefault, typeParams, methodDeprecated, methodDeprecatedDesc);
}
 
Example #26
Source File: ClassModel.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
public ClassModel(ProcessingEnvironment env, TypeMirrorFactory typeFactory, TypeElement modelElt) {
  this.elementUtils = env.getElementUtils();
  this.typeUtils = env.getTypeUtils();
  this.env = env;
  this.typeFactory = typeFactory;
  this.docFactory = new Doc.Factory(env.getMessager(), elementUtils, typeUtils, typeFactory, modelElt);
  this.messager = env.getMessager();
  this.modelElt = modelElt;
  this.annotationValueInfoFactory = new AnnotationValueInfoFactory(typeFactory);
  this.deprecated = modelElt.getAnnotation(Deprecated.class) != null;
}
 
Example #27
Source File: ClassTestBase.java    From vertx-codegen with Apache License 2.0 4 votes vote down vote up
void checkMethod(MethodInfo meth, String name, int numParams, TypeLiteral<?> returnType, MethodKind kind, Doc comment, MethodCheck... checks) {
  checkMethod(meth, name, numParams, returnType.type, kind, comment, checks);
}
 
Example #28
Source File: AbstractRxGenerator.java    From vertx-rx with Apache License 2.0 4 votes vote down vote up
protected void startMethodTemplate(ClassTypeInfo type, MethodInfo method, String deprecated, PrintWriter writer) {
  Doc doc = method.getDoc();
  if (doc != null) {
    writer.println("  /**");
    Token.toHtml(doc.getTokens(), "   *", this::renderLinkToHtml, "\n", writer);
    for (ParamInfo param : method.getParams()) {
      writer.print("   * @param ");
      writer.print(param.getName());
      writer.print(" ");
      if (param.getDescription() != null) {
        Token.toHtml(param.getDescription().getTokens(), "", this::renderLinkToHtml, "", writer);
      }
      writer.println();
    }
    if (!method.getReturnType().getName().equals("void")) {
      writer.print("   * @return ");
      if (method.getReturnDescription() != null) {
        Token.toHtml(method.getReturnDescription().getTokens(), "", this::renderLinkToHtml, "", writer);
      }
      writer.println();
    }
    if (deprecated != null && deprecated.length() > 0) {
      writer.print("   * @deprecated ");
      writer.println(deprecated);
    }
    writer.println("   */");
  }
  if (method.isDeprecated() || deprecated != null && deprecated.length() > 0) {
    writer.println("  @Deprecated()");
  }
  writer.print("  public ");
  if (method.isStaticMethod()) {
    writer.print("static ");
  }
  if (method.getTypeParams().size() > 0) {
    writer.print(method.getTypeParams().stream().map(TypeParamInfo::getName).collect(joining(", ", "<", ">")));
    writer.print(" ");
  }
  writer.print(genTranslatedTypeName(method.getReturnType()));
  writer.print(" ");
  writer.print(method.getName());
  writer.print("(");
  writer.print(method.getParams().stream().map(it -> genTranslatedTypeName(it.getType()) + " " + it.getName()).collect(joining(", ")));
  writer.print(")");
}
 
Example #29
Source File: WebApiProxyMethodInfo.java    From vertx-web with Apache License 2.0 4 votes vote down vote up
public WebApiProxyMethodInfo(Set<ClassTypeInfo> ownerTypes, String name, TypeInfo returnType, Text returnDescription, boolean fluent, boolean cacheReturn, List<ParamInfo> params, String comment, Doc doc, boolean staticMethod, boolean defaultMethod, List<TypeParamInfo.Method> typeParams, boolean proxyIgnore, boolean proxyClose, boolean deprecated, Text deprecatedDesc) {
  super(ownerTypes, name, returnType, returnDescription, fluent, cacheReturn, params, comment, doc, staticMethod, defaultMethod, typeParams, proxyIgnore, proxyClose, deprecated, deprecatedDesc);
  paramsToExtract = params.subList(0, params.size() - 2);
  requestContextName = params.get(params.size() - 2).getName();
}
 
Example #30
Source File: ConstantInfo.java    From vertx-codegen with Apache License 2.0 4 votes vote down vote up
public ConstantInfo(Doc doc, String name, TypeInfo type) {
  this.doc = doc;
  this.name = name;
  this.type = type;
}