use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class ModuleRunConfigurationManager method getState.
@Nullable
@Override
public Element getState() {
try {
final Element e = new Element("state");
writeExternal(e);
return e;
} catch (WriteExternalException e1) {
LOG.error(e1);
return null;
}
}
use of com.intellij.openapi.util.WriteExternalException in project intellij by bazelbuild.
the class BlazeCommandRunConfiguration method writeExternal.
@Override
@SuppressWarnings("ThrowsUncheckedException")
public void writeExternal(Element element) throws WriteExternalException {
super.writeExternal(element);
if (sanitizeCorruptedDefaultRunConfiguration(element)) {
logger.info("Serializing an apparently corrupted run configuration:\n" + new XMLOutputter().outputString(element), new Exception());
}
if (targetPattern != null) {
Element targetElement = new Element(TARGET_TAG);
targetElement.setText(targetPattern);
if (targetKind != null) {
targetElement.setAttribute(KIND_ATTR, targetKind.toString());
}
element.addContent(targetElement);
}
if (keepInSync != null) {
element.setAttribute(KEEP_IN_SYNC_TAG, Boolean.toString(keepInSync));
}
element.setAttribute(HANDLER_ATTR, handlerProvider.getId());
handler.getState().writeExternal(elementState);
// copy our internal state to the provided Element, skipping items already present
Set<String> baseAttributes = element.getAttributes().stream().map(Attribute::getName).collect(Collectors.toSet());
for (Attribute attribute : elementState.getAttributes()) {
if (!baseAttributes.contains(attribute.getName())) {
element.setAttribute(attribute.clone());
}
}
Set<String> baseChildren = element.getChildren().stream().map(Element::getName).collect(Collectors.toSet());
// The method tag is written by RunManagerImpl *after* this writeExternal call,
// so it isn't already present.
// We still have to avoid writing it ourselves, or we wind up duplicating it.
baseChildren.add(METHOD_TAG);
for (Element child : elementState.getChildren()) {
if (!baseChildren.contains(child.getName())) {
element.addContent(child.clone());
}
}
}
use of com.intellij.openapi.util.WriteExternalException in project intellij by bazelbuild.
the class RunConfigurationSerializer method writeToXml.
public static Element writeToXml(RunConfiguration configuration) {
RunnerAndConfigurationSettings settings = RunManagerImpl.getInstanceImpl(configuration.getProject()).getSettings(configuration);
Element element = new Element("configuration");
try {
runWithPathVariableSet(configuration.getProject(), () -> ((RunnerAndConfigurationSettingsImpl) settings).writeExternal(element));
} catch (WriteExternalException e) {
logger.warn("Error serializing run configuration to XML", e);
}
return element;
}
use of com.intellij.openapi.util.WriteExternalException in project netbeans-mmd-plugin by raydac.
the class MindMapFacetConfiguration method writeExternal.
@Override
public void writeExternal(final Element element) throws WriteExternalException {
try {
for (final String key : this.preferences.keys()) {
Element el = element.getChild(key);
if (el == null) {
el = new Element(key);
element.addContent(el);
}
el.setText(this.preferences.get(key, null));
}
} catch (Exception ex) {
throw new WriteExternalException("Can't write preferences", ex);
}
}
use of com.intellij.openapi.util.WriteExternalException in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRunConfigurationTestCase method doTestProducedConfigurations.
protected void doTestProducedConfigurations(@Nullable PsiElement context) {
assertNotNull(context);
ConfigurationContext configurationContext = new ConfigurationContext(context);
List<ConfigurationFromContext> configurationAndSettings = configurationContext.getConfigurationsFromContext();
Element configurationsElement = new Element("configurations");
if (configurationAndSettings != null) {
for (ConfigurationFromContext setting : configurationAndSettings) {
try {
RunConfiguration configuration = setting.getConfiguration();
Element configurationElement = new Element("configurations");
configurationElement.setAttribute("name", configuration.getName());
configurationElement.setAttribute("class", configuration.getClass().getSimpleName());
configuration.writeExternal(configurationElement);
configurationsElement.addContent(configurationElement);
} catch (WriteExternalException e) {
throw new RuntimeException(e);
}
}
}
assertSameLinesWithFile(getTestDataPath() + "/" + getTestName(true) + ".xml", JDOMUtil.writeElement(configurationsElement));
}
Aggregations