plugindescription.scala
来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 78 行
SCALA
78 行
/* NSC -- new Scala compiler * Copyright 2007-2008 LAMP/EPFL * @author Lex Spoon */// $Id: PluginDescription.scala 14416 2008-03-19 01:17:25Z mihaylov $package scala.tools.nsc.pluginsimport java.io.Fileimport scala.xml.{Node,NodeSeq}/** A description of a compiler plugin, suitable for serialization * to XML for inclusion in the plugin's .jar file. * * @author Lex Spoon * @version 1.0, 2007-5-21 */abstract class PluginDescription { /** A short name of the compiler, used to identify it in * various contexts. The phase defined by the plugin * should have the same name. */ val name: String /** The name of the main class for the plugin */ val classname: String /** An XML representation of this description. It can be * read back using <code>PluginDescription.fromXML</code>. * It should be stored inside the jar. */ def toXML: Node = { <plugin> <name>{name}</name> <classname>{classname}</classname> </plugin> }}/** Utilities for the PluginDescription class. * * @author Lex Spoon * @version 1.0, 2007-5-21 */object PluginDescription { def fromXML(xml: Node): Option[PluginDescription] = { // check the top-level tag xml match { case <plugin>{_*}</plugin> => () case _ => return None } /** Extract one field */ def getField(field: String): Option[String] = { val text = (xml \\ field).text.trim if (text == "") None else Some(text) } // extract the required fields val name1 = getField("name") match { case None => return None case Some(str) => str } val classname1 = getField("classname") match { case None => return None case Some(str) => str } Some(new PluginDescription { val name = name1 val classname = classname1 }) }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?