use of com.github.javaparser.javadoc.JavadocBlockTag in project javaparser by javaparser.
the class JavadocParserTest method parseParamBlockTags.
@Test
public void parseParamBlockTags() {
String text = EOL + " * Add a field to this and automatically add the import of the type if needed" + EOL + " *" + EOL + " * @param typeClass the type of the field" + EOL + " * @param name the name of the field" + EOL + " * @param modifiers the modifiers like {@link Modifier#PUBLIC}" + EOL + " * @return the {@link FieldDeclaration} created" + EOL + " ";
Javadoc res = JavadocParser.parse(text);
assertEquals(new Javadoc(JavadocDescription.parseText("Add a field to this and automatically add the import of the type if needed")).addBlockTag(JavadocBlockTag.createParamBlockTag("typeClass", "the type of the field")).addBlockTag(JavadocBlockTag.createParamBlockTag("name", "the name of the field")).addBlockTag(JavadocBlockTag.createParamBlockTag("modifiers", "the modifiers like {@link Modifier#PUBLIC}")).addBlockTag(new JavadocBlockTag(JavadocBlockTag.Type.RETURN, "the {@link FieldDeclaration} created")), res);
}
use of com.github.javaparser.javadoc.JavadocBlockTag in project javaparser by javaparser.
the class JavadocParserTest method parseBlockTagsAndEmptyDescription.
@Test
public void parseBlockTagsAndEmptyDescription() {
String text = EOL + " * @deprecated" + EOL + " * @see #getEndColumn" + EOL + " ";
assertEquals(new Javadoc(JavadocDescription.parseText("")).addBlockTag(new JavadocBlockTag(JavadocBlockTag.Type.DEPRECATED, "")).addBlockTag(new JavadocBlockTag(JavadocBlockTag.Type.SEE, "#getEndColumn")), JavadocParser.parse(text));
}
use of com.github.javaparser.javadoc.JavadocBlockTag in project flow by vaadin.
the class OpenAPIObjectGenerator method createRequestBody.
private RequestBody createRequestBody(MethodDeclaration methodDeclaration, ResolvedTypeParametersMap resolvedTypeParametersMap) {
Map<String, String> paramsDescription = new HashMap<>();
methodDeclaration.getJavadoc().ifPresent(javadoc -> {
for (JavadocBlockTag blockTag : javadoc.getBlockTags()) {
if (blockTag.getType() == JavadocBlockTag.Type.PARAM) {
paramsDescription.put(blockTag.getName().orElse(""), blockTag.getContent().toText());
}
}
});
RequestBody requestBody = new RequestBody();
Content requestBodyContent = new Content();
requestBody.content(requestBodyContent);
MediaType requestBodyObject = new MediaType();
requestBodyContent.addMediaType("application/json", requestBodyObject);
Schema requestSchema = new ObjectSchema();
requestSchema.setRequired(new ArrayList<>());
requestBodyObject.schema(requestSchema);
methodDeclaration.getParameters().forEach(parameter -> {
GeneratorType generatorType = createSchemaType(parameter, resolvedTypeParametersMap);
Schema paramSchema = parseResolvedTypeToSchema(generatorType, parameter.getAnnotations());
paramSchema.setDescription("");
usedTypes.putAll(collectUsedTypesFromSchema(paramSchema));
String name = (isReservedWord(parameter.getNameAsString()) ? "_" : "").concat(parameter.getNameAsString());
if (GeneratorUtils.isBlank(paramSchema.get$ref())) {
paramSchema.description(paramsDescription.remove(parameter.getNameAsString()));
}
requestSchema.addProperties(name, paramSchema);
requestSchema.addRequiredItem(name);
});
if (!paramsDescription.isEmpty()) {
requestSchema.addExtension(EXTENSION_VAADIN_CONNECT_PARAMETERS_DESCRIPTION, new LinkedHashMap<>(paramsDescription));
}
return requestBody;
}
use of com.github.javaparser.javadoc.JavadocBlockTag in project javaparser by javaparser.
the class JavadocParserTest method parseBlockTagsAndProvideTagName.
@Test
public void parseBlockTagsAndProvideTagName() {
String expectedText = EOL + " * @unofficial" + EOL + " " + " ";
Javadoc underTest = new Javadoc(JavadocDescription.parseText("")).addBlockTag(new JavadocBlockTag("unofficial", ""));
assertEquals(underTest, JavadocParser.parse(expectedText));
assertEquals(1, underTest.getBlockTags().size());
assertEquals("unofficial", underTest.getBlockTags().get(0).getTagName());
}
use of com.github.javaparser.javadoc.JavadocBlockTag in project javaparser by javaparser.
the class JavadocParserTest method parseMultilineParamBlockTags.
@Test
public void parseMultilineParamBlockTags() {
String text = EOL + " * Add a field to this and automatically add the import of the type if needed" + EOL + " *" + EOL + " * @param typeClass the type of the field" + EOL + " * continued in a second line" + EOL + " * @param name the name of the field" + EOL + " * @param modifiers the modifiers like {@link Modifier#PUBLIC}" + EOL + " * @return the {@link FieldDeclaration} created" + EOL + " ";
Javadoc res = JavadocParser.parse(text);
assertEquals(new Javadoc(JavadocDescription.parseText("Add a field to this and automatically add the import of the type if needed")).addBlockTag(JavadocBlockTag.createParamBlockTag("typeClass", "the type of the field" + EOL + " continued in a second line")).addBlockTag(JavadocBlockTag.createParamBlockTag("name", "the name of the field")).addBlockTag(JavadocBlockTag.createParamBlockTag("modifiers", "the modifiers like {@link Modifier#PUBLIC}")).addBlockTag(new JavadocBlockTag(JavadocBlockTag.Type.RETURN, "the {@link FieldDeclaration} created")), res);
}
Aggregations