1 package org.incava.java; 2 3 import java.util.*; 4 import net.sourceforge.pmd.ast.*; 5 import org.incava.lang.StringExt; 6 7 8 11 public class FunctionUtil extends SimpleNodeUtil 12 { 13 16 public static Token getThrows(SimpleNode function) 17 { 18 Token tk = function.getFirstToken(); 19 while (true) { 20 if (tk.kind == JavaParserConstants.THROWS) { 21 return tk; 22 } 23 else if (tk == function.getLastToken()) { 24 break; 25 } 26 else { 27 tk = tk.next; 28 } 29 } 30 return null; 31 } 32 33 36 public static ASTNameList getThrowsList(SimpleNode function) 37 { 38 List children = getChildren(function); 39 Iterator it = children.iterator(); 40 while (it.hasNext()) { 41 Object obj = it.next(); 42 if (obj instanceof Token && ((Token)obj).kind == JavaParserConstants.THROWS && it.hasNext()) { 43 ASTNameList throwsList = (ASTNameList)it.next(); 44 return throwsList; 45 } 46 } 47 return null; 48 } 49 50 protected static String toFullName(Token tk, ASTFormalParameters params) 51 { 52 List types = ParameterUtil.getParameterTypes(params); 53 String args = StringExt.join(types, ", "); 54 return tk.image + "(" + args + ")"; 55 } 56 57 } 58 | Popular Tags |