import org.jastadd.plugin.compiler.ast.IOutlineNode; aspect MainDeclaration { syn IOutlineNode[] Program.mainTypes() { LinkedList list = new LinkedList(); collectMainTypes(list); IOutlineNode[] result = new IOutlineNode[list.size()]; int i = 0; for (Iterator itr = list.iterator(); itr.hasNext(); i++) { result[i] = (IOutlineNode)itr.next(); } return result; } protected void ASTNode.collectMainTypes(Collection c) { for(int i = 0; i < getNumChild(); i++) getChild(i).collectMainTypes(c); } protected void ClassDecl.collectMainTypes(Collection c) { super.collectMainTypes(c); if(hasMainType()) c.add(this); } syn boolean TypeDecl.hasMainType() = false; eq ClassDecl.hasMainType() { boolean hasMain = false; for (int i = 0; i < getNumBodyDecl(); i++) { BodyDecl decl = getBodyDecl(i); // Currently main methods in inner classes are not considered. if (decl instanceof MethodDecl) { MethodDecl mDecl = (MethodDecl)decl; if (mDecl.getID().equals("main")) { hasMain = true; } } } return hasMain; } }