void () { enableInspectionTool(new LocalInspectionTool() { @NotNull @Override public String getShortName() { return getDisplayName(); } @NotNull @Override public PsiElementVisitor buildVisitor(@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"); } } }; } @NotNull @Override public HighlightDisplayLevel getDefaultLevel() { return HighlightDisplayLevel.ERROR; } @Nls @NotNull @Override public String getDisplayName() { return "x"; } @Nls @NotNull @Override public String getGroupDisplayName() { return getDisplayName(); } }); doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false); }