diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java index 2ae270612cdb..2a15e7249a78 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java @@ -18,7 +18,7 @@ import com.intellij.codeInspection.SuppressIntentionActionFromFix; import com.intellij.featureStatistics.FeatureUsageTracker; import com.intellij.featureStatistics.FeatureUsageTrackerImpl; import com.intellij.injected.editor.EditorWindow; -import com.intellij.internal.statistic.customUsageCollectors.actions.IntentionsCollector; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.IntentionsCollector; import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.TransactionGuard; diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index dd66211779b3..8ae73a1b6341 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -31,7 +31,7 @@ import com.intellij.ide.ui.search.OptionDescription; import com.intellij.ide.util.PropertiesComponent; import com.intellij.ide.util.gotoByName.*; import com.intellij.ide.util.treeView.smartTree.TreeElement; -import com.intellij.internal.statistic.customUsageCollectors.ui.ToolbarClicksCollector; +import com.intellij.internal.statistic.collectors.fus.ui.persistence.ToolbarClicksCollector; import com.intellij.lang.Language; import com.intellij.lang.LanguagePsiElementExternalizer; import com.intellij.navigation.ItemPresentation; diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java deleted file mode 100644 index 41f27ece8df7..000000000000 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/FileTypeUsagesCollector.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2000-2012 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. - */ -package com.intellij.openapi.fileTypes; - -import com.intellij.internal.statistic.AbstractProjectsUsagesCollector; -import com.intellij.internal.statistic.CollectUsagesException; -import com.intellij.internal.statistic.beans.GroupDescriptor; -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.project.Project; -import com.intellij.project.ProjectKt; -import com.intellij.psi.search.FileTypeIndex; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.NotNullFunction; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.HashSet; -import java.util.Set; - -/** - * @author Nikolay Matveev - */ -public class FileTypeUsagesCollector extends AbstractProjectsUsagesCollector { - private static final String GROUP_ID = "file-type"; - - @NotNull - @Override - public GroupDescriptor getGroupId() { - return GroupDescriptor.create(GROUP_ID); - } - - @NotNull - @Override - public Set getProjectUsages(@NotNull final Project project) throws CollectUsagesException { - final Set usedFileTypes = new HashSet<>(); - final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); - if (fileTypeManager == null) { - throw new CollectUsagesException("Cannot get instance of FileTypeManager"); - } - final FileType[] registeredFileTypes = fileTypeManager.getRegisteredFileTypes(); - for (final FileType fileType : registeredFileTypes) { - if (project.isDisposed()) { - throw new CollectUsagesException("Project is disposed"); - } - ApplicationManager.getApplication().runReadAction(() -> { - FileTypeIndex.processFiles(fileType, file -> { - //skip files from .idea directory otherwise 99% of projects would have XML and PLAIN_TEXT file types - if (!ProjectKt.getStateStore(project).isProjectFile(file)) { - usedFileTypes.add(fileType); - return false; - } - return true; - }, GlobalSearchScope.projectScope(project)); - }); - } - return ContainerUtil.map2Set(usedFileTypes, (NotNullFunction)fileType -> new UsageDescriptor(fileType.getName(), 1)); - } -} diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java index 7d6201ce5d6c..79fcfcae24eb 100644 --- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java @@ -20,7 +20,7 @@ import com.intellij.icons.AllIcons; import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.ide.plugins.PluginNode; -import com.intellij.internal.statistic.customUsageCollectors.ideSettings.IdeInitialConfigButtonUsages; +import com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages; import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase; import com.intellij.openapi.ui.VerticalFlowLayout; diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java index 185ad990e67b..90abf858ecec 100644 --- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java @@ -17,7 +17,7 @@ package com.intellij.ide.customize; import com.intellij.ide.cloudConfig.CloudConfigProvider; import com.intellij.ide.startup.StartupActionScriptManager; -import com.intellij.internal.statistic.customUsageCollectors.ideSettings.IdeInitialConfigButtonUsages; +import com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages; import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.text.StringUtil; diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java index 2abf7eac5e0b..6f9b5ef7acee 100644 --- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java @@ -16,7 +16,7 @@ package com.intellij.ide.customize; import com.intellij.ide.plugins.PluginManager; -import com.intellij.internal.statistic.customUsageCollectors.ideSettings.IdeInitialConfigButtonUsages; +import com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages; import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.VerticalFlowLayout; diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/UsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/UsagesCollector.java index acab5f52ba8f..cad9202290e4 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/UsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/UsagesCollector.java @@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull; import java.util.Set; import java.util.function.Function; +@Deprecated // to be removed in 2018.2 public abstract class UsagesCollector { public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.statistics.usagesCollector"); diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ProductivityUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ProductivityUsageCollector.java new file mode 100644 index 000000000000..b7d30e855cd4 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ProductivityUsageCollector.java @@ -0,0 +1,41 @@ +// 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.internal.statistic.collectors.fus; + +import com.intellij.featureStatistics.FeatureDescriptor; +import com.intellij.featureStatistics.ProductivityFeaturesRegistry; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.FUStatisticsDifferenceSender; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +public class ProductivityUsageCollector extends ApplicationUsagesCollector implements FUStatisticsDifferenceSender { + + private static final String GROUP_ID = "statistics.productivity"; + @NotNull + @Override + public String getGroupId() { + return GROUP_ID; + } + + @NotNull + @Override + public Set getUsages() { + Set usages = ContainerUtil.newHashSet(); + + final ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance(); + for (String featureId : registry.getFeatureIds()) { + final FeatureDescriptor featureDescriptor = registry.getFeatureDescriptor(featureId); + if (featureDescriptor != null) { + int count = featureDescriptor.getUsageCount(); + if (count > 0) { + usages.add(new UsageDescriptor(featureId, count)); + } + } + } + + return usages; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/ActionUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/ActionUsagesCollector.java new file mode 100644 index 000000000000..f7f309577aad --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/ActionUsagesCollector.java @@ -0,0 +1,27 @@ +// 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.internal.statistic.collectors.fus.actions; + +import com.intellij.ide.actions.ActionsCollector; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.FUStatisticsDifferenceSender; +import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +public final class ActionUsagesCollector extends ApplicationUsagesCollector implements FUStatisticsDifferenceSender { + + @NotNull + public Set getUsages() { + ActionsCollector.State state = ActionsCollector.getInstance().getState(); + assert state != null; + return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(UsageDescriptorKeyValidator.ensureProperKey(e.getKey()), e.getValue())); + } + + @NotNull + public String getGroupId() { + return "statistics.actions.performed"; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/IntentionUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/IntentionUsagesCollector.java new file mode 100644 index 000000000000..556c87069853 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/IntentionUsagesCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.fus.actions; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.IntentionsCollector; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.FUStatisticsDifferenceSender; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +import static com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator.ensureProperKey; + +public final class IntentionUsagesCollector extends ApplicationUsagesCollector implements FUStatisticsDifferenceSender { + + @NotNull + public Set getUsages() { + IntentionsCollector.State state = IntentionsCollector.getInstance().getState(); + assert state != null; + return ContainerUtil.map2Set(state.myIntentions.entrySet(), e -> new UsageDescriptor(ensureProperKey(e.getKey()), e.getValue())); + } + + @NotNull + public String getGroupId() { + return "statistics.actions.intentions"; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/MainMenuUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/MainMenuUsagesCollector.java new file mode 100644 index 000000000000..406e37b38bca --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/MainMenuUsagesCollector.java @@ -0,0 +1,31 @@ +// 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.internal.statistic.collectors.fus.actions; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.MainMenuCollector; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.FUStatisticsDifferenceSender; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +import static com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator.ensureProperKey; + +public final class MainMenuUsagesCollector extends ApplicationUsagesCollector implements FUStatisticsDifferenceSender { + + @NotNull + public Set getUsages() { + MainMenuCollector.State state = MainMenuCollector.getInstance().getState(); + assert state != null; + return ContainerUtil.map2Set(state.myValues.entrySet(), e -> { + String key = e.getKey().replaceAll(" -> ", "-"); + return new UsageDescriptor(ensureProperKey(key), e.getValue()); + }); + } + + @NotNull + public String getGroupId() { + return "statistics.actions.main.menu"; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionIdProvider.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionIdProvider.java new file mode 100644 index 000000000000..e2a41f2370e3 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionIdProvider.java @@ -0,0 +1,6 @@ +// 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.internal.statistic.collectors.fus.actions.persistence; + +public interface ActionIdProvider { + String getId(); +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionsCollectorImpl.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionsCollectorImpl.java similarity index 52% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionsCollectorImpl.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionsCollectorImpl.java index d69bf4f09255..dc6e2a0df780 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionsCollectorImpl.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/ActionsCollectorImpl.java @@ -1,25 +1,17 @@ // 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.internal.statistic.customUsageCollectors.actions; +package com.intellij.internal.statistic.collectors.fus.actions.persistence; import com.intellij.ide.actions.ActionsCollector; -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.eventLog.FeatureUsageLogger; import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; -import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; -import com.intellij.internal.statistic.service.fus.collectors.FUStatisticsDifferenceSender; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.RoamingType; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Set; - /** * @author Konstantin Bulenkov */ @@ -56,36 +48,4 @@ public class ActionsCollectorImpl extends ActionsCollector implements Persistent public void loadState(@NotNull State state) { myState = state; } - - @Deprecated // old statistics service format - final static class ActionUsagesCollector extends UsagesCollector { - private static final GroupDescriptor GROUP = GroupDescriptor.create("Actions", GroupDescriptor.HIGHER_PRIORITY); - - @NotNull - public Set getUsages() { - State state = getInstance().getState(); - assert state != null; - return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); - } - - @NotNull - public GroupDescriptor getGroupId() { - return GROUP; - } - } - - final static class ActionUsagesCollectorNew extends ApplicationUsagesCollector implements FUStatisticsDifferenceSender { - - @NotNull - public Set getUsages() { - State state = getInstance().getState(); - assert state != null; - return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); - } - - @NotNull - public String getGroupId() { - return "statistics.actions"; - } - } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/IntentionsCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/IntentionsCollector.java similarity index 80% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/IntentionsCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/IntentionsCollector.java index 3adf9daf88fa..57c96561533a 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/IntentionsCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/IntentionsCollector.java @@ -1,18 +1,15 @@ // 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.internal.statistic.customUsageCollectors.actions; +package com.intellij.internal.statistic.collectors.fus.actions.persistence; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionActionDelegate; import com.intellij.codeInspection.LocalQuickFix; 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; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.MapAnnotation; import com.intellij.util.xmlb.annotations.Tag; import org.jetbrains.annotations.NotNull; @@ -89,26 +86,10 @@ public class IntentionsCollector implements PersistentStateComponent myIntentions = new HashMap<>(); } - - final static class IntentionUsagesCollector extends UsagesCollector { - private static final GroupDescriptor GROUP = GroupDescriptor.create("Intentions"); - - @NotNull - public Set getUsages() { - State state = getInstance().getState(); - assert state != null; - return ContainerUtil.map2Set(state.myIntentions.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); - } - - @NotNull - public GroupDescriptor getGroupId() { - return GROUP; - } - } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/MainMenuCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/MainMenuCollector.java similarity index 83% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/MainMenuCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/MainMenuCollector.java index de6486048172..4f876e4f2026 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/MainMenuCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/actions/persistence/MainMenuCollector.java @@ -1,16 +1,13 @@ // 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.internal.statistic.customUsageCollectors.actions; +package com.intellij.internal.statistic.collectors.fus.actions.persistence; 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.*; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.MapAnnotation; import com.intellij.util.xmlb.annotations.Tag; import org.jetbrains.annotations.NotNull; @@ -125,25 +122,9 @@ public class MainMenuCollector implements PersistentStateComponent myValues = new HashMap<>(); } - - final static class MainMenuUsagesCollector extends UsagesCollector { - private static final GroupDescriptor GROUP = GroupDescriptor.create("Main Menu", GroupDescriptor.HIGHER_PRIORITY); - - @NotNull - public Set getUsages() { - State state = getInstance().getState(); - assert state != null; - return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); - } - - @NotNull - public GroupDescriptor getGroupId() { - return GROUP; - } - } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/fileTypes/FileTypeUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/fileTypes/FileTypeUsagesCollector.java new file mode 100644 index 000000000000..e432b4bb7a41 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/fileTypes/FileTypeUsagesCollector.java @@ -0,0 +1,63 @@ +// 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.internal.statistic.collectors.fus.fileTypes; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.fileTypes.FileTypeManager; +import com.intellij.openapi.project.Project; +import com.intellij.project.ProjectKt; +import com.intellij.psi.search.FileTypeIndex; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.util.NotNullFunction; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Nikolay Matveev + */ +public class FileTypeUsagesCollector extends ProjectUsagesCollector { + @NotNull + @Override + public String getGroupId() { + return "statistics.file.types"; + } + + @NotNull + @Override + public Set getUsages(@NotNull final Project project) { + return getDescriptors(project); + } + + @NotNull + public static Set getDescriptors(@NotNull Project project) { + final Set usedFileTypes = new HashSet<>(); + final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); + if (fileTypeManager == null) { + return Collections.emptySet(); + } + final FileType[] registeredFileTypes = fileTypeManager.getRegisteredFileTypes(); + for (final FileType fileType : registeredFileTypes) { + if (project.isDisposed()) { + return Collections.emptySet(); + } + ApplicationManager.getApplication().runReadAction(() -> { + FileTypeIndex.processFiles(fileType, file -> { + //skip files from .idea directory otherwise 99% of projects would have XML and PLAIN_TEXT file types + if (!ProjectKt.getStateStore(project).isProjectFile(file)) { + usedFileTypes.add(fileType); + return false; + } + return true; + }, GlobalSearchScope.projectScope(project)); + }); + } + return ContainerUtil + .map2Set(usedFileTypes, (NotNullFunction)fileType -> new UsageDescriptor(fileType.getName(), 1)); + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/jdk/JdkInfoUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/jdk/JdkInfoUsageCollector.java new file mode 100644 index 000000000000..9777d32d85dc --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/jdk/JdkInfoUsageCollector.java @@ -0,0 +1,31 @@ +// 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.internal.statistic.collectors.fus.jdk; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.util.lang.JavaVersion; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.Set; + +import static com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator.ensureProperKey; + +/** + * @author Konstantin Bulenkov + */ +public class JdkInfoUsageCollector extends ApplicationUsagesCollector { + @NotNull + @Override + public Set getUsages() { + final String vendor = System.getProperty("java.vendor", "Unknown"); + final String version = "1." + JavaVersion.current().feature; + return Collections.singleton(new UsageDescriptor(ensureProperKey(vendor + "." + version), 1)); + } + + @NotNull + @Override + public String getGroupId() { + return "statistics.jdk.user"; + } +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/os/OsNameUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/os/OsNameUsageCollector.java new file mode 100644 index 000000000000..cb1b2d8c6530 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/os/OsNameUsageCollector.java @@ -0,0 +1,27 @@ +// 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.internal.statistic.collectors.fus.os; + +import com.google.common.collect.ImmutableSet; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator; +import com.intellij.openapi.util.SystemInfo; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.Set; + +import static com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator.ensureProperKey; + +public class OsNameUsageCollector extends ApplicationUsagesCollector { + @NotNull + @Override + public Set getUsages() { + String osName = SystemInfo.isLinux ? "Linux" : SystemInfo.isMac ? "Mac.OS.X" : SystemInfo.isWindows ? "Windows" : SystemInfo.OS_NAME; + return ImmutableSet.of(new UsageDescriptor(ensureProperKey(osName), 1)); + } + + @NotNull + @Override + public String getGroupId() { return "statistics.os.name"; } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/os/OsVersionUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/os/OsVersionUsageCollector.java new file mode 100644 index 000000000000..f574d30e5d39 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/os/OsVersionUsageCollector.java @@ -0,0 +1,68 @@ +// 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.internal.statistic.collectors.fus.os; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.Version; +import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +public class OsVersionUsageCollector extends ApplicationUsagesCollector { + @NotNull + @Override + public Set getUsages() { + return getDescriptors(); + } + + @NotNull + public static Set getDescriptors() { + UsageDescriptor descriptor; + + if (SystemInfo.isLinux) { + String releaseId = null, releaseVersion = null; + + try { + Map values = Files.lines(Paths.get("/etc/os-release")) + .map(line -> StringUtil.split(line, "=")) + .filter(parts -> parts.size() == 2) + .collect( + Collectors.toMap(parts -> parts.get(0), parts -> StringUtil.unquoteString(parts.get(1)))); + releaseId = values.get("ID"); + releaseVersion = values.get("VERSION_ID"); + } + catch (IOException ignored) { + } + + if (releaseId == null) releaseId = "unknown"; + + if (releaseVersion == null) { + releaseVersion = SystemInfo.OS_VERSION; + Version version = Version.parseVersion(releaseVersion); + if (version != null) { + releaseVersion = version.toCompactString(); + } + } + + descriptor = new UsageDescriptor("Linux/" + releaseId + " " + releaseVersion, 1); + } + else { + descriptor = new UsageDescriptor(UsageDescriptorKeyValidator.ensureProperKey(SystemInfo.OS_NAME + "." + SystemInfo.OS_VERSION), 1); + } + + return Collections.singleton(descriptor); + } + + @NotNull + @Override + public String getGroupId() { return "statistics.os.version"; } +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/plugins/DisabledPluginsUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/plugins/DisabledPluginsUsagesCollector.java new file mode 100644 index 000000000000..0bd8deec3fbe --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/plugins/DisabledPluginsUsagesCollector.java @@ -0,0 +1,23 @@ +// 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.internal.statistic.collectors.fus.plugins; + +import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +public class DisabledPluginsUsagesCollector extends ApplicationUsagesCollector { + + @NotNull + public String getGroupId() { + return "statistics.plugins.disabled"; + } + + @NotNull + public Set getUsages() { + return ContainerUtil.map2Set(PluginManagerCore.getDisabledPlugins(), descriptor -> new UsageDescriptor(descriptor, 1)); + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/plugins/NonBundledPluginsUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/plugins/NonBundledPluginsUsagesCollector.java new file mode 100644 index 000000000000..fded088baad6 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/plugins/NonBundledPluginsUsagesCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.fus.plugins; + +import com.intellij.ide.plugins.IdeaPluginDescriptor; +import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Set; + +public class NonBundledPluginsUsagesCollector extends ApplicationUsagesCollector { + @NotNull + public String getGroupId() { + return "statistics.plugins.non.bundled"; + } + + @NotNull + public Set getUsages() { + final IdeaPluginDescriptor[] plugins = PluginManagerCore.getPlugins(); + final List nonBundledEnabledPlugins = ContainerUtil.filter(plugins, d -> d.isEnabled() && !d.isBundled() && d.getPluginId() != null); + + return ContainerUtil.map2Set(nonBundledEnabledPlugins, descriptor -> new UsageDescriptor(descriptor.getPluginId().getIdString(), 1)); + } + +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/A11YUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/A11YUsagesCollector.java new file mode 100644 index 000000000000..f398fd0b2e70 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/A11YUsagesCollector.java @@ -0,0 +1,31 @@ +// 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.internal.statistic.collectors.fus.ui; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.util.ui.accessibility.ScreenReader; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.Set; + +/** + * @author tav + */ +public class A11YUsagesCollector extends ApplicationUsagesCollector { + @NotNull + @Override + public Set getUsages() { + String activity = ScreenReader.isActive() ? "ENABLED" : "DISABLED"; + String os = SystemInfo.isWindows ? "Windows" : SystemInfo.isLinux ? "Linux" : SystemInfo.isMac ? "Mac" : "Unknown OS"; + return Collections.singleton(new UsageDescriptor(os + ".screen.reader." + activity, 1)); + } + + @NotNull + @Override + public String getGroupId() { + return "statistics.ui.a11y.screen.reader"; + } +} + diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorSchemesUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/EditorColorSchemesUsagesCollector.java similarity index 64% rename from platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorSchemesUsagesCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/EditorColorSchemesUsagesCollector.java index 7068e1b1f994..48b5f20c7d91 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorSchemesUsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/EditorColorSchemesUsagesCollector.java @@ -1,26 +1,11 @@ -/* - * 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. - */ -package com.intellij.openapi.editor.colors.impl; +// 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.internal.statistic.collectors.fus.ui; -import com.intellij.internal.statistic.CollectUsagesException; -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.service.fus.collectors.ApplicationUsagesCollector; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme; import com.intellij.openapi.options.SchemeManager; import com.intellij.ui.ColorUtil; import com.intellij.util.containers.ContainerUtil; @@ -30,7 +15,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Set; -public class EditorColorSchemesUsagesCollector extends UsagesCollector { +public class EditorColorSchemesUsagesCollector extends ApplicationUsagesCollector { public static final String GROUP_ID = "Color Schemes"; public static final String SCHEME_NAME_OTHER = "Other"; @@ -53,7 +38,12 @@ public class EditorColorSchemesUsagesCollector extends UsagesCollector { @NotNull @Override - public Set getUsages() throws CollectUsagesException { + public Set getUsages() { + return getDescriptors(); + } + + @NotNull + public static Set getDescriptors() { EditorColorsScheme currentScheme = EditorColorsManager.getInstance().getGlobalScheme(); Set usages = ContainerUtil.newHashSet(); String schemeName = SCHEME_NAME_OTHER; @@ -71,7 +61,7 @@ public class EditorColorSchemesUsagesCollector extends UsagesCollector { schemeName = knownName; } boolean isDark = ColorUtil.isDark(currentScheme.getDefaultBackground()); - schemeName += " (" + (isDark ? "Dark" : "Light") + ")"; + schemeName += "[" + (isDark ? "Dark" : "Light") + "]"; } usages.add(new UsageDescriptor(schemeName, 1)); } @@ -90,8 +80,8 @@ public class EditorColorSchemesUsagesCollector extends UsagesCollector { @NotNull @Override - public GroupDescriptor getGroupId() { - return GroupDescriptor.create(GROUP_ID); + public String getGroupId() { + return "statistics.ui.editor.color.schemes"; } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/FontSizeInfoUsageCollector.kt b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/FontSizeInfoUsageCollector.kt new file mode 100644 index 000000000000..00fa99163d6e --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/FontSizeInfoUsageCollector.kt @@ -0,0 +1,57 @@ +// 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.internal.statistic.collectors.fus.ui + +import com.intellij.ide.ui.UISettings +import com.intellij.ide.util.PropertiesComponent +import com.intellij.internal.statistic.CollectUsagesException +import com.intellij.internal.statistic.beans.UsageDescriptor +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector +import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator.ensureProperKey +import com.intellij.openapi.editor.colors.EditorColorsManager +import com.intellij.openapi.editor.colors.impl.AppEditorFontOptions + +/** + * @author Konstantin Bulenkov + */ +class FontSizeInfoUsageCollector : ApplicationUsagesCollector() { + @Throws(CollectUsagesException::class) + override fun getUsages(): Set { + val scheme = EditorColorsManager.getInstance().globalScheme + val ui = UISettings.shadowInstance + var usages = setOf( + UsageDescriptor("UI.font.size[${ui.fontSize}]"), + UsageDescriptor(ensureProperKey("UI.font.name[${ui.fontFace}]")), + UsageDescriptor("Presentation.mode.font.size[${ui.presentationModeFontSize}]") + ) + if (!scheme.isUseAppFontPreferencesInEditor) { + usages += setOf( + UsageDescriptor("Editor.font.size[${scheme.editorFontSize}]"), + UsageDescriptor(ensureProperKey("Editor.font.name[${scheme.editorFontName}]")) + ) + } + else { + val appPrefs = AppEditorFontOptions.getInstance().fontPreferences + usages += setOf( + UsageDescriptor("IDE.editor.font.size[${appPrefs.getSize(appPrefs.fontFamily)}]"), + UsageDescriptor(ensureProperKey("IDE.editor.font.name[${appPrefs.fontFamily}]")) + ) + } + if (!scheme.isUseEditorFontPreferencesInConsole) { + usages += setOf( + UsageDescriptor("Console.font.size[${scheme.consoleFontSize}]"), + UsageDescriptor(ensureProperKey("Console.font.name[${scheme.consoleFontName}]")) + ) + } + val quickDocFontSize = PropertiesComponent.getInstance().getValue("quick.doc.font.size") + if (quickDocFontSize != null) { + usages += setOf( + UsageDescriptor("QuickDoc.font.size[" + quickDocFontSize +"]") + ) + } + return usages + } + + override fun getGroupId(): String { + return "statistics.ui.fonts" + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/HiDPIModeUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/HiDPIModeUsagesCollector.java new file mode 100644 index 000000000000..fc253e814854 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/HiDPIModeUsagesCollector.java @@ -0,0 +1,30 @@ +// 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.internal.statistic.collectors.fus.ui; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.Set; + +/** + * @author tav + */ +public class HiDPIModeUsagesCollector extends ApplicationUsagesCollector { + @NotNull + @Override + public Set getUsages() { + String mode = UIUtil.isJreHiDPIEnabled() ? "per_monitor_dpi" : "system_dpi"; + String os = SystemInfo.isWindows ? "Windows" : SystemInfo.isLinux ? "Linux" : SystemInfo.isMac ? "Mac" : "UnknownOS"; + return Collections.singleton(new UsageDescriptor(os + "." + mode, 1)); + } + + @NotNull + @Override + public String getGroupId() { + return "statistics.ui.hidpi.mode"; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/LaFUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/LaFUsagesCollector.java new file mode 100644 index 000000000000..4ee86338eb40 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/LaFUsagesCollector.java @@ -0,0 +1,35 @@ +// 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.internal.statistic.collectors.fus.ui; + +import com.intellij.ide.ui.LafManager; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.text.StringUtil; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.util.Collections; +import java.util.Set; + +import static com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator.ensureProperKey; + +public class LaFUsagesCollector extends ApplicationUsagesCollector { + @NotNull + @Override + public Set getUsages() { + UIManager.LookAndFeelInfo laf = LafManager.getInstance().getCurrentLookAndFeel(); + String key = SystemInfo.OS_NAME + "."; + if (!StringUtil.isEmptyOrSpaces(SystemInfo.SUN_DESKTOP)) { + key=key.replaceAll(" ", "_"); + key += SystemInfo.SUN_DESKTOP + "."; + } + return laf != null ? Collections.singleton(new UsageDescriptor(ensureProperKey(key + laf.getName()), 1)) + : Collections.emptySet(); + } + + @NotNull + @Override + public String getGroupId() { return "statistics.ui.look.and.feel"; } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ScaleInfoUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ScaleInfoUsageCollector.java new file mode 100644 index 000000000000..b2ef3b9c82c8 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ScaleInfoUsageCollector.java @@ -0,0 +1,44 @@ +// 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.internal.statistic.collectors.fus.ui; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.util.ui.JBUI; +import org.jdesktop.swingx.util.OS; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.Set; + +/** + * @author tav + */ +public class ScaleInfoUsageCollector extends ApplicationUsagesCollector { + @NotNull + @Override + public Set getUsages() { + return getDescriptors(); + } + + @NotNull + public static Set getDescriptors() { + float scale = JBUI.sysScale(); + + int scaleBase = (int)Math.floor(scale); + float scaleFract = scale - scaleBase; + + if (scaleFract == 0.0f) scaleFract = 0.0f; // count integer scale on a precise match only + else if (scaleFract < 0.375f) scaleFract = 0.25f; + else if (scaleFract < 0.625f) scaleFract = 0.5f; + else scaleFract = 0.75f; + + scale = scaleBase + scaleFract; + + String os = OS.isWindows() ? "Windows" : OS.isLinux() ? "Linux" : OS.isMacOSX() ? "Mac" : "UnknownOS"; + return Collections.singleton(new UsageDescriptor(os + "_" + scale, 1)); + } + + @NotNull + @Override + public String getGroupId() { return "statistics.ui.screen.scale"; } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ShortcutUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ShortcutUsagesCollector.java new file mode 100644 index 000000000000..e9829d685d71 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ShortcutUsagesCollector.java @@ -0,0 +1,36 @@ +// 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.internal.statistic.collectors.fus.ui; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.collectors.fus.ui.persistence.ShortcutsCollector; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.FUStatisticsDifferenceSender; +import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +import static com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator.*; + +public final class ShortcutUsagesCollector extends ApplicationUsagesCollector implements FUStatisticsDifferenceSender { + + private static String getGroupName() { + if (SystemInfo.isMac) return "statistics.ui.shortcuts.on.mac"; + if (SystemInfo.isWindows) return "statistics.ui.shortcuts.on.windows"; + if (SystemInfo.isLinux) return "statistics.ui.shortcuts.on.linux"; + return "statistics.ui.shortcuts.on.other.os"; + } + + @NotNull + public Set getUsages() { + ShortcutsCollector.MyState state = ShortcutsCollector.getInstance().getState(); + return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(ensureProperKey(e.getKey()), e.getValue())); + } + + @NotNull + public String getGroupId() { + return getGroupName(); + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ToolbarClicksUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ToolbarClicksUsagesCollector.java new file mode 100644 index 000000000000..8a28d93cff3f --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/ToolbarClicksUsagesCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.fus.ui; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.collectors.fus.ui.persistence.ToolbarClicksCollector; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.internal.statistic.service.fus.collectors.FUStatisticsDifferenceSender; +import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +import static com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator.*; + +public final class ToolbarClicksUsagesCollector extends ApplicationUsagesCollector implements FUStatisticsDifferenceSender { + @NotNull + public Set getUsages() { + ToolbarClicksCollector.ClicksState state = ToolbarClicksCollector.getInstance().getState(); + assert state != null; + return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(ensureProperKey(e.getKey()), e.getValue())); + } + + @NotNull + public String getGroupId() { + return "statistics.ui.toolbar.clicks"; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/UiInfoUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/UiInfoUsageCollector.java new file mode 100644 index 000000000000..1b0652b682ed --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/UiInfoUsageCollector.java @@ -0,0 +1,96 @@ +// 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.internal.statistic.collectors.fus.ui; + +import com.intellij.ide.GeneralSettings; +import com.intellij.ide.ui.UISettings; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector; +import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; +import com.intellij.util.ui.UIUtil; +import gnu.trove.THashSet; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.util.Set; + +import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getBooleanUsage; + +/** + * @author Konstantin Bulenkov + */ +public class UiInfoUsageCollector extends ApplicationUsagesCollector { + + @NotNull + @Override + public Set getUsages() { + return getDescriptors(); + } + + @NotNull + public static Set getDescriptors() { + Set set = new THashSet<>(); + + add(set, "Nav.Bar.visible", navbar() ? 1 : 0); + add(set, "Nav.Bar.floating", navbar() ? 0 : 1); + add(set, "Toolbar.visible", toolbar() ? 1 : 0); + add(set, "Toolbar.hidden", toolbar() ? 0 : 1); + add(set, "Toolbar.and.NavBar", !toolbar() && navbar() ? 1 : 0); + add(set, "Toolbar.and.NavBar.hidden", !toolbar() && !navbar() ? 1 : 0); + add(set, "Status.bar.visible", status() ? 1 : 0); + add(set, "Status.bar.hidden", status() ? 0 : 1); + add(set, "Tool.Window.buttons.visible", stripes() ? 1 : 0); + add(set, "Tool.Window.buttons.hidden", stripes() ? 0 : 1); + add(set, "Recent.Files[15]", recent() == 15 ? 1 : 0); + add(set, "Recent.Files[15_30]", 15 < recent() && recent() < 31 ? 1 : 0); + add(set, "Recent.Files[30_50]", 30 < recent() && recent() < 51 ? 1 : 0); + add(set, "Recent.Files[more.than.50]", 50 < recent() ? 1 : 0); + add(set, "Block.cursor", EditorSettingsExternalizable.getInstance().isBlockCursor() ? 1 : 0); + add(set, "Line.Numbers", EditorSettingsExternalizable.getInstance().isLineNumbersShown() ? 1 : 0); + add(set, "Gutter.Icons", EditorSettingsExternalizable.getInstance().areGutterIconsShown() ? 1 : 0); + add(set, "Soft.Wraps", EditorSettingsExternalizable.getInstance().isUseSoftWraps() ? 1 : 0); + add(set, "Tabs.None", tabPlace() == 0 ? 1 : 0); + add(set, "Tabs.Top", tabPlace() == SwingConstants.TOP ? 1 : 0); + add(set, "Tabs.Bottom", tabPlace() == SwingConstants.BOTTOM ? 1 : 0); + add(set, "Tabs.Left", tabPlace() == SwingConstants.LEFT ? 1 : 0); + add(set, "Tabs.Right", tabPlace() == SwingConstants.RIGHT ? 1 : 0); + add(set, "Retina", UIUtil.isRetina() ? 1 : 0); + add(set, "Show.tips.on.startup", GeneralSettings.getInstance().isShowTipsOnStartup() ? 1 : 0); + set.add(getBooleanUsage("Allow.merging.buttons", UISettings.getInstance().getAllowMergeButtons())); + + return set; + } + + @NotNull + @Override + public String getGroupId() { + return "statistics.ui.info.features"; + } + + private static void add(Set set, String key, int value) { + set.add(new UsageDescriptor(key, value)); + } + + private static int tabPlace() { + return UISettings.getInstance().getEditorTabPlacement(); + } + + private static int recent() { + return UISettings.getInstance().getRecentFilesLimit(); + } + + private static boolean stripes() { + return UISettings.getInstance().getHideToolStripes(); + } + + private static boolean status() { + return UISettings.getInstance().getShowStatusBar(); + } + + private static boolean toolbar() { + return UISettings.getInstance().getShowMainToolbar(); + } + + private static boolean navbar() { + return UISettings.getInstance().getShowNavigationBar(); + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ShortcutsCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ShortcutsCollector.java similarity index 90% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ShortcutsCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ShortcutsCollector.java index 9442e93b3462..6c0fbc5c8dc1 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ShortcutsCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ShortcutsCollector.java @@ -1,15 +1,11 @@ // 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.internal.statistic.customUsageCollectors.ui; +package com.intellij.internal.statistic.collectors.fus.ui.persistence; -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.*; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.MapAnnotation; @@ -19,7 +15,10 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import static java.awt.event.InputEvent.ALT_GRAPH_MASK; @@ -41,7 +40,7 @@ import static java.awt.event.KeyEvent.*; } ) public class ShortcutsCollector implements PersistentStateComponent { - final static class MyState { + public final static class MyState { @Tag("counts") @MapAnnotation(surroundWithTag = false, keyAttributeName = "shortcut", valueAttributeName = "count") public final Map myValues = new HashMap<>(); @@ -104,32 +103,10 @@ public class ShortcutsCollector implements PersistentStateComponent getUsages() { - MyState state = getInstance().getState(); - return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); - } - - @NotNull - public GroupDescriptor getGroupId() { - return GROUP; - } - } - private static String getLocaleUnawareKeyText(int keyCode) { if (keyCode >= VK_0 && keyCode <= VK_9 || keyCode >= VK_A && keyCode <= VK_Z) { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ToolbarClicksCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ToolbarClicksCollector.java similarity index 71% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ToolbarClicksCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ToolbarClicksCollector.java index d86bf4d1d194..add4544f4210 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ToolbarClicksCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/fus/ui/persistence/ToolbarClicksCollector.java @@ -1,23 +1,18 @@ // 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.internal.statistic.customUsageCollectors.ui; +package com.intellij.internal.statistic.collectors.fus.ui.persistence; -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; import com.intellij.openapi.components.*; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.MapAnnotation; import com.intellij.util.xmlb.annotations.Tag; import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; -import java.util.Set; /** * @author Konstantin Bulenkov @@ -30,7 +25,7 @@ import java.util.Set; } ) public class ToolbarClicksCollector implements PersistentStateComponent { - final static class ClicksState { + public final static class ClicksState { @Tag("counts") @MapAnnotation(surroundWithTag = false, keyAttributeName = "action", valueAttributeName = "count") public Map myValues = new HashMap<>(); @@ -71,23 +66,7 @@ public class ToolbarClicksCollector implements PersistentStateComponent getUsages() { - ClicksState state = getInstance().getState(); - assert state != null; - return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); - } - - @NotNull - public GroupDescriptor getGroupId() { - return GROUP; - } - } -} +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ExperimentalFeaturesUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ExperimentalFeaturesUsageCollector.java similarity index 86% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ExperimentalFeaturesUsageCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ExperimentalFeaturesUsageCollector.java index 34fa28da0ab8..48086cb59dad 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ExperimentalFeaturesUsageCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ExperimentalFeaturesUsageCollector.java @@ -1,5 +1,5 @@ -// 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.internal.statistic.customUsageCollectors; +// 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.internal.statistic.collectors.legacy; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; @@ -14,6 +14,7 @@ import java.util.stream.Collectors; /** * @author Konstantin Bulenkov */ +@Deprecated // to be removed in 2018.2 public class ExperimentalFeaturesUsageCollector extends UsagesCollector { private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("Experimental Features"); diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/RegistryUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/LegacyRegistryUsagesCollector.java similarity index 79% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/RegistryUsagesCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/LegacyRegistryUsagesCollector.java index 3d255486f2f4..12eb3c0d2c67 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/RegistryUsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/LegacyRegistryUsagesCollector.java @@ -1,5 +1,5 @@ -// 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.internal.statistic.customUsageCollectors; +// 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.internal.statistic.collectors.legacy; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; @@ -13,7 +13,8 @@ import java.util.stream.Collectors; /** * @author Konstantin Bulenkov */ -public class RegistryUsagesCollector extends UsagesCollector { +@Deprecated // to be removed in 2018.2 +public class LegacyRegistryUsagesCollector extends UsagesCollector { private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("Registry"); @NotNull diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyActionUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyActionUsagesCollector.java new file mode 100644 index 000000000000..279181c432f5 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyActionUsagesCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.legacy.actions; + +import com.intellij.ide.actions.ActionsCollector; +import com.intellij.internal.statistic.UsagesCollector; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // old statistics service format +public final class LegacyActionUsagesCollector extends UsagesCollector { + private static final GroupDescriptor GROUP = GroupDescriptor.create("Actions", GroupDescriptor.HIGHER_PRIORITY); + + @NotNull + public Set getUsages() { + ActionsCollector.State state = ActionsCollector.getInstance().getState(); + assert state != null; + return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); + } + + @NotNull + public GroupDescriptor getGroupId() { + return GROUP; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyIntentionUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyIntentionUsagesCollector.java new file mode 100644 index 000000000000..a5d3c10be3c8 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyIntentionUsagesCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.legacy.actions; + +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.collectors.fus.actions.persistence.IntentionsCollector; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // to be removed in 2018.2 +public final class LegacyIntentionUsagesCollector extends UsagesCollector { + private static final GroupDescriptor GROUP = GroupDescriptor.create("Intentions"); + + @NotNull + public Set getUsages() { + IntentionsCollector.State state = IntentionsCollector.getInstance().getState(); + assert state != null; + return ContainerUtil.map2Set(state.myIntentions.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); + } + + @NotNull + public GroupDescriptor getGroupId() { + return GROUP; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyMainMenuUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyMainMenuUsagesCollector.java new file mode 100644 index 000000000000..33c33fd6c367 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/actions/LegacyMainMenuUsagesCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.legacy.actions; + +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.collectors.fus.actions.persistence.MainMenuCollector; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // to be removed in 2018.2 +public final class LegacyMainMenuUsagesCollector extends UsagesCollector { + private static final GroupDescriptor GROUP = GroupDescriptor.create("Main Menu", GroupDescriptor.HIGHER_PRIORITY); + + @NotNull + public Set getUsages() { + MainMenuCollector.State state = MainMenuCollector.getInstance().getState(); + assert state != null; + return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); + } + + @NotNull + public GroupDescriptor getGroupId() { + return GROUP; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/build/BuildNumberUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/build/BuildNumberUsageCollector.java similarity index 55% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/build/BuildNumberUsageCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/build/BuildNumberUsageCollector.java index 3af8f07cabf6..f950a54cca15 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/build/BuildNumberUsageCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/build/BuildNumberUsageCollector.java @@ -1,19 +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. - */ -package com.intellij.internal.statistic.customUsageCollectors.build; +// 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.internal.statistic.collectors.legacy.build; import com.intellij.internal.statistic.CollectUsagesException; import com.intellij.internal.statistic.UsagesCollector; @@ -28,6 +14,7 @@ import java.util.Set; /** * @author Ivan Chirkov */ +@Deprecated // to be removed in 2018.2 public class BuildNumberUsageCollector extends UsagesCollector { @NotNull @Override diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/fileTypes/LegacyFileTypeUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/fileTypes/LegacyFileTypeUsagesCollector.java new file mode 100644 index 000000000000..6979dc29f3ad --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/fileTypes/LegacyFileTypeUsagesCollector.java @@ -0,0 +1,31 @@ +// 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.internal.statistic.collectors.legacy.fileTypes; + +import com.intellij.internal.statistic.AbstractProjectsUsagesCollector; +import com.intellij.internal.statistic.CollectUsagesException; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.collectors.fus.fileTypes.FileTypeUsagesCollector; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +/** + * @author Nikolay Matveev + */ +public class LegacyFileTypeUsagesCollector extends AbstractProjectsUsagesCollector { + private static final String GROUP_ID = "file-type"; + + @NotNull + @Override + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID); + } + + @NotNull + @Override + public Set getProjectUsages(@NotNull final Project project) throws CollectUsagesException { + return FileTypeUsagesCollector.getDescriptors(project); + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ideSettings/IdeInitialConfigButtonUsages.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ideSettings/IdeInitialConfigButtonUsages.java similarity index 78% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ideSettings/IdeInitialConfigButtonUsages.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ideSettings/IdeInitialConfigButtonUsages.java index 04160ca96a09..228b3668e8a1 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ideSettings/IdeInitialConfigButtonUsages.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ideSettings/IdeInitialConfigButtonUsages.java @@ -1,19 +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. - */ -package com.intellij.internal.statistic.customUsageCollectors.ideSettings; +// 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.internal.statistic.collectors.legacy.ideSettings; import javax.swing.*; import java.util.Collections; diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ideSettings/IdeInitialConfigUsageCollectors.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ideSettings/IdeInitialConfigUsageCollectors.java similarity index 82% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ideSettings/IdeInitialConfigUsageCollectors.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ideSettings/IdeInitialConfigUsageCollectors.java index d1aaccd9ab82..9bd1b78576af 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ideSettings/IdeInitialConfigUsageCollectors.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ideSettings/IdeInitialConfigUsageCollectors.java @@ -1,19 +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. - */ -package com.intellij.internal.statistic.customUsageCollectors.ideSettings; +// 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.internal.statistic.collectors.legacy.ideSettings; import com.intellij.ide.WelcomeWizardUtil; import com.intellij.internal.statistic.CollectUsagesException; @@ -28,7 +14,7 @@ import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; -import static com.intellij.internal.statistic.customUsageCollectors.ideSettings.IdeInitialConfigButtonUsages.*; +import static com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages.*; public final class IdeInitialConfigUsageCollectors { public static class ConfigImport extends Base { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/jdk/JdkSettingsUsageCollector.kt b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/jdk/JdkSettingsUsageCollector.kt similarity index 78% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/jdk/JdkSettingsUsageCollector.kt rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/jdk/JdkSettingsUsageCollector.kt index 38198cb3c146..4eb1eed1b35b 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/jdk/JdkSettingsUsageCollector.kt +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/jdk/JdkSettingsUsageCollector.kt @@ -1,19 +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. - */ -package com.intellij.internal.statistic.customUsageCollectors.jdk +// 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.internal.statistic.collectors.legacy.jdk import com.intellij.internal.statistic.UsagesCollector import com.intellij.internal.statistic.beans.GroupDescriptor @@ -24,6 +10,7 @@ import java.util.function.Function /** * @author Konstantin Bulenkov */ +@Deprecated("") // to be removed in 2018.2 class JdkSettingsUsageCollector : UsagesCollector() { override fun getUsages(): Set { return ManagementFactory.getRuntimeMXBean().inputArguments diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/jdk/JdkInfoUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/jdk/LegacyJdkInfoUsageCollector.java similarity index 84% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/jdk/JdkInfoUsageCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/jdk/LegacyJdkInfoUsageCollector.java index 564aa070249c..1d6f1e0b068b 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/jdk/JdkInfoUsageCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/jdk/LegacyJdkInfoUsageCollector.java @@ -1,5 +1,5 @@ // 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.internal.statistic.customUsageCollectors.jdk; +package com.intellij.internal.statistic.collectors.legacy.jdk; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; @@ -13,7 +13,8 @@ import java.util.Set; /** * @author Konstantin Bulenkov */ -class JdkInfoUsageCollector extends UsagesCollector { +@Deprecated // to be removed in 2018.2 +class LegacyJdkInfoUsageCollector extends UsagesCollector { @NotNull @Override public Set getUsages() { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/os/OsNameUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/os/LegacyOsNameUsageCollector.java similarity index 53% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/os/OsNameUsageCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/os/LegacyOsNameUsageCollector.java index 1cc9070917d1..7e41227d6b12 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/os/OsNameUsageCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/os/LegacyOsNameUsageCollector.java @@ -1,19 +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. - */ -package com.intellij.internal.statistic.customUsageCollectors.os; +// 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.internal.statistic.collectors.legacy.os; import com.intellij.internal.statistic.CollectUsagesException; import com.intellij.internal.statistic.UsagesCollector; @@ -28,7 +14,8 @@ import java.util.Set; /** * @author peter */ -class OsNameUsageCollector extends UsagesCollector { +@Deprecated // to be removed in 2018.2 +class LegacyOsNameUsageCollector extends UsagesCollector { @NotNull @Override public Set getUsages() throws CollectUsagesException { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/os/LegacyOsVersionUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/os/LegacyOsVersionUsageCollector.java new file mode 100644 index 000000000000..b91e8fdf4d52 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/os/LegacyOsVersionUsageCollector.java @@ -0,0 +1,29 @@ +// 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.internal.statistic.collectors.legacy.os; + +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.collectors.fus.os.OsVersionUsageCollector; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +/** + * @author peter + */ +@Deprecated + // to be removed in 2018.2 +class LegacyOsVersionUsageCollector extends UsagesCollector { + @NotNull + @Override + public Set getUsages() { + return OsVersionUsageCollector.getDescriptors(); + } + + @NotNull + @Override + public GroupDescriptor getGroupId() { + return GroupDescriptor.create("user.os.version"); + } +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/plugins/LegacyDisabledPluginsUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/plugins/LegacyDisabledPluginsUsagesCollector.java new file mode 100644 index 000000000000..52fe70f34148 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/plugins/LegacyDisabledPluginsUsagesCollector.java @@ -0,0 +1,26 @@ +// 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.internal.statistic.collectors.legacy.plugins; + +import com.intellij.ide.plugins.PluginManagerCore; +import com.intellij.internal.statistic.UsagesCollector; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // to be removed in 2018.2 +public class LegacyDisabledPluginsUsagesCollector extends UsagesCollector { + private static final String GROUP_ID = "disabled-plugins"; + + @NotNull + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY); + } + + @NotNull + public Set getUsages() { + return ContainerUtil.map2Set(PluginManagerCore.getDisabledPlugins(), descriptor -> new UsageDescriptor(descriptor, 1)); + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/NonBundledPluginsUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/plugins/LegacyNonBundledPluginsUsagesCollector.java similarity index 54% rename from platform/platform-impl/src/com/intellij/ide/plugins/NonBundledPluginsUsagesCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/plugins/LegacyNonBundledPluginsUsagesCollector.java index e4c68285bd5b..fd772f8e4f6e 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/NonBundledPluginsUsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/plugins/LegacyNonBundledPluginsUsagesCollector.java @@ -1,32 +1,19 @@ -/* - * Copyright 2000-2011 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. - */ -package com.intellij.ide.plugins; +// 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.internal.statistic.collectors.legacy.plugins; +import com.intellij.ide.plugins.IdeaPluginDescriptor; +import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.openapi.util.Condition; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.Set; -public class NonBundledPluginsUsagesCollector extends UsagesCollector { +@Deprecated // to be removed in 2018.2 +public class LegacyNonBundledPluginsUsagesCollector extends UsagesCollector { private static final String GROUP_ID = "non-bundled-plugins"; @NotNull diff --git a/platform/platform-impl/src/com/intellij/featureStatistics/FeaturesUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/productivity/LegacyProductivityFeaturesUsageCollector.java similarity index 57% rename from platform/platform-impl/src/com/intellij/featureStatistics/FeaturesUsageCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/productivity/LegacyProductivityFeaturesUsageCollector.java index 80836ca10175..e7f3ccebd16f 100644 --- a/platform/platform-impl/src/com/intellij/featureStatistics/FeaturesUsageCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/productivity/LegacyProductivityFeaturesUsageCollector.java @@ -1,20 +1,8 @@ -/* - * Copyright 2000-2010 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. - */ -package com.intellij.featureStatistics; +// 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.internal.statistic.collectors.legacy.productivity; +import com.intellij.featureStatistics.FeatureDescriptor; +import com.intellij.featureStatistics.ProductivityFeaturesRegistry; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; @@ -23,7 +11,8 @@ import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; -public class FeaturesUsageCollector extends UsagesCollector { +@Deprecated // to be removed in 2018.2 +public class LegacyProductivityFeaturesUsageCollector extends UsagesCollector { @NotNull @Override diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/A11YUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyA11YUsagesCollector.java similarity index 80% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/A11YUsagesCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyA11YUsagesCollector.java index ad347da84b1f..59bd776bb720 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/A11YUsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyA11YUsagesCollector.java @@ -1,5 +1,5 @@ -// 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.internal.statistic.customUsageCollectors.ui; +// 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.internal.statistic.collectors.legacy.ui; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; @@ -14,7 +14,8 @@ import java.util.Set; /** * @author tav */ -public class A11YUsagesCollector extends UsagesCollector { +@Deprecated // to be removed in 2018.2 +public class LegacyA11YUsagesCollector extends UsagesCollector { @NotNull @Override public Set getUsages() { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyEditorColorSchemesUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyEditorColorSchemesUsagesCollector.java new file mode 100644 index 000000000000..623267cb7c99 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyEditorColorSchemesUsagesCollector.java @@ -0,0 +1,29 @@ +// 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.internal.statistic.collectors.legacy.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.collectors.fus.ui.EditorColorSchemesUsagesCollector; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // to be removed in 2018.2 +public class LegacyEditorColorSchemesUsagesCollector extends UsagesCollector { + + public static final String GROUP_ID = "Color Schemes"; + + @NotNull + @Override + public Set getUsages() { + return EditorColorSchemesUsagesCollector.getDescriptors(); + } + + @NotNull + @Override + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID); + } + +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/FontSizeInfoUsageCollector.kt b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyFontSizeInfoUsageCollector.kt similarity index 73% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/FontSizeInfoUsageCollector.kt rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyFontSizeInfoUsageCollector.kt index 332fc5a83ceb..b67d482aba33 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/FontSizeInfoUsageCollector.kt +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyFontSizeInfoUsageCollector.kt @@ -1,19 +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. - */ -package com.intellij.internal.statistic.customUsageCollectors.ui +// 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.internal.statistic.collectors.legacy.ui import com.intellij.ide.ui.UISettings import com.intellij.ide.util.PropertiesComponent @@ -27,7 +13,7 @@ import com.intellij.openapi.editor.colors.impl.AppEditorFontOptions /** * @author Konstantin Bulenkov */ -class FontSizeInfoUsageCollector : UsagesCollector() { +class LegacyFontSizeInfoUsageCollector : UsagesCollector() { @Throws(CollectUsagesException::class) override fun getUsages(): Set { val scheme = EditorColorsManager.getInstance().globalScheme diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/HiDPIModeUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyHiDPIModeUsagesCollector.java similarity index 79% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/HiDPIModeUsagesCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyHiDPIModeUsagesCollector.java index c8626fcd957a..1cf29d54ac1f 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/HiDPIModeUsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyHiDPIModeUsagesCollector.java @@ -1,5 +1,5 @@ -// 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.internal.statistic.customUsageCollectors.ui; +// 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.internal.statistic.collectors.legacy.ui; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; @@ -14,7 +14,8 @@ import java.util.Set; /** * @author tav */ -public class HiDPIModeUsagesCollector extends UsagesCollector { +@Deprecated // to be removed in 2018.2 +public class LegacyHiDPIModeUsagesCollector extends UsagesCollector { @NotNull @Override public Set getUsages() { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/LaFUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyLaFUsagesCollector.java similarity index 52% rename from platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/LaFUsagesCollector.java rename to platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyLaFUsagesCollector.java index 20a3c31a9bbe..041d91e29f3a 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/LaFUsagesCollector.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyLaFUsagesCollector.java @@ -1,22 +1,7 @@ -/* - * 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. - */ -package com.intellij.internal.statistic.customUsageCollectors.ui; +// 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.internal.statistic.collectors.legacy.ui; import com.intellij.ide.ui.LafManager; -import com.intellij.internal.statistic.CollectUsagesException; import com.intellij.internal.statistic.UsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; @@ -28,10 +13,11 @@ import javax.swing.*; import java.util.Collections; import java.util.Set; -public class LaFUsagesCollector extends UsagesCollector { +@Deprecated // to be removed in 2018.2 +public class LegacyLaFUsagesCollector extends UsagesCollector { @NotNull @Override - public Set getUsages() throws CollectUsagesException { + public Set getUsages() { UIManager.LookAndFeelInfo laf = LafManager.getInstance().getCurrentLookAndFeel(); String key = SystemInfo.OS_NAME + " - "; if (!StringUtil.isEmptyOrSpaces(SystemInfo.SUN_DESKTOP)) { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyScaleInfoUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyScaleInfoUsageCollector.java new file mode 100644 index 000000000000..8d772b074ac3 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyScaleInfoUsageCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.legacy.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.collectors.fus.ui.ScaleInfoUsageCollector; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +/** + * @author tav + */ +@Deprecated // to be removed in 2018.2 +public class LegacyScaleInfoUsageCollector extends UsagesCollector { + @NotNull + @Override + public Set getUsages() { + return ScaleInfoUsageCollector.getDescriptors(); + } + + @NotNull + @Override + public GroupDescriptor getGroupId() { + return GroupDescriptor.create("user.ui.screen.scale"); + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyShortcutUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyShortcutUsagesCollector.java new file mode 100644 index 000000000000..4719fee92054 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyShortcutUsagesCollector.java @@ -0,0 +1,35 @@ +// 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.internal.statistic.collectors.legacy.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.collectors.fus.ui.persistence.ShortcutsCollector; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // to be removed in 2018.2 +public final class LegacyShortcutUsagesCollector extends UsagesCollector { + private static final GroupDescriptor GROUP = GroupDescriptor.create(getGroupName(), GroupDescriptor.HIGHER_PRIORITY); + + private static String getGroupName() { + if (SystemInfo.isMac) return "Shortcuts on Mac"; + if (SystemInfo.isWindows) return "Shortcuts on Windows"; + if (SystemInfo.isLinux) return "Shortcuts on Linux"; + return "Shortcuts on OtherOs"; + } + + @NotNull + public Set getUsages() { + ShortcutsCollector.MyState state = ShortcutsCollector.getInstance().getState(); + return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); + } + + @NotNull + public GroupDescriptor getGroupId() { + return GROUP; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyToolbarClicksUsagesCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyToolbarClicksUsagesCollector.java new file mode 100644 index 000000000000..164088368031 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyToolbarClicksUsagesCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.legacy.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.collectors.fus.ui.persistence.ToolbarClicksCollector; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // to be removed in 2018.2 +public final class LegacyToolbarClicksUsagesCollector extends UsagesCollector { + private static final GroupDescriptor GROUP = GroupDescriptor.create("Toolbar Clicks", GroupDescriptor.HIGHER_PRIORITY); + + @NotNull + public Set getUsages() { + ToolbarClicksCollector.ClicksState state = ToolbarClicksCollector.getInstance().getState(); + assert state != null; + return ContainerUtil.map2Set(state.myValues.entrySet(), e -> new UsageDescriptor(e.getKey(), e.getValue())); + } + + @NotNull + public GroupDescriptor getGroupId() { + return GROUP; + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyUiInfoUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyUiInfoUsageCollector.java new file mode 100644 index 000000000000..09d1156e8c28 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/collectors/legacy/ui/LegacyUiInfoUsageCollector.java @@ -0,0 +1,28 @@ +// 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.internal.statistic.collectors.legacy.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.collectors.fus.ui.UiInfoUsageCollector; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +/** + * @author Konstantin Bulenkov + */ +@Deprecated // to be removed in 2018.2 +class LegacyUiInfoUsageCollector extends UsagesCollector { + @NotNull + @Override + public Set getUsages() { + return UiInfoUsageCollector.getDescriptors(); + } + + @NotNull + @Override + public GroupDescriptor getGroupId() { + return GroupDescriptor.create("UI Features"); + } +} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionIdProvider.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionIdProvider.java deleted file mode 100644 index 03164ad55ad7..000000000000 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/actions/ActionIdProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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.internal.statistic.customUsageCollectors.actions; - -public interface ActionIdProvider { - String getId(); -} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/os/OsVersionUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/os/OsVersionUsageCollector.java deleted file mode 100644 index 489f884fcf27..000000000000 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/os/OsVersionUsageCollector.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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. - */ -package com.intellij.internal.statistic.customUsageCollectors.os; - -import com.intellij.internal.statistic.CollectUsagesException; -import com.intellij.internal.statistic.UsagesCollector; -import com.intellij.internal.statistic.beans.GroupDescriptor; -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.Version; -import com.intellij.openapi.util.text.StringUtil; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Collections; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * @author peter - */ -class OsVersionUsageCollector extends UsagesCollector { - @NotNull - @Override - public Set getUsages() throws CollectUsagesException { - UsageDescriptor descriptor; - - if (SystemInfo.isLinux) { - String releaseId = null, releaseVersion = null; - - try { - Map values = Files.lines(Paths.get("/etc/os-release")) - .map(line -> StringUtil.split(line, "=")) - .filter(parts -> parts.size() == 2) - .collect(Collectors.toMap(parts -> parts.get(0), parts -> StringUtil.unquoteString(parts.get(1)))); - releaseId = values.get("ID"); - releaseVersion = values.get("VERSION_ID"); - } - catch (IOException ignored) { } - - if (releaseId == null) releaseId = "unknown"; - - if (releaseVersion == null) { - releaseVersion = SystemInfo.OS_VERSION; - Version version = Version.parseVersion(releaseVersion); - if (version != null) { - releaseVersion = version.toCompactString(); - } - } - - descriptor = new UsageDescriptor("Linux/" + releaseId + " " + releaseVersion, 1); - } - else { - descriptor = new UsageDescriptor(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, 1); - } - - return Collections.singleton(descriptor); - } - - @NotNull - @Override - public GroupDescriptor getGroupId() { - return GroupDescriptor.create("user.os.version"); - } -} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ScaleInfoUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ScaleInfoUsageCollector.java deleted file mode 100644 index 539b3803df1f..000000000000 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/ScaleInfoUsageCollector.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ -package com.intellij.internal.statistic.customUsageCollectors.ui; - -import com.intellij.internal.statistic.CollectUsagesException; -import com.intellij.internal.statistic.UsagesCollector; -import com.intellij.internal.statistic.beans.GroupDescriptor; -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.util.ui.JBUI; -import org.jdesktop.swingx.util.OS; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.Set; - -/** - * @author tav - */ -public class ScaleInfoUsageCollector extends UsagesCollector { - @NotNull - @Override - public Set getUsages() throws CollectUsagesException { - float scale = JBUI.sysScale(); - - int scaleBase = (int)Math.floor(scale); - float scaleFract = scale - scaleBase; - - if (scaleFract == 0.0f) scaleFract = 0.0f; // count integer scale on a precise match only - else if (scaleFract < 0.375f) scaleFract = 0.25f; - else if (scaleFract < 0.625f) scaleFract = 0.5f; - else scaleFract = 0.75f; - - scale = scaleBase + scaleFract; - - String os = OS.isWindows() ? "Windows" : OS.isLinux() ? "Linux" : OS.isMacOSX() ? "Mac" : "Unknown OS"; - return Collections.singleton(new UsageDescriptor(os + " " + scale, 1)); - } - - @NotNull - @Override - public GroupDescriptor getGroupId() { - return GroupDescriptor.create("user.ui.screen.scale"); - } -} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/UiInfoUsageCollector.java b/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/UiInfoUsageCollector.java deleted file mode 100644 index ccc01a8e6909..000000000000 --- a/platform/platform-impl/src/com/intellij/internal/statistic/customUsageCollectors/ui/UiInfoUsageCollector.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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. - */ -package com.intellij.internal.statistic.customUsageCollectors.ui; - -import com.intellij.ide.GeneralSettings; -import com.intellij.ide.ui.UISettings; -import com.intellij.internal.statistic.UsagesCollector; -import com.intellij.internal.statistic.beans.GroupDescriptor; -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; -import com.intellij.util.ui.UIUtil; -import gnu.trove.THashSet; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.util.Set; - -import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getBooleanUsage; - -/** - * @author Konstantin Bulenkov - */ -class UiInfoUsageCollector extends UsagesCollector { - @NotNull - @Override - public Set getUsages() { - Set set = new THashSet<>(); - - add(set, "Nav Bar visible", navbar() ? 1 : 0); - add(set, "Nav Bar floating", navbar() ? 0 : 1); - add(set, "Toolbar visible", toolbar() ? 1 : 0); - add(set, "Toolbar hidden", toolbar() ? 0 : 1); - add(set, "Toolbar + NavBar", !toolbar() && navbar() ? 1 : 0); - add(set, "Toolbar and NavBar hidden", !toolbar() && !navbar() ? 1 : 0); - add(set, "Status bar visible", status() ? 1 : 0); - add(set, "Status bar hidden", status() ? 0 : 1); - add(set, "Tool Window buttons visible", stripes() ? 1 : 0); - add(set, "Tool Window buttons hidden", stripes() ? 0 : 1); - add(set, "Recent Files = 15", recent() == 15 ? 1 : 0); - add(set, "Recent Files (15, 30]", 15 < recent() && recent() < 31 ? 1 : 0); - add(set, "Recent Files (30, 50]", 30 < recent() && recent() < 51 ? 1 : 0); - add(set, "Recent Files > 50", 50 < recent() ? 1 : 0); - add(set, "Block cursor", EditorSettingsExternalizable.getInstance().isBlockCursor() ? 1 : 0); - add(set, "Line Numbers", EditorSettingsExternalizable.getInstance().isLineNumbersShown() ? 1 : 0); - add(set, "Gutter Icons", EditorSettingsExternalizable.getInstance().areGutterIconsShown() ? 1 : 0); - add(set, "Soft Wraps", EditorSettingsExternalizable.getInstance().isUseSoftWraps() ? 1 : 0); - add(set, "Tabs None", tabPlace() == 0 ? 1 : 0); - add(set, "Tabs Top", tabPlace() == SwingConstants.TOP ? 1 : 0); - add(set, "Tabs Bottom", tabPlace() == SwingConstants.BOTTOM ? 1 : 0); - add(set, "Tabs Left", tabPlace() == SwingConstants.LEFT ? 1 : 0); - add(set, "Tabs Right", tabPlace() == SwingConstants.RIGHT ? 1 : 0); - add(set, "Retina", UIUtil.isRetina() ? 1 : 0); - add(set, "Show tips on startup", GeneralSettings.getInstance().isShowTipsOnStartup() ? 1 : 0); - set.add(getBooleanUsage("Allow merging buttons", UISettings.getInstance().getAllowMergeButtons())); - - return set; - } - - @NotNull - @Override - public GroupDescriptor getGroupId() { - return GroupDescriptor.create("UI Features"); - } - - private static void add(Set set, String key, int value) { - set.add(new UsageDescriptor(key, value)); - } - - private static int tabPlace() { - return UISettings.getInstance().getEditorTabPlacement(); - } - - private static int recent() { - return UISettings.getInstance().getRecentFilesLimit(); - } - - private static boolean stripes() { - return UISettings.getInstance().getHideToolStripes(); - } - - private static boolean status() { - return UISettings.getInstance().getShowStatusBar(); - } - - private static boolean toolbar() { - return UISettings.getInstance().getShowMainToolbar(); - } - - private static boolean navbar() { - return UISettings.getInstance().getShowNavigationBar(); - } -} diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/service/fus/beans/FSGroup.java b/platform/platform-impl/src/com/intellij/internal/statistic/service/fus/beans/FSGroup.java index 8cb0ac1492d2..1f6c898d3043 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/service/fus/beans/FSGroup.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/service/fus/beans/FSGroup.java @@ -2,6 +2,7 @@ package com.intellij.internal.statistic.service.fus.beans; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.UsageDescriptorKeyValidator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -11,24 +12,16 @@ import java.util.Set; public class FSGroup { - private static final String FORBIDDEN_PATTERN = "[,\\s\\n]+"; - private static final String FORBIDDEN_PATTERN_REPLACEMENT = "[??]"; - public String id; public Map metrics ; private FSGroup(String id, Set usages) { this.id = id; for (UsageDescriptor usage : usages) { - getMetrics().put(replaceForbiddenPattern(usage), usage.getValue()); + getMetrics().put(UsageDescriptorKeyValidator.replaceForbiddenSymbols(usage.getKey()), usage.getValue()); } } - @NotNull - private static String replaceForbiddenPattern(@NotNull UsageDescriptor usage) { - return usage.getKey().replaceAll(FORBIDDEN_PATTERN, FORBIDDEN_PATTERN_REPLACEMENT); - } - @NotNull public Map getMetrics() { if (metrics == null) { diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/service/fus/collectors/UsageDescriptorKeyValidator.java b/platform/platform-impl/src/com/intellij/internal/statistic/service/fus/collectors/UsageDescriptorKeyValidator.java new file mode 100644 index 000000000000..82ce14d16abb --- /dev/null +++ b/platform/platform-impl/src/com/intellij/internal/statistic/service/fus/collectors/UsageDescriptorKeyValidator.java @@ -0,0 +1,19 @@ +// 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.internal.statistic.service.fus.collectors; + +import org.jetbrains.annotations.NotNull; + +public class UsageDescriptorKeyValidator { + public static final String FORBIDDEN_PATTERN = "[,\\s\\n]+"; + public static final String FORBIDDEN_PATTERN_REPLACEMENT = "[??]"; + + @NotNull + public static String replaceForbiddenSymbols(@NotNull String key) { + return key.replaceAll(FORBIDDEN_PATTERN, FORBIDDEN_PATTERN_REPLACEMENT); + } + + @NotNull + public static String ensureProperKey(@NotNull String key) { + return key.replaceAll(FORBIDDEN_PATTERN, "."); + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionButton.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionButton.java index b231c47a0922..873d776532e9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionButton.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionButton.java @@ -18,7 +18,7 @@ package com.intellij.openapi.actionSystem.impl; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; import com.intellij.ide.HelpTooltip; -import com.intellij.internal.statistic.customUsageCollectors.ui.ToolbarClicksCollector; +import com.intellij.internal.statistic.collectors.fus.ui.persistence.ToolbarClicksCollector; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionButtonLook; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java index 6755344ae749..96dbbcc42925 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java @@ -10,8 +10,8 @@ import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.ide.plugins.PluginManager; import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.idea.IdeaLogger; -import com.intellij.internal.statistic.customUsageCollectors.actions.ActionIdProvider; -import com.intellij.internal.statistic.customUsageCollectors.actions.ActionsCollectorImpl; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionIdProvider; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionsCollectorImpl; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java index e0e2299da461..75620457321e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionMenuItem.java @@ -4,7 +4,7 @@ package com.intellij.openapi.actionSystem.impl; import com.intellij.featureStatistics.FeatureUsageTracker; import com.intellij.ide.ui.UISettings; import com.intellij.ide.ui.laf.IconCache; -import com.intellij.internal.statistic.customUsageCollectors.actions.MainMenuCollector; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.MainMenuCollector; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java index 0a44b2cab584..5d1d835dcbe0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java @@ -5,7 +5,7 @@ import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; import com.intellij.ide.HelpTooltip; import com.intellij.ide.impl.DataManagerImpl; -import com.intellij.internal.statistic.customUsageCollectors.ui.ToolbarClicksCollector; +import com.intellij.internal.statistic.collectors.fus.ui.persistence.ToolbarClicksCollector; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionButtonLook; diff --git a/platform/platform-impl/src/com/intellij/openapi/application/ImportOldConfigsPanel.java b/platform/platform-impl/src/com/intellij/openapi/application/ImportOldConfigsPanel.java index 073c47c77f84..439e0c3bb7d6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/ImportOldConfigsPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/ImportOldConfigsPanel.java @@ -2,7 +2,7 @@ package com.intellij.openapi.application; import com.intellij.ide.cloudConfig.CloudConfigProvider; -import com.intellij.internal.statistic.customUsageCollectors.ideSettings.IdeInitialConfigButtonUsages; +import com.intellij.internal.statistic.collectors.legacy.ideSettings.IdeInitialConfigButtonUsages; import com.intellij.openapi.MnemonicHelper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.Pair; diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java index 3c4df10ebc0e..c7060aed3298 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java @@ -19,7 +19,7 @@ import com.intellij.ide.DataManager; import com.intellij.ide.IdeEventQueue; import com.intellij.ide.ProhibitAWTEvents; import com.intellij.ide.impl.DataManagerImpl; -import com.intellij.internal.statistic.customUsageCollectors.ui.ShortcutsCollector; +import com.intellij.internal.statistic.collectors.fus.ui.persistence.ShortcutsCollector; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java index 7be943a95bb0..b1467dae9238 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java @@ -3,7 +3,7 @@ package com.intellij.openapi.keymap.impl; import com.intellij.ide.DataManager; import com.intellij.ide.IdeEventQueue; -import com.intellij.internal.statistic.customUsageCollectors.ui.ShortcutsCollector; +import com.intellij.internal.statistic.collectors.fus.ui.persistence.ShortcutsCollector; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java index 39c953cb67a5..f182c2998863 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeader.java @@ -5,7 +5,7 @@ import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; import com.intellij.ide.ui.UISettings; import com.intellij.ide.ui.UISettingsListener; -import com.intellij.internal.statistic.customUsageCollectors.ui.ToolbarClicksCollector; +import com.intellij.internal.statistic.collectors.fus.ui.persistence.ToolbarClicksCollector; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegMenuItemUI.java b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegMenuItemUI.java index e80baefaa426..807190f15c3c 100644 --- a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegMenuItemUI.java +++ b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegMenuItemUI.java @@ -17,7 +17,7 @@ package com.intellij.ui.plaf.beg; import com.intellij.ide.ui.UISettings; -import com.intellij.internal.statistic.customUsageCollectors.actions.MainMenuCollector; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.MainMenuCollector; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.impl.ActionMenuItem; diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index cc9c16f69ccc..077d16644b92 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -906,11 +906,13 @@ + + + - diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 6e4127605a12..5deaf23b3691 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -202,12 +202,12 @@ - - + + - - + serviceImplementation="com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionsCollectorImpl"/> + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java index c653acf45da0..1c009a5a36d4 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/FileTypeUsagesCollectorTest.java @@ -17,6 +17,7 @@ package com.intellij.openapi.fileTypes; import com.intellij.internal.statistic.CollectUsagesException; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.collectors.legacy.fileTypes.LegacyFileTypeUsagesCollector; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.util.NotNullFunction; import com.intellij.util.containers.ContainerUtil; @@ -32,7 +33,7 @@ import java.util.Set; public class FileTypeUsagesCollectorTest extends LightPlatformCodeInsightFixtureTestCase { private void doTest(@NotNull Collection fileTypes) throws CollectUsagesException { - final Set usages = new FileTypeUsagesCollector().getProjectUsages(getProject()); + final Set usages = new LegacyFileTypeUsagesCollector().getProjectUsages(getProject()); for (UsageDescriptor usage : usages) { assertEquals(1, usage.getValue()); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/CheckoutAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/CheckoutAction.java index 29e6b7db1cdd..698b89b0ac13 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/CheckoutAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/CheckoutAction.java @@ -15,11 +15,13 @@ */ package com.intellij.openapi.vcs.checkout; -import com.intellij.internal.statistic.customUsageCollectors.actions.ActionIdProvider; +import com.intellij.internal.statistic.collectors.fus.actions.persistence.ActionIdProvider; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.project.*; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.vcs.CheckoutProvider; import com.intellij.openapi.vcs.ProjectLevelVcsManager; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsOptionsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsOptionsUsagesCollector.java new file mode 100644 index 000000000000..8f07d6081779 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsOptionsUsagesCollector.java @@ -0,0 +1,25 @@ +// 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.vcs.statistics; + +import com.intellij.internal.statistic.AbstractProjectsUsagesCollector; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // to be removed in 2018.2 +public class LegacyVcsOptionsUsagesCollector extends AbstractProjectsUsagesCollector { + private static final String GROUP_ID = "vcs-options"; + + @NotNull + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID); + } + + @NotNull + public Set getProjectUsages(@NotNull Project project) { + return VcsOptionsUsagesCollector.getDescriptors(project); + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsStatsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsStatsUsagesCollector.java new file mode 100644 index 000000000000..a7a1f23c2572 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsStatsUsagesCollector.java @@ -0,0 +1,25 @@ +// 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.vcs.statistics; + +import com.intellij.internal.statistic.AbstractProjectsUsagesCollector; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +@Deprecated // to be removed in 2018.2 +public class LegacyVcsStatsUsagesCollector extends AbstractProjectsUsagesCollector { + private static final String GROUP_ID = "vcs-stats"; + + @NotNull + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID); + } + + @NotNull + public Set getProjectUsages(@NotNull Project project) { + return VcsStatsUsagesCollector.getDescriptors(project); + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/DisabledPluginsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsUsagesCollector.java similarity index 63% rename from platform/platform-impl/src/com/intellij/ide/plugins/DisabledPluginsUsagesCollector.java rename to platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsUsagesCollector.java index 4ab48850c44d..38294390c383 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/DisabledPluginsUsagesCollector.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/LegacyVcsUsagesCollector.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2010 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. @@ -13,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.ide.plugins; +package com.intellij.openapi.vcs.statistics; -import com.intellij.internal.statistic.UsagesCollector; +import com.intellij.internal.statistic.AbstractProjectsUsagesCollector; import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.util.Function; -import com.intellij.util.containers.ContainerUtil; +import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import java.util.Set; -public class DisabledPluginsUsagesCollector extends UsagesCollector { - private static final String GROUP_ID = "disabled-plugins"; +@Deprecated // to be removed in 2018.2 +public class LegacyVcsUsagesCollector extends AbstractProjectsUsagesCollector { + private static final String GROUP_ID = "vcs"; @NotNull public GroupDescriptor getGroupId() { @@ -33,7 +33,7 @@ public class DisabledPluginsUsagesCollector extends UsagesCollector { } @NotNull - public Set getUsages() { - return ContainerUtil.map2Set(PluginManagerCore.getDisabledPlugins(), descriptor -> new UsageDescriptor(descriptor, 1)); + public Set getProjectUsages(@NotNull Project project) { + return VcsNamesUsagesCollector.getDescriptors(project); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsNamesUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsNamesUsagesCollector.java new file mode 100644 index 000000000000..c94986797525 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsNamesUsagesCollector.java @@ -0,0 +1,46 @@ +// 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.vcs.statistics; + +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vcs.AbstractVcs; +import com.intellij.openapi.vcs.ProjectLevelVcsManager; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class VcsNamesUsagesCollector extends ProjectUsagesCollector { + + @NotNull + public String getGroupId() { + return "statistics.vcs.names"; + } + + @NotNull + public Set getUsages(@NotNull Project project) { + return getDescriptors(project); + } + + @NotNull + public static Set getDescriptors(@NotNull Project project) { + Set usages = new HashSet<>(); + + AbstractVcs[] activeVcss = ProjectLevelVcsManager.getInstance(project).getAllActiveVcss(); + List vcsNames = ContainerUtil.map(activeVcss, AbstractVcs::getName); + + for (String vcs : vcsNames) { + usages.add(new UsageDescriptor(vcs, 1)); + } + + if (vcsNames.size() > 1) { + usages.add(new UsageDescriptor(StringUtil.join(ContainerUtil.sorted(vcsNames), ","), 1)); + } + + return usages; + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsOptionsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsOptionsUsagesCollector.java index ef7247fa90b4..b7bc07b0d402 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsOptionsUsagesCollector.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsOptionsUsagesCollector.java @@ -1,23 +1,8 @@ -/* - * 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-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.vcs.statistics; -import com.intellij.internal.statistic.AbstractProjectsUsagesCollector; -import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsConfiguration; import org.jetbrains.annotations.NotNull; @@ -28,16 +13,17 @@ import java.util.Set; import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getBooleanUsage; import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getEnumUsage; -public class VcsOptionsUsagesCollector extends AbstractProjectsUsagesCollector { - private static final String GROUP_ID = "vcs-options"; +public class VcsOptionsUsagesCollector extends ProjectUsagesCollector { + @NotNull + public String getGroupId() { return "statistics.vcs.options"; } @NotNull - public GroupDescriptor getGroupId() { - return GroupDescriptor.create(GROUP_ID); + public Set getUsages(@NotNull Project project) { + return getDescriptors(project); } @NotNull - public Set getProjectUsages(@NotNull Project project) { + public static Set getDescriptors(@NotNull Project project) { VcsConfiguration configuration = VcsConfiguration.getInstance(project); Set usages = new HashSet<>(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatsUsagesCollector.java index 98e3641ade70..a06c9fe629d2 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatsUsagesCollector.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsStatsUsagesCollector.java @@ -1,30 +1,32 @@ -// 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. +// 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.vcs.statistics; -import com.intellij.internal.statistic.AbstractProjectsUsagesCollector; -import com.intellij.internal.statistic.beans.GroupDescriptor; import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.internal.statistic.service.fus.collectors.ProjectUsagesCollector; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.changes.ChangeListManagerImpl; import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx; -import java.util.HashSet; import org.jetbrains.annotations.NotNull; +import java.util.HashSet; import java.util.Set; import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getBooleanUsage; import static com.intellij.internal.statistic.utils.StatisticsUtilKt.getCountingUsage; -public class VcsStatsUsagesCollector extends AbstractProjectsUsagesCollector { - private static final String GROUP_ID = "vcs-stats"; - +public class VcsStatsUsagesCollector extends ProjectUsagesCollector { @NotNull - public GroupDescriptor getGroupId() { - return GroupDescriptor.create(GROUP_ID); + public String getGroupId() { + return "statistics.vcs.metrics"; } @NotNull - public Set getProjectUsages(@NotNull Project project) { + public Set getUsages(@NotNull Project project) { + return getDescriptors(project); + } + + @NotNull + public static Set getDescriptors(@NotNull Project project) { Set usages = new HashSet<>(); ChangeListManagerImpl clm = ChangeListManagerImpl.getInstanceImpl(project); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.java deleted file mode 100644 index 0e57ad30c39f..000000000000 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/statistics/VcsUsagesCollector.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2000-2010 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. - */ -package com.intellij.openapi.vcs.statistics; - -import com.intellij.internal.statistic.AbstractProjectsUsagesCollector; -import com.intellij.internal.statistic.beans.GroupDescriptor; -import com.intellij.internal.statistic.beans.UsageDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vcs.AbstractVcs; -import com.intellij.openapi.vcs.ProjectLevelVcsManager; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class VcsUsagesCollector extends AbstractProjectsUsagesCollector { - private static final String GROUP_ID = "vcs"; - - @NotNull - public GroupDescriptor getGroupId() { - return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY); - } - - @NotNull - public Set getProjectUsages(@NotNull Project project) { - Set usages = new HashSet<>(); - - AbstractVcs[] activeVcss = ProjectLevelVcsManager.getInstance(project).getAllActiveVcss(); - List vcsNames = ContainerUtil.map(activeVcss, AbstractVcs::getName); - - for (String vcs : vcsNames) { - usages.add(new UsageDescriptor(vcs, 1)); - } - - if (vcsNames.size() > 1) { - usages.add(new UsageDescriptor(StringUtil.join(ContainerUtil.sorted(vcsNames), ","), 1)); - } - - return usages; - } -}