本文整理汇总了Java中com.github.javaparser.ast.body.Parameter.getComment方法的典型用法代码示例。如果您正苦于以下问题:Java Parameter.getComment方法的具体用法?Java Parameter.getComment怎么用?Java Parameter.getComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.body.Parameter
的用法示例。
在下文中一共展示了Parameter.getComment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
public void visit(MethodDeclaration n, Object arg) {
MethodDVO methodDVO = new MethodDVO();
methodDVO.setMethodName(n.getName());
methodDVO.setVisivility(GargoyleJavaParser.toStringVisibility(n.getModifiers()));
methodDVO.setDescription(n.getComment() != null ? n.getComment().toString() : "");
ArrayList<MethodParameterDVO> methodParameterDVOList = new ArrayList<>();
methodDVO.setMethodParameterDVOList(methodParameterDVOList);
List<Parameter> parameters = n.getParameters();
for (Parameter p : parameters) {
// String string2 = p.toString();
VariableDeclaratorId id2 = p.getId();
String varName = id2.getName();
Type type = p.getType();
String typeName = type.toString();
Comment comment = p.getComment();
methodParameterDVOList.add(new MethodParameterDVO(varName, typeName, "", comment == null ? "" : comment.toString()));
}
onMethodDVOVisite.accept(methodDVO);
super.visit(n, arg);
}
示例2: parseParameters
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
/**
*
* @param params
* list of parameters to parse
* @return
* a list of Field structures
*/
private List<Field> parseParameters(List<Parameter> params) {
List<Field> fields = new ArrayList<>();
if (params != null) {
for (Parameter parameter : params) {
Field field = new Field();
field.setName(parameter.getId().getName());
field.setType(parameter.getType().toString());
if (parameter.getComment() != null) {
List<String> doc = ParserUtils.prepareComments(parameter.getComment().getContent());
field.setDoc(doc);
}
fields.add(field);
}
}
return fields;
}
示例3: visit
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
@Override
public JCTree visit(final Parameter n, final Object arg) {
//ARG0: JCModifiers mods
JCModifiers arg0;
// TODO - Forcing flag below. Check if should use make.Param
long jcmodifier = setJCTreeModifiers(n.getModifiers(), 0) | Flags.PARAMETER;
arg0 = new AJCModifiers(make.Modifiers(jcmodifier), null);
//ARG1: Name name
//JCTree result = n.getId().accept(this, arg);
Name arg1 = names.fromString(n.getId().getName());
//ARG2: JCExpression vartype
JCExpression arg2 = (JCExpression) n.getType().accept(this, arg);
//ARG3: JCExpression init
// TODO - There is not such field in Java Parser
JCExpression arg3 = null;
/* TODO - annotations not supported
if (n.getAnnotations() != null) {
for (final AnnotationExpr a : n.getAnnotations()) {
JCTree result = a.accept(this, arg);
}
}
*/
return new AJCVariableDecl(make.VarDef(arg0, arg1, arg2, arg3), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
示例4: setParamAs
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
void setParamAs(Parameter param) {
checkNotNull(param);
this.parameter = Optional.of(param);
Pattern defaultPrimitive = Pattern.compile(".*=([\\-a-zA-Z0-9_\\.]*.*)");
Pattern defaultEnumPrimitive = Pattern.compile(".*=(?:cv::)([\\-a-zA-Z0-9_\\.]*.*)");
if (param.getComment() != null && param.getType() instanceof PrimitiveType) {
//System.out.println("Checking match");
Matcher matchesPrimitive = defaultPrimitive.matcher(param.getComment().getContent());
Matcher matchesEnumPrimitive = defaultEnumPrimitive.matcher(param.getComment().getContent());
//if (matchesPrimitive.find()) System.out.println("Primitive Matcher: " + matchesPrimitive
// .group());
//if (matchesEnumPrimitive.find()) System.out.println("Enum Matcher: " +
// matchesEnumPrimitive.group(1));
if (matchesEnumPrimitive.matches()) {
//System.out.println("Matching Enum: " + matchesEnumPrimitive.group(1));
this.literalDefaultValue = Optional.of(matchesEnumPrimitive.group(1));
//The default value should be assigned
} else if (matchesPrimitive.matches()) {
//System.out.println("Matching Primitive: " + matchesPrimitive.group(1));
this.literalDefaultValue = Optional.of(matchesPrimitive.group(1));
this.defaultValue = Optional.of(new PrimitiveDefaultValue((PrimitiveType) param.getType()));
}
} else if (param.getType() instanceof PrimitiveType) {
this.literalDefaultValue = Optional.of(this.literalDefaultValue.orElse("0"));
this.defaultValue = Optional.of(this.defaultValue.orElse(new PrimitiveDefaultValue(
(PrimitiveType) param.getType())));
} else if (isOutput() || !listAnnotationsMatching().isEmpty()) {
this.defaultValue = Optional.of(this.defaultValue.orElse(new ObjectDefaultValue(param
.getType())));
} else {
this.defaultValue = Optional.of(this.defaultValue.orElse(new NullDefaultValue()));
}
//System.out.println(param.getType().getClass());
}