alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (TemplatePlugin.scala)

This example Scala source code file (TemplatePlugin.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

global, global, list, list, plugin, some, string, templateannotationchecker, templatecomponent, templateinfotransformcomponent, templateplugin, templateplugin, templatetraversecomponent, unit

The Scala TemplatePlugin.scala source code

package plugintemplate

import scala.tools.nsc.Global
import scala.tools.nsc.plugins.Plugin

/** A class describing the compiler plugin
 *
 *  @todo Adapt the name of this class to the plugin being
 *  implemented
 */
class TemplatePlugin(val global: Global) extends Plugin {
  /** The name of this plugin. Extracted from the properties file. */
  val name = PluginProperties.pluginName

  val runsAfter = List[String]("refchecks")

  /** A short description of the plugin, read from the properties file */
  val description = PluginProperties.pluginDescription
  
  /** @todo A description of the plugin's options */
  override val optionsHelp = Some(
    "  -P:"+ name +":option     sets some option for this plugin")

  /** @todo Implement parsing of plugin options */
  override def processOptions(options: List[String], error: String => Unit) {
    super.processOptions(options, error)
  }

  /** The compiler components that will be applied when running
   *  this plugin
   *
   *  @todo Adapt to the plugin being implemented
   */
  val components = TemplatePlugin.components(global)

  val checker = new TemplateAnnotationChecker {
    val global: TemplatePlugin.this.global.type = TemplatePlugin.this.global
  }
  global.addAnnotationChecker(checker.checker)
}

object TemplatePlugin {
  /** Yields the list of Components to be executed in this plugin
   *
   *  @todo: Adapt to specific implementation.
   */
  def components(global: Global) =
    List(new TemplateComponent(global),
         new TemplateTraverseComponent(global),
         new TemplateTransformComponent(global),
         new TemplateInfoTransformComponent(global))
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala TemplatePlugin.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.