Search in sources :

Example 1 with SkipDefaultValuesSerializationFilters

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());
        }
    }
}
Also used : SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) Element(org.jdom.Element) XExpression(com.intellij.xdebugger.XExpression) XExpressionState(com.intellij.xdebugger.impl.breakpoints.XExpressionState)

Example 2 with 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;
}
Also used : SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) Element(org.jdom.Element)

Example 3 with SkipDefaultValuesSerializationFilters

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;
}
Also used : ArtifactPropertiesState(org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState) SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) Element(org.jdom.Element) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with SkipDefaultValuesSerializationFilters

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;
}
Also used : SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) Element(org.jdom.Element) ProcessorConfigProfile(org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile) Accessor(com.intellij.util.xmlb.Accessor)

Example 5 with SkipDefaultValuesSerializationFilters

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;
    }
}
Also used : PersistentStateComponent(com.intellij.openapi.components.PersistentStateComponent) SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) Element(org.jdom.Element)

Aggregations

SkipDefaultValuesSerializationFilters (com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters)15 Element (org.jdom.Element)10 PersistentStateComponent (com.intellij.openapi.components.PersistentStateComponent)1 Accessor (com.intellij.util.xmlb.Accessor)1 XExpression (com.intellij.xdebugger.XExpression)1 XExpressionState (com.intellij.xdebugger.impl.breakpoints.XExpressionState)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 ProcessorConfigProfile (org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile)1 JpsModelSerializerExtension (org.jetbrains.jps.model.serialization.JpsModelSerializerExtension)1 ArtifactPropertiesState (org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState)1