PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly, @NotNull LocalInspectionToolSession session) { return new JavaElementVisitor() { @Override public void visitIdentifier(@NotNull PsiIdentifier identifier) { if (identifier.getText().equals("k")) { holder.registerProblem(identifier, "Variable 'k' is never used"); } } }; }