PsiElementVisitor (@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitMethod(@NotNull PsiMethod method) { checkBody(method.getBody(), holder); } @Override public void visitClassInitializer(@NotNull PsiClassInitializer initializer) { checkBody(initializer.getBody(), holder); } @Override public void visitLambdaExpression(@NotNull PsiLambdaExpression expression) { checkBody(expression.getBody(), holder); } @Override public void visitField(@NotNull PsiField field) { checkField(field, holder); } }; }