本文整理汇总了Java中com.github.javaparser.ast.body.Parameter.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Parameter.getType方法的具体用法?Java Parameter.getType怎么用?Java Parameter.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.body.Parameter
的用法示例。
在下文中一共展示了Parameter.getType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: visit
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
@Override
public void visit(final Parameter n, final Object arg) {
printer.printLn("Parameter");
printJavaComment(n.getComment(), arg);
printAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
if (n.getType() != null) {
n.getType().accept(this, arg);
}
if (n.isVarArgs()) {
printer.print("...");
}
printer.print(" ");
n.getId().accept(this, arg);
}
示例3: visit
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
@Override
public Node visit(CatchClause _n, Object _arg) {
Parameter param = cloneNodes(_n.getParam(), _arg);
BlockStmt catchBlock = cloneNodes(_n.getCatchBlock(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
CatchClause r = new CatchClause(
_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
param.getModifiers(), param.getAnnotations(), param.getType(), param.getId(), catchBlock
);
r.setComment(comment);
return r;
}
示例4: visit
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
@Override public void visit(final Parameter n, final Object arg) {
printJavaComment(n.getComment(), arg);
printAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
if (n.getType() != null) {
n.getType().accept(this, arg);
}
if (n.isVarArgs()) {
printer.print("...");
}
printer.print(" ");
n.getId().accept(this, arg);
}
示例5: 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());
}
示例6: visit
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
@Override
public Type visit(Parameter node, Boolean solveLambdas) {
if (node.getType() instanceof UnknownType) {
throw new IllegalStateException("Parameter has unknown type: " + node);
}
return facade.convertToUsage(node.getType(), node);
}
示例7: visit
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
@Override public void visit(final Parameter n, final Object arg) {
printJavaComment(n.getComment(), arg);
printAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
if (n.getType() != null) {
n.getType().accept(this, arg);
}
if (n.isVarArgs()) {
printer.print("...");
}
printer.print(" ");
n.getId().accept(this, arg);
}
示例8: visit
import com.github.javaparser.ast.body.Parameter; //导入方法依赖的package包/类
@Override
public ResolvedType visit(Parameter node, Boolean solveLambdas) {
if (node.getType() instanceof UnknownType) {
throw new IllegalStateException("Parameter has unknown type: " + node);
}
return facade.convertToUsage(node.getType(), node);
}