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

Scala example source code file (DetachPlugin.scala)

This example Scala source code file (DetachPlugin.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

boolean, detach, detachplugin, enable, enable, global, list, list, option, option, p:detach:enable, plugin, plugin, string

The Scala DetachPlugin.scala source code

/* NSC -- new Scala compiler
 * Copyright 2005-2011 LAMP/EPFL
 * @author Stephane Micheloud
 */

package scala.tools.detach

import scala.tools.nsc.{Global, Phase}
import scala.tools.nsc.plugins.{Plugin, PluginComponent}

class DetachPlugin(val global: Global) extends Plugin {
  import global._

  val name = "detach"
  val description = "Perform detaching of remote closures"

  object detach extends {
    val global = DetachPlugin.this.global
    val runsAfter = List("lambdalift")
    override val runsBefore = List("constructors")
  } with Detach

  val components = List[PluginComponent](detach)

  def setEnabled(flag: Boolean) { detach.isEnabled = flag }

  override def processOptions(options: List[String], error: String => Unit) = {
    var enabled = false
    for (option <- options) {
      if (option == "enable") {
        enabled = true
      } else {
        error("Option not understood: "+option)
      }
    }
    setEnabled(enabled)
  }

  override val optionsHelp: Option[String] =
    Some("  -P:detach:enable               Enable detaching of remote closures")
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala DetachPlugin.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.