Ejemplo n.º 1
0
 /*
  * @see ASTVisitor#visit(FunctionDeclaration)
  */
 public boolean visit(FunctionDeclaration node) {
   if (node.getJavadoc() != null) {
     node.getJavadoc().accept(this);
   }
   if (node.getAST().apiLevel() == AST.JLS2) {
     printModifiers(node.getModifiers());
   }
   if (node.getAST().apiLevel() >= AST.JLS3) {
     printModifiers(node.modifiers());
   }
   //		if (!node.isConstructor()) {
   //			if (node.getAST().apiLevel() == AST.JLS2) {
   //				node.getReturnType().accept(this);
   //			} else {
   //				if (node.getReturnType2() != null) {
   //					node.getReturnType2().accept(this);
   //				} else {
   //					// methods really ought to have a return type
   //					this.fBuffer.append("void");//$NON-NLS-1$
   //				}
   //			}
   //			this.fBuffer.append(" ");//$NON-NLS-1$
   //		}
   if (node.getName() != null) node.getName().accept(this);
   this.fBuffer.append("("); // $NON-NLS-1$
   for (Iterator it = node.parameters().iterator(); it.hasNext(); ) {
     SingleVariableDeclaration v = (SingleVariableDeclaration) it.next();
     v.accept(this);
     if (it.hasNext()) {
       this.fBuffer.append(","); // $NON-NLS-1$
     }
   }
   this.fBuffer.append(")"); // $NON-NLS-1$
   for (int i = 0; i < node.getExtraDimensions(); i++) {
     this.fBuffer.append("[]"); // $NON-NLS-1$
   }
   if (!node.thrownExceptions().isEmpty()) {
     this.fBuffer.append(" throws "); // $NON-NLS-1$
     for (Iterator it = node.thrownExceptions().iterator(); it.hasNext(); ) {
       Name n = (Name) it.next();
       n.accept(this);
       if (it.hasNext()) {
         this.fBuffer.append(", "); // $NON-NLS-1$
       }
     }
     this.fBuffer.append(" "); // $NON-NLS-1$
   }
   if (node.getBody() == null) {
     this.fBuffer.append(";"); // $NON-NLS-1$
   } else {
     node.getBody().accept(this);
   }
   return false;
 }
 private boolean methodThrowsException(FunctionDeclaration method, Name exception) {
   ASTMatcher matcher = new ASTMatcher();
   for (Iterator iter = method.thrownExceptions().iterator(); iter.hasNext(); ) {
     Name thrown = (Name) iter.next();
     if (exception.subtreeMatch(matcher, thrown)) return true;
   }
   return false;
 }