|
Scala example source code file (TemplateTransformComponent.scala)
The Scala TemplateTransformComponent.scala source codepackage plugintemplate import scala.tools.nsc._ import scala.tools.nsc.plugins.PluginComponent import scala.tools.nsc.transform.Transform // import scala.tools.nsc.transform.TypingTransformers /** This class implements a plugin component using tree transformers. If * a <code>Typer is needed during transformation, the component * should mix in <code>TypingTransformers. This provides a local * variable <code>localTyper: Typer that is always updated to * the current context. * * @todo Adapt the name of this class to the plugin, and implement it. */ class TemplateTransformComponent(val global: Global) extends PluginComponent // with TypingTransformers with Transform { import global._ import global.definitions._ val runsAfter = List[String]("refchecks") /** The phase name of the compiler plugin * @todo Adapt to specific plugin. */ val phaseName = "plugintemplatetransform" def newTransformer(unit: CompilationUnit) = new TemplateTransformer /** The tree transformer that implements the behavior of this * component. Change the superclass to <code>TypingTransformer * to make a local typechecker <code>localTyper available. * * @todo Implement. */ class TemplateTransformer extends /*Typing*/ Transformer { /** When using <code>preTransform, each node is * visited before its children. */ def preTransform(tree: Tree): Tree = tree match { case _ => tree } /** When using <code>postTransform, each node is * visited after its children. */ def postTransform(tree: Tree): Tree = tree match { case New(tpt) => println("post-transforming new "+ tpt) tree case _ => tree } override def transform(tree: Tree): Tree = { postTransform(super.transform(preTransform(tree))) } } } Other Scala examples (source code examples)Here is a short list of links related to this Scala TemplateTransformComponent.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.