add run configuration types to usage statistics[r=nik]
authorNikolay Matveev <Nikolay.Matveev@jetbrains.com>
Thu, 9 Jun 2011 14:59:16 +0000 (18:59 +0400)
committerNikolay Matveev <Nikolay.Matveev@jetbrains.com>
Thu, 9 Jun 2011 17:03:27 +0000 (21:03 +0400)
(cherry picked from commit b318a361021efda5371b37cf1d2dab4367f9947c)

platform/lang-impl/src/com/intellij/execution/impl/statistics/RunConfigurationTypeUsagesCollector.java [new file with mode: 0644]
platform/platform-resources/src/META-INF/LangExtensions.xml

diff --git a/platform/lang-impl/src/com/intellij/execution/impl/statistics/RunConfigurationTypeUsagesCollector.java b/platform/lang-impl/src/com/intellij/execution/impl/statistics/RunConfigurationTypeUsagesCollector.java
new file mode 100644 (file)
index 0000000..469e523
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.execution.impl.statistics;
+
+import com.intellij.execution.RunManager;
+import com.intellij.execution.configurations.ConfigurationFactory;
+import com.intellij.execution.configurations.ConfigurationType;
+import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.internal.statistic.AbstractApplicationUsagesCollector;
+import com.intellij.internal.statistic.beans.GroupDescriptor;
+import com.intellij.internal.statistic.beans.UsageDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.HashSet;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Set;
+
+/**
+ * @author Nikolay Matveev
+ */
+public class RunConfigurationTypeUsagesCollector extends AbstractApplicationUsagesCollector {
+
+  private static final String GROUP_ID = "runConfigurationType";
+
+  @NotNull
+  @Override
+  public GroupDescriptor getGroupId() {
+    return GroupDescriptor.create(GROUP_ID);
+  }
+
+  @NotNull
+  @Override
+  public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) {
+    final Set<String> runConfigurationTypes = new HashSet<String>();
+    final RunManager runManager = RunManager.getInstance(project);
+    for (RunConfiguration runConfiguration : runManager.getAllConfigurations()) {
+      if (!runManager.isTemporary(runConfiguration)) {
+        final ConfigurationFactory configurationFactory = runConfiguration.getFactory();
+        final ConfigurationType configurationType = configurationFactory.getType();
+        final StringBuilder keyBuilder = new StringBuilder();
+        keyBuilder.append(configurationType.getId());
+        if (configurationType.getConfigurationFactories().length > 1) {
+          keyBuilder.append(".").append(configurationFactory.getName());
+        }
+        runConfigurationTypes.add(keyBuilder.toString());
+      }
+    }
+    return ContainerUtil.map2Set(runConfigurationTypes, new Function<String, UsageDescriptor>() {
+      @Override
+      public UsageDescriptor fun(String runConfigurationType) {
+        return new UsageDescriptor(runConfigurationType, 1);
+      }
+    });
+  }
+}
index 877f22d23fdca364a246877b5518938872a47e90..830a5769bb54b497f76c64a639ab33d8ebc0f0f5 100644 (file)
 
   <statistics.usagesCollector  implementation="com.intellij.facet.impl.statistics.FrameworkUsagesCollector"/>
   <statistics.usagesCollector  implementation="com.intellij.facet.impl.statistics.ModuleTypeUsagesCollector"/>
+  <statistics.usagesCollector implementation="com.intellij.execution.impl.statistics.RunConfigurationTypeUsagesCollector"/>
 
   <renamePsiElementProcessor implementation="com.intellij.refactoring.rename.RenamePsiFileProcessor" order="last"/>
   <renameInputValidator implementation="com.intellij.refactoring.rename.RenameToIgnoredDirectoryFileInputValidator" order="last"/>