private JavaMethod createMethod (MethodDeclaration method) { String className = classStack.peek().getName(); String name = method.getName(); boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC); String returnType = method.getType().toString(); ArrayList<Argument> arguments = new ArrayList<Argument>(); if (method.getParameters() != null) { for (Parameter parameter : method.getParameters()) { arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName())); } } return new JavaMethod(className, name, isStatic, returnType, null, arguments, method.getBeginLine(), method.getEndLine()); }
private JavaMethod createMethod (MethodDeclaration method) { String className = classStack.peek().getName(); String name = method.getName(); boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC); String returnType = method.getType().toString(); ArrayList<Argument> arguments = new ArrayList<Argument>(); if (method.getParameters() != null) { for (Parameter parameter : method.getParameters()) { arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName())); } } return new JavaMethod(className, name, isStatic, returnType, null, arguments, method.getBeginLine(), method.getEndLine()); }
@Override public void visit(MethodDeclaration m, Object arg) { System.out.println("From [" + m.getBeginLine() + "," + m.getBeginColumn() + "] to [" + m.getEndLine() + "," + m.getEndColumn() + "] is method:"); System.out.println(m);
private JavaMethod createMethod (MethodDeclaration method) { String className = classStack.peek().getName(); String name = method.getName(); boolean isStatic = ModifierSet.hasModifier(method.getModifiers(), ModifierSet.STATIC); String returnType = method.getType().toString(); ArrayList<Argument> arguments = new ArrayList<Argument>(); if (method.getParameters() != null) { for (Parameter parameter : method.getParameters()) { arguments.add(new Argument(getArgumentType(parameter), parameter.getId().getName())); } } return new JavaMethod(className, name, isStatic, returnType, null, arguments, method.getBeginLine(), method.getEndLine()); }
/** * Visit the Controller methods. * <p> * We visit each methods that are annotated with the Route annotations with the {@link RouteMethodSourceVisitor}. * The routes are add to the model indexed by their Path. The routes are ordered according to natural ordering * and their hierarchy. * </p> * * @param method {@inheritDoc} * @param controller The ControllerModel we are building. */ @Override public void visit(MethodDeclaration method, ControllerModel controller) { List<AnnotationExpr> annos = method.getAnnotations(); if(annos ==null || annos.isEmpty()){ return; } for(AnnotationExpr anno: annos){ if(anno.getName().getName().equals(ANNOTATION_ROUTE)){ ControllerRouteModel route = new ControllerRouteModel(); route.setMethodName(method.getName()); routeVisitor.visit(method, route); //controllerParsed the method, annotations and params LOGGER.info("[controller]The route method " + route.getMethodName() + " starting at line " + method.getBeginLine() + " has been properly visited."); //add the route to the controller controller.addRoute(route); } } }