/* NSC -- new Scala compiler
* Copyright 2005-2007 LAMP/EPFL
* @author Sean McDirmid
*/
// $Id$
package scala.tools.nsc.doc
import java.io.StringReader
import org.xml.sax.InputSource
import scala.collection.immutable._
import scala.xml._
object DocUtil {
//def dquote(str: String): NodeSeq =
// DQUOTE :: Text(str) :: DQUOTE :: Nil
def load(str: String): NodeSeq = {
val xmlSrc =
if (str.matches("^()*<[^>]+>.*<[^>]+>()*$")) str
else "" + str + ""
XML.load(new StringReader(xmlSrc))
}
//object DQUOTE extends SpecialNode {
// def toString(sb: StringBuffer) = {
// sb.append("\""); sb
// }
// def label = "#PCDATA"
//}
def br(nodes: NodeSeq): NodeSeq = nodes ++
def hr(nodes: NodeSeq): NodeSeq = nodes ++
trait UrlContext {
def relative: String
def aref(href0: String, target: String, text: String): NodeSeq = {
val href = relative + Utility.escape(href0)
if ((target ne null) && target.indexOf('<') != -1) throw new Error(target)
val t0 = Text(text)
if (target ne null)
{t0};
else
{t0};
}
val encoding = Properties.encodingString
val header =
;
def body0(hasBody: Boolean, nodes: NodeSeq): NodeSeq =
if (!hasBody) nodes else {nodes};
val dtype = ""
def page(title: String, body: NodeSeq, hasBody: Boolean): NodeSeq =
{Text(title)}
{header}
{body0(hasBody, body)}
} // UrlContext
def div0(title: String): NodeSeq =
{Text(title)}
;
def merge[T](ts0: TreeSet[T], ts1: TreeSet[T]): TreeSet[T] = {
var ts = ts0
for (val t <- ts1.toList) ts = ts + t
ts
}
def merge[T,S <: Ordered[S]](ts0: ListMap[T,TreeSet[S]],
ts1: ListMap[T,TreeSet[S]]): ListMap[T,TreeSet[S]] = {
var ts = ts0
for (val t <- ts1.elements) {
if (!ts.contains(t._1))
ts = ts.update(t._1, new TreeSet[S]);
ts = ts.update(t._1, merge(ts(t._1), t._2))
}
ts
}
}