InspectionProfileImpl (@NotNull InspectionToolWrapper toolWrapper, @NotNull InspectionManagerEx managerEx, @Nullable PsiElement psiElement) { final Project project = managerEx.getProject(); InspectionProfileImpl rootProfile = InspectionProfileManager.getInstance(project).getCurrentProfile(); LinkedHashSet<InspectionToolWrapper<?, ?>> allWrappers = new LinkedHashSet<>(); allWrappers.add(toolWrapper); rootProfile.collectDependentInspections(toolWrapper, allWrappers, project); List<InspectionToolWrapper<?, ?>> toolWrappers = allWrappers.size() == 1 ? Collections.singletonList(allWrappers.iterator().next()) : new ArrayList<>(allWrappers); InspectionProfileImpl model = new InspectionProfileImpl(toolWrapper.getDisplayName(), new InspectionToolsSupplier.Simple(toolWrappers), rootProfile); for (InspectionToolWrapper wrapper : toolWrappers) { model.enableTool(wrapper.getShortName(), project); } try { Element element = new Element("toCopy"); for (InspectionToolWrapper wrapper : toolWrappers) { wrapper.getTool().writeSettings(element); InspectionToolWrapper tw = psiElement == null ? model.getInspectionTool(wrapper.getShortName(), project) : model.getInspectionTool(wrapper.getShortName(), psiElement); assert tw != null; tw.getTool().readSettings(element); } } catch (WriteExternalException | InvalidDataException ignored) { } model.setSingleTool(toolWrapper.getShortName()); return model; }