diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java index 55a72aa7dbb3..2e7751fbf219 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java @@ -18,7 +18,6 @@ import com.intellij.util.EventDispatcher; import com.intellij.util.containers.hash.LinkedHashMap; import com.intellij.util.xmlb.SkipDefaultsSerializationFilter; import com.intellij.util.xmlb.XmlSerializer; -import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.Transient; import com.intellij.util.xmlb.annotations.XCollection; import org.jdom.Element; @@ -202,8 +201,7 @@ public class DebuggerSettings implements Cloneable, PersistentStateComponent getCapturePoints() { return myCapturePoints; } diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java index 4ef874f4fe55..67a4e61157ae 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaBreakpointProperties.java @@ -8,7 +8,6 @@ import com.intellij.openapi.util.Comparing; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.util.ArrayUtil; import com.intellij.util.xmlb.annotations.OptionTag; -import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.XCollection; import com.intellij.xdebugger.breakpoints.XBreakpointProperties; import org.jetbrains.annotations.Nullable; @@ -27,8 +26,7 @@ public class JavaBreakpointProperties extend private boolean INSTANCE_FILTERS_ENABLED = false; private InstanceFilter[] myInstanceFilters; - @Tag("instance-filters") - @XCollection + @XCollection(propertyElementName = "instance-filters") public InstanceFilter[] getInstanceFilters() { return myInstanceFilters != null ? myInstanceFilters : InstanceFilter.EMPTY_ARRAY; } @@ -49,8 +47,7 @@ public class JavaBreakpointProperties extend } } - @Tag("class-filters") - @XCollection + @XCollection(propertyElementName = "class-filters") public final ClassFilter[] getClassFilters() { return myClassFilters != null ? myClassFilters : ClassFilter.EMPTY_ARRAY; } @@ -68,8 +65,7 @@ public class JavaBreakpointProperties extend return Comparing.equal(a, b); } - @Tag("class-exclusion-filters") - @XCollection + @XCollection(propertyElementName = "class-exclusion-filters") public ClassFilter[] getClassExclusionFilters() { return myClassExclusionFilters != null ? myClassExclusionFilters : ClassFilter.EMPTY_ARRAY; } diff --git a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaExceptionBreakpointProperties.java b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaExceptionBreakpointProperties.java index 92c756e288c9..e019ca3afb8d 100644 --- a/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaExceptionBreakpointProperties.java +++ b/java/debugger/impl/src/org/jetbrains/java/debugger/breakpoints/properties/JavaExceptionBreakpointProperties.java @@ -6,7 +6,6 @@ package org.jetbrains.java.debugger.breakpoints.properties; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.util.xmlb.annotations.Attribute; import com.intellij.util.xmlb.annotations.OptionTag; -import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.Nullable; @@ -66,8 +65,7 @@ public class JavaExceptionBreakpointProperties extends JavaBreakpointProperties< return changed; } - @Tag("catch-class-filters") - @XCollection + @XCollection(propertyElementName = "catch-class-filters") public final ClassFilter[] getCatchClassFilters() { return myCatchClassFilters != null ? myCatchClassFilters : ClassFilter.EMPTY_ARRAY; } @@ -78,8 +76,7 @@ public class JavaExceptionBreakpointProperties extends JavaBreakpointProperties< return changed; } - @Tag("catch-class-exclusion-filters") - @XCollection + @XCollection(propertyElementName = "catch-class-exclusion-filters") public ClassFilter[] getCatchClassExclusionFilters() { return myCatchClassExclusionFilters != null ? myCatchClassExclusionFilters : ClassFilter.EMPTY_ARRAY; } diff --git a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java index 1157ab5ab212..fbbabd07dfa3 100644 --- a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java +++ b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsProjectConfiguration.java @@ -63,7 +63,8 @@ public class JsonSchemaMappingsProjectConfiguration implements PersistentStateCo } static class MyState { - @Tag("state") @XCollection + @Tag("state") + @XCollection public Map myState = new TreeMap<>(); public MyState() { diff --git a/platform/core-api/src/com/intellij/ide/plugins/PluginBean.java b/platform/core-api/src/com/intellij/ide/plugins/PluginBean.java index 8662877cc321..22b279707a09 100644 --- a/platform/core-api/src/com/intellij/ide/plugins/PluginBean.java +++ b/platform/core-api/src/com/intellij/ide/plugins/PluginBean.java @@ -12,16 +12,13 @@ import java.util.ArrayList; import java.util.List; public class PluginBean { - @Tag(APPLICATION_COMPONENTS) - @XCollection + @XCollection(propertyElementName = APPLICATION_COMPONENTS) public OldComponentConfig[] applicationComponents; - @Tag(PROJECT_COMPONENTS) - @XCollection + @XCollection(propertyElementName = PROJECT_COMPONENTS) public OldComponentConfig[] projectComponents; - @Tag(MODULE_COMPONENTS) - @XCollection + @XCollection(propertyElementName = MODULE_COMPONENTS) public OldComponentConfig[] moduleComponents; @NonNls public static final String APPLICATION_COMPONENTS = "application-components"; diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSettings.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSettings.java index a328b4192c7b..8364cf61fdf0 100644 --- a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSettings.java +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSettings.java @@ -22,8 +22,7 @@ public class PushSettings implements PersistentStateComponent FORCE_PUSH_TARGETS = ContainerUtil.newArrayList(); } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/TaskActivationState.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/TaskActivationState.java index 96a5ce6f5e64..8523aa531582 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/TaskActivationState.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/TaskActivationState.java @@ -10,38 +10,27 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; -/** -* @author Vladislav.Soroka -* @since 10/30/2014 -*/ @Tag("activation") public class TaskActivationState { - @Tag("before_run") - @XCollection(elementName = "task", valueAttributeName = "name") + @XCollection(elementName = "task", valueAttributeName = "name", propertyElementName = "before_run") public List beforeRunTasks = new ArrayList<>(); - @Tag("before_sync") - @XCollection(elementName = "task", valueAttributeName = "name") + @XCollection(elementName = "task", valueAttributeName = "name", propertyElementName = "before_sync") public List beforeSyncTasks = new ArrayList<>(); - @Tag("after_sync") - @XCollection(elementName = "task", valueAttributeName = "name") + @XCollection(elementName = "task", valueAttributeName = "name", propertyElementName = "after_sync") public List afterSyncTasks = new ArrayList<>(); - @Tag("before_compile") - @XCollection(elementName = "task", valueAttributeName = "name") + @XCollection(elementName = "task", valueAttributeName = "name", propertyElementName = "before_compile") public List beforeCompileTasks = new ArrayList<>(); - @Tag("after_compile") - @XCollection(elementName = "task", valueAttributeName = "name") + @XCollection(elementName = "task", valueAttributeName = "name", propertyElementName = "after_compile") public List afterCompileTasks = new ArrayList<>(); - @Tag("after_rebuild") - @XCollection(elementName = "task", valueAttributeName = "name") + @XCollection(elementName = "task", valueAttributeName = "name", propertyElementName = "after_rebuild") public List afterRebuildTask = new ArrayList<>(); - @Tag("before_rebuild") - @XCollection(elementName = "task", valueAttributeName = "name") + @XCollection(elementName = "task", valueAttributeName = "name", propertyElementName = "before_rebuild") public List beforeRebuildTask = new ArrayList<>(); public boolean isEmpty() { diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifacts.java b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifacts.java index f7e8fd49b0ff..6a7da3460a70 100644 --- a/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifacts.java +++ b/platform/lang-api/src/com/intellij/facet/frameworks/beans/Artifacts.java @@ -7,7 +7,6 @@ import com.intellij.util.xmlb.annotations.Property; import com.intellij.util.xmlb.annotations.XCollection; public class Artifacts { - @Property(surroundWithTag = false) @XCollection public Artifact[] myVersions; diff --git a/platform/lang-impl/src/com/intellij/execution/startup/ProjectStartupConfigurationBase.java b/platform/lang-impl/src/com/intellij/execution/startup/ProjectStartupConfigurationBase.java index 7d0fd8de86b3..6e0830b101d1 100644 --- a/platform/lang-impl/src/com/intellij/execution/startup/ProjectStartupConfigurationBase.java +++ b/platform/lang-impl/src/com/intellij/execution/startup/ProjectStartupConfigurationBase.java @@ -17,8 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; public class ProjectStartupConfigurationBase implements PersistentStateComponent { - @Tag("configurations") - @XCollection + @XCollection(propertyElementName = "configurations") private final List myList; protected ProjectStartupConfigurationBase() { diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionByTypeElement.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionByTypeElement.java index 0510b5ab8af1..6357c2eeb5f2 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionByTypeElement.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionByTypeElement.java @@ -49,8 +49,7 @@ public class DisabledAutodetectionByTypeElement { return myFacetTypeId; } - @Tag("modules") - @XCollection + @XCollection(propertyElementName = "modules") public List getModuleElements() { return myModuleElements; } diff --git a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionInfo.java b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionInfo.java index c78a040e55c3..6c8b000bcdab 100644 --- a/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionInfo.java +++ b/platform/lang-impl/src/com/intellij/framework/detection/impl/exclude/old/DisabledAutodetectionInfo.java @@ -1,11 +1,9 @@ /* * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ - package com.intellij.framework.detection.impl.exclude.old; import com.intellij.util.containers.SortedList; -import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,8 +16,7 @@ import java.util.List; public class DisabledAutodetectionInfo { private List myElements = new SortedList<>(DisabledAutodetectionByTypeElement.COMPARATOR); - @Tag("autodetection-disabled") - @XCollection + @XCollection(propertyElementName = "autodetection-disabled") public List getElements() { return myElements; } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewFileNestingService.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewFileNestingService.java index 93e8980168ca..a85ca28a2ca3 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewFileNestingService.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewFileNestingService.java @@ -13,7 +13,6 @@ import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.util.ModificationTracker; import com.intellij.util.containers.SortedList; import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.XCollection; import org.jetbrains.annotations.NotNull; @@ -96,8 +95,7 @@ public class ProjectViewFileNestingService implements PersistentStateComponent

myRules = new SortedList<>(Comparator.comparing(o -> o.getParentFileSuffix())); public MyState() { diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/AutomaticModuleUnloader.kt b/platform/lang-impl/src/com/intellij/openapi/module/impl/AutomaticModuleUnloader.kt index 29bdd2c017d7..71f04942e968 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/AutomaticModuleUnloader.kt +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/AutomaticModuleUnloader.kt @@ -13,7 +13,6 @@ import com.intellij.openapi.module.ModuleDescription import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ui.configuration.ConfigureUnloadedModulesDialog -import com.intellij.util.xmlb.annotations.Tag import com.intellij.util.xmlb.annotations.XCollection import com.intellij.xml.util.XmlStringUtil @@ -154,8 +153,7 @@ class AutomaticModuleUnloader(private val project: Project) : PersistentStateCom } class LoadedModulesListStorage { - @Tag("loaded-modules") - @XCollection(elementName = "module", valueAttributeName = "name") + @get:XCollection(elementName = "module", valueAttributeName = "name", propertyElementName = "loaded-modules") var modules: MutableList = ArrayList() } diff --git a/platform/platform-api/src/com/intellij/ide/ui/SplitterProportionsDataImpl.java b/platform/platform-api/src/com/intellij/ide/ui/SplitterProportionsDataImpl.java index 7a0fcf7ff010..ccc0ccf7b7c5 100644 --- a/platform/platform-api/src/com/intellij/ide/ui/SplitterProportionsDataImpl.java +++ b/platform/platform-api/src/com/intellij/ide/ui/SplitterProportionsDataImpl.java @@ -1,27 +1,12 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ - package com.intellij.ide.ui; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.ui.SplitterProportionsData; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.util.SmartList; import com.intellij.util.text.StringTokenizer; import com.intellij.util.xmlb.Converter; @@ -29,7 +14,6 @@ import com.intellij.util.xmlb.annotations.Tag; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.awt.*; import java.util.List; @@ -54,8 +38,7 @@ public class SplitterProportionsDataImpl implements SplitterProportionsData { proportions.add(prop); } if (root instanceof Container) { - Component[] children = ((Container)root).getComponents(); - for (Component child : children) { + for (Component child : ((Container)root).getComponents()) { doSaveSplitterProportions(child); } } @@ -100,7 +83,7 @@ public class SplitterProportionsDataImpl implements SplitterProportionsData { } @Override - public void readExternal(Element element) throws InvalidDataException { + public void readExternal(Element element) { proportions.clear(); String prop = element.getAttributeValue(ATTRIBUTE_PROPORTIONS); String version = element.getAttributeValue(ATTRIBUTE_VERSION); @@ -114,7 +97,7 @@ public class SplitterProportionsDataImpl implements SplitterProportionsData { } @Override - public void writeExternal(Element element) throws WriteExternalException { + public void writeExternal(Element element) { StringBuilder result = new StringBuilder(); String sep = ""; for (Float proportion : proportions) { @@ -127,7 +110,7 @@ public class SplitterProportionsDataImpl implements SplitterProportionsData { } public static final class SplitterProportionsConverter extends Converter { - @Nullable + @NotNull @Override public SplitterProportionsDataImpl fromString(@NotNull String value) { SplitterProportionsDataImpl data = new SplitterProportionsDataImpl(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsStateService.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsStateService.java index acf4772549ec..17af491b64b3 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsStateService.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsStateService.java @@ -77,8 +77,7 @@ public class MasterDetailsStateService implements PersistentStateComponent myStates = new ArrayList<>(); - @Tag("states") - @XCollection + @XCollection(style = XCollection.Style.v2) public List getStates() { return myStates; } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/SplitterProportionsData.java b/platform/platform-api/src/com/intellij/openapi/ui/SplitterProportionsData.java index 0e4f8211f105..7dc4785c0a3b 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/SplitterProportionsData.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/SplitterProportionsData.java @@ -1,19 +1,6 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ - package com.intellij.openapi.ui; import com.intellij.openapi.util.JDOMExternalizable; @@ -22,7 +9,6 @@ import org.jetbrains.annotations.NonNls; import java.awt.*; public interface SplitterProportionsData extends JDOMExternalizable { - void saveSplitterProportions(Component root); void restoreSplitterProportions(Component root); diff --git a/platform/projectModel-api/src/com/intellij/openapi/components/StoredProperty.kt b/platform/projectModel-api/src/com/intellij/openapi/components/StoredProperty.kt index 31574e2572e7..c5812d2e8907 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/components/StoredProperty.kt +++ b/platform/projectModel-api/src/com/intellij/openapi/components/StoredProperty.kt @@ -37,6 +37,12 @@ abstract class BaseState : SerializationFilter, ModificationTracker { return result } + fun bean(defaultValue: T): StoredPropertyBase { + val result = ObjectStoredProperty(defaultValue) + properties.add(result) + return result + } + /** * Empty string is always normalized to null. */ @@ -52,6 +58,12 @@ abstract class BaseState : SerializationFilter, ModificationTracker { return result } + fun storedProperty(defaultValue: Long = 0): StoredPropertyBase { + val result = LongStoredProperty(defaultValue) + properties.add(result) + return result + } + fun storedProperty(defaultValue: Float = 0f): StoredPropertyBase { val result = FloatStoredProperty(defaultValue) properties.add(result) @@ -221,6 +233,35 @@ private class IntStoredProperty(override val defaultValue: Int) : StoredProperty } } +private class LongStoredProperty(override val defaultValue: Long) : StoredPropertyBase() { + override var value = defaultValue + + override operator fun getValue(thisRef: BaseState, property: KProperty<*>) = value + + override fun setValue(thisRef: BaseState, property: KProperty<*>, value: Long) { + if (this.value != value) { + thisRef.ownModificationCount++ + this.value = value + } + } + + override fun equals(other: Any?) = this === other || (other is LongStoredProperty && value == other.value) + + override fun hashCode() = value.hashCode() + + override fun toString() = if (value == defaultValue) "" else value.toString() + + override fun setValue(other: StoredProperty): Boolean { + val newValue = (other as LongStoredProperty).value + if (newValue == value) { + return false + } + + value = newValue + return true + } +} + private class FloatStoredProperty(override val defaultValue: Float) : StoredPropertyBase() { override var value = defaultValue diff --git a/platform/tasks-platform-impl/src/com/intellij/tasks/context/XDebuggerBreakpointsContextProvider.java b/platform/tasks-platform-impl/src/com/intellij/tasks/context/XDebuggerBreakpointsContextProvider.java index 9339c2de24e7..7bc2b4b09463 100644 --- a/platform/tasks-platform-impl/src/com/intellij/tasks/context/XDebuggerBreakpointsContextProvider.java +++ b/platform/tasks-platform-impl/src/com/intellij/tasks/context/XDebuggerBreakpointsContextProvider.java @@ -18,20 +18,20 @@ package com.intellij.tasks.context; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; -import com.intellij.util.xmlb.Accessor; -import com.intellij.util.xmlb.SerializationFilter; -import com.intellij.util.xmlb.XmlSerializer; import com.intellij.xdebugger.XDebuggerManager; +import com.intellij.xdebugger.impl.BreakpointManagerState; import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import static com.intellij.configurationStore.XmlSerializer.deserialize; +import static com.intellij.configurationStore.XmlSerializer.serialize; + /** * @author Dmitry Avdeev */ public class XDebuggerBreakpointsContextProvider extends WorkingContextProvider { - private final XBreakpointManagerImpl myBreakpointManager; public XDebuggerBreakpointsContextProvider(XDebuggerManager xDebuggerManager) { @@ -52,21 +52,17 @@ public class XDebuggerBreakpointsContextProvider extends WorkingContextProvider @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()); + BreakpointManagerState state = new BreakpointManagerState(); + myBreakpointManager.saveState(state); + Element serialize = serialize(state); + if (serialize != null) { + toElement.addContent(serialize.removeContent()); + } } @Override public void loadContext(Element fromElement) throws InvalidDataException { - XBreakpointManagerImpl.BreakpointManagerState state = - XmlSerializer.deserialize(fromElement, XBreakpointManagerImpl.BreakpointManagerState.class); - myBreakpointManager.loadState(state); + myBreakpointManager.loadState(deserialize(fromElement, BreakpointManagerState.class)); } @Override diff --git a/platform/tasks-platform-impl/src/com/intellij/tasks/context/XDebuggerWatchesProvider.java b/platform/tasks-platform-impl/src/com/intellij/tasks/context/XDebuggerWatchesProvider.java index 12fddd63d7f8..d8d7f8403409 100644 --- a/platform/tasks-platform-impl/src/com/intellij/tasks/context/XDebuggerWatchesProvider.java +++ b/platform/tasks-platform-impl/src/com/intellij/tasks/context/XDebuggerWatchesProvider.java @@ -17,20 +17,20 @@ package com.intellij.tasks.context; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; -import com.intellij.util.xmlb.Accessor; -import com.intellij.util.xmlb.SerializationFilter; -import com.intellij.util.xmlb.XmlSerializer; import com.intellij.xdebugger.XDebuggerManager; +import com.intellij.xdebugger.impl.WatchesManagerState; import com.intellij.xdebugger.impl.XDebuggerManagerImpl; import com.intellij.xdebugger.impl.XDebuggerWatchesManager; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import static com.intellij.configurationStore.XmlSerializer.deserialize; +import static com.intellij.configurationStore.XmlSerializer.serialize; + /** * @author Dmitry Avdeev */ public class XDebuggerWatchesProvider extends WorkingContextProvider { - private final XDebuggerWatchesManager myWatchesManager; public XDebuggerWatchesProvider(XDebuggerManager xDebuggerManager) { @@ -51,26 +51,23 @@ public class XDebuggerWatchesProvider extends WorkingContextProvider { @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()); + WatchesManagerState state = new WatchesManagerState(); + myWatchesManager.saveState(state); + Element serialize = serialize(state); + if (serialize != null) { + toElement.addContent(serialize.removeContent()); + } } @Override public void loadContext(Element fromElement) throws InvalidDataException { - XDebuggerWatchesManager.WatchesManagerState state = - XmlSerializer.deserialize(fromElement, XDebuggerWatchesManager.WatchesManagerState.class); + WatchesManagerState state = deserialize(fromElement, WatchesManagerState.class); myWatchesManager.loadState(state); } @Override public void clearContext() { - myWatchesManager.loadState(null); + myWatchesManager.clearContext(); } } diff --git a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java index b78579945cd0..a4857df9115c 100644 --- a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java @@ -4,6 +4,7 @@ package com.intellij.util.xmlb; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.ArrayUtil; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.AbstractCollection; @@ -57,11 +58,20 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple return newAnnotation == null && (annotation == null || annotation.surroundWithTag()); } + @NotNull + private Class[] getElementTypes() { + if (newAnnotation != null) { + return newAnnotation.elementTypes(); + } + return annotation == null ? ArrayUtil.EMPTY_CLASS_ARRAY : annotation.elementTypes(); + } + @NotNull private synchronized List getElementBindings() { if (itemBindings == null) { Binding binding = serializer.getBinding(itemType); - if (annotation == null || annotation.elementTypes().length == 0) { + Class[] elementTypes = getElementTypes(); + if (elementTypes.length == 0) { itemBindings = binding == null ? Collections.emptyList() : Collections.singletonList(binding); } else { @@ -70,7 +80,7 @@ abstract class AbstractCollectionBinding extends NotNullDeserializeBinding imple itemBindings.add(binding); } - for (Class aClass : annotation.elementTypes()) { + for (Class aClass : elementTypes) { Binding b = serializer.getBinding(aClass); if (b != null && !itemBindings.contains(b)) { itemBindings.add(b); diff --git a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java index 61d45851268c..4eb39663ed9e 100644 --- a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java @@ -457,6 +457,11 @@ public class BeanBinding extends NotNullDeserializeBinding { return new AccessorBindingWrapper(accessor, binding, inline); } + XCollection xCollection = accessor.getAnnotation(XCollection.class); + if (xCollection != null && (xCollection.propertyElementName().length() != 0 || xCollection.style() == XCollection.Style.v2)) { + return new TagBinding(accessor, xCollection.propertyElementName()); + } + return new OptionTagBinding(accessor, accessor.getAnnotation(OptionTag.class)); } } diff --git a/platform/util/src/com/intellij/util/xmlb/TagBinding.java b/platform/util/src/com/intellij/util/xmlb/TagBinding.java index 658df4d3f18d..73b22a4b4543 100644 --- a/platform/util/src/com/intellij/util/xmlb/TagBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/TagBinding.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.util.xmlb; @@ -33,6 +21,12 @@ class TagBinding extends BasePrimitiveBinding implements MultiNodeBinding { myTextIfEmpty = tagAnnotation.textIfEmpty(); } + public TagBinding(@NotNull MutableAccessor accessor, @NotNull String suggestedName) { + super(accessor, suggestedName, null); + + myTextIfEmpty = ""; + } + @Nullable @Override public Object serialize(@NotNull Object o, @Nullable SerializationFilter filter) { diff --git a/platform/util/src/com/intellij/util/xmlb/annotations/XCollection.java b/platform/util/src/com/intellij/util/xmlb/annotations/XCollection.java index 9da44be41fe8..a7995d53e0b7 100644 --- a/platform/util/src/com/intellij/util/xmlb/annotations/XCollection.java +++ b/platform/util/src/com/intellij/util/xmlb/annotations/XCollection.java @@ -12,8 +12,6 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Experimental. - * * ```xml *

- * */ - v1 + v1, + + /** + * Wrap not using option tag (OptionTag), but simple tag (Tag). + * + * + * + */ + v2, } Style style() default Style.v1; diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java index ddb732a4ae8a..74ace4355bf9 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java @@ -70,8 +70,7 @@ public final class VcsConfiguration implements PersistentStateComponent IGNORED_UNREGISTERED_ROOTS = ContainerUtil.newArrayList(); public enum StandardOption { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index 5a81d9f6e004..b39ca5d6274d 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.xdebugger.impl; @@ -1005,12 +993,12 @@ public class XDebugSessionImpl implements XDebugSession { return getSessionName(); } - public void setWatchExpressions(@NotNull XExpression[] watchExpressions) { + public void setWatchExpressions(@NotNull List watchExpressions) { mySessionData.setWatchExpressions(watchExpressions); myDebuggerManager.getWatchesManager().setWatches(getConfigurationName(), watchExpressions); } - XExpression[] getWatchExpressions() { + List getWatchExpressions() { return myDebuggerManager.getWatchesManager().getWatches(getConfigurationName()); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java index 091d3545d6ed..f4ce31303a50 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.xdebugger.impl; @@ -28,7 +16,10 @@ import com.intellij.execution.ui.RunContentManager; import com.intellij.execution.ui.RunContentWithExecutorListener; import com.intellij.notification.NotificationGroup; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.*; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; +import com.intellij.openapi.components.StoragePathMacros; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter; @@ -42,7 +33,6 @@ import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; -import com.intellij.util.xmlb.annotations.Property; import com.intellij.xdebugger.*; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpointListener; @@ -53,7 +43,6 @@ import com.intellij.xdebugger.impl.evaluate.quick.common.ValueLookupManager; import com.intellij.xdebugger.impl.settings.XDebuggerSettingManagerImpl; import com.intellij.xdebugger.impl.ui.ExecutionPointHighlighter; import com.intellij.xdebugger.impl.ui.XDebugSessionTab; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -67,11 +56,8 @@ import java.util.concurrent.atomic.AtomicReference; /** * @author nik */ -@State(name = XDebuggerManagerImpl.COMPONENT_NAME, storages = @Storage(StoragePathMacros.WORKSPACE_FILE)) -public class XDebuggerManagerImpl extends XDebuggerManager - implements NamedComponent, PersistentStateComponent { - - @NonNls public static final String COMPONENT_NAME = "XDebuggerManager"; +@State(name = "XDebuggerManager", storages = @Storage(StoragePathMacros.WORKSPACE_FILE)) +public class XDebuggerManagerImpl extends XDebuggerManager implements PersistentStateComponent { public static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup("Debugger messages", ToolWindowId.DEBUG, false); @@ -82,6 +68,8 @@ public class XDebuggerManagerImpl extends XDebuggerManager private final ExecutionPointHighlighter myExecutionPointHighlighter; private final AtomicReference myActiveSession = new AtomicReference<>(); + private XDebuggerState myState = new XDebuggerState(); + public XDebuggerManagerImpl(final Project project, final StartupManager startupManager, MessageBus messageBus) { myProject = project; myBreakpointManager = new XBreakpointManagerImpl(project, this, startupManager); @@ -172,12 +160,6 @@ public class XDebuggerManagerImpl extends XDebuggerManager return myProject; } - @NotNull - @Override - public String getComponentName() { - return COMPONENT_NAME; - } - @Override @NotNull public XDebugSession startSession(@NotNull ExecutionEnvironment environment, @NotNull XDebugProcessStarter processStarter) throws ExecutionException { @@ -327,7 +309,10 @@ public class XDebuggerManagerImpl extends XDebuggerManager @Override public XDebuggerState getState() { - return new XDebuggerState(myBreakpointManager.getState(), myWatchesManager.getState()); + XDebuggerState state = myState; + myBreakpointManager.saveState(state.getBreakpointManagerState()); + myWatchesManager.saveState(state.getWatchesManagerState()); + return state; } public boolean isFullLineHighlighter() { @@ -336,48 +321,12 @@ public class XDebuggerManagerImpl extends XDebuggerManager @Override public void loadState(@NotNull XDebuggerState state) { - myBreakpointManager.loadState(state.myBreakpointManagerState); - myWatchesManager.loadState(state.myWatchesManagerState); + myState = state; + myBreakpointManager.loadState(state.getBreakpointManagerState()); + myWatchesManager.loadState(state.getWatchesManagerState()); } public void showExecutionPosition() { myExecutionPointHighlighter.navigateTo(); } - - @SuppressWarnings("UnusedDeclaration") - public static class XDebuggerState { - @NotNull - private XBreakpointManagerImpl.BreakpointManagerState myBreakpointManagerState; - @NotNull - private XDebuggerWatchesManager.WatchesManagerState myWatchesManagerState; - - public XDebuggerState() { - this(new XBreakpointManagerImpl.BreakpointManagerState(), new XDebuggerWatchesManager.WatchesManagerState()); - } - - public XDebuggerState(@NotNull XBreakpointManagerImpl.BreakpointManagerState breakpointManagerState, @NotNull XDebuggerWatchesManager.WatchesManagerState watchesManagerState) { - myBreakpointManagerState = breakpointManagerState; - myWatchesManagerState = watchesManagerState; - } - - @NotNull - @Property(surroundWithTag = false) - public XBreakpointManagerImpl.BreakpointManagerState getBreakpointManagerState() { - return myBreakpointManagerState; - } - - public void setBreakpointManagerState(@NotNull final XBreakpointManagerImpl.BreakpointManagerState breakpointManagerState) { - myBreakpointManagerState = breakpointManagerState; - } - - @NotNull - @Property(surroundWithTag = false) - public XDebuggerWatchesManager.WatchesManagerState getWatchesManagerState() { - return myWatchesManagerState; - } - - public void setWatchesManagerState(@NotNull XDebuggerWatchesManager.WatchesManagerState watchesManagerState) { - myWatchesManagerState = watchesManagerState; - } - } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java index 03ab840be119..b00b42cbe4a5 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java @@ -3,37 +3,28 @@ */ package com.intellij.xdebugger.impl; -import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.xmlb.annotations.Attribute; -import com.intellij.util.xmlb.annotations.Property; -import com.intellij.util.xmlb.annotations.Tag; -import com.intellij.util.xmlb.annotations.XCollection; import com.intellij.xdebugger.XExpression; import com.intellij.xdebugger.impl.breakpoints.XExpressionState; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; import java.util.List; import java.util.Map; /** * @author egor */ -public class XDebuggerWatchesManager implements PersistentStateComponent { - private final Map watches = ContainerUtil.newConcurrentMap(); +public class XDebuggerWatchesManager { + private final Map> watches = ContainerUtil.newConcurrentMap(); @NotNull - public XExpression[] getWatches(String confName) { - XExpression[] expressions = watches.get(confName); - if (expressions == null) { - return new XExpression[0]; - } - return expressions; + public List getWatches(String confName) { + return ContainerUtil.notNullize(watches.get(confName)); } - public void setWatches(String configurationName, XExpression[] expressions) { - if (expressions != null && expressions.length > 0) { + public void setWatches(String configurationName, List expressions) { + if (expressions != null && expressions.size() > 0) { watches.put(configurationName, expressions); } else { @@ -41,61 +32,29 @@ public class XDebuggerWatchesManager implements PersistentStateComponent entry : watches.entrySet()) { - state.expressions.add(new ConfigurationState(entry.getKey(), entry.getValue())); + @NotNull + public WatchesManagerState saveState(@NotNull WatchesManagerState state) { + List expressions = new SmartList<>(); + for (Map.Entry> entry : watches.entrySet()) { + expressions.add(new ConfigurationState(entry.getKey(), entry.getValue())); } + + state.setExpressions(expressions); return state; } - @Override - public void loadState(WatchesManagerState state) { + public void clearContext() { watches.clear(); - if (state != null) { - for (ConfigurationState expressionState : state.expressions) { - WatchState[] expressionStates = expressionState.myExpressionStates; - if (expressionStates != null) { - watches.put(expressionState.myName, ContainerUtil.mapNotNull(expressionStates, XExpressionState::toXExpression, new XExpression[0])); - } + } + + public void loadState(@NotNull WatchesManagerState state) { + clearContext(); + + for (ConfigurationState expressionState : ContainerUtil.notNullize(state.getExpressions())) { + List expressionStates = expressionState.getExpressionStates(); + if (expressionStates != null) { + watches.put(expressionState.getName(), ContainerUtil.mapNotNull(expressionStates, XExpressionState::toXExpression)); } } } - - @Tag("watches-manager") - public static class WatchesManagerState { - @Property(surroundWithTag = false) - @XCollection - public List expressions = new ArrayList<>(); - } - - @Tag("configuration") - public static class ConfigurationState { - @Attribute("name") - public String myName; - - @Property(surroundWithTag = false) - @XCollection - public WatchState[] myExpressionStates; - - public ConfigurationState() { - } - - public ConfigurationState(String name, XExpression[] expressions) { - myName = name; - myExpressionStates = new WatchState[expressions.length]; - for (int i = 0; i < expressions.length; i++) { - myExpressionStates[i] = new WatchState(expressions[i]); - } - } - } - @Tag("watch") - public static class WatchState extends XExpressionState { - public WatchState() {} - - public WatchState(XExpression expression) { - super(expression); - } - } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java index ce5b7cbae573..a42220601648 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java @@ -5,7 +5,6 @@ package com.intellij.xdebugger.impl.breakpoints; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; @@ -16,14 +15,14 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.ex.http.HttpFileSystem; import com.intellij.openapi.vfs.ex.http.HttpVirtualFileListener; import com.intellij.util.EventDispatcher; +import com.intellij.util.SmartList; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters; import com.intellij.util.xmlb.XmlSerializer; -import com.intellij.util.xmlb.annotations.AbstractCollection; -import com.intellij.util.xmlb.annotations.Tag; -import com.intellij.util.xmlb.annotations.XCollection; import com.intellij.xdebugger.XDebuggerUtil; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.breakpoints.*; +import com.intellij.xdebugger.impl.BreakpointManagerState; import com.intellij.xdebugger.impl.XDebuggerManagerImpl; import one.util.streamex.StreamEx; import org.jdom.Element; @@ -36,7 +35,7 @@ import java.util.*; /** * @author nik */ -public class XBreakpointManagerImpl implements XBreakpointManager, PersistentStateComponent { +public class XBreakpointManagerImpl implements XBreakpointManager { private static final Logger LOG = Logger.getInstance("#com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl"); public static final SkipDefaultValuesSerializationFilters SERIALIZATION_FILTER = new SkipDefaultValuesSerializationFilters(); private final MultiValuesMap> myBreakpoints = new MultiValuesMap<>(true); @@ -333,34 +332,41 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta myLineBreakpointManager.queueBreakpointUpdate(breakpoint); } - @Override - public BreakpointManagerState getState() { + @NotNull + public BreakpointManagerState saveState(@NotNull BreakpointManagerState state) { myDependentBreakpointManager.saveState(); - BreakpointManagerState state = new BreakpointManagerState(); + + List> defaultBreakpoints = new SmartList<>(); for (XBreakpointBase breakpoint : myDefaultBreakpoints.values()) { final BreakpointState breakpointState = breakpoint.getState(); if (differsFromDefault(breakpoint.getType(), breakpointState)) { - state.getDefaultBreakpoints().add(breakpointState); + defaultBreakpoints.add(breakpointState); } } - for (XBreakpointBase breakpoint : myBreakpoints.values()) { - state.getBreakpoints().add(breakpoint.getState()); - } + List> breakpoints = new SmartList<>(); + for (XBreakpointBase breakpoint : myBreakpoints.values()) { + breakpoints.add(breakpoint.getState()); + } + + List> breakpointsDefaults = new SmartList<>(); for (Map.Entry> entry : myBreakpointsDefaults.entrySet()) { if (statesAreDifferent(entry.getValue(), createBreakpointDefaults(entry.getKey()))) { - state.getBreakpointsDefaults().add(entry.getValue()); + breakpointsDefaults.add(entry.getValue()); } } + state.setDefaultBreakpoints(defaultBreakpoints); + state.setBreakpoints(breakpoints); + state.setBreakpointsDefaults(breakpointsDefaults); + state.setBreakpointsDialogProperties(myBreakpointsDialogSettings); state.setTime(myTime); state.setDefaultGroup(myDefaultGroup); return state; } - private

boolean differsFromDefault(XBreakpointType type, - BreakpointState state) { + private

boolean differsFromDefault(XBreakpointType type, BreakpointState state) { final XBreakpoint

defaultBreakpoint = createDefaultBreakpoint(type); if (defaultBreakpoint == null) { return false; @@ -376,7 +382,6 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta return !JDOMUtil.areElementsEqual(elem1, elem2); } - @Override public void loadState(@NotNull BreakpointManagerState state) { myBreakpointsDialogSettings = state.getBreakpointsDialogProperties(); @@ -385,15 +390,15 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta myBreakpointsDefaults.clear(); ApplicationManager.getApplication().runReadAction(() -> { - state.getDefaultBreakpoints().forEach(breakpointState -> loadBreakpoint(breakpointState, true)); + ContainerUtil.notNullize(state.getDefaultBreakpoints()).forEach(breakpointState -> loadBreakpoint(breakpointState, true)); XBreakpointUtil.breakpointTypes().remove(myDefaultBreakpoints::containsKey).forEach(this::addDefaultBreakpoint); myBreakpoints.values().forEach(this::doRemoveBreakpoint); - state.getBreakpoints().forEach(breakpointState -> loadBreakpoint(breakpointState, false)); + ContainerUtil.notNullize(state.getBreakpoints()).forEach(breakpointState -> loadBreakpoint(breakpointState, false)); - for (BreakpointState defaults : state.getBreakpointsDefaults()) { + for (BreakpointState defaults : ContainerUtil.notNullize(state.getBreakpointsDefaults())) { XBreakpointType type = XBreakpointUtil.findType(defaults.getTypeId()); if (type != null) { myBreakpointsDefaults.put(type, defaults); @@ -504,73 +509,4 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta state.setSuspendPolicy(type.getDefaultSuspendPolicy()); return state; } - - @Tag("breakpoint-manager") - public static class BreakpointManagerState { - private List myDefaultBreakpoints = new ArrayList<>(); - private List myBreakpoints = new ArrayList<>(); - private List myBreakpointsDefaults = new ArrayList<>(); - private XBreakpointsDialogState myBreakpointsDialogProperties; - - private long myTime; - private String myDefaultGroup; - - @Tag("default-breakpoints") - @XCollection - public List getDefaultBreakpoints() { - return myDefaultBreakpoints; - } - - @Tag("breakpoints") - @AbstractCollection(surroundWithTag = false, - elementTypes = {BreakpointState.class, LineBreakpointState.class}) - public List getBreakpoints() { - return myBreakpoints; - } - - @Tag("breakpoints-defaults") - @AbstractCollection(surroundWithTag = false, - elementTypes = {BreakpointState.class, LineBreakpointState.class}) - public List getBreakpointsDefaults() { - return myBreakpointsDefaults; - } - - @Tag("breakpoints-dialog") - public XBreakpointsDialogState getBreakpointsDialogProperties() { - return myBreakpointsDialogProperties; - } - - public void setBreakpoints(final List breakpoints) { - myBreakpoints = breakpoints; - } - - @SuppressWarnings("UnusedDeclaration") - public void setDefaultBreakpoints(List defaultBreakpoints) { - myDefaultBreakpoints = defaultBreakpoints; - } - - public void setBreakpointsDefaults(List breakpointsDefaults) { - myBreakpointsDefaults = breakpointsDefaults; - } - - public void setBreakpointsDialogProperties(XBreakpointsDialogState breakpointsDialogProperties) { - myBreakpointsDialogProperties = breakpointsDialogProperties; - } - - public long getTime() { - return myTime; - } - - public void setTime(long time) { - myTime = time; - } - - public String getDefaultGroup() { - return myDefaultGroup; - } - - public void setDefaultGroup(String defaultGroup) { - myDefaultGroup = defaultGroup; - } - } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XDependentBreakpointManager.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XDependentBreakpointManager.java index 3a9ba3b61857..8af3802a54c3 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XDependentBreakpointManager.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XDependentBreakpointManager.java @@ -1,25 +1,14 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.xdebugger.impl.breakpoints; import com.intellij.openapi.util.MultiValuesMap; -import com.intellij.util.SmartList; import com.intellij.util.EventDispatcher; +import com.intellij.util.SmartList; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpointListener; +import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -94,20 +83,20 @@ public class XDependentBreakpointManager { } public void saveState() { - Map, String> breakpoint2Id = new HashMap<>(); + Map, String> breakpointToId = new THashMap<>(); int id = 0; for (XBreakpointBase breakpoint : myMaster2Info.keySet()) { - breakpoint2Id.put(breakpoint, String.valueOf(id++)); + breakpointToId.put(breakpoint, String.valueOf(id++)); } for (XDependentBreakpointInfo info : mySlave2Info.values()) { - XBreakpointDependencyState state = new XBreakpointDependencyState(breakpoint2Id.get(info.mySlaveBreakpoint), - breakpoint2Id.get(info.myMasterBreakpoint), + XBreakpointDependencyState state = new XBreakpointDependencyState(breakpointToId.get(info.mySlaveBreakpoint), + breakpointToId.get(info.myMasterBreakpoint), info.myLeaveEnabled); info.mySlaveBreakpoint.setDependencyState(state); } - for (Map.Entry, String> entry : breakpoint2Id.entrySet()) { + for (Map.Entry, String> entry : breakpointToId.entrySet()) { if (!mySlave2Info.containsKey(entry.getKey())) { entry.getKey().setDependencyState(new XBreakpointDependencyState(entry.getValue())); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java index c8eecda7e88c..ce96c769d2eb 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.xdebugger.impl.frame; @@ -32,7 +20,7 @@ import com.intellij.ui.DoubleClickListener; import com.intellij.ui.ListenerUtil; import com.intellij.ui.border.CustomLineBorder; import com.intellij.util.Alarm; -import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.SmartList; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; import com.intellij.xdebugger.XDebugSession; @@ -257,10 +245,10 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, } @NotNull - private XExpression[] getExpressions() { + private List getExpressions() { XDebuggerTree tree = getTree(); XDebugSession session = getSession(tree); - XExpression[] expressions; + List expressions; if (session != null) { expressions = ((XDebugSessionImpl)session).getSessionData().getWatchExpressions(); } @@ -268,11 +256,11 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, XDebuggerTreeNode root = tree.getRoot(); List current = root instanceof WatchesRootNode ? ((WatchesRootNode)tree.getRoot()).getWatchChildren() : Collections.emptyList(); - List list = ContainerUtil.newArrayList(); + List list = new SmartList<>(); for (WatchNode child : current) { list.add(child.getExpression()); } - expressions = list.toArray(new XExpression[list.size()]); + expressions = list; } return expressions; } @@ -326,13 +314,12 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget, } public void updateSessionData() { - List watchExpressions = ContainerUtil.newArrayList(); + List expressions = new SmartList<>(); List children = myRootNode.getWatchChildren(); for (WatchNode child : children) { - watchExpressions.add(child.getExpression()); + expressions.add(child.getExpression()); } XDebugSession session = getSession(getTree()); - XExpression[] expressions = watchExpressions.toArray(new XExpression[watchExpressions.size()]); if (session != null) { ((XDebugSessionImpl)session).setWatchExpressions(expressions); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/XDebuggerSettingManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/XDebuggerSettingManagerImpl.java index 9c9e398ea269..3556f0846d1f 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/XDebuggerSettingManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/XDebuggerSettingManagerImpl.java @@ -119,8 +119,7 @@ public class XDebuggerSettingManagerImpl extends XDebuggerSettingsManager implem } public static class SettingsState { - @Tag("debuggers") - @XCollection + @XCollection(propertyElementName = "debuggers") public List specificStates = new SmartList<>(); private XDebuggerDataViewSettings myDataViewSettings = new XDebuggerDataViewSettings(); private XDebuggerGeneralSettings myGeneralSettings = new XDebuggerGeneralSettings(); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/state.kt b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/state.kt new file mode 100644 index 000000000000..dfddb2df4304 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/state.kt @@ -0,0 +1,81 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + */ +package com.intellij.xdebugger.impl + +import com.intellij.openapi.components.BaseState +import com.intellij.util.SmartList +import com.intellij.util.xmlb.annotations.Attribute +import com.intellij.util.xmlb.annotations.Property +import com.intellij.util.xmlb.annotations.Tag +import com.intellij.util.xmlb.annotations.XCollection +import com.intellij.xdebugger.XExpression +import com.intellij.xdebugger.impl.breakpoints.BreakpointState +import com.intellij.xdebugger.impl.breakpoints.LineBreakpointState +import com.intellij.xdebugger.impl.breakpoints.XBreakpointsDialogState +import com.intellij.xdebugger.impl.breakpoints.XExpressionState +import java.util.* + +@Tag("breakpoint-manager") +class BreakpointManagerState : BaseState() { + @get:XCollection(propertyElementName = "default-breakpoints") + var defaultBreakpoints by storedProperty>>(SmartList()) + + @get:XCollection(elementTypes = arrayOf(BreakpointState::class, LineBreakpointState::class), style = XCollection.Style.v2) + var breakpoints by storedProperty>>(SmartList()) + + @get:XCollection(propertyElementName = "breakpoints-defaults", elementTypes = arrayOf(BreakpointState::class, LineBreakpointState::class)) + var breakpointsDefaults by storedProperty>>(SmartList()) + + @get:Tag("breakpoints-dialog") + var breakpointsDialogProperties: XBreakpointsDialogState? = null + + var time by storedProperty(0L) + var defaultGroup by string() +} + +@Tag("watches-manager") +class WatchesManagerState : BaseState() { + @get:Property(surroundWithTag = false) + @get:XCollection + var expressions by storedProperty>(SmartList()) +} + +@Tag("configuration") +class ConfigurationState : BaseState { + @get:Attribute + var name by string() + + @Suppress("MemberVisibilityCanPrivate") + @get:Property(surroundWithTag = false) + @get:XCollection + var expressionStates by storedProperty>(SmartList()) + + @Suppress("unused") + constructor() + + constructor(name: String, expressions: List) { + this.name = name + val list = ArrayList(expressions.size) + expressionStates = list + for (i in expressions.indices) { + list.set(i, WatchState(expressions[i])) + } + } +} + +@Tag("watch") +class WatchState : XExpressionState { + @Suppress("unused") + constructor() : super() + + constructor(expression: XExpression) : super(expression) +} + +internal class XDebuggerState : BaseState() { + @get:Property(surroundWithTag = false) + var breakpointManagerState by bean(BreakpointManagerState()) + + @get:Property(surroundWithTag = false) + var watchesManagerState by bean(WatchesManagerState()) +} \ No newline at end of file diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionData.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionData.java index 1729f21bc0dd..1e3193c61fe0 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionData.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionData.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.xdebugger.impl.ui; @@ -20,6 +8,8 @@ import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.xdebugger.XExpression; import org.jetbrains.annotations.NotNull; +import java.util.List; + /** * @author nik */ @@ -27,21 +17,21 @@ public class XDebugSessionData extends UserDataHolderBase { public static final DataKey DATA_KEY = DataKey.create("XDebugSessionData"); @NotNull - private XExpression[] myWatchExpressions; + private List myWatchExpressions; private final String myConfigurationName; private boolean myBreakpointsMuted = false; - public XDebugSessionData(@NotNull XExpression[] watchExpressions, @NotNull String configurationName) { + public XDebugSessionData(@NotNull List watchExpressions, @NotNull String configurationName) { myWatchExpressions = watchExpressions; myConfigurationName = configurationName; } - public void setWatchExpressions(@NotNull XExpression[] watchExpressions) { + public void setWatchExpressions(@NotNull List watchExpressions) { myWatchExpressions = watchExpressions; } @NotNull - public XExpression[] getWatchExpressions() { + public List getWatchExpressions() { return myWatchExpressions; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java index 1c1f0440cd6a..bfab89f4244c 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.xdebugger.impl.ui.tree.nodes; @@ -32,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.tree.TreeNode; +import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -42,15 +31,17 @@ public class WatchesRootNode extends XValueContainerNode { private final XWatchesView myWatchesView; private final List myChildren; + @SuppressWarnings("unused") + // required for com.google.gct.core public WatchesRootNode(@NotNull XDebuggerTree tree, @NotNull XWatchesView watchesView, @NotNull XExpression[] expressions) { - this(tree, watchesView, expressions, null, false); + this(tree, watchesView, Arrays.asList(expressions), null, false); } public WatchesRootNode(@NotNull XDebuggerTree tree, @NotNull XWatchesView watchesView, - @NotNull XExpression[] expressions, + @NotNull List expressions, @Nullable XStackFrame stackFrame, boolean watchesInVariables) { super(tree, null, new XValueContainer() { diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XBreakpointManagerTest.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XBreakpointManagerTest.java index 1f6a45c2c2d1..e4c18c119b39 100644 --- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XBreakpointManagerTest.java +++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XBreakpointManagerTest.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.xdebugger; @@ -22,8 +10,10 @@ import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpointListener; import com.intellij.xdebugger.breakpoints.XLineBreakpoint; import org.jdom.Element; +import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; +import java.io.IOException; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -153,7 +143,7 @@ public class XBreakpointManagerTest extends XBreakpointsTestCase { assertEmpty(myBreakpointManager.getBreakpoints(MY_LINE_BREAKPOINT_TYPE)); } - public void testConditionConvert() { + public void testConditionConvert() throws IOException, JDOMException { String condition = "old-style condition"; String logExpression = "old-style expression"; String oldStyle = @@ -167,13 +157,7 @@ public class XBreakpointManagerTest extends XBreakpointsTestCase { "" + "