use of japa.parser.ast.type.ClassOrInterfaceType in project enumerable by hraberg.
the class ExpressionInterpreter method naryOperation.
@SuppressWarnings({ "rawtypes", "unchecked" })
public Value naryOperation(final AbstractInsnNode insn, final List values) throws AnalyzerException {
if (insn.getOpcode() == MULTIANEWARRAY) {
throw new UnsupportedOperationException(AbstractVisitor.OPCODES[insn.getOpcode()]);
} else {
MethodInsnNode node = (MethodInsnNode) insn;
ClassOrInterfaceType returnType = createClassOrInterfaceType(getReturnType(node.desc).getClassName());
Expression scope = null;
boolean isConstructor = node.getOpcode() == INVOKESPECIAL && "<init>".equals(node.name);
if (node.getOpcode() == INVOKESTATIC) {
String className = getObjectType(node.owner).getClassName();
scope = new NameExpr(removeJavaLang(className));
} else if (!isConstructor) {
ExpressionValue target = (ExpressionValue) values.remove(0);
if (!(target.expression instanceof ThisExpr))
scope = target.expression;
}
List<Expression> arguments = values.isEmpty() ? null : new ArrayList<Expression>();
for (ExpressionValue value : (List<ExpressionValue>) values) arguments.add(value.expression);
if (isConstructor) {
arguments.remove(0);
ExpressionValue newExpressionValue = (ExpressionValue) values.remove(0);
ClassOrInterfaceType type = (ClassOrInterfaceType) newExpressionValue.type;
newExpressionValue.expression = new ObjectCreationExpr(scope, type, arguments.isEmpty() ? null : arguments);
return new ExpressionValue(returnType, newExpressionValue.expression);
}
return new ExpressionValue(returnType, new MethodCallExpr(scope, node.name, arguments));
}
}
use of japa.parser.ast.type.ClassOrInterfaceType in project Japid by branaway.
the class JavaSyntaxTool method parseCode.
public static List<CodeNode> parseCode(String code) {
try {
final List<CodeNode> nodes = new LinkedList();
CompilationUnit cu = parse(code);
VoidVisitorAdapter visitor = new VoidVisitorAdapter() {
int nested = 0;
@Override
public void visit(AnnotationDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(AnnotationMemberDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ArrayAccessExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ArrayCreationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ArrayInitializerExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(AssertStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(AssignExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(BinaryExpr n, Object arg) {
if (n.getOperator() == Operator.binOr) {
nodes.add(new CodeNode(nested++, new BinaryOrExpr(n)));
} else {
nodes.add(new CodeNode(nested++, n));
}
super.visit(n, arg);
nested--;
}
@Override
public void visit(BlockComment n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(BlockStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(BooleanLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(BreakStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(CastExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(CatchClause n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(CharLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ClassExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ClassOrInterfaceDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ClassOrInterfaceType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(CompilationUnit n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ConditionalExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ConstructorDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ContinueStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(DoStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(DoubleLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EmptyMemberDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EmptyStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EmptyTypeDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EnclosedExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EnumConstantDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EnumDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ExplicitConstructorInvocationStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ExpressionStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(FieldAccessExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(FieldDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ForeachStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ForStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(IfStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ImportDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(InitializerDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(InstanceOfExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(IntegerLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(IntegerLiteralMinValueExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(JavadocComment n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(LabeledStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(LineComment n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(LongLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(LongLiteralMinValueExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(MarkerAnnotationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(MemberValuePair n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(MethodCallExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(MethodDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(NameExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(NormalAnnotationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(NullLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ObjectCreationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(PackageDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(Parameter n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(PrimitiveType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(QualifiedNameExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ReferenceType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ReturnStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SingleMemberAnnotationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(StringLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SuperExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SwitchEntryStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SwitchStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SynchronizedStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ThisExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ThrowStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(TryStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(TypeDeclarationStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(TypeParameter n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(UnaryExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(VariableDeclarationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(VariableDeclarator n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(VariableDeclaratorId n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(VoidType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(WhileStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(WildcardType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
};
cu.accept(visitor, null);
return nodes;
} catch (ParseException e) {
throw new RuntimeException("invalid Java code: " + code + ". " + e);
}
}
use of japa.parser.ast.type.ClassOrInterfaceType in project jsonschema2pojo by joelittlejohn.
the class TypeUtil method buildClass.
private static JClass buildClass(JClassContainer _package, ClassOrInterfaceType c, int arrayCount) {
final String packagePrefix = (c.getScope() != null) ? c.getScope().toString() + "." : "";
JClass _class = _package.owner().ref(packagePrefix + c.getName());
for (int i = 0; i < arrayCount; i++) {
_class = _class.array();
}
List<Type> typeArgs = c.getTypeArgs();
if (typeArgs != null && typeArgs.size() > 0) {
JClass[] genericArgumentClasses = new JClass[typeArgs.size()];
for (int i = 0; i < typeArgs.size(); i++) {
final Type type = typeArgs.get(i);
final JClass resolvedClass;
if (type instanceof WildcardType) {
final WildcardType wildcardType = (WildcardType) type;
if (wildcardType.getSuper() != null) {
throw new IllegalArgumentException("\"? super \" declaration is not yet supported");
} else if (wildcardType.getExtends() != null) {
resolvedClass = buildClass(_package, (ClassOrInterfaceType) wildcardType.getExtends().getType(), 0).wildcard();
} else {
resolvedClass = _package.owner().ref(Object.class).wildcard();
}
} else {
final ReferenceType referenceType = (ReferenceType) type;
resolvedClass = buildClass(_package, (ClassOrInterfaceType) referenceType.getType(), referenceType.getArrayCount());
}
genericArgumentClasses[i] = resolvedClass;
}
_class = _class.narrow(genericArgumentClasses);
}
return _class;
}
use of japa.parser.ast.type.ClassOrInterfaceType in project japid42 by branaway.
the class JavaSyntaxTool method parseCode.
public static List<CodeNode> parseCode(String code) {
try {
final List<CodeNode> nodes = new LinkedList();
CompilationUnit cu = parse(code);
VoidVisitorAdapter visitor = new VoidVisitorAdapter() {
int nested = 0;
@Override
public void visit(AnnotationDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(AnnotationMemberDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ArrayAccessExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ArrayCreationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ArrayInitializerExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(AssertStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(AssignExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(BinaryExpr n, Object arg) {
if (n.getOperator() == Operator.binOr) {
nodes.add(new CodeNode(nested++, new BinaryOrExpr(n)));
} else {
nodes.add(new CodeNode(nested++, n));
}
super.visit(n, arg);
nested--;
}
@Override
public void visit(BlockComment n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(BlockStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(BooleanLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(BreakStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(CastExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(CatchClause n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(CharLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ClassExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ClassOrInterfaceDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ClassOrInterfaceType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(CompilationUnit n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ConditionalExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ConstructorDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ContinueStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(DoStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(DoubleLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EmptyMemberDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EmptyStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EmptyTypeDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EnclosedExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EnumConstantDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(EnumDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ExplicitConstructorInvocationStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ExpressionStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(FieldAccessExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(FieldDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ForeachStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ForStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(IfStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ImportDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(InitializerDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(InstanceOfExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(IntegerLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(IntegerLiteralMinValueExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(JavadocComment n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(LabeledStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(LineComment n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(LongLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(LongLiteralMinValueExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(MarkerAnnotationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(MemberValuePair n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(MethodCallExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(MethodDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(NameExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(NormalAnnotationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(NullLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ObjectCreationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(PackageDeclaration n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(Parameter n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(PrimitiveType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(QualifiedNameExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ReferenceType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ReturnStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SingleMemberAnnotationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(StringLiteralExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SuperExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SwitchEntryStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SwitchStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(SynchronizedStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ThisExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(ThrowStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(TryStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(TypeDeclarationStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(TypeParameter n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(UnaryExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(VariableDeclarationExpr n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(VariableDeclarator n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(VariableDeclaratorId n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(VoidType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(WhileStmt n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
@Override
public void visit(WildcardType n, Object arg) {
nodes.add(new CodeNode(nested++, n));
super.visit(n, arg);
nested--;
}
};
cu.accept(visitor, null);
return nodes;
} catch (ParseException e) {
throw new RuntimeException("invalid Java code: " + code + ". " + e);
}
}
use of japa.parser.ast.type.ClassOrInterfaceType in project jsonschema2pojo by joelittlejohn.
the class TypeUtil method resolveType.
public static JClass resolveType(JClassContainer _package, String typeDefinition) {
try {
FieldDeclaration fieldDeclaration = (FieldDeclaration) JavaParser.parseBodyDeclaration(typeDefinition + " foo;");
ClassOrInterfaceType c = (ClassOrInterfaceType) ((ReferenceType) fieldDeclaration.getType()).getType();
return buildClass(_package, c, 0);
} catch (ParseException e) {
throw new GenerationException("Couldn't parse type: " + typeDefinition, e);
}
}
Aggregations