GroovyElementVisitor (@NotNull ProblemsHolder problemsHolder, boolean isOnTheFly) { return new GroovyElementVisitor() { @Override public void visitClosure(@NotNull GrClosableBlock closure) { check(closure, problemsHolder); } @Override public void visitLambdaBody(@NotNull GrLambdaBody body) { check(body, problemsHolder); } @Override public void visitMethod(@NotNull GrMethod method) { final GrOpenBlock block = method.getBlock(); if (block != null) { check(block, problemsHolder); } } @Override public void visitFile(@NotNull GroovyFileBase file) { check(file, problemsHolder); } @Override public void visitClassInitializer(@NotNull GrClassInitializer initializer) { check(initializer.getBlock(), problemsHolder); } }; }