package sxr
import java.io.{File, Reader, Writer}
import scala.collection.jcl.TreeSet
private object object sxr.AnnotateAnnotate
{
import FileUtil.{withReader, withWriter}
def (java.io.File,java.io.File,scala.collection.jcl.TreeSet[sxr.Token],sxr.Styler)Unitapply(java.io.Filesource: java.io.FileFile, java.io.Filetarget: java.io.FileFile, scala.collection.jcl.TreeSet[sxr.Token]tokens: scala.collection.jcl.TreeSet[sxr.Token]TreeSet[Token], sxr.Stylerstyler: sxr.StylerStyler)
{
(java.io.File)((java.io.BufferedReader) => Unit)UnitwithReader(java.io.Filesource) { java.io.BufferedReaderinput =>
(java.io.File)((java.io.BufferedWriter) => Unit)UnitwithWriter(java.io.Filetarget) { java.io.BufferedWriteroutput =>
sxr.Annotatenew sxr.AnnotateAnnotate(java.io.BufferedReaderinput, java.io.BufferedWriteroutput, scala.collection.jcl.TreeSet[sxr.Token]tokens, sxr.Stylerstyler).()Unitannotate()
}
}
}
}
private class class Annotate extends java.lang.Object with NotNull with ScalaObjectAnnotate(java.io.Readerinput: java.io.ReaderReader, java.io.Writeroutput: java.io.WriterWriter, scala.collection.jcl.TreeSet[sxr.Token]tokens: scala.collection.jcl.TreeSet[sxr.Token]TreeSet[Token], sxr.Stylerstyler: sxr.StylerStyler) extends NotNullNotNull
{
def ()Unitannotate()
{
java.io.Writeroutput.(java.lang.String)Unitwrite(sxr.Stylerstyler.=> Stringhead)
(Int)Unitannotate(Int(0)0)
java.io.Writeroutput.(java.lang.String)Unitwrite(sxr.Stylerstyler.=> Stringtail)
}
private def (Int)Unitannotate(Intindex: IntInt)
{
Unitif(scala.collection.jcl.TreeSet[sxr.Token]tokens.=> BooleanisEmpty)
(Int)Unittransfer(java.lang.Integer.Int(2147483647)MAX_VALUE)
else
{
val sxr.Tokentoken = scala.collection.jcl.TreeSet[sxr.Token]tokens.=> sxr.TokenfirstKey
scala.collection.jcl.TreeSet[sxr.Token]tokens.(sxr.Token)Booleanremove(sxr.Tokentoken)
Unitif(sxr.Tokentoken.=> Intstart (Int)Boolean< Intindex)
{
(Any)Unitprintln(java.lang.String("Overlapping span detected at index ")"Overlapping span detected at index " (Any)java.lang.String+ Intindex (Any)java.lang.String+ java.lang.String(": ")": " (Any)java.lang.String+ sxr.Tokentoken)
(Int)Unitannotate(Intindex)
}
else
{
(Int)Unittransfer(sxr.Tokentoken.=> Intstart (Int)Int- Intindex)
val List[sxr.Annotation]styledList = (sxr.Token)List[sxr.Annotation]styler(sxr.Tokentoken)
for(((sxr.Annotation) => Unit)Unitstyled <- List[sxr.Annotation]styledList)
java.io.Writeroutput.(java.lang.String)Unitwrite(sxr.Annotationstyled.=> Stringopen)
(Int)Unittransfer(sxr.Tokentoken.=> Intlength)
for(((sxr.Annotation) => Unit)Unitstyled <- List[sxr.Annotation]styledList.=> List[sxr.Annotation]reverse)
java.io.Writeroutput.(java.lang.String)Unitwrite(sxr.Annotationstyled.=> Stringclose)
(Int)Unitannotate(sxr.Tokentoken.=> Intstart (Int)Int+ sxr.Tokentoken.=> Intlength)
}
}
}
private def (Int)Unittransfer(Intchars: IntInt)
{
Unitif(Intchars (Int)Boolean> Int(0)0)
{
val Intc = java.io.Readerinput.()Intread()
Unitif(Intc (Int)Boolean>= Int(0)0)
{
(Char)Unitwrite(Intc.CharasInstanceOf[CharChar])
(Int)Unittransfer(Intchars (Int)Int- Int(1)1)
}
}
}
private def (Char)Unitwrite(Charc: CharChar)
{
Charc Unitmatch
{
Unitcase Char('>')'>' => java.io.Writeroutput.(java.lang.String)Unitwrite(java.lang.String(">")">")
Unitcase Char('&')'&' => java.io.Writeroutput.(java.lang.String)Unitwrite(java.lang.String("&")"&")
Unitcase Char('<')'<' => java.io.Writeroutput.(java.lang.String)Unitwrite(java.lang.String("<")"<")
Unitcase Char('"')'"' => java.io.Writeroutput.(java.lang.String)Unitwrite(java.lang.String(""")""")
Unitcase _ => java.io.Writeroutput.(Int)Unitwrite(implicit scala.Predef.char2int : (Char)Intc)
}
}
}