private void copyToolsConfigurations(InspectionProfileImpl profile) {
   try {
     for (ToolsImpl toolList : profile.myTools.values()) {
       final ToolsImpl tools = myTools.get(toolList.getShortName());
       final ScopeToolState defaultState = toolList.getDefaultState();
       tools.setDefaultState(
           copyToolSettings((InspectionTool) defaultState.getTool()),
           defaultState.isEnabled(),
           defaultState.getLevel());
       tools.removeAllScopes();
       tools.setEnabled(toolList.isEnabled());
       final List<ScopeToolState> nonDefaultToolStates = toolList.getNonDefaultTools();
       if (nonDefaultToolStates != null) {
         for (ScopeToolState state : nonDefaultToolStates) {
           final InspectionTool inspectionTool =
               copyToolSettings((InspectionTool) state.getTool());
           if (state.getScope() != null) {
             tools.addTool(state.getScope(), inspectionTool, state.isEnabled(), state.getLevel());
           } else {
             tools.addTool(
                 state.getScopeName(), inspectionTool, state.isEnabled(), state.getLevel());
           }
         }
       }
     }
   } catch (WriteExternalException e) {
     LOG.error(e);
   } catch (InvalidDataException e) {
     LOG.error(e);
   }
 }
 @Nullable
 @Override
 public InspectionToolWrapper getEnabledTool(
     @Nullable PsiElement element, boolean includeDoNotShow) {
   if (!myEnabled) return null;
   if (myTools != null && element != null) {
     final Project project = element.getProject();
     final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
     for (ScopeToolState state : myTools) {
       final NamedScope scope = state.getScope(project);
       if (scope != null) {
         final PackageSet set = scope.getValue();
         if (set != null && set.contains(element.getContainingFile(), manager)) {
           return state.isEnabled()
                   && (includeDoNotShow
                       || !HighlightDisplayLevel.DO_NOT_SHOW.equals(state.getLevel()))
               ? state.getTool()
               : null;
         }
       }
     }
   }
   return myDefaultState.isEnabled()
           && (includeDoNotShow
               || !HighlightDisplayLevel.DO_NOT_SHOW.equals(myDefaultState.getLevel()))
       ? myDefaultState.getTool()
       : null;
 }
 @NotNull
 public HighlightDisplayLevel getLevel(final NamedScope scope, Project project) {
   if (myTools != null && scope != null) {
     for (ScopeToolState state : myTools) {
       if (Comparing.equal(state.getScope(project), scope)) {
         return state.getLevel();
       }
     }
   }
   return myDefaultState.getLevel();
 }
 public HighlightDisplayLevel getLevel(PsiElement element) {
   if (myTools == null || element == null) return myDefaultState.getLevel();
   final Project project = element.getProject();
   final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
   for (ScopeToolState state : myTools) {
     final NamedScope scope = state.getScope(project);
     final PackageSet set = scope != null ? scope.getValue() : null;
     if (set != null && set.contains(element.getContainingFile(), manager)) {
       return state.getLevel();
     }
   }
   return myDefaultState.getLevel();
 }
 public Set<HighlightSeverity> getUsedSeverities() {
   LOG.assertTrue(myInitialized);
   final Set<HighlightSeverity> result = new HashSet<HighlightSeverity>();
   for (ToolsImpl tools : myTools.values()) {
     for (ScopeToolState state : tools.getTools()) {
       result.add(state.getLevel().getSeverity());
     }
   }
   return result;
 }
 public void setScope(int idx, NamedScope namedScope) {
   if (myTools != null && myTools.size() > idx && idx >= 0) {
     final ScopeToolState scopeToolState = myTools.get(idx);
     InspectionToolWrapper toolWrapper = scopeToolState.getTool();
     myTools.remove(idx);
     myTools.add(
         idx,
         new ScopeToolState(
             namedScope, toolWrapper, scopeToolState.isEnabled(), scopeToolState.getLevel()));
   }
 }
 public void writeExternal(@NotNull Element inspectionElement) throws WriteExternalException {
   if (myTools != null) {
     for (ScopeToolState state : myTools) {
       final Element scopeElement = new Element("scope");
       scopeElement.setAttribute("name", state.getScopeName());
       scopeElement.setAttribute(LEVEL_ATTRIBUTE, state.getLevel().getName());
       scopeElement.setAttribute(ENABLED_ATTRIBUTE, Boolean.toString(state.isEnabled()));
       InspectionToolWrapper toolWrapper = state.getTool();
       if (toolWrapper.isInitialized()) {
         toolWrapper.getTool().writeSettings(scopeElement);
       }
       inspectionElement.addContent(scopeElement);
     }
   }
   inspectionElement.setAttribute(ENABLED_ATTRIBUTE, Boolean.toString(isEnabled()));
   inspectionElement.setAttribute(LEVEL_ATTRIBUTE, getLevel().getName());
   inspectionElement.setAttribute(
       ENABLED_BY_DEFAULT_ATTRIBUTE, Boolean.toString(myDefaultState.isEnabled()));
   InspectionToolWrapper toolWrapper = myDefaultState.getTool();
   if (toolWrapper.isInitialized()) {
     toolWrapper.getTool().writeSettings(inspectionElement);
   }
 }
 public HighlightDisplayLevel getLevel() {
   return myDefaultState.getLevel();
 }