Search in sources :

Example 1 with Accessor

use of com.intellij.util.xmlb.Accessor in project intellij-community by JetBrains.

the class XDebuggerBreakpointsContextProvider method saveContext.

@Override
public void saveContext(Element toElement) throws WriteExternalException {
    XBreakpointManagerImpl.BreakpointManagerState state = myBreakpointManager.getState();
    Element serialize = XmlSerializer.serialize(state, new SerializationFilter() {

        @Override
        public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
            return accessor.read(bean) != null;
        }
    });
    toElement.addContent(serialize.removeContent());
}
Also used : SerializationFilter(com.intellij.util.xmlb.SerializationFilter) Element(org.jdom.Element) Accessor(com.intellij.util.xmlb.Accessor) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)

Example 2 with Accessor

use of com.intellij.util.xmlb.Accessor in project intellij-community by JetBrains.

the class XDebuggerWatchesProvider method saveContext.

@Override
public void saveContext(Element toElement) throws WriteExternalException {
    XDebuggerWatchesManager.WatchesManagerState state = myWatchesManager.getState();
    Element serialize = XmlSerializer.serialize(state, new SerializationFilter() {

        @Override
        public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
            return accessor.read(bean) != null;
        }
    });
    toElement.addContent(serialize.removeContent());
}
Also used : XDebuggerWatchesManager(com.intellij.xdebugger.impl.XDebuggerWatchesManager) SerializationFilter(com.intellij.util.xmlb.SerializationFilter) Element(org.jdom.Element) Accessor(com.intellij.util.xmlb.Accessor)

Example 3 with Accessor

use of com.intellij.util.xmlb.Accessor 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 4 with Accessor

use of com.intellij.util.xmlb.Accessor in project intellij-community by JetBrains.

the class PersistableCodeStyleSchemes method getState.

@Nullable
@Override
public Element getState() {
    CodeStyleScheme currentScheme = getCurrentScheme();
    CURRENT_SCHEME_NAME = currentScheme == null ? null : currentScheme.getName();
    return XmlSerializer.serialize(this, new SerializationFilter() {

        @Override
        public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
            if ("CURRENT_SCHEME_NAME".equals(accessor.getName())) {
                return !CodeStyleSchemeImpl.DEFAULT_SCHEME_NAME.equals(accessor.read(bean));
            } else {
                return accessor.getValueClass().equals(String.class);
            }
        }
    });
}
Also used : CodeStyleScheme(com.intellij.psi.codeStyle.CodeStyleScheme) SerializationFilter(com.intellij.util.xmlb.SerializationFilter) Accessor(com.intellij.util.xmlb.Accessor) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with Accessor

use of com.intellij.util.xmlb.Accessor in project intellij-community by JetBrains.

the class LoggerInitializedWithForeignClassInspectionBase method writeSettings.

@Override
public void writeSettings(@NotNull Element element) throws WriteExternalException {
    loggerClassName = formatString(loggerFactoryClassNames);
    loggerFactoryMethodName = formatString(loggerFactoryMethodNames);
    XmlSerializer.serializeInto(this, element, new SerializationFilterBase() {

        @Override
        protected boolean accepts(@NotNull Accessor accessor, @NotNull Object bean, @Nullable Object beanValue) {
            if ("loggerClassName".equals(accessor.getName()) && DEFAULT_LOGGER_CLASS_NAMES.equals(beanValue)) {
                return false;
            }
            if ("loggerFactoryMethodNames".equals(accessor.getName()) && DEFAULT_FACTORY_METHOD_NAMES.equals(beanValue)) {
                return false;
            }
            return true;
        }
    });
}
Also used : SerializationFilterBase(com.intellij.util.xmlb.SerializationFilterBase) Accessor(com.intellij.util.xmlb.Accessor)

Aggregations

Accessor (com.intellij.util.xmlb.Accessor)5 SerializationFilter (com.intellij.util.xmlb.SerializationFilter)3 Element (org.jdom.Element)3 CodeStyleScheme (com.intellij.psi.codeStyle.CodeStyleScheme)1 SerializationFilterBase (com.intellij.util.xmlb.SerializationFilterBase)1 SkipDefaultValuesSerializationFilters (com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters)1 XDebuggerWatchesManager (com.intellij.xdebugger.impl.XDebuggerWatchesManager)1 XBreakpointManagerImpl (com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)1 Nullable (org.jetbrains.annotations.Nullable)1 ProcessorConfigProfile (org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile)1