diff --git a/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.kt b/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.kt index a84d7364771a..a1c7aaacb6ff 100644 --- a/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.kt +++ b/platform/configuration-store-impl/testSrc/DoNotSaveDefaults.kt @@ -1,6 +1,7 @@ package com.intellij.configurationStore import com.intellij.ide.util.PropertiesComponent +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.PathManager import com.intellij.openapi.application.ex.PathManagerEx @@ -102,8 +103,7 @@ class DoNotSaveDefaultsTest { componentManager.stateStore.storageManager.expandMacros(APP_CONFIG)), setOf( "path.macros.xml" /* todo EP to register (provide) macro dynamically */, "stubIndex.xml" /* low-level non-roamable stuff */, - "usage.statistics.xml" /* SHOW_NOTIFICATION_ATTR in internal mode */, - "feature.usage.statistics.xml" /* non-roamable usage counters */, + UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML /* SHOW_NOTIFICATION_ATTR in internal mode */, "tomee.extensions.xml", "jboss.extensions.xml", "glassfish.extensions.xml" /* javaee non-roamable stuff, it will be better to fix it */, "dimensions.xml" /* non-roamable sizes of window, dialogs, etc. */, diff --git a/platform/platform-impl/src/com/intellij/featureStatistics/FeatureUsageTrackerImpl.java b/platform/platform-impl/src/com/intellij/featureStatistics/FeatureUsageTrackerImpl.java index 8fa5bebf6d41..d85e98f5d7a5 100644 --- a/platform/platform-impl/src/com/intellij/featureStatistics/FeatureUsageTrackerImpl.java +++ b/platform/platform-impl/src/com/intellij/featureStatistics/FeatureUsageTrackerImpl.java @@ -1,6 +1,7 @@ // Copyright 2000-2018 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.featureStatistics; +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.RoamingType; import com.intellij.openapi.components.State; @@ -17,7 +18,10 @@ import java.util.Set; @SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext"}) @State( name = "FeatureUsageStatistics", - storages = @Storage(value = "feature.usage.statistics.xml", roamingType = RoamingType.DISABLED) + storages = { + @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED), + @Storage(value = "feature.usage.statistics.xml", roamingType = RoamingType.DISABLED, deprecated = true) + } ) public class FeatureUsageTrackerImpl extends FeatureUsageTracker implements PersistentStateComponent { private static final int HOUR = 1000 * 60 * 60; diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/ApplicationStatisticsPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/ApplicationStatisticsPersistenceComponent.java index 65fc273c5ccb..2e8f9b356cc5 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/ApplicationStatisticsPersistenceComponent.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/ApplicationStatisticsPersistenceComponent.java @@ -6,6 +6,7 @@ import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; import com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistence; import com.intellij.internal.statistic.persistence.CollectedUsages; +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.internal.statistic.utils.StatisticsUploadAssistant; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.*; @@ -27,7 +28,10 @@ import java.util.concurrent.TimeUnit; @State( name = "StatisticsApplicationUsages", - storages = @Storage(value = "statistics.application.usages.xml", roamingType = RoamingType.DISABLED) + storages = { + @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED), + @Storage(value = "statistics.application.usages.xml", roamingType = RoamingType.DISABLED, deprecated = true) + } ) public class ApplicationStatisticsPersistenceComponent extends ApplicationStatisticsPersistence implements PersistentStateComponent, diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/UsageTrigger.java b/platform/platform-impl/src/com/intellij/internal/statistic/UsageTrigger.java index 9f82f2ef6224..303e6f780fe5 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/UsageTrigger.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/UsageTrigger.java @@ -4,6 +4,7 @@ package com.intellij.internal.statistic; import com.intellij.internal.statistic.beans.ConvertUsagesUtil; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.openapi.components.*; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.MapAnnotation; @@ -17,7 +18,10 @@ import java.util.Set; @State( name = "UsageTrigger", - storages = @Storage(value = "statistics.application.usages.xml", roamingType = RoamingType.DISABLED) + storages = { + @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED), + @Storage(value = "statistics.application.usages.xml", roamingType = RoamingType.DISABLED, deprecated = true) + } ) public class UsageTrigger implements PersistentStateComponent { final static class State { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionsCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionsCollector.java index 46d4fd88948f..459478553d28 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionsCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionsCollector.java @@ -5,6 +5,7 @@ import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.ConvertUsagesUtil; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.openapi.components.*; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.MapAnnotation; @@ -21,7 +22,10 @@ import java.util.Set; */ @State( name = "ActionsCollector", - storages = @Storage(value = "statistics.actions.xml", roamingType = RoamingType.DISABLED) + storages = { + @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED), + @Storage(value = "statistics.actions.xml", roamingType = RoamingType.DISABLED, deprecated = true) + } ) public class ActionsCollector implements PersistentStateComponent { public void record(String actionId) { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/IntentionsCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/IntentionsCollector.java index 712c8a389ee9..3adf9daf88fa 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/IntentionsCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/IntentionsCollector.java @@ -8,6 +8,7 @@ import com.intellij.codeInspection.ex.QuickFixWrapper; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.lang.Language; import com.intellij.openapi.components.*; import com.intellij.openapi.util.text.StringUtil; @@ -24,7 +25,10 @@ import java.util.*; */ @State( name = "IntentionsCollector", - storages = @Storage(value = "statistics.intentions.xml", roamingType = RoamingType.DISABLED) + storages = { + @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED), + @Storage(value = "statistics.intentions.xml", roamingType = RoamingType.DISABLED, deprecated = true) + } ) public class IntentionsCollector implements PersistentStateComponent { private State myState = new State(); diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/MainMenuCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/MainMenuCollector.java index 0c702f5662ac..de6486048172 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/MainMenuCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/MainMenuCollector.java @@ -5,6 +5,7 @@ import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.ConvertUsagesUtil; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.impl.ActionMenu; import com.intellij.openapi.components.*; @@ -28,7 +29,10 @@ import java.util.stream.Collectors; */ @State( name = "MainMenuCollector", - storages = @Storage(value = "statistics.main_menu.xml", roamingType = RoamingType.DISABLED) + storages = { + @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED), + @Storage(value = "statistics.main_menu.xml", roamingType = RoamingType.DISABLED, deprecated = true) + } ) public class MainMenuCollector implements PersistentStateComponent { private State myState = new State(); diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ShortcutsCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ShortcutsCollector.java index 09972cda4576..9442e93b3462 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ShortcutsCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ShortcutsCollector.java @@ -4,6 +4,7 @@ package com.intellij.internal.statistic.customUsageCollectors.ui; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.KeyboardShortcut; import com.intellij.openapi.components.*; @@ -34,7 +35,10 @@ import static java.awt.event.KeyEvent.*; */ @State( name = "ShortcutsCollector", - storages = @Storage(value = "statistics.shortcuts.xml", roamingType = RoamingType.DISABLED) + storages = { + @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED), + @Storage(value = "statistics.shortcuts.xml", roamingType = RoamingType.DISABLED, deprecated = true) + } ) public class ShortcutsCollector implements PersistentStateComponent { final static class MyState { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ToolbarClicksCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ToolbarClicksCollector.java index 74cf0fb421de..d86bf4d1d194 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ToolbarClicksCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ToolbarClicksCollector.java @@ -5,6 +5,7 @@ import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.ConvertUsagesUtil; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionWithDelegate; import com.intellij.openapi.actionSystem.AnAction; @@ -23,7 +24,10 @@ import java.util.Set; */ @State( name = "ToolbarClicksCollector", - storages = @Storage(value = "statistics.toolbar.clicks.xml", roamingType = RoamingType.DISABLED) + storages = { + @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED), + @Storage(value = "statistics.toolbar.clicks.xml", roamingType = RoamingType.DISABLED, deprecated = true) + } ) public class ToolbarClicksCollector implements PersistentStateComponent { final static class ClicksState { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java index 385c6bc2a0f0..3bdb19faba37 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/persistence/UsageStatisticsPersistenceComponent.java @@ -21,10 +21,11 @@ import java.util.Set; @State( name = "UsagesStatistic", - storages = @Storage(value = "usage.statistics.xml", roamingType = RoamingType.DISABLED) + storages = @Storage(value = UsageStatisticsPersistenceComponent.USAGE_STATISTICS_XML, roamingType = RoamingType.DISABLED) ) public class UsageStatisticsPersistenceComponent extends BasicSentUsagesPersistenceComponent implements NamedComponent, PersistentStateComponent { + public static final String USAGE_STATISTICS_XML = "usage.statistics.xml"; @NonNls private boolean isShowNotification = true; @NotNull private SendPeriod myPeriod = SendPeriod.DAILY; diff --git a/platform/projectModel-api/src/com/intellij/openapi/components/Storage.java b/platform/projectModel-api/src/com/intellij/openapi/components/Storage.java index 955966249e72..262dc3515e8b 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/components/Storage.java +++ b/platform/projectModel-api/src/com/intellij/openapi/components/Storage.java @@ -1,18 +1,4 @@ -/* - * 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-2018 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.components; import org.jetbrains.annotations.NonNls; @@ -33,7 +19,9 @@ public @interface Storage { /** * Relative to component container configuration root path. - * Consider to use shorthand form - {@code @Storage("yourName.xml")} (when you need to specify only file path). + * Consider using shorthand form - {@code @Storage("yourName.xml")} (when you need to specify only file path). + * + * Consider reusing existing storage files instead of a new one. No-one need myriads config files. Related components should reuse storage file. */ @NonNls String value() default "";