use of com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters in project intellij-community by JetBrains.
the class DebuggerUtilsImpl method writeTextWithImports.
@Override
public void writeTextWithImports(Element root, String name, TextWithImports value) {
if (value.getKind() == CodeFragmentKind.EXPRESSION) {
JDOMExternalizerUtil.writeField(root, name, value.toExternalForm());
} else {
Element element = JDOMExternalizerUtil.writeOption(root, name);
XExpression expression = TextWithImportsImpl.toXExpression(value);
if (expression != null) {
XmlSerializer.serializeInto(new XExpressionState(expression), element, new SkipDefaultValuesSerializationFilters());
}
}
}
use of com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters in project intellij-community by JetBrains.
the class ArtifactManagerImpl method serializePackagingElement.
private static Element serializePackagingElement(PackagingElement<?> packagingElement) {
Element element = new Element(PACKAGING_ELEMENT_NAME);
element.setAttribute(TYPE_ID_ATTRIBUTE, packagingElement.getType().getId());
final Object bean = packagingElement.getState();
if (bean != null) {
XmlSerializer.serializeInto(bean, element, new SkipDefaultValuesSerializationFilters());
}
if (packagingElement instanceof CompositePackagingElement) {
for (PackagingElement<?> child : ((CompositePackagingElement<?>) packagingElement).getChildren()) {
element.addContent(serializePackagingElement(child));
}
}
return element;
}
use of com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters in project intellij-community by JetBrains.
the class ArtifactManagerImpl method serializeProperties.
@Nullable
private static <S> ArtifactPropertiesState serializeProperties(ArtifactPropertiesProvider provider, ArtifactProperties<S> properties) {
final ArtifactPropertiesState state = new ArtifactPropertiesState();
state.setId(provider.getId());
final Element options = new Element("options");
XmlSerializer.serializeInto(properties.getState(), options, new SkipDefaultValuesSerializationFilters());
if (options.getContent().isEmpty() && options.getAttributes().isEmpty())
return null;
state.setOptions(options);
return state;
}
use of com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters in project intellij-community by JetBrains.
the class CompilerConfigurationImpl method getState.
@Override
public Element getState() {
Element state = new Element("state");
XmlSerializer.serializeInto(myState, state, new SkipDefaultValuesSerializationFilters() {
@Override
public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
return super.accepts(accessor, bean);
}
});
if (!myAddNotNullAssertions) {
addChild(state, JpsJavaCompilerConfigurationSerializer.ADD_NOTNULL_ASSERTIONS).setAttribute(JpsJavaCompilerConfigurationSerializer.ENABLED, String.valueOf(myAddNotNullAssertions));
}
if (myExcludesConfiguration.getExcludeEntryDescriptions().length > 0) {
myExcludesConfiguration.writeExternal(addChild(state, JpsJavaCompilerConfigurationSerializer.EXCLUDE_FROM_COMPILE));
}
Element resourceExtensions = new Element(JpsJavaCompilerConfigurationSerializer.RESOURCE_EXTENSIONS);
for (String pattern : getRegexpPatterns()) {
addChild(resourceExtensions, JpsJavaCompilerConfigurationSerializer.ENTRY).setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, pattern);
}
if (!JDOMUtil.isEmpty(resourceExtensions)) {
state.addContent(resourceExtensions);
}
if ((myWildcardPatternsInitialized || !myWildcardPatterns.isEmpty()) && !DEFAULT_WILDCARD_PATTERNS.equals(myWildcardPatterns)) {
final Element wildcardPatterns = addChild(state, JpsJavaCompilerConfigurationSerializer.WILDCARD_RESOURCE_PATTERNS);
for (final String wildcardPattern : myWildcardPatterns) {
addChild(wildcardPatterns, JpsJavaCompilerConfigurationSerializer.ENTRY).setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, wildcardPattern);
}
}
Element annotationProcessingSettings = new Element(JpsJavaCompilerConfigurationSerializer.ANNOTATION_PROCESSING);
Element profileElement = new Element("profile");
profileElement.setAttribute("default", "true");
AnnotationProcessorProfileSerializer.writeExternal(myDefaultProcessorsProfile, profileElement);
if (!JDOMUtil.isEmpty(profileElement, 2)) {
annotationProcessingSettings.addContent(profileElement);
}
for (ProcessorConfigProfile profile : myModuleProcessorProfiles) {
Element element = new Element("profile");
AnnotationProcessorProfileSerializer.writeExternal(profile, element);
annotationProcessingSettings.addContent(element);
}
if (!JDOMUtil.isEmpty(annotationProcessingSettings)) {
state.addContent(annotationProcessingSettings);
}
if (!StringUtil.isEmpty(myBytecodeTargetLevel) || !myModuleBytecodeTarget.isEmpty()) {
final Element bytecodeTarget = addChild(state, JpsJavaCompilerConfigurationSerializer.BYTECODE_TARGET_LEVEL);
if (!StringUtil.isEmpty(myBytecodeTargetLevel)) {
bytecodeTarget.setAttribute(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE, myBytecodeTargetLevel);
}
if (!myModuleBytecodeTarget.isEmpty()) {
final List<String> moduleNames = new ArrayList<>(myModuleBytecodeTarget.keySet());
Collections.sort(moduleNames, String.CASE_INSENSITIVE_ORDER);
for (String name : moduleNames) {
final Element moduleElement = addChild(bytecodeTarget, JpsJavaCompilerConfigurationSerializer.MODULE);
moduleElement.setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, name);
final String value = myModuleBytecodeTarget.get(name);
moduleElement.setAttribute(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE, value != null ? value : "");
}
}
}
return state;
}
use of com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters in project intellij-community by JetBrains.
the class FacetUtil method saveFacetConfiguration.
public static Element saveFacetConfiguration(final FacetConfiguration configuration) throws WriteExternalException {
if (configuration instanceof PersistentStateComponent) {
Object state = ((PersistentStateComponent) configuration).getState();
if (state instanceof Element)
return ((Element) state);
return XmlSerializer.serialize(state, new SkipDefaultValuesSerializationFilters());
} else {
final Element config = new Element(JpsFacetSerializer.CONFIGURATION_TAG);
configuration.writeExternal(config);
return config;
}
}
Aggregations