public static void doSetup( final LightProjectDescriptor descriptor, final LocalInspectionTool[] localInspectionTools, final Map<String, InspectionTool> availableInspectionTools) throws Exception { assertNull( "Previous test " + ourTestCase + " hasn't called tearDown(). Probably overriden without super call.", ourTestCase); IdeaLogger.ourErrorsOccurred = null; if (ourProject == null || !ourProjectDescriptor.equals(descriptor)) { initProject(descriptor); } ProjectManagerEx.getInstanceEx().setCurrentTestProject(ourProject); ((PsiDocumentManagerImpl) PsiDocumentManager.getInstance(getProject())) .clearUncommitedDocuments(); for (LocalInspectionTool tool : localInspectionTools) { enableInspectionTool(availableInspectionTools, new LocalInspectionToolWrapper(tool)); } final InspectionProfileImpl profile = new InspectionProfileImpl("Configurable") { @NotNull public InspectionProfileEntry[] getInspectionTools(PsiElement element) { if (availableInspectionTools != null) { final Collection<InspectionTool> tools = availableInspectionTools.values(); return tools.toArray(new InspectionTool[tools.size()]); } return new InspectionTool[0]; } @Override public List<ToolsImpl> getAllEnabledInspectionTools() { List<ToolsImpl> result = new ArrayList<ToolsImpl>(); for (InspectionProfileEntry entry : getInspectionTools(null)) { result.add(new ToolsImpl(entry, entry.getDefaultLevel(), true)); } return result; } public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) { return key != null && availableInspectionTools.containsKey(key.toString()); } public HighlightDisplayLevel getErrorLevel( @NotNull HighlightDisplayKey key, PsiElement element) { InspectionTool localInspectionTool = availableInspectionTools.get(key.toString()); return localInspectionTool != null ? localInspectionTool.getDefaultLevel() : HighlightDisplayLevel.WARNING; } public InspectionTool getInspectionTool( @NotNull String shortName, @NotNull PsiElement element) { if (availableInspectionTools.containsKey(shortName)) { return availableInspectionTools.get(shortName); } return null; } }; final InspectionProfileManager inspectionProfileManager = InspectionProfileManager.getInstance(); inspectionProfileManager.addProfile(profile); inspectionProfileManager.setRootProfile(profile.getName()); InspectionProjectProfileManager.getInstance(getProject()).updateProfile(profile); InspectionProjectProfileManager.getInstance(getProject()).setProjectProfile(profile.getName()); assertFalse(getPsiManager().isDisposed()); CodeStyleSettingsManager.getInstance(getProject()) .setTemporarySettings(new CodeStyleSettings()); }