GroovyElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new GroovyElementVisitor() { @Override public void visitClosure(@NotNull GrClosableBlock closure) { super.visitClosure(closure); check(closure, holder, ReturnStatus.getReturnStatus(closure)); } @Override public void visitMethod(@NotNull GrMethod method) { super.visitMethod(method); final GrOpenBlock block = method.getBlock(); if (block != null) { check(block, holder, ReturnStatus.getReturnStatus(method)); } } }; }