本文整理汇总了Java中japa.parser.ast.type.ClassOrInterfaceType.accept方法的典型用法代码示例。如果您正苦于以下问题:Java ClassOrInterfaceType.accept方法的具体用法?Java ClassOrInterfaceType.accept怎么用?Java ClassOrInterfaceType.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类japa.parser.ast.type.ClassOrInterfaceType
的用法示例。
在下文中一共展示了ClassOrInterfaceType.accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseType
import japa.parser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
private JType parseType(String type, JCodeModel codeModel) {
final String text = "public class Ignored extends " + type + " {}";
try {
CompilationUnit compilationUnit = JavaParser.parse(
new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8");
final List<TypeDeclaration> typeDeclarations = compilationUnit
.getTypes();
final TypeDeclaration typeDeclaration = typeDeclarations.get(0);
final ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) typeDeclaration;
final List<ClassOrInterfaceType> _extended = classDeclaration
.getExtends();
final ClassOrInterfaceType classOrInterfaceType = _extended.get(0);
return classOrInterfaceType.accept(
this.typeToJTypeConvertingVisitor, codeModel);
} catch (ParseException pex) {
throw new IllegalArgumentException(
"Could not parse the type definition [" + type + "].", pex);
} catch (UnsupportedEncodingException uex) {
throw new UnsupportedOperationException(uex);
}
}
示例2: visit
import japa.parser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
public R visit(EnumDeclaration n, A arg) {
if (n.getJavaDoc() != null) {
n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (AnnotationExpr a : n.getAnnotations()) {
a.accept(this, arg);
}
}
if (n.getImplements() != null) {
for (ClassOrInterfaceType c : n.getImplements()) {
c.accept(this, arg);
}
}
if (n.getEntries() != null) {
for (EnumConstantDeclaration e : n.getEntries()) {
e.accept(this, arg);
}
}
if (n.getMembers() != null) {
for (BodyDeclaration member : n.getMembers()) {
member.accept(this, arg);
}
}
return null;
}
示例3: visit
import japa.parser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
public void visit(EnumDeclaration n, A arg) {
if (n.getJavaDoc() != null) {
n.getJavaDoc().accept(this, arg);
}
if (n.getAnnotations() != null) {
for (AnnotationExpr a : n.getAnnotations()) {
a.accept(this, arg);
}
}
if (n.getImplements() != null) {
for (ClassOrInterfaceType c : n.getImplements()) {
c.accept(this, arg);
}
}
if (n.getEntries() != null) {
for (EnumConstantDeclaration e : n.getEntries()) {
e.accept(this, arg);
}
}
if (n.getMembers() != null) {
for (BodyDeclaration member : n.getMembers()) {
member.accept(this, arg);
}
}
}
示例4: visit
import japa.parser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
public void visit(TypeParameter n, Object arg) {
printer.print(n.getName());
if (n.getTypeBound() != null) {
printer.print(" extends ");
for (Iterator<ClassOrInterfaceType> i = n.getTypeBound().iterator(); i.hasNext();) {
ClassOrInterfaceType c = i.next();
c.accept(this, arg);
if (i.hasNext()) {
printer.print(" & ");
}
}
}
}