public void writeExternal(@NotNull Element inspectionElement) {
    if (myTools != null) {
      for (ScopeToolState state : myTools) {
        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()));
        String keyExternalName = state.getEditorAttributesExternalName();
        if (keyExternalName != null) {
          scopeElement.setAttribute("editorAttributes", keyExternalName);
        }
        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()));
    @Nullable String attributesKey = myDefaultState.getEditorAttributesExternalName();
    if (attributesKey != null) {
      inspectionElement.setAttribute("editorAttributes", attributesKey);
    }
    InspectionToolWrapper<?,?> toolWrapper = myDefaultState.getTool();
    if (toolWrapper.isInitialized()) {
      ScopeToolState.tryWriteSettings(toolWrapper.getTool(), inspectionElement);
    }
  }
public void writeExternal(@NotNull Element inspectionElement)