Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Scala version statistics collector.
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/org/jetbrains/plugins/scala/statistics/ScalaApplicationUsagesCollector.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |