PHP temporary run configuration type usages collector(cherry picked from commit 890d711)
authorNikolay Matveev <Nikolay.Matveev@jetbrains.com>
Tue, 13 Sep 2011 12:50:21 +0000 (16:50 +0400)
committerNikolay Matveev <Nikolay.Matveev@jetbrains.com>
Tue, 13 Sep 2011 12:52:48 +0000 (16:52 +0400)
platform/lang-impl/src/com/intellij/execution/impl/statistics/AbstractRunConfigurationTypeUsagesCollector.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/execution/impl/statistics/RunConfigurationTypeUsagesCollector.java
platform/lang-impl/src/com/intellij/execution/impl/statistics/TemporaryRunConfigurationTypeUsagesCollector.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/AbstractRunConfigurationTypeUsagesCollector.java b/platform/lang-impl/src/com/intellij/execution/impl/statistics/AbstractRunConfigurationTypeUsagesCollector.java
new file mode 100644 (file)
index 0000000..f1fbceb
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.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 abstract class AbstractRunConfigurationTypeUsagesCollector extends AbstractApplicationUsagesCollector {
+
+  protected abstract boolean isApplicable(@NotNull RunManager runManager, @NotNull RunConfiguration runConfiguration);
+
+  @NotNull
+  @Override
+  public final 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 ((runConfiguration != null) && isApplicable(runManager, 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 6ee3a40c109136989c73f23c37062083cf6fa3ea..85d3f20050df3341263972c3d15ab57f219a5de5 100644 (file)
 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 {
+public class RunConfigurationTypeUsagesCollector extends AbstractRunConfigurationTypeUsagesCollector {
 
-  private static final String GROUP_ID = "run-configuration-type";
+  private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("run-configuration-type");
 
   @NotNull
   @Override
   public GroupDescriptor getGroupId() {
-    return GroupDescriptor.create(GROUP_ID);
+    return 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 ((runConfiguration != null) && (!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);
-      }
-    });
+  protected boolean isApplicable(@NotNull RunManager runManager, @NotNull RunConfiguration runConfiguration) {
+    return !runManager.isTemporary(runConfiguration);
   }
 }
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/statistics/TemporaryRunConfigurationTypeUsagesCollector.java b/platform/lang-impl/src/com/intellij/execution/impl/statistics/TemporaryRunConfigurationTypeUsagesCollector.java
new file mode 100644 (file)
index 0000000..1ab9ef5
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.RunConfiguration;
+import com.intellij.internal.statistic.beans.GroupDescriptor;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author Nikolay Matveev
+ */
+public class TemporaryRunConfigurationTypeUsagesCollector extends AbstractRunConfigurationTypeUsagesCollector {
+
+  private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("run-configuration-type-temporary");
+
+  @NotNull
+  @Override
+  public GroupDescriptor getGroupId() {
+    return GROUP_ID;
+  }
+
+  @Override
+  protected boolean isApplicable(@NotNull RunManager runManager, @NotNull RunConfiguration runConfiguration) {
+    return runManager.isTemporary(runConfiguration);
+  }
+}
index 91a472285550ee1d0b165827739ae126c600e7dc..9978a033babe88f3aab817816798cf3c3d9a8d39 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"/>
+  <statistics.usagesCollector implementation="com.intellij.execution.impl.statistics.TemporaryRunConfigurationTypeUsagesCollector"/>
   <statistics.usagesCollector implementation="com.intellij.openapi.fileTypes.FileTypeUsagesCollector"/>
 
   <renamePsiElementProcessor implementation="com.intellij.refactoring.rename.RenamePsiFileProcessor" order="last"/>