public static boolean isEmptyBlock(Statement origStatement) {
        Stack<ASTNode> stack = new Stack<ASTNode>();
        stack.push(origStatement);

        while (!stack.isEmpty()) {
            ASTNode statement = stack.pop();
            if (!(statement instanceof BlockStatement)) {
                return false;
            }
            if (((BlockStatement) statement).isEmpty()) {
                return true;
            }
            if (((BlockStatement) statement).getStatements().size() != 1) {
                return false;
            }
            stack.push(((BlockStatement) statement).getStatements().get(0));
        }
        return false;
    }
public static boolean isEmptyBlock ( Statement origStatement ) { Stack < ASTNode > stack = new Stack < ASTNode > ( ) ; stack . push ( origStatement ) ; while ( ! stack . isEmpty ( ) ) { ASTNode statement = stack . pop ( ) ; if ( ! ( statement instanceof BlockStatement ) ) { return false ; } if ( ( ( BlockStatement ) statement ) . isEmpty ( ) ) { return true ; } if ( ( ( BlockStatement ) statement ) . getStatements ( ) . size ( ) != 1 ) { return false ; } stack . push ( ( ( BlockStatement ) statement ) . getStatements ( ) . get ( 0 ) ) ; } return false ; }
Return true if the Statement is a block and it is empty (contains no "meaningful" statements).
This implementation also addresses some "weirdness" around some statement types (specifically finally)
where the BlockStatement answered false to isEmpty() even if it was.
@param origStatement - the Statement to check
@return true if the BlockStatement is empty