From 33d511c280b19302cd3bf94e67cf68b9814ed824 Mon Sep 17 00:00:00 2001 From: Philippe Suter <philippe.suter@gmail.com> Date: Mon, 4 Jul 2011 17:38:19 +0000 Subject: [PATCH] stub for plugin test --- plugintest/project/build/project.scala | 4 +++ .../src/main/scala/plugintest/Plugin.scala | 34 +++++++++++++++++++ .../src/main/scala/plugintest/package.scala | 19 +++++++++++ 3 files changed, 57 insertions(+) create mode 100644 plugintest/project/build/project.scala create mode 100644 plugintest/src/main/scala/plugintest/Plugin.scala create mode 100644 plugintest/src/main/scala/plugintest/package.scala diff --git a/plugintest/project/build/project.scala b/plugintest/project/build/project.scala new file mode 100644 index 000000000..4fbe5b8a7 --- /dev/null +++ b/plugintest/project/build/project.scala @@ -0,0 +1,4 @@ +import sbt._ + +class PluginTestProject(info: ProjectInfo) extends DefaultProject(info) { +} diff --git a/plugintest/src/main/scala/plugintest/Plugin.scala b/plugintest/src/main/scala/plugintest/Plugin.scala new file mode 100644 index 000000000..0df83947c --- /dev/null +++ b/plugintest/src/main/scala/plugintest/Plugin.scala @@ -0,0 +1,34 @@ +package plugintest + +import scala.tools.nsc +import scala.tools.nsc.{Global,Phase} +import scala.tools.nsc.plugins._ + +class TestPlugin(val global : Global) extends Plugin { + import global._ + + val name = "test!" + val description = "Mini plugin to toy with ``MyAny'' type of things" + + override val optionsHelp : Option[String] = None + + val components = List[PluginComponent](new Component(global)) + val descriptions : List[String]("tests with ``MyAny''") +} + +class Component(val global : Global) extends PluginComponent { + import global._ + + override val runsRightAfter : Option[String] = None + override val runsAfter : List[String] = List("refchecks") + + val phaseName = "test!" + + def newPhase(previous : Phase) = new PluginPhase(previous) +} + +class PluginPhase(previous : Phase) extends StdPhase(previous) { + def apply(unit : CompilationUnit) : Unit = { + println("Phase ran !") + } +} diff --git a/plugintest/src/main/scala/plugintest/package.scala b/plugintest/src/main/scala/plugintest/package.scala new file mode 100644 index 000000000..e1e92fda4 --- /dev/null +++ b/plugintest/src/main/scala/plugintest/package.scala @@ -0,0 +1,19 @@ +package object plugintest { + trait MyAny + + sealed trait IsMyAny[T] { + val manifest : ClassManifest[T] + } + + implicit def isMyAny[T <: MyAny : ClassManifest] = new IsMyAny[T] { + val manifest = implicitly[ClassManifest[T]] + } + + implicit object IntIsMyAny extends IsMyAny[Int] { + val manifest = implicitly[ClassManifest[Int]] + } + + implicit object BooleanIsMyAny extends IsMyAny[Boolean] { + val manifest = implicitly[ClassManifest[Boolean]] + } +} -- GitLab