Ejemplo n.º 1
0
 @Override
 public Void visitFormalParameterList(FormalParameterList node) {
   String groupEnd = null;
   writer.print('(');
   NodeList<FormalParameter> parameters = node.getParameters();
   int size = parameters.size();
   for (int i = 0; i < size; i++) {
     FormalParameter parameter = parameters.get(i);
     if (i > 0) {
       writer.print(", ");
     }
     if (groupEnd == null && parameter instanceof DefaultFormalParameter) {
       if (parameter.getKind() == ParameterKind.NAMED) {
         groupEnd = "}";
         writer.print('{');
       } else {
         groupEnd = "]";
         writer.print('[');
       }
     }
     parameter.accept(this);
   }
   if (groupEnd != null) {
     writer.print(groupEnd);
   }
   writer.print(')');
   return null;
 }
Ejemplo n.º 2
0
 /**
  * Return the body of the function that contains the given parameter, or {@code null} if no
  * function body could be found.
  *
  * @param node the parameter contained in the function whose body is to be returned
  * @return the body of the function that contains the given parameter
  */
 private FunctionBody getFunctionBody(FormalParameter node) {
   ASTNode parent = node.getParent();
   while (parent != null) {
     if (parent instanceof ConstructorDeclaration) {
       return ((ConstructorDeclaration) parent).getBody();
     } else if (parent instanceof FunctionExpression) {
       return ((FunctionExpression) parent).getBody();
     } else if (parent instanceof MethodDeclaration) {
       return ((MethodDeclaration) parent).getBody();
     }
     parent = parent.getParent();
   }
   return null;
 }