void () { InspectionProfileImpl profile = new InspectionProfileImpl("Foo"); InspectionsKt.disableAllTools(profile); profile.enableTool(new UnusedDeclarationInspectionBase(true).getShortName(), getProject()); GlobalInspectionContextImpl context = ((InspectionManagerEx)InspectionManager.getInstance(getProject())).createNewGlobalContext(); context.setExternalProfile(profile); context.initializeTools(new ArrayList<>(), new ArrayList<>(), new ArrayList<>()); }