private void writeState(final Element element) {
   JDOMExternalizerUtil.writeField(
       element, INSTRUMENTATION_TYPE_NAME, myInstrumentationType.toString());
   JDOMExternalizerUtil.writeField(element, LANGUAGE_ANNOTATION_NAME, myLanguageAnnotation);
   JDOMExternalizerUtil.writeField(element, PATTERN_ANNOTATION_NAME, myPatternAnnotation);
   JDOMExternalizerUtil.writeField(element, SUBST_ANNOTATION_NAME, mySubstAnnotation);
   if (myIncludeUncomputablesAsLiterals) {
     JDOMExternalizerUtil.writeField(element, INCLUDE_UNCOMPUTABLES_AS_LITERALS, "true");
   }
   if (mySourceModificationAllowed) {
     JDOMExternalizerUtil.writeField(element, SOURCE_MODIFICATION_ALLOWED, "true");
   }
   switch (myDfaOption) {
     case OFF:
       break;
     case RESOLVE:
       JDOMExternalizerUtil.writeField(element, RESOLVE_REFERENCES, Boolean.TRUE.toString());
       break;
     case ASSIGNMENTS:
       JDOMExternalizerUtil.writeField(
           element, LOOK_FOR_VAR_ASSIGNMENTS, Boolean.TRUE.toString());
       break;
     case DFA:
       JDOMExternalizerUtil.writeField(element, USE_DFA_IF_AVAILABLE, Boolean.TRUE.toString());
       break;
   }
 }
 static boolean shouldLoadPlugins() {
   try {
     // no plugins during bootstrap
     Class.forName("com.intellij.openapi.extensions.Extensions");
   } catch (ClassNotFoundException e) {
     return false;
   }
   //noinspection HardCodedStringLiteral
   final String loadPlugins = System.getProperty("idea.load.plugins");
   return loadPlugins == null || Boolean.TRUE.toString().equals(loadPlugins);
 }
 @Override
 public void writeExternal(Element element) throws WriteExternalException {
   for (String s : myGroupPath) {
     Element path = new Element(PATH);
     path.setAttribute(VALUE, s);
     element.addContent(path);
   }
   if (myComponent instanceof String) {
     element.setAttribute(VALUE, (String) myComponent);
     element.setAttribute(IS_ACTION, Boolean.TRUE.toString());
   } else if (myComponent instanceof Separator) {
     element.setAttribute(SEPARATOR, Boolean.TRUE.toString());
   } else if (myComponent instanceof Group) {
     final String groupId =
         ((Group) myComponent).getId() != null && ((Group) myComponent).getId().length() != 0
             ? ((Group) myComponent).getId()
             : ((Group) myComponent).getName();
     element.setAttribute(VALUE, groupId != null ? groupId : "");
     element.setAttribute(IS_GROUP, Boolean.TRUE.toString());
   }
   element.setAttribute(ACTION_TYPE, Integer.toString(myActionType));
   element.setAttribute(POSITION, Integer.toString(myAbsolutePosition));
   DefaultJDOMExternalizer.writeExternal(this, element);
 }
  public void readDirectoryMappings(final Element element) {
    myMappings.clear();

    final List<VcsDirectoryMapping> mappingsList = new ArrayList<VcsDirectoryMapping>();
    boolean haveNonEmptyMappings = false;
    for (Element child : element.getChildren(ELEMENT_MAPPING)) {
      final String vcs = child.getAttributeValue(ATTRIBUTE_VCS);
      if (vcs != null && !vcs.isEmpty()) {
        haveNonEmptyMappings = true;
      }
      VcsDirectoryMapping mapping =
          new VcsDirectoryMapping(child.getAttributeValue(ATTRIBUTE_DIRECTORY), vcs);
      mappingsList.add(mapping);

      Element rootSettingsElement = child.getChild(ELEMENT_ROOT_SETTINGS);
      if (rootSettingsElement != null) {
        String className = rootSettingsElement.getAttributeValue(ATTRIBUTE_CLASS);
        AbstractVcs vcsInstance = findVcsByName(mapping.getVcs());
        if (vcsInstance != null && className != null) {
          final VcsRootSettings rootSettings = vcsInstance.createEmptyVcsRootSettings();
          if (rootSettings != null) {
            try {
              rootSettings.readExternal(rootSettingsElement);
              mapping.setRootSettings(rootSettings);
            } catch (InvalidDataException e) {
              LOG.error(
                  "Failed to load VCS root settings class "
                      + className
                      + " for VCS "
                      + vcsInstance.getClass().getName(),
                  e);
            }
          }
        }
      }
    }
    boolean defaultProject =
        Boolean.TRUE.toString().equals(element.getAttributeValue(ATTRIBUTE_DEFAULT_PROJECT));
    // run autodetection if there's no VCS in default project and
    if (haveNonEmptyMappings || !defaultProject) {
      myMappingsLoaded = true;
    }
    myMappings.setDirectoryMappings(mappingsList);
  }
 public void writeDirectoryMappings(final Element element) {
   if (myProject.isDefault()) {
     element.setAttribute(ATTRIBUTE_DEFAULT_PROJECT, Boolean.TRUE.toString());
   }
   for (VcsDirectoryMapping mapping : getDirectoryMappings()) {
     Element child = new Element(ELEMENT_MAPPING);
     child.setAttribute(ATTRIBUTE_DIRECTORY, mapping.getDirectory());
     child.setAttribute(ATTRIBUTE_VCS, mapping.getVcs());
     final VcsRootSettings rootSettings = mapping.getRootSettings();
     if (rootSettings != null) {
       Element rootSettingsElement = new Element(ELEMENT_ROOT_SETTINGS);
       rootSettingsElement.setAttribute(ATTRIBUTE_CLASS, rootSettings.getClass().getName());
       try {
         rootSettings.writeExternal(rootSettingsElement);
         child.addContent(rootSettingsElement);
       } catch (WriteExternalException e) {
         // don't add element
       }
     }
     element.addContent(child);
   }
 }