Permalink
Browse files

Added Scala version statistics collector.

  • Loading branch information...
1 parent 8b57b0d commit b66080e05687e4101fe6fb386d0df45a6ac75e15 @Alefas Alefas committed Mar 3, 2014
@@ -17,6 +17,8 @@
</extensionPoints>
<extensions defaultExtensionNs="com.intellij">
+ <statistics.usagesCollector
+ implementation="org.jetbrains.plugins.scala.statistics.ScalaApplicationUsagesCollector" />
<lang.rearranger language="Scala" implementationClass="org.jetbrains.plugins.scala.lang.rearranger.ScalaRearranger"/>
<compileServer.plugin classpath="scala-library.jar;compiler-settings.jar;jps/nailgun.jar;jps/scala-jps-plugin.jar;jps/sbt-interface.jar;jps/incremental-compiler.jar;jps/jline.jar"/>
<projectTemplatesFactory implementation="org.jetbrains.plugins.scala.config.scalaProjectTemplate.ScalaProjectTemplatesFactory"/>
@@ -0,0 +1,40 @@
+package org.jetbrains.plugins.scala
+package statistics
+
+import com.intellij.internal.statistic.AbstractApplicationUsagesCollector
+import com.intellij.internal.statistic.beans.{UsageDescriptor, GroupDescriptor}
+import com.intellij.openapi.project.Project
+import java.util
+import scala.collection.mutable
+import com.intellij.openapi.module.{ModuleManager, ModuleUtil, ModuleUtilCore}
+import org.jetbrains.plugins.scala.config.ScalaFacet
+
+/**
+ * @author Alefas
+ * @since 03.03.14
+ */
+class ScalaApplicationUsagesCollector extends AbstractApplicationUsagesCollector {
+ override def getProjectUsages(project: Project): util.Set[UsageDescriptor] = {
+ val set: mutable.HashSet[UsageDescriptor] = new mutable.HashSet[UsageDescriptor]
+
+ //collecting Scala version
+ var scala_version: Option[String] = None
+ for (module <- ModuleManager.getInstance(project).getModules) {
+ ScalaFacet.findIn(module) match {
+ case Some(facet) =>
+ scala_version = Some(facet.version)
+ case _ =>
+ }
+ }
+
+ scala_version.foreach {
+ case version: String => set += new UsageDescriptor(version, 1)
+ }
+
+ import scala.collection.JavaConversions._
+ set
+
+ }
+
+ override def getGroupId: GroupDescriptor = new GroupDescriptor("Scala")
+}

0 comments on commit b66080e

Please sign in to comment.