if (type.getNodeType() == ASTNode.TYPE_DECLARATION) {
List<AbstractTypeDeclaration> types = cu.types(); for(AbstractTypeDeclaration type : types) { if(type.getNodeType() == ASTNode.TYPE_DECLARATION) { // Class def found List<BodyDeclaration> bodies = type.bodyDeclarations(); for(BodyDeclaration body : bodies) { if(body.getNodeType() == ASTNode.METHOD_DECLARATION) { MethodDeclaration method = (MethodDeclaration)body; System.out.println("method declaration: "); System.out.println("name: " + method.getName().getFullyQualifiedName()); System.out.println("modifiers: " + method.getModifiers()); System.out.println("return type: " + method.getReturnType2().toString()); } } } }
/** * Builds a CFG for the provided node. * * @param node the node for which to build a CFG. * @return the list of basic blocks representing CFGs for each method in this compilation unit */ public List<CFGBasicBlock> buildCFG(CompilationUnit node) { List<CFGBasicBlock> results = new LinkedList<CFGBasicBlock>(); for (AbstractTypeDeclaration decl : (List<AbstractTypeDeclaration>) node.types()) { if (decl.getNodeType() == TYPE_DECLARATION) { results.addAll(buildCFG((TypeDeclaration) decl)); } else { throw new NotImplementedException(node); } } return results; }
IExtendedModifier[] modifiers; for (final AbstractTypeDeclaration type : types) { if (type.getNodeType() == ASTNode.TYPE_DECLARATION) {